Skip to content

Commit 41913cc

Browse files
committed
Add direct 'hconfig' access to NUOPC layer, and leverage by the ESMX
layer implementation.
1 parent 7b22a6d commit 41913cc

File tree

4 files changed

+32
-58
lines changed

4 files changed

+32
-58
lines changed

src/addon/ESMX/Comps/ESMX_Data/ESMX_Data.F90

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ subroutine SetServices(xdata, rc)
8585
type(xstate_wrap) :: is
8686
type(xdata_state), pointer :: xstate
8787
character(len=64) :: value
88-
type(ESMF_Config) :: config
8988
type(ESMF_HConfig) :: hconfig, hconfigNode
9089
character(80) :: compLabel
9190
character(:), allocatable :: badKey
@@ -160,12 +159,9 @@ subroutine SetServices(xdata, rc)
160159
line=__LINE__, file=__FILE__)) return ! bail out
161160
if (isFlag) then
162161
! Config present, assert it is in the ESMX YAML format
163-
call ESMF_GridCompGet(xdata, config=config, rc=rc)
162+
call ESMF_GridCompGet(xdata, hconfig=hconfig, rc=rc)
164163
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
165164
line=__LINE__, file=__FILE__)) return ! bail out
166-
call ESMF_ConfigGet(config, hconfig=hconfig, rc=rc)
167-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
168-
line=__LINE__, file=__FILE__)) return ! bail out
169165
hconfigNode = ESMF_HConfigCreateAt(hconfig, keyString=compLabel, rc=rc)
170166
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
171167
line=__LINE__, file=__FILE__)) return ! bail out
@@ -743,7 +739,6 @@ subroutine x_comp_get_config(xdata, xstate, rc)
743739
logical :: isPresent
744740
integer :: stat
745741
logical :: check
746-
type(ESMF_Config) :: config
747742
type(ESMF_HConfig) :: hconfig
748743
type(ESMF_HConfig) :: xdatacfg
749744

@@ -760,12 +755,8 @@ subroutine x_comp_get_config(xdata, xstate, rc)
760755
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
761756
line=__LINE__, file=__FILE__)) return
762757
if (isPresent) then
763-
! get config from component
764-
call ESMF_GridCompGet(xdata, config=config, rc=rc)
765-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
766-
line=__LINE__, file=__FILE__)) return
767-
! access hconfig
768-
call ESMF_ConfigGet(config, hconfig=hconfig, rc=rc)
758+
! get hconfig from component
759+
call ESMF_GridCompGet(xdata, hconfig=hconfig, rc=rc)
769760
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
770761
line=__LINE__, file=__FILE__)) return
771762
isPresent = ESMF_HConfigIsDefined(hconfig, &

src/addon/ESMX/Driver/ESMX_Driver.F90

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ subroutine SetModelServices(driver, rc)
9292
integer :: i, j, componentCount, ompNumThreads
9393
integer, allocatable :: petList(:), devList(:)
9494
type(ESMF_GridComp) :: comp
95-
type(ESMF_Config) :: config
9695
type(ESMF_HConfig) :: hconfig, hconfigNode, hconfigNode2
9796
character(:), allocatable :: configKey(:)
9897
character(:), allocatable :: componentList(:)
@@ -106,33 +105,22 @@ subroutine SetModelServices(driver, rc)
106105
rc = ESMF_SUCCESS
107106

108107
! Look for config in the component
109-
call ESMF_GridCompGet(driver, configIsPresent=isFlag, rc=rc)
108+
call ESMF_GridCompGet(driver, hconfigIsPresent=isFlag, rc=rc)
110109
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
111110
line=__LINE__, file=FILENAME)) return ! bail out
112111

