-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsample_driver.F90
502 lines (414 loc) · 18.5 KB
/
sample_driver.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
#define MODNAME "SAMPLE_DRIVER"
module sample_driver_mod
!-----------------------------------------------------------------------------
! Code that specializes generic NUOPC_Driver
!-----------------------------------------------------------------------------
use ESMF
use NUOPC
use NUOPC_Driver, &
driver_routine_SS => SetServices, &
driver_label_SetModelServices => label_SetModelServices
#define STR_(x) #x
#define STR(x) STR_(x)
#ifdef COMP1_MOD
use COMP1_MOD, only: COMP1_SS => SetServices
#endif
#ifdef COMP2_MOD
use COMP2_MOD, only: COMP2_SS => SetServices
#endif
#ifdef COMP3_MOD
use COMP3_MOD, only: COMP3_SS => SetServices
#endif
#ifdef COMP4_MOD
use COMP4_MOD, only: COMP4_SS => SetServices
#endif
#ifdef COMP5_MOD
use COMP5_MOD, only: COMP5_SS => SetServices
#endif
implicit none
private
public SetServices
CHARACTER(LEN=*), PARAMETER :: label_InternalState = 'InternalState'
CHARACTER(LEN=*), PARAMETER :: defaultConfigFile = 'sample.rc'
CHARACTER(LEN=16), DIMENSION(10), PARAMETER :: CUSTOMFIELDLIST = (/ &
"dummy_field_1", "dummy_field_2", &
"dummy_field_3", "dummy_field_4", &
"dummy_field_5", "dummy_field_6", &
"dummy_field_7", "dummy_field_8", &
"dummy_field_9", "dummy_field_10" /)
CHARACTER(LEN=10), DIMENSION(10), PARAMETER :: CUSTOMUNITSLIST = (/ &
"Pa", "kg", &
"W m-2", "m", &
"kg", "m s-1", &
"kg", "W m-2", &
"m", "K" /)
type model_internalstate_type
logical :: defaultConfig = .FALSE.
integer :: verbosity = 1
integer :: timeStepSeconds = 3600
integer :: stepCount = 24
end type
type model_internalstate_wrapper
type(model_internalstate_type), pointer :: wrap
end type
!-----------------------------------------------------------------------------
contains
!-----------------------------------------------------------------------------
#undef METHOD
#define METHOD "SetServices"
subroutine SetServices(driver, rc)
type(ESMF_GridComp) :: driver
integer, intent(out) :: rc
#ifdef DEBUG
call ESMF_LogWrite(MODNAME//": entered "//METHOD, ESMF_LOGMSG_INFO)
#endif
rc = ESMF_SUCCESS
! NUOPC_Driver registers the generic methods
call NUOPC_CompDerive(driver, driver_routine_SS, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
! attach specializing method(s)
call NUOPC_CompSpecialize(driver, specLabel=driver_label_SetModelServices, &
specRoutine=SetModelServices, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
#ifdef DEBUG
call ESMF_LogWrite(MODNAME//": leaving "//METHOD, ESMF_LOGMSG_INFO)
#endif
end subroutine
!-----------------------------------------------------------------------------
#undef METHOD
#define METHOD "SetModelServices"
subroutine SetModelServices(driver, rc)
type(ESMF_GridComp) :: driver
integer, intent(out) :: rc
! local variables
character(ESMF_MAXSTR) :: dname
integer :: stat
type(model_internalstate_wrapper) :: is
logical :: configIsPresent
type(ESMF_Config) :: config
character(ESMF_MAXSTR) :: tmpStr
type(NUOPC_FreeFormat) :: attrFF
type(ESMF_Time) :: startTime
type(ESMF_Time) :: stopTime
type(ESMF_TimeInterval) :: timeStep
type(ESMF_Clock) :: internalClock
integer :: compListSize
character(len=32), allocatable :: compList(:)
character(len=32) :: compMod
character(len=32) :: compName
integer :: i
type(ESMF_GridComp) :: child
#ifdef DEBUG
call ESMF_LogWrite(MODNAME//": entered "//METHOD, ESMF_LOGMSG_INFO)
#endif
rc = ESMF_SUCCESS
! query the Driver for info
call ESMF_GridCompGet(driver, name=dname, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
! allocate memory for this internal state and set it in the
! component
allocate(is%wrap, stat=stat)
if (ESMF_LogFoundAllocError(statusToCheck=stat, &
msg='Allocation of internal state memory failed.', &
method=METHOD, file=__FILE__, rcToReturn=rc)) return ! bail out
call ESMF_UserCompSetInternalState(driver, label_InternalState, is, rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
! log component modules built into executable
if (is%wrap%verbosity .gt. 0) then
write (tmpStr, "(A,A)") trim(dname)//': ', &
'Component Modules in Executable'
call ESMF_LogWrite(trim(tmpStr),ESMF_LOGMSG_INFO)
#ifdef COMP1_MOD
write (tmpStr, "(A,A20)") trim(dname)//': ', &
STR(COMP1_MOD)
call ESMF_LogWrite(trim(tmpStr),ESMF_LOGMSG_INFO)
#endif
#ifdef COMP2_MOD
write (tmpStr, "(A,A20)") trim(dname)//': ', &
STR(COMP2_MOD)
call ESMF_LogWrite(trim(tmpStr),ESMF_LOGMSG_INFO)
#endif
#ifdef COMP3_MOD
write (tmpStr, "(A,A20)") trim(dname)//': ', &
STR(COMP3_MOD)
call ESMF_LogWrite(trim(tmpStr),ESMF_LOGMSG_INFO)
#endif
#ifdef COMP4_MOD
write (tmpStr, "(A,A20)") trim(dname)//': ', &
STR(COMP4_MOD)
call ESMF_LogWrite(trim(tmpStr),ESMF_LOGMSG_INFO)
#endif
#ifdef COMP5_MOD
write (tmpStr, "(A,A20)") trim(dname)//': ', &
STR(COMP5_MOD)
call ESMF_LogWrite(trim(tmpStr),ESMF_LOGMSG_INFO)
#endif
endif
! check driver for config
call ESMF_GridCompGet(driver, configIsPresent=configIsPresent, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
if (configIsPresent) then
is%wrap%defaultConfig = .FALSE.
call ESMF_GridCompGet(driver, config=config, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out else
else
is%wrap%defaultConfig = .TRUE.
! create config file
config = ESMF_ConfigCreate(rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
! load the default config file
call ESMF_ConfigLoadFile(config, trim(defaultConfigFile), rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
! set the config file
call ESMF_GridCompSet(driver, config=config, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
endif
! read and ingest free format driver attributes
attrFF = NUOPC_FreeFormatCreate(config, &
label=trim(dname)//"_attributes::", relaxedflag=.true., rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
call NUOPC_CompAttributeIngest(driver, attrFF, addFlag=.true., rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
call NUOPC_FreeFormatDestroy(attrFF, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
! determine the component list
compListSize = ESMF_ConfigGetLen(config, &
label=trim(dname)//"_component_list:", rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
allocate(compList(compListSize), stat=stat)
if (ESMF_LogFoundAllocError(statusToCheck=stat, &
msg="Allocation of component list memory failed.", &
method=METHOD, file=__FILE__, rcToReturn=rc)) return ! bail out
call ESMF_ConfigGetAttribute(config, valueList=compList, &
label=trim(dname)//"_component_list:", count=compListSize, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
! read and ingest free format driver attributes
attrFF = NUOPC_FreeFormatCreate(config, &
label=trim(dname)//"_attributes::", relaxedflag=.true., rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
call NUOPC_CompAttributeIngest(driver, attrFF, addFlag=.true., rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
call NUOPC_FreeFormatDestroy(attrFF, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
! store attributes in internal state
call ESMF_AttributeGet(driver, name="verbosity", value=tmpStr, &
defaultValue="default", convention="NUOPC", purpose="Instance", rc=rc)
is%wrap%verbosity = ESMF_UtilString2Int(tmpStr, &
specialStringList=(/"default","none","max"/), &
specialValueList=(/is%wrap%verbosity,0,255/), rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
call ESMF_AttributeGet(driver, name="time_step_seconds", value=tmpStr, &
defaultValue="default", convention="NUOPC", purpose="Instance", rc=rc)
is%wrap%timeStepSeconds = ESMF_UtilString2Int(tmpStr, &
specialStringList=(/"default"/), &
specialValueList=(/is%wrap%timeStepSeconds/), rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
call ESMF_AttributeGet(driver, name="step_count", value=tmpStr, &
defaultValue="default", convention="NUOPC", purpose="Instance", rc=rc)
is%wrap%stepCount = ESMF_UtilString2Int(tmpStr, &
specialStringList=(/"default"/), &
specialValueList=(/is%wrap%stepCount/), rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
! log driver attributes
if (is%wrap%verbosity .gt. 0) then
write (tmpStr, "(A,A)") trim(dname)//': ', &
'Driver Attributes'
call ESMF_LogWrite(trim(tmpStr),ESMF_LOGMSG_INFO)
write (tmpStr, "(A,A20,I0)") trim(dname)//': ', &
'Verbosity: ',is%wrap%verbosity
call ESMF_LogWrite(trim(tmpStr),ESMF_LOGMSG_INFO)
write (tmpStr, "(A,A20,I0)") trim(dname)//': ', &
'Time Step: ',is%wrap%timeStepSeconds
call ESMF_LogWrite(trim(tmpStr),ESMF_LOGMSG_INFO)
write (tmpStr, "(A,A20,I0)") trim(dname)//': ', &
'Step Count: ',is%wrap%stepCount
call ESMF_LogWrite(trim(tmpStr),ESMF_LOGMSG_INFO)
endif
! determine information for each component and add to the driver
do i=1, compListSize
call ESMF_ConfigGetAttribute(config, compMod, &
label=trim(compList(i))//"_mod:", &
default=trim(compList(i)), rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
call ESMF_ConfigGetAttribute(config, compName, &
label=trim(compList(i))//"_name:", &
default=trim(compList(i)), rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
select case (trim(compMod))
#ifdef COMP1_MOD
case (STR(COMP1_MOD))
! SetServices for component 1
call NUOPC_DriverAddComp(driver, trim(compName), COMP1_SS, &
comp=child, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
#endif
#ifdef COMP2_MOD
case (STR(COMP2_MOD))
! SetServices for component 2
call NUOPC_DriverAddComp(driver, trim(compName), COMP2_SS, &
comp=child, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
#endif
#ifdef COMP3_MOD
case (STR(COMP3_MOD))
! SetServices for component 3
call NUOPC_DriverAddComp(driver, trim(compName), COMP3_SS, &
comp=child, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
#endif
#ifdef COMP4_MOD
case (STR(COMP4_MOD))
! SetServices for component 4
call NUOPC_DriverAddComp(driver, trim(compName), COMP4_SS, &
comp=child, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
#endif
#ifdef COMP5_MOD
case (STR(COMP5_MOD))
! SetServices for component 5
call NUOPC_DriverAddComp(driver, trim(compName), COMP5_SS, &
comp=child, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
#endif
case default
call ESMF_LogSetError(rcToCheck=ESMF_RC_NOT_FOUND, &
msg=trim(compMod)//" was requested "// &
"but is not available in the executable!", &
method=METHOD, file=__FILE__, rcToReturn=rc)
return ! bail out
end select
! read and ingest free format component attributes
attrFF = NUOPC_FreeFormatCreate(config, &
label=trim(compList(i))//"_attributes::", relaxedflag=.true., rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
call NUOPC_CompAttributeIngest(child, attrFF, addFlag=.true., rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
call NUOPC_FreeFormatDestroy(attrFF, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
enddo
if (is%wrap%verbosity .gt. 0) then
write (tmpStr, "(A,A)") trim(dname)//': ', &
'Active Components'
call ESMF_LogWrite(trim(tmpStr),ESMF_LOGMSG_INFO)
do i=1, compListSize
call ESMF_ConfigGetAttribute(config, compName, &
label=trim(compList(i))//"_name:", &
default=trim(compList(i)), rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
write (tmpStr, "(A,A20)") trim(dname)//': ', &
trim(compName)
call ESMF_LogWrite(trim(tmpStr),ESMF_LOGMSG_INFO)
enddo
endif
deallocate(compList, stat=stat)
if (ESMF_LogFoundDeallocError(statusToCheck=stat, &
msg="Deallocation of component list memory failed.", &
line=__LINE__, file=__FILE__)) return ! bail out
! set the driver clock
call ESMF_TimeSet(startTime, s = 0, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
call ESMF_TimeSet(stopTime, &
s=(is%wrap%timeStepSeconds * is%wrap%stepCount), rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
call ESMF_TimeIntervalSet(timeStep, s=is%wrap%timeStepSeconds, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
internalClock = ESMF_ClockCreate(name=trim(dname)//"_clock", &
timeStep=timeStep, startTime=startTime, stopTime=stopTime, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
call ESMF_GridCompSet(driver, clock=internalClock, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
call CustomFieldSetup(driver, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
#ifdef DEBUG
call ESMF_LogWrite(MODNAME//": leaving "//METHOD, ESMF_LOGMSG_INFO)
#endif
end subroutine
!-----------------------------------------------------------------------------
#undef METHOD
#define METHOD "CustomFieldSetup"
subroutine CustomFieldSetup(driver, rc)
type(ESMF_GridComp) :: driver
integer, intent(out) :: rc
! local variables
character(ESMF_MAXSTR) :: dname
type(model_internalstate_wrapper) :: is
integer :: i
character(ESMF_MAXSTR) :: tmpStr
#ifdef DEBUG
call ESMF_LogWrite(MODNAME//": entered "//METHOD, ESMF_LOGMSG_INFO)
#endif
rc = ESMF_SUCCESS
! query the Driver for info
call ESMF_GridCompGet(driver, name=dname, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
! query component for its internal State
nullify(is%wrap)
call ESMF_UserCompGetInternalState(driver, label_InternalState, is, rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
if (is%wrap%verbosity .gt. 0) then
write (tmpStr, "(A,A)") trim(dname)//': ', &
'Custom Dictionary Fields'
call ESMF_LogWrite(trim(tmpStr),ESMF_LOGMSG_INFO)
endif
do i=1, size(CUSTOMFIELDLIST)
if (.NOT.NUOPC_FieldDictionaryHasEntry(trim(CUSTOMFIELDLIST(i)))) then
call NUOPC_FieldDictionaryAddEntry( &
standardName=trim(CUSTOMFIELDLIST(i)), &
canonicalUnits=trim(CUSTOMUNITSLIST(i)), rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return ! bail out
if (is%wrap%verbosity .ge. 1) then
write (tmpStr, "(A,A20,A10)") trim(dname)//': ', &
trim(CUSTOMFIELDLIST(i)),trim(CUSTOMUNITSLIST(i))
call ESMF_LogWrite(trim(tmpStr),ESMF_LOGMSG_INFO)
endif
endif
enddo
#ifdef DEBUG
call ESMF_LogWrite(MODNAME//": leaving "//METHOD, ESMF_LOGMSG_INFO)
#endif
end subroutine
end module