@@ -69,7 +69,7 @@ module ESMF_InitMod
69
69
public ESMF_IsInitialized, ESMF_IsFinalized
70
70
71
71
! should be private to framework - needed by other modules
72
- public ESMF_FrameworkInternalInit
72
+ public ESMF_FrameworkInternalInit
73
73
74
74
! EOPI
75
75
@@ -98,7 +98,8 @@ subroutine ESMF_Initialize(keywordEnforcer, configFilenameFromArgNum, &
98
98
defaultDefaultLogFilename , defaultLogFilename , &
99
99
defaultLogAppendFlag , logAppendFlag , defaultLogKindFlag , logKindFlag , &
100
100
mpiCommunicator , ioUnitLBound , ioUnitUBound , &
101
- defaultGlobalResourceControl , globalResourceControl , config , vm , rc )
101
+ defaultGlobalResourceControl , globalResourceControl , config , hconfig , &
102
+ vm , rc )
102
103
!
103
104
! !ARGUMENTS:
104
105
type (ESMF_KeywordEnforcer), optional :: keywordEnforcer ! must use keywords below
@@ -119,6 +120,7 @@ subroutine ESMF_Initialize(keywordEnforcer, configFilenameFromArgNum, &
119
120
logical , intent (in ), optional :: defaultGlobalResourceControl
120
121
logical , intent (in ), optional :: globalResourceControl
121
122
type (ESMF_Config), intent (out ), optional :: config
123
+ type (ESMF_HConfig), intent (out ), optional :: hconfig
122
124
type (ESMF_VM), intent (out ), optional :: vm
123
125
integer , intent (out ), optional :: rc
124
126
@@ -153,6 +155,8 @@ subroutine ESMF_Initialize(keywordEnforcer, configFilenameFromArgNum, &
153
155
! file specification via the command line.
154
156
! \item[8.6.0] Added {\tt defaultDefaultCalKind} argument to allow specifiation
155
157
! of a default for {\tt defaultCalKind}.
158
+ ! \item[8.7.0] Added argument {\tt hconfig} to simplify direct access to the
159
+ ! default {\tt ESMF\_HConfig} object.
156
160
! \end{description}
157
161
! \end{itemize}
158
162
!
@@ -383,8 +387,12 @@ subroutine ESMF_Initialize(keywordEnforcer, configFilenameFromArgNum, &
383
387
! Returns the default {\tt ESMF\_Config} if the
384
388
! {\tt configFilename} argument was provided. Otherwise the
385
389
! presence of this argument triggers an error.
390
+ ! \item [{[hconfig]}]
391
+ ! Returns the default {\tt ESMF\_HConfig} if the
392
+ ! {\tt configFilename} argument was provided. Otherwise the
393
+ ! presence of this argument triggers an error.
386
394
! \item [{[vm]}]
387
- ! Returns the global {\tt ESMF\_VM} that was created
395
+ ! Returns the global {\tt ESMF\_VM} that was created
388
396
! during initialization.
389
397
! \item [{[rc]}]
390
398
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
@@ -412,13 +420,13 @@ subroutine ESMF_Initialize(keywordEnforcer, configFilenameFromArgNum, &
412
420
ioUnitLBound= ioUnitLBound, ioUnitUBound= ioUnitUBound, &
413
421
defaultGlobalResourceControl= defaultGlobalResourceControl, &
414
422
globalResourceControl= globalResourceControl, &
415
- config= config, rc= localrc)
416
-
423
+ config= config, hconfig = hconfig, rc= localrc)
424
+
417
425
! on failure LogErr is not initialized -> explicit print on error
418
426
if (localrc .ne. ESMF_SUCCESS) then
419
427
write (ESMF_UtilIOStderr,* ) ESMF_METHOD, " : Error initializing framework"
420
- return
421
- endif
428
+ return
429
+ endif
422
430
! on success LogErr is assumed to be functioning
423
431
424
432
! obtain global VM
@@ -490,14 +498,14 @@ subroutine ESMF_InitializePreMPI(keywordEnforcer, rc)
490
498
491
499
! initialize pre MPI parts of global VM
492
500
call ESMF_VMInitializePreMPI(rc= localrc)
493
-
501
+
494
502
! on failure LogErr is not initialized -> explicit print on error
495
503
if (localrc .ne. ESMF_SUCCESS) then
496
504
write (ESMF_UtilIOStderr,* ) ESMF_METHOD, " : Error initializing framework"
497
- return
498
- endif
505
+ return
506
+ endif
499
507
! on success LogErr is assumed to be functioning
500
-
508
+
501
509
if (present (rc)) rc = ESMF_SUCCESS
502
510
end subroutine ESMF_InitializePreMPI
503
511
!- -----------------------------------------------------------------------------
@@ -515,7 +523,7 @@ subroutine ESMF_FrameworkInternalInit(lang, configFilenameFromArgNum, &
515
523
defaultDefaultLogFilename , defaultLogFilename , &
516
524
defaultLogAppendFlag , logAppendFlag , defaultLogKindFlag , logKindFlag , &
517
525
mpiCommunicator , ioUnitLBound , ioUnitUBound , &
518
- defaultGlobalResourceControl , globalResourceControl , config , rc )
526
+ defaultGlobalResourceControl , globalResourceControl , config , hconfig , rc )
519
527
!
520
528
! !ARGUMENTS:
521
529
integer , intent (in ) :: lang
@@ -536,6 +544,7 @@ subroutine ESMF_FrameworkInternalInit(lang, configFilenameFromArgNum, &
536
544
logical , intent (in ), optional :: defaultGlobalResourceControl
537
545
logical , intent (in ), optional :: globalResourceControl
538
546
type (ESMF_Config), intent (out ), optional :: config
547
+ type (ESMF_HConfig), intent (out ), optional :: hconfig
539
548
integer , intent (out ), optional :: rc
540
549
541
550
!
@@ -597,13 +606,17 @@ subroutine ESMF_FrameworkInternalInit(lang, configFilenameFromArgNum, &
597
606
! Returns the default {\tt ESMF\_Config} if the
598
607
! {\tt configFilename} argument was provided. Otherwise the
599
608
! presence of this argument triggers an error.
609
+ ! \item [{[hconfig]}]
610
+ ! Returns the default {\tt ESMF\_HConfig} if the
611
+ ! {\tt configFilename} argument was provided. Otherwise the
612
+ ! presence of this argument triggers an error.
600
613
! \item [{[rc]}]
601
614
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
602
615
! \end{description}
603
616
!
604
617
! EOPI
605
618
606
- logical :: rcpresent ! Return code present
619
+ logical :: rcpresent ! Return code present
607
620
integer :: localrc
608
621
logical , save :: already_init = .false. ! Static, maintains state.
609
622
logical :: openflag, isPresent
@@ -619,7 +632,7 @@ subroutine ESMF_FrameworkInternalInit(lang, configFilenameFromArgNum, &
619
632
character (ESMF_MAXSTR) :: errmsg
620
633
integer :: errmsg_l
621
634
type (ESMF_Config) :: configInternal
622
- type (ESMF_HConfig) :: hconfig , hconfigNode, hconfigNodePrev
635
+ type (ESMF_HConfig) :: hconfigInternal , hconfigNode, hconfigNodePrev
623
636
624
637
logical :: globalResourceControlSet, logAppendFlagSet
625
638
character (160 ) :: defaultLogFilenameSet, defaultLogFilenameS
@@ -809,10 +822,10 @@ subroutine ESMF_FrameworkInternalInit(lang, configFilenameFromArgNum, &
809
822
ESMF_CONTEXT, rcToReturn= rc)) return
810
823
811
824
! access hconfig
812
- call ESMF_ConfigGet(configInternal, hconfig= hconfig , rc= localrc)
825
+ call ESMF_ConfigGet(configInternal, hconfig= hconfigInternal , rc= localrc)
813
826
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
814
827
ESMF_CONTEXT, rcToReturn= rc)) return
815
- isFlag = ESMF_HConfigIsNull(hconfig , rc= localrc)
828
+ isFlag = ESMF_HConfigIsNull(hconfigInternal , rc= localrc)
816
829
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
817
830
ESMF_CONTEXT, rcToReturn= rc)) return
818
831
validHConfigNode = .false. ! not until found
@@ -827,7 +840,7 @@ subroutine ESMF_FrameworkInternalInit(lang, configFilenameFromArgNum, &
827
840
return ! bail out
828
841
endif
829
842
! find the hconfigNode holding predefined label map
830
- hconfigNode = ESMF_HConfigCreate(hconfig , rc= localrc)
843
+ hconfigNode = ESMF_HConfigCreate(hconfigInternal , rc= localrc)
831
844
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
832
845
ESMF_CONTEXT, rcToReturn= rc)) return
833
846
validHConfigNode = .true.
@@ -1319,12 +1332,17 @@ subroutine ESMF_FrameworkInternalInit(lang, configFilenameFromArgNum, &
1319
1332
ESMF_CONTEXT, rcToReturn= rc)) return
1320
1333
endif
1321
1334
! optionally destroy the Config
1322
- if (.not. present (config)) then
1335
+ if (.not. ( present (config) .or. present (hconfig) )) then
1323
1336
call ESMF_ConfigDestroy(configInternal, rc= localrc)
1324
1337
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
1325
1338
ESMF_CONTEXT, rcToReturn= rc)) return
1326
1339
else
1327
- config = configInternal ! return back to user
1340
+ if (present (config)) then
1341
+ config = configInternal ! return back to user
1342
+ endif
1343
+ if (present (hconfig)) then
1344
+ hconfig = hconfigInternal ! return back to user
1345
+ endif
1328
1346
endif
1329
1347
endif
1330
1348
@@ -1381,12 +1399,21 @@ subroutine ESMF_FrameworkInternalInit(lang, configFilenameFromArgNum, &
1381
1399
1382
1400
already_init = .true.
1383
1401
1384
- if (.not. haveConfig.and. present (config)) then
1385
- call ESMF_LogSetError(ESMF_RC_ARG_INCOMP, &
1386
- msg= " Cannot request 'config' without identifying " // &
1402
+ if (.not. haveConfig) then
1403
+ if (present (config)) then
1404
+ call ESMF_LogSetError(ESMF_RC_ARG_INCOMP, &
1405
+ msg= " Cannot request 'config' without identifying " // &
1387
1406
" a valid config file" , &
1388
1407
ESMF_CONTEXT, rcToReturn= rc)
1389
- return ! bail out
1408
+ return ! bail out
1409
+ endif
1410
+ if (present (hconfig)) then
1411
+ call ESMF_LogSetError(ESMF_RC_ARG_INCOMP, &
1412
+ msg= " Cannot request 'hconfig' without identifying " // &
1413
+ " a valid config file" , &
1414
+ ESMF_CONTEXT, rcToReturn= rc)
1415
+ return ! bail out
1416
+ endif
1390
1417
endif
1391
1418
1392
1419
if (rcpresent) rc = ESMF_SUCCESS
0 commit comments