113112
if (isFlag) then
114-
! Get config from component
115-
call ESMF_GridCompGet(driver, config=config, rc=rc)
116-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
117-
line=__LINE__, file=FILENAME)) return ! bail out
118-
! Access hconfig
119-
call ESMF_ConfigGet(config, hconfig=hconfig, rc=rc)
113+
! Get hconfig from component
114+
call ESMF_GridCompGet(driver, hconfig=hconfig, rc=rc)
120115
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
121116
line=__LINE__, file=FILENAME)) return ! bail out
122117
else
123-
! Attempt to open hconfig from default file "esmxRun.yaml"
124-
config = ESMF_ConfigCreate(rc=rc)
125-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
126-
line=__LINE__, file=FILENAME)) return ! bail out
127-
call ESMF_ConfigLoadFile(config, filename="esmxRun.yaml", rc=rc)
118+
! Attempt to open hconfig from default file "esmxRun.yaml", set on Comp
119+
call ESMF_GridCompSet(driver, configFile="esmxRun.yaml", rc=rc)
128120
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
129121
line=__LINE__, file=FILENAME)) return ! bail out
130-
! Set config on the component
131-
call ESMF_GridCompSet(driver, config=config, rc=rc)
132-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
133-
line=__LINE__, file=FILENAME)) return ! bail out
134-
! Access hconfig
135-
call ESMF_ConfigGet(config, hconfig=hconfig, rc=rc)
122+
! Get hconfig from component
123+
call ESMF_GridCompGet(driver, hconfig=hconfig, rc=rc)
136124
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
137125
line=__LINE__, file=FILENAME)) return ! bail out
138126
! Find hconfig node that holds driver level attributes, conditionally ingest
@@ -308,15 +296,15 @@ subroutine SetModelServices(driver, rc)
308296
! add child component with SetVM and SetServices in CompDef
309297
#if defined (__INTEL_LLVM_COMPILER) || (__NVCOMPILER)
310298
!TODO: remove once IFX, NVHPC, and PGI compilers work correctly w/o work-around
311-
call NUOPC_DriverAddGridCompPtr(driver, trim(compLabel), config=config, &
299+
call NUOPC_DriverAddGridCompPtr(driver, trim(compLabel), hconfig=hconfig, &
312300
compSetServicesRoutine=CompDef(j)%ssPtr, compSetVMRoutine=CompDef(j)%svPtr, &
313301
info=info, petList=petList, devList=devList, comp=comp, rc=rc)
314302
if (ESMF_LogFoundError(rcToCheck=rc, &
315303
msg="Unable to add component '"//trim(compLabel)// &
316304
"' to driver via Fortran module.", &
317305
line=__LINE__, file=FILENAME)) return ! bail out
318306
#else
319-
call NUOPC_DriverAddComp(driver, trim(compLabel), config=config, &
307+
call NUOPC_DriverAddComp(driver, trim(compLabel), hconfig=hconfig, &
320308
compSetServicesRoutine=CompDef(j)%ssPtr, compSetVMRoutine=CompDef(j)%svPtr, &
321309
info=info, petList=petList, devList=devList, comp=comp, rc=rc)
322310
if (ESMF_LogFoundError(rcToCheck=rc, &
@@ -326,7 +314,7 @@ subroutine SetModelServices(driver, rc)
326314
#endif
327315
else
328316
! add child component with SetVM and SetServices in shared object
329-
call NUOPC_DriverAddComp(driver, trim(compLabel), config=config, &
317+
call NUOPC_DriverAddComp(driver, trim(compLabel), hconfig=hconfig, &
330318
sharedObj=trim(model), info=info, petList=petList, devList=devList, &
331319
comp=comp, rc=rc)
332320
if (ESMF_LogFoundError(rcToCheck=rc, &
@@ -383,18 +371,14 @@ subroutine SetRunSequence(driver, rc)
383371
integer, intent(out) :: rc
384372

385373
! local variables
386-
type(ESMF_Config) :: config
387374
type(ESMF_HConfig) :: hconfig, hconfigNode
388375
character(:), allocatable :: configKey(:)
389376
logical :: isFlag
390377

391378
rc = ESMF_SUCCESS
392379

393-
! Query the driver for config -> hconfig
394-
call ESMF_GridCompGet(driver, config=config, rc=rc)
395-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
396-
line=__LINE__, file=FILENAME)) return ! bail out
397-
call ESMF_ConfigGet(config, hconfig=hconfig, rc=rc)
380+
! Query the driver for hconfig
381+
call ESMF_GridCompGet(driver, hconfig=hconfig, rc=rc)
398382
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
399383
line=__LINE__, file=FILENAME)) return ! bail out
400384

src/addon/ESMX/ESMX_App.F90

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ program ESMX_App
1919

2020
integer :: rc, urc
2121
type(ESMF_GridComp) :: driver
22-
type(ESMF_Config) :: config
2322
type(ESMF_HConfig) :: hconfig, hconfigNode
2423
character(:), allocatable :: configKey(:)
2524
character(:), allocatable :: valueString
@@ -32,13 +31,7 @@ program ESMX_App
3231
configKey = ["ESMX", "App "]
3332
call ESMF_Initialize(configFilenameFromArgNum=1, & ! arg 1 to spec alt. config
3433
configFileName="esmxRun.yaml", configKey=configKey, &
35-
config=config, defaultDefaultCalKind=ESMF_CALKIND_GREGORIAN, rc=rc)
36-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
37-
line=__LINE__, file=FILENAME)) &
38-
call ESMF_Finalize(endflag=ESMF_END_ABORT)
39-
40-
! Access hconfig
41-
call ESMF_ConfigGet(config, hconfig=hconfig, rc=rc)
34+
hconfig=hconfig, defaultDefaultCalKind=ESMF_CALKIND_GREGORIAN, rc=rc)
4235
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
4336
line=__LINE__, file=FILENAME)) &
4437
call ESMF_Finalize(endflag=ESMF_END_ABORT)
@@ -140,7 +133,7 @@ program ESMX_App
140133
endif
141134

