Skip to content

Commit f7246f7

Browse files
committed
Implement HConfig support in CompGet(). Switch unit testing from comp.rc
to comp.yaml.
1 parent 03e5b23 commit f7246f7

File tree

10 files changed

+252
-76
lines changed

10 files changed

+252
-76
lines changed

src/Superstructure/Component/src/ESMF_Comp.F90

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module ESMF_CompMod
4545
use ESMF_BaseMod
4646
use ESMF_VMMod
4747
use ESMF_ConfigMod
48+
use ESMF_HConfigMod
4849
use ESMF_CalendarMod
4950
use ESMF_ClockMod
5051
use ESMF_GridMod
@@ -1325,8 +1326,8 @@ end subroutine ESMF_CompExecute
13251326
recursive subroutine ESMF_CompGet(compp, name, vm, vm_parent, vmplan, &
13261327
vm_info, contextflag, grid, gridList, mesh, meshList, locstream, &
13271328
locstreamList, xgrid, xgridList, importState, exportState, clock, dirPath, &
1328-
configFile, config, compType, currentMethod, currentPhase, timeout, &
1329-
localPet, petCount, petList, compStatus, compTunnel, rc)
1329+
configFile, config, hconfig, compType, currentMethod, currentPhase, &
1330+
timeout, localPet, petCount, petList, compStatus, compTunnel, rc)
13301331
!
13311332
! !ARGUMENTS:
13321333
type(ESMF_CompClass), pointer :: compp
@@ -1350,6 +1351,7 @@ recursive subroutine ESMF_CompGet(compp, name, vm, vm_parent, vmplan, &
13501351
character(len=*), intent(out), optional :: dirPath
13511352
character(len=*), intent(out), optional :: configFile
13521353
type(ESMF_Config), intent(out), optional :: config
1354+
type(ESMF_HConfig), intent(out), optional :: hconfig
13531355
type(ESMF_CompType_Flag), intent(out), optional :: compType
13541356
type(ESMF_Method_Flag), intent(out), optional :: currentMethod
13551357
integer, intent(out), optional :: currentPhase
@@ -1475,6 +1477,20 @@ recursive subroutine ESMF_CompGet(compp, name, vm, vm_parent, vmplan, &
14751477
config = compp%config
14761478
endif
14771479

1480+
! access hconfig
1481+
if (present(hconfig)) then
1482+
if (.not.compp%compStatus%configIsPresent) then
1483+
call ESMF_LogSetError(ESMF_RC_OBJ_BAD, &
1484+
msg="requested HConfig object is not present.", &
1485+
ESMF_CONTEXT, rcToReturn=rc)
1486+
return ! bail out
1487+
endif
1488+
call ESMF_ConfigGet(compp%config, hconfig=hconfig, rc=localrc)
1489+
if (ESMF_LogFoundError(localrc, &
1490+
ESMF_ERR_PASSTHRU, &
1491+
ESMF_CONTEXT, rcToReturn=rc)) return
1492+
endif
1493+
14781494
! access name
14791495
if (present(name)) then
14801496
call ESMF_GetName(compp%base, name, rc=localrc)
@@ -2717,13 +2733,14 @@ end function ESMF_CompStatusGetInit
27172733
!
27182734
! !INTERFACE:
27192735
recursive subroutine ESMF_CompStatusGet(compStatus, clockIsPresent, &
2720-
configIsPresent, configFileIsPresent, vmIsPresent, isIsPresent, &
2721-
esIsPresent, gridIsPresent, meshIsPresent, locstreamIsPresent, &
2722-
xgridIsPresent, rc)
2736+
hconfigIsPresent, configIsPresent, configFileIsPresent, vmIsPresent, &
2737+
isIsPresent, esIsPresent, gridIsPresent, meshIsPresent, &
2738+
locstreamIsPresent, xgridIsPresent, rc)
27232739
!
27242740
! !ARGUMENTS:
27252741
type(ESMF_CompStatus), intent(in) :: compStatus
27262742
logical, intent(out), optional :: clockIsPresent
2743+
logical, intent(out), optional :: hconfigIsPresent
27272744
logical, intent(out), optional :: configIsPresent
27282745
logical, intent(out), optional :: configFileIsPresent
27292746
logical, intent(out), optional :: vmIsPresent
@@ -2753,6 +2770,10 @@ recursive subroutine ESMF_CompStatusGet(compStatus, clockIsPresent, &
27532770
clockIsPresent = compStatus%clockIsPresent
27542771
endif
27552772

2773+
if (present(hconfigIsPresent)) then
2774+
hconfigIsPresent = compStatus%configIsPresent ! hconfig kept in config
2775+
endif
2776+
27562777
if (present(configIsPresent)) then
27572778
configIsPresent = compStatus%configIsPresent
27582779
endif

src/Superstructure/Component/src/ESMF_CplComp.F90

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ module ESMF_CplCompMod
4040
use ESMF_BaseMod
4141
use ESMF_VMMod
4242
use ESMF_ConfigMod
43+
use ESMF_HConfigMod
4344
use ESMF_ClockTypeMod
4445
use ESMF_ClockMod
4546
use ESMF_StateTypesMod
@@ -790,14 +791,16 @@ end subroutine ESMF_CplCompFinalizeAct
790791
! !IROUTINE: ESMF_CplCompGet - Get CplComp information
791792
!
792793
! !INTERFACE:
793-
subroutine ESMF_CplCompGet(cplcomp, keywordEnforcer, configIsPresent, config, &
794-
configFileIsPresent, configFile, clockIsPresent, clock, localPet, &
794+
subroutine ESMF_CplCompGet(cplcomp, keywordEnforcer, hconfigIsPresent, hconfig, &
795+
configIsPresent, config, configFileIsPresent, configFile, clockIsPresent, clock, localPet, &
795796
petCount, contextflag, currentMethod, currentPhase, vmIsPresent, &
796797
vm, name, rc)
797798
!
798799
! !ARGUMENTS:
799800
type(ESMF_CplComp), intent(in) :: cplcomp
800801
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
802+
logical, intent(out), optional :: hconfigIsPresent
803+
type(ESMF_HConfig), intent(out), optional :: hconfig
801804
logical, intent(out), optional :: configIsPresent
802805
type(ESMF_Config), intent(out), optional :: config
803806
logical, intent(out), optional :: configFileIsPresent
@@ -817,6 +820,11 @@ subroutine ESMF_CplCompGet(cplcomp, keywordEnforcer, configIsPresent, config, &
817820
! !STATUS:
818821
! \begin{itemize}
819822
! \item\apiStatusCompatibleVersion{5.2.0r}
823+
! \item\apiStatusModifiedSinceVersion{5.2.0r}
824+
! \begin{description}
825+
! \item[8.7.0] Added arguments {\tt hconfigIsPresent} and {\tt hconfig} to
826+
! simplify direct usage of {\tt ESMF\_HConfig} objects with Components.
827+
! \end{description}
820828
! \end{itemize}
821829
!
822830
! !DESCRIPTION:
@@ -829,13 +837,24 @@ subroutine ESMF_CplCompGet(cplcomp, keywordEnforcer, configIsPresent, config, &
829837
! \item[{[configIsPresent]}]
830838
! {\tt .true.} if {\tt config} was set in CplComp object,
831839
! {\tt .false.} otherwise.
840+
! \item[{[hconfigIsPresent]}]
841+
! {\tt .true.} if {\tt hconfig} is available in the CplComp object,
842+
! {\tt .false.} otherwise.
843+
! \item[{[hconfig]}]
844+
! Return the associated HConfig object.
845+
! It is an error to query for the HConfig object if none is associated with
846+
! the CplComp. If unsure, get {\tt hconfigIsPresent} first to determine
847+
! the status.
848+
! \item[{[configIsPresent]}]
849+
! {\tt .true.} if {\tt config} is available in the CplComp object,
850+
! {\tt .false.} otherwise.
832851
! \item[{[config]}]
833-
! Return the associated Config.
852+
! Return the associated Config object.
834853
! It is an error to query for the Config if none is associated with
835854
! the CplComp. If unsure, get {\tt configIsPresent} first to determine
836855
! the status.
837856
! \item[{[configFileIsPresent]}]
838-
! {\tt .true.} if {\tt configFile} was set in CplComp object,
857+
! {\tt .true.} if {\tt configFile} is available in the CplComp object,
839858
! {\tt .false.} otherwise.
840859
! \item[{[configFile]}]
841860
! Return the associated configuration filename.
@@ -889,7 +908,7 @@ subroutine ESMF_CplCompGet(cplcomp, keywordEnforcer, configIsPresent, config, &
889908

890909
! call Comp method
891910
call ESMF_CompGet(cplcomp%compp, name=name, vm=vm, contextflag=contextflag,&
892-
clock=clock, configFile=configFile, config=config, &
911+
clock=clock, configFile=configFile, config=config, hconfig=hconfig, &
893912
currentMethod=currentMethod, currentPhase=currentPhase, &
894913
localPet=localPet, petCount=petCount, compStatus=compStatus, rc=localrc)
895914
if (ESMF_LogFoundError(localrc, &
@@ -904,6 +923,7 @@ subroutine ESMF_CplCompGet(cplcomp, keywordEnforcer, configIsPresent, config, &
904923
! call Comp method
905924
call ESMF_CompStatusGet(compStatus, &
906925
clockIsPresent = clockIsPresent, &
926+
hconfigIsPresent = hconfigIsPresent, &
907927
configIsPresent = configIsPresent, &
908928
configFileIsPresent = configFileIsPresent, &
909929
vmIsPresent = vmIsPresent, &

src/Superstructure/Component/src/ESMF_GridComp.F90

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ module ESMF_GridCompMod
4040
use ESMF_BaseMod
4141
use ESMF_VMMod
4242
use ESMF_ConfigMod
43+
use ESMF_HConfigMod
4344
use ESMF_ClockTypeMod
4445
use ESMF_ClockMod
4546
use ESMF_StateTypesMod
@@ -903,10 +904,10 @@ recursive subroutine ESMF_GridCompGet(gridcomp, keywordEnforcer, &
903904
gridIsPresent, grid, gridList, meshIsPresent, mesh, meshList, &
904905
locstreamIsPresent, locstream, locstreamList, xgridIsPresent, &
905906
xgrid, xgridList, importStateIsPresent, importState, &
906-
exportStateIsPresent, exportState, configIsPresent, config, &
907-
configFileIsPresent, configFile, clockIsPresent, clock, localPet, &
908-
petCount, contextflag, currentMethod, currentPhase, comptype, &
909-
vmIsPresent, vm, name, rc)
907+
exportStateIsPresent, exportState, hconfigIsPresent, hconfig, &
908+
configIsPresent, config, configFileIsPresent, configFile, &
909+
clockIsPresent, clock, localPet, petCount, contextflag, &
910+
currentMethod, currentPhase, comptype, vmIsPresent, vm, name, rc)
910911
!
911912
! !ARGUMENTS:
912913
type(ESMF_GridComp), intent(in) :: gridcomp
@@ -927,6 +928,8 @@ recursive subroutine ESMF_GridCompGet(gridcomp, keywordEnforcer, &
927928
type(ESMF_State), intent(out), optional :: importState
928929
logical, intent(out), optional :: exportStateIsPresent
929930
type(ESMF_State), intent(out), optional :: exportState
931+
logical, intent(out), optional :: hconfigIsPresent
932+
type(ESMF_HConfig), intent(out), optional :: hconfig
930933
logical, intent(out), optional :: configIsPresent
931934
type(ESMF_Config), intent(out), optional :: config
932935
logical, intent(out), optional :: configFileIsPresent
@@ -956,6 +959,8 @@ recursive subroutine ESMF_GridCompGet(gridcomp, keywordEnforcer, &
956959
! These arguments add support for accessing references to multiple geom objects,
957960
! either of the same type, or different type, associated with the same
958961
! {\tt ESMF\_GridComp} object.
962+
! \item[8.7.0] Added arguments {\tt hconfigIsPresent} and {\tt hconfig} to
963+
! simplify direct usage of {\tt ESMF\_HConfig} objects with Components.
959964
! \end{sloppypar}
960965
! \end{description}
961966
! \end{itemize}
@@ -1057,16 +1062,24 @@ recursive subroutine ESMF_GridCompGet(gridcomp, keywordEnforcer, &
10571062
! It is an error to query for the export State if none is associated with
10581063
! the GridComp. If unsure, get {\tt exportStateIsPresent} first to determine
10591064
! the status.
1065+
! \item[{[hconfigIsPresent]}]
1066+
! {\tt .true.} if {\tt hconfig} is available in the GridComp object,
1067+
! {\tt .false.} otherwise.
1068+
! \item[{[hconfig]}]
1069+
! Return the associated HConfig object.
1070+
! It is an error to query for the HConfig object if none is associated with
1071+
! the GridComp. If unsure, get {\tt hconfigIsPresent} first to determine
1072+
! the status.
10601073
! \item[{[configIsPresent]}]
1061-
! {\tt .true.} if {\tt config} was set in GridComp object,
1074+
! {\tt .true.} if {\tt config} is available in the GridComp object,
10621075
! {\tt .false.} otherwise.
10631076
! \item[{[config]}]
1064-
! Return the associated Config.
1077+
! Return the associated Config object.
10651078
! It is an error to query for the Config if none is associated with
10661079
! the GridComp. If unsure, get {\tt configIsPresent} first to determine
10671080
! the status.
10681081
! \item[{[configFileIsPresent]}]
1069-
! {\tt .true.} if {\tt configFile} was set in GridComp object,
1082+
! {\tt .true.} if {\tt configFile} is available in the GridComp object,
10701083
! {\tt .false.} otherwise.
10711084
! \item[{[configFile]}]
10721085
! Return the associated configuration filename.
@@ -1128,8 +1141,9 @@ recursive subroutine ESMF_GridCompGet(gridcomp, keywordEnforcer, &
11281141
locstream=locstream, locstreamList=locstreamList, &
11291142
xgrid=xgrid, xgridList=xgridList, &
11301143
importState=importState, exportState=exportState, clock=clock,&
1131-
configFile=configFile, config=config, currentMethod=currentMethod, &
1132-
currentPhase=currentPhase, localPet=localPet, petCount=petCount, &
1144+
configFile=configFile, config=config, hconfig=hconfig, &
1145+
currentMethod=currentMethod, currentPhase=currentPhase, &
1146+
localPet=localPet, petCount=petCount, &
11331147
comptype=comptype, compStatus=compStatus, rc=localrc)
11341148
if (ESMF_LogFoundError(localrc, &
11351149
ESMF_ERR_PASSTHRU, &
@@ -1143,6 +1157,7 @@ recursive subroutine ESMF_GridCompGet(gridcomp, keywordEnforcer, &
11431157
! call Comp method
11441158
call ESMF_CompStatusGet(compStatus, &
11451159
clockIsPresent = clockIsPresent, &
1160+
hconfigIsPresent = hconfigIsPresent, &
11461161
configIsPresent = configIsPresent, &
11471162
configFileIsPresent = configFileIsPresent, &
11481163
vmIsPresent = vmIsPresent, &

src/Superstructure/Component/tests/ESMC_ComponentUTest.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ int main(void){
262262
//NEX_UTest
263263
strcpy(name, "Create ESMC_GridComp object");
264264
strcpy(failMsg, "Did not return ESMF_SUCCESS");
265-
gcomp = ESMC_GridCompCreate("gridded component in C", "comp.rc", clock, &rc);
265+
gcomp = ESMC_GridCompCreate("gridded component in C", "comp.yaml", clock,
266+
&rc);
266267
ESMC_Test((rc==ESMF_SUCCESS), name, failMsg, &result, __FILE__, __LINE__, 0);
267268
//----------------------------------------------------------------------------
268269

@@ -327,8 +328,9 @@ int main(void){
327328
//NEX_UTest
328329
strcpy(name, "Create ESMC_GridComp object");
329330
strcpy(failMsg, "Did not return ESMF_SUCCESS");
330-
gcomp = ESMC_GridCompCreate("gridded Component in C with Fortran registration",
331-
"comp.rc", clock, &rc);
331+
gcomp = ESMC_GridCompCreate(
332+
"gridded Component in C with Fortran registration",
333+
"comp.yaml", clock, &rc);
332334
ESMC_Test((rc==ESMF_SUCCESS), name, failMsg, &result, __FILE__, __LINE__, 0);
333335
//----------------------------------------------------------------------------
334336

@@ -379,7 +381,8 @@ int main(void){
379381
//NEX_UTest
380382
strcpy(name, "Create ESMC_CplComp object");
381383
strcpy(failMsg, "Did not return ESMF_SUCCESS");
382-
cplcomp = ESMC_CplCompCreate("coupler component in C", "comp.rc", clock, &rc);
384+
cplcomp = ESMC_CplCompCreate("coupler component in C", "comp.yaml", clock,
385+
&rc);
383386
ESMC_Test((rc==ESMF_SUCCESS), name, failMsg, &result, __FILE__, __LINE__, 0);
384387
//----------------------------------------------------------------------------
385388

@@ -436,8 +439,9 @@ int main(void){
436439
//NEX_UTest
437440
strcpy(name, "Create ESMC_CplComp object");
438441
strcpy(failMsg, "Did not return ESMF_SUCCESS");
439-
cplcomp = ESMC_CplCompCreate("coupler component in C with Fortran registration",
440-
"comp.rc", clock, &rc);
442+
cplcomp = ESMC_CplCompCreate(
443+
"coupler component in C with Fortran registration",
444+
"comp.yaml", clock, &rc);
441445
ESMC_Test((rc==ESMF_SUCCESS), name, failMsg, &result, __FILE__, __LINE__, 0);
442446
//----------------------------------------------------------------------------
443447

src/Superstructure/Component/tests/ESMF_CompSetServUTest.F90

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ program ESMF_CompSetServUTest
9494

9595
cname = "Atmosphere"
9696
comp1 = ESMF_GridCompCreate(name=cname, petList=petList, &
97-
configFile="comp.rc", rc=rc)
97+
configFile="comp.yaml", rc=rc)
9898

9999
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
100100

@@ -162,8 +162,8 @@ program ESMF_CompSetServUTest
162162
write(failMsg, *) "Did not return ESMF_SUCCESS"
163163

164164
cname = "Atmosphere - child in parent VM context"
165-
comp1 = ESMF_GridCompCreate(name=cname, configFile="comp.rc", &
166-
contextflag=ESMF_CONTEXT_PARENT_VM, rc=rc)
165+
comp1 = ESMF_GridCompCreate(name=cname, configFile="comp.yaml", &
166+
contextflag=ESMF_CONTEXT_PARENT_VM, rc=rc)
167167

168168
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
169169

@@ -202,8 +202,8 @@ program ESMF_CompSetServUTest
202202
write(failMsg, *) "Did not return ESMF_SUCCESS"
203203

204204
cname = "Atmosphere - child in parent VM context"
205-
comp1 = ESMF_GridCompCreate(name=cname, configFile="comp.rc", &
206-
contextflag=ESMF_CONTEXT_PARENT_VM, rc=rc)
205+
comp1 = ESMF_GridCompCreate(name=cname, configFile="comp.yaml", &
206+
contextflag=ESMF_CONTEXT_PARENT_VM, rc=rc)
207207

208208
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
209209

@@ -273,7 +273,7 @@ program ESMF_CompSetServUTest
273273

274274
cname = "Atmosphere - in its own context"
275275
comp1 = ESMF_GridCompCreate(name=cname, petList=petList, &
276-
configFile="comp.rc", rc=rc)
276+
configFile="comp.yaml", rc=rc)
277277

278278
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
279279

@@ -415,7 +415,7 @@ program ESMF_CompSetServUTest
415415

416416
cname = "Atmosphere - child in parent VM context"
417417
comp1 = ESMF_GridCompCreate(name=cname, &
418-
configFile="comp.rc", contextflag=ESMF_CONTEXT_PARENT_VM, rc=rc)
418+
configFile="comp.yaml", contextflag=ESMF_CONTEXT_PARENT_VM, rc=rc)
419419

420420
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
421421

src/Superstructure/Component/tests/ESMF_ComponentUTest.F90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ program ESMF_ComponentUTest
5252
!NEX_UTest
5353
! Verifing that a Gridded Component can be created
5454
cname = "Atmosphere - default context"
55-
comp1 = ESMF_GridCompCreate(name=cname, configFile="comp.rc", rc=rc)
55+
comp1 = ESMF_GridCompCreate(name=cname, configFile="comp.yaml", rc=rc)
5656
write(failMsg, *) "Did not return ESMF_SUCCESS"
5757
write(name, *) "Creating a Gridded Component"
5858
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
@@ -95,7 +95,7 @@ program ESMF_ComponentUTest
9595
! Verifing that a Gridded Component can be created in parent VM context
9696
cname = "Atmosphere - child in parent VM context"
9797
comp1 = ESMF_GridCompCreate(name=cname, &
98-
configFile="comp.rc", contextflag=ESMF_CONTEXT_PARENT_VM, rc=rc)
98+
configFile="comp.yaml", contextflag=ESMF_CONTEXT_PARENT_VM, rc=rc)
9999
write(failMsg, *) "Did not return ESMF_SUCCESS"
100100
write(name, *) "Creating a Gridded Component"
101101
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
@@ -178,7 +178,7 @@ program ESMF_ComponentUTest
178178
! Verifing that a Gridded Component can be created in new VM context
179179
cname = "Atmosphere - child in new VM context"
180180
comp1 = ESMF_GridCompCreate(name=cname, &
181-
configFile="comp.rc", contextflag=ESMF_CONTEXT_OWN_VM, rc=rc)
181+
configFile="comp.yaml", contextflag=ESMF_CONTEXT_OWN_VM, rc=rc)
182182
write(failMsg, *) "Did not return ESMF_SUCCESS"
183183
write(name, *) "Creating a Gridded Component"
184184
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)

0 commit comments

Comments
 (0)