142135
! Create esmx driver
143-
driver = ESMF_GridCompCreate(name="ESMX_Driver", config=config, rc=rc)
136+
driver = ESMF_GridCompCreate(name="ESMX_Driver", hconfig=hconfig, rc=rc)
144137
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
145138
line=__LINE__, file=FILENAME)) &
146139
call ESMF_Finalize(endflag=ESMF_END_ABORT)

src/addon/NUOPC/src/NUOPC_Driver.F90

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4534,7 +4534,7 @@ recursive subroutine FinalizeReset(driver, importState, exportState, clock, rc)
45344534
! Private name; call using NUOPC_DriverAddComp()
45354535
recursive subroutine NUOPC_DriverAddGridCompPtr(driver, compLabel, &
45364536
compSetServicesRoutine, compSetVMRoutine, petList, devList, info, config, &
4537-
comp, rc)
4537+
hconfig, comp, rc)
45384538
! !ARGUMENTS:
45394539
type(ESMF_GridComp) :: driver
45404540
character(len=*), intent(in) :: compLabel
@@ -4558,6 +4558,7 @@ recursive subroutine SetVMRoutine(gridcomp, rc)
45584558
integer, intent(in), optional :: devList(:)
45594559
type(ESMF_Info), intent(in), optional :: info
45604560
type(ESMF_Config), intent(in), optional :: config
4561+
type(ESMF_HConfig), intent(in), optional :: hconfig
45614562
type(ESMF_GridComp), intent(out), optional :: comp
45624563
integer, intent(out), optional :: rc
45634564
!
@@ -4578,7 +4579,7 @@ recursive subroutine SetVMRoutine(gridcomp, rc)
45784579

45794580
call NUOPC_DriverAddGridComp(driver, compLabel, &
45804581
compSetServicesRoutine, compSetVMRoutine, petList, devList, info, &
4581-
config, comp, rc=localrc)
4582+
config, hconfig, comp, rc=localrc)
45824583
if (ESMF_LogFoundError(rcToCheck=localrc, msg=ESMF_LOGERR_PASSTHRU, &
45834584
line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) &
45844585
return ! bail out
@@ -4595,7 +4596,7 @@ recursive subroutine SetVMRoutine(gridcomp, rc)
45954596
! Private name; call using NUOPC_DriverAddComp()
45964597
recursive subroutine NUOPC_DriverAddGridComp(driver, compLabel, &
45974598
compSetServicesRoutine, compSetVMRoutine, petList, devList, info, config, &
4598-
comp, rc)
4599+
hconfig, comp, rc)
45994600
! !ARGUMENTS:
46004601
type(ESMF_GridComp) :: driver
46014602
character(len=*), intent(in) :: compLabel
@@ -4639,6 +4640,7 @@ recursive subroutine SetVMRoutine(gridcomp, rc)
46394640
integer, intent(in), optional :: devList(:)
46404641
type(ESMF_Info), intent(in), optional :: info
46414642
type(ESMF_Config), intent(in), optional :: config
4643+
type(ESMF_HConfig), intent(in), optional :: hconfig
46424644
type(ESMF_GridComp), intent(out), optional :: comp
46434645
integer, intent(out), optional :: rc
46444646
!
@@ -4712,7 +4714,8 @@ recursive subroutine SetVMRoutine(gridcomp, rc)
47124714
i = is%wrap%modelCount
47134715
cmEntry%wrap%label = trim(compLabel)
47144716
cmEntry%wrap%component = ESMF_GridCompCreate(name=trim(compLabel), &
4715-
config=config, petList=petList, devList=devList, rc=localrc)
4717+
config=config, hconfig=hconfig, petList=petList, devList=devList, &
4718+
rc=localrc)
47164719
if (ESMF_LogFoundError(rcToCheck=localrc, msg=ESMF_LOGERR_PASSTHRU, &
47174720
line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) &
47184721
return ! bail out
@@ -4810,7 +4813,7 @@ recursive subroutine SetVMRoutine(gridcomp, rc)
48104813
! !INTERFACE:
48114814
! Private name; call using NUOPC_DriverAddComp()
48124815
recursive subroutine NUOPC_DriverAddGridCompSO(driver, compLabel, &
4813-
sharedObj, petList, devList, info, config, comp, rc)
4816+
sharedObj, petList, devList, info, config, hconfig, comp, rc)
48144817
! !ARGUMENTS:
48154818
type(ESMF_GridComp) :: driver
48164819
character(len=*), intent(in) :: compLabel
@@ -4819,6 +4822,7 @@ recursive subroutine NUOPC_DriverAddGridCompSO(driver, compLabel, &
48194822
integer, intent(in), optional :: devList(:)
48204823
type(ESMF_Info), intent(in), optional :: info
48214824
type(ESMF_Config), intent(in), optional :: config
4825+
type(ESMF_HConfig), intent(in), optional :: hconfig
48224826
type(ESMF_GridComp), intent(out), optional :: comp
48234827
integer, intent(out), optional :: rc
48244828
!
@@ -4896,7 +4900,8 @@ recursive subroutine NUOPC_DriverAddGridCompSO(driver, compLabel, &
48964900
i = is%wrap%modelCount
48974901
cmEntry%wrap%label = trim(compLabel)
48984902
cmEntry%wrap%component = ESMF_GridCompCreate(name=trim(compLabel), &
4899-
config=config, petList=petList, devList=devList, rc=localrc)
4903+
config=config, hconfig=hconfig, petList=petList, devList=devList, &
4904+
rc=localrc)
49004905
if (ESMF_LogFoundError(rcToCheck=localrc, msg=ESMF_LOGERR_PASSTHRU, &
49014906
line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) &
49024907
return ! bail out
@@ -4993,7 +4998,7 @@ recursive subroutine NUOPC_DriverAddGridCompSO(driver, compLabel, &
49934998
! Private name; call using NUOPC_DriverAddComp()
49944999
recursive subroutine NUOPC_DriverAddCplComp(driver, srcCompLabel, &
49955000
dstCompLabel, compSetServicesRoutine, compSetVMRoutine, petList, devList, &
4996-
info, config, comp, rc)
5001+
info, config, hconfig, comp, rc)
49975002
! !ARGUMENTS:
49985003
type(ESMF_GridComp) :: driver
49995004
character(len=*), intent(in) :: srcCompLabel
@@ -5038,6 +5043,7 @@ recursive subroutine SetVMRoutine(cplcomp, rc)
50385043
integer, target, intent(in), optional :: devList(:)
50395044
type(ESMF_Info), intent(in), optional :: info
50405045
type(ESMF_Config), intent(in), optional :: config
5046+
type(ESMF_HConfig), intent(in), optional :: hconfig
50415047
type(ESMF_CplComp), intent(out), optional :: comp
50425048
integer, intent(out), optional :: rc
50435049
!
@@ -5177,7 +5183,7 @@ recursive subroutine SetVMRoutine(cplcomp, rc)
51775183
endif
51785184
cmEntry%wrap%connector = ESMF_CplCompCreate(&
51795185
name=trim(cmEntry%wrap%label), petList=connectorPetList, &
5180-
devList=devList, config=config, rc=localrc)
5186+
devList=devList, config=config, hconfig=hconfig, rc=localrc)
51815187
if (ESMF_LogFoundError(rcToCheck=localrc, msg=ESMF_LOGERR_PASSTHRU, &
51825188
line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) &
51835189
return ! bail out
@@ -5194,7 +5200,7 @@ recursive subroutine SetVMRoutine(cplcomp, rc)
51945200
endif
51955201
cmEntry%wrap%connector = ESMF_CplCompCreate(&
51965202
name=trim(cmEntry%wrap%label), devList=devList, config=config, &
5197-
rc=localrc)
5203+
hconfig=hconfig, rc=localrc)
51985204
if (ESMF_LogFoundError(rcToCheck=localrc, msg=ESMF_LOGERR_PASSTHRU, &
51995205
line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) &
52005206
return ! bail out

0 commit comments

Comments
 (0)