Skip to content

Commit 53fb3ac

Browse files
committed
Support 'hconfig' object in CompSet().
1 parent 48ff3cd commit 53fb3ac

File tree

5 files changed

+168
-26
lines changed

5 files changed

+168
-26
lines changed

src/Superstructure/Component/src/ESMF_Comp.F90

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,7 +1901,7 @@ end subroutine ESMF_CompPrint
19011901
! !INTERFACE:
19021902
recursive subroutine ESMF_CompSet(compp, name, vm, vm_info, grid, gridList, &
19031903
mesh, meshList, locstream, locstreamList, xgrid, xgridList, clock, &
1904-
dirPath, configFile, config, rc)
1904+
dirPath, configFile, config, hconfig, rc)
19051905
!
19061906
! !ARGUMENTS:
19071907
type(ESMF_CompClass), pointer :: compp
@@ -1920,7 +1920,8 @@ recursive subroutine ESMF_CompSet(compp, name, vm, vm_info, grid, gridList, &
19201920
character(len=*), intent(in), optional :: dirPath
19211921
character(len=*), intent(in), optional :: configFile
19221922
type(ESMF_Config), intent(in), optional :: config
1923-
integer, intent(out), optional :: rc
1923+
type(ESMF_HConfig), intent(in), optional :: hconfig
1924+
integer, intent(out), optional :: rc
19241925

19251926
!
19261927
! !DESCRIPTION:
@@ -2072,14 +2073,29 @@ recursive subroutine ESMF_CompSet(compp, name, vm, vm_info, grid, gridList, &
20722073
endif
20732074

20742075
! config handling
2075-
if (present(config)) then
2076-
compp%config = config
2076+
if (present(hconfig)) then
2077+
if (present(config).or.present(configFile)) then
2078+
call ESMF_LogSetError(ESMF_RC_ARG_BAD, &
2079+
msg="Must only specify one of: "// &
2080+
"'hconfig', 'config', or 'configFile' arguments!", &
2081+
ESMF_CONTEXT, rcToReturn=rc)
2082+
return
2083+
endif
2084+
compp%config = ESMF_ConfigCreate(hconfig=hconfig, rc=localrc)
2085+
if (ESMF_LogFoundError(localrc, &
2086+
ESMF_ERR_PASSTHRU, &
2087+
ESMF_CONTEXT, rcToReturn=rc)) return
20772088
compp%compStatus%configIsPresent = .true.
2089+
else if (present(config)) then
20782090
if (present(configFile)) then
2079-
! a config object gets priority over a name if both are specified.
2080-
call ESMF_LogWrite("Ignoring configFile because config object given.", &
2081-
ESMF_LOGMSG_WARNING)
2091+
call ESMF_LogSetError(ESMF_RC_ARG_BAD, &
2092+
msg="Must only specify one of: "// &
2093+
"'hconfig', 'config', or 'configFile' arguments!", &
2094+
ESMF_CONTEXT, rcToReturn=rc)
2095+
return
20822096
endif
2097+
compp%config = config
2098+
compp%compStatus%configIsPresent = .true.
20832099
else if (present(configFile)) then
20842100
! name of a specific config file. open it and store the config object.
20852101
compp%configFile = configFile

src/Superstructure/Component/src/ESMF_CplComp.F90

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ recursive function ESMF_CplCompCreate(keywordEnforcer, hconfig, config, &
456456
type(ESMF_CplComp) :: cplcomp
457457
integer :: localrc ! local error localrc
458458

459+
ESMF_INIT_CHECK_DEEP(ESMF_HConfigGetInit,hconfig,rc)
459460
ESMF_INIT_CHECK_DEEP(ESMF_ConfigGetInit,config,rc)
460461
ESMF_INIT_CHECK_DEEP(ESMF_ClockGetInit,clock,rc)
461462

@@ -1887,12 +1888,13 @@ end subroutine ESMF_CplCompServiceLoop
18871888
! !IROUTINE: ESMF_CplCompSet - Set or reset information about the CplComp
18881889
!
18891890
! !INTERFACE:
1890-
subroutine ESMF_CplCompSet(cplcomp, keywordEnforcer, config, configFile, &
1891-
clock, name, rc)
1891+
subroutine ESMF_CplCompSet(cplcomp, keywordEnforcer, hconfig, config, &
1892+
configFile, clock, name, rc)
18921893
!
18931894
! !ARGUMENTS:
18941895
type(ESMF_CplComp), intent(inout) :: cplcomp
18951896
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
1897+
type(ESMF_HConfig), intent(in), optional :: hconfig
18961898
type(ESMF_Config), intent(in), optional :: config
18971899
character(len=*), intent(in), optional :: configFile
18981900
type(ESMF_Clock), intent(in), optional :: clock
@@ -1902,6 +1904,11 @@ subroutine ESMF_CplCompSet(cplcomp, keywordEnforcer, config, configFile, &
19021904
! !STATUS:
19031905
! \begin{itemize}
19041906
! \item\apiStatusCompatibleVersion{5.2.0r}
1907+
! \item\apiStatusModifiedSinceVersion{5.2.0r}
1908+
! \begin{description}
1909+
! \item[8.7.0] Added argument {\tt hconfig} to simplify direct usage of
1910+
! {\tt ESMF\_HConfig} objects with Components.
1911+
! \end{description}
19051912
! \end{itemize}
19061913
!
19071914
! !DESCRIPTION:
@@ -1913,18 +1920,23 @@ subroutine ESMF_CplCompSet(cplcomp, keywordEnforcer, config, configFile, &
19131920
! {\tt ESMF\_CplComp} to change.
19141921
! \item[{[name]}]
19151922
! Set the name of the {\tt ESMF\_CplComp}.
1923+
! \item[{[hconfig]}]
1924+
! An already-created {\tt ESMF\_HConfig} object to be attached to the
1925+
! component.
1926+
! Only one of {\tt hconfig}, {\tt config}, or {\tt configFile} must be
1927+
! specified.
19161928
! \item[{[config]}]
19171929
! An already-created {\tt ESMF\_Config} object to be attached to the
19181930
! component.
1919-
! If both {\tt config} and {\tt configFile} arguments are specified,
1920-
! {\tt config} takes priority.
1931+
! Only one of {\tt hconfig}, {\tt config}, or {\tt configFile} must be
1932+
! specified.
19211933
! \item[{[configFile]}]
1922-
! The filename of an {\tt ESMF\_Config} format file.
1934+
! The filename of a config file.
19231935
! If specified, a new {\tt ESMF\_Config} object is created and attached to the
19241936
! component. The {\tt configFile} file is opened and associated
19251937
! with the new config object.
1926-
! If both {\tt config} and {\tt configFile} arguments are specified,
1927-
! {\tt config} takes priority.
1938+
! Only one of {\tt hconfig}, {\tt config}, or {\tt configFile} must be
1939+
! specified.
19281940
! \item[{[clock]}]
19291941
! Set the private clock for this {\tt ESMF\_CplComp}.
19301942
! \item[{[rc]}]
@@ -1940,6 +1952,7 @@ subroutine ESMF_CplCompSet(cplcomp, keywordEnforcer, config, configFile, &
19401952
localrc = ESMF_RC_NOT_IMPL
19411953

19421954
ESMF_INIT_CHECK_DEEP(ESMF_CplCompGetInit,cplcomp,rc)
1955+
ESMF_INIT_CHECK_DEEP(ESMF_HConfigGetInit,hconfig,rc)
19431956
ESMF_INIT_CHECK_DEEP(ESMF_ConfigGetInit,config,rc)
19441957
ESMF_INIT_CHECK_DEEP(ESMF_ClockGetInit,clock,rc)
19451958

@@ -1948,14 +1961,14 @@ subroutine ESMF_CplCompSet(cplcomp, keywordEnforcer, config, configFile, &
19481961
cplcomp%name = trim(name)
19491962
! call Comp method (without name)
19501963
call ESMF_CompSet(cplcomp%compp, clock=clock, &
1951-
configFile=configFile, config=config, rc=localrc)
1964+
configFile=configFile, config=config, hconfig=hconfig, rc=localrc)
19521965
if (ESMF_LogFoundError(localrc, &
19531966
ESMF_ERR_PASSTHRU, &
19541967
ESMF_CONTEXT, rcToReturn=rc)) return
19551968
else
19561969
! call Comp method
19571970
call ESMF_CompSet(cplcomp%compp, name=name, clock=clock, &
1958-
configFile=configFile, config=config, rc=localrc)
1971+
configFile=configFile, config=config, hconfig=hconfig, rc=localrc)
19591972
if (ESMF_LogFoundError(localrc, &
19601973
ESMF_ERR_PASSTHRU, &
19611974
ESMF_CONTEXT, rcToReturn=rc)) return

src/Superstructure/Component/src/ESMF_GridComp.F90

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,7 +2130,7 @@ end subroutine ESMF_GridCompServiceLoop
21302130
! !INTERFACE:
21312131
subroutine ESMF_GridCompSet(gridcomp, keywordEnforcer, grid, gridList, &
21322132
mesh, meshList, locstream, locstreamList, xgrid, xgridList, &
2133-
config, configFile, clock, name, rc)
2133+
hconfig, config, configFile, clock, name, rc)
21342134
!
21352135
! !ARGUMENTS:
21362136
type(ESMF_GridComp), intent(inout) :: gridcomp
@@ -2143,6 +2143,7 @@ subroutine ESMF_GridCompSet(gridcomp, keywordEnforcer, grid, gridList, &
21432143
type(ESMF_LocStream), intent(in), optional :: locstreamList(:)
21442144
type(ESMF_XGrid), intent(in), optional :: xgrid
21452145
type(ESMF_XGrid), intent(in), optional :: xgridList(:)
2146+
type(ESMF_HConfig), intent(in), optional :: hconfig
21462147
type(ESMF_Config), intent(in), optional :: config
21472148
character(len=*), intent(in), optional :: configFile
21482149
type(ESMF_Clock), intent(in), optional :: clock
@@ -2160,6 +2161,8 @@ subroutine ESMF_GridCompSet(gridcomp, keywordEnforcer, grid, gridList, &
21602161
! These arguments add support for holding references to multiple geom objects,
21612162
! either of the same type, or different type, in the same
21622163
! {\tt ESMF\_GridComp} object.
2164+
! \item[8.7.0] Added argument {\tt hconfig} to simplify direct usage of
2165+
! {\tt ESMF\_HConfig} objects with Components.
21632166
! \end{sloppypar}
21642167
! \end{description}
21652168
! \end{itemize}
@@ -2257,18 +2260,23 @@ subroutine ESMF_GridCompSet(gridcomp, keywordEnforcer, grid, gridList, &
22572260
! By default, i.e. if neither {\tt xgrid} nor {\tt xgridList} are provided,
22582261
! the {\tt ESMF\_XGrid} association of the incoming {\tt gridcomp}
22592262
! component remains unchanged.
2263+
! \item[{[hconfig]}]
2264+
! An already-created {\tt ESMF\_HConfig} object to be attached to the
2265+
! component.
2266+
! Only one of {\tt hconfig}, {\tt config}, or {\tt configFile} must be
2267+
! specified.
22602268
! \item[{[config]}]
22612269
! An already-created {\tt ESMF\_Config} object to be attached to the
22622270
! component.
2263-
! If both {\tt config} and {\tt configFile} arguments are specified,
2264-
! {\tt config} takes priority.
2271+
! Only one of {\tt hconfig}, {\tt config}, or {\tt configFile} must be
2272+
! specified.
22652273
! \item[{[configFile]}]
2266-
! The filename of an {\tt ESMF\_Config} format file.
2274+
! The filename of a config file.
22672275
! If specified, a new {\tt ESMF\_Config} object is created and attached to the
22682276
! component. The {\tt configFile} file is opened and associated
22692277
! with the new config object.
2270-
! If both {\tt config} and {\tt configFile} arguments are specified,
2271-
! {\tt config} takes priority.
2278+
! Only one of {\tt hconfig}, {\tt config}, or {\tt configFile} must be
2279+
! specified.
22722280
! \item[{[clock]}]
22732281
! Set the private clock for this {\tt ESMF\_GridComp}.
22742282
! \item[{[name]}]
@@ -2287,6 +2295,7 @@ subroutine ESMF_GridCompSet(gridcomp, keywordEnforcer, grid, gridList, &
22872295

22882296
ESMF_INIT_CHECK_DEEP(ESMF_GridCompGetInit,gridcomp,rc)
22892297
ESMF_INIT_CHECK_DEEP(ESMF_GridGetInit,grid,rc)
2298+
ESMF_INIT_CHECK_DEEP(ESMF_HConfigGetInit,hconfig,rc)
22902299
ESMF_INIT_CHECK_DEEP(ESMF_ConfigGetInit,config,rc)
22912300
ESMF_INIT_CHECK_DEEP(ESMF_ClockGetInit,clock,rc)
22922301

@@ -2298,7 +2307,7 @@ subroutine ESMF_GridCompSet(gridcomp, keywordEnforcer, grid, gridList, &
22982307
grid=grid, gridList=gridList, mesh=mesh, meshList=meshList, &
22992308
locstream=locstream, locstreamList=locstreamList, xgrid=xgrid, &
23002309
xgridList=xgridList, clock=clock, configFile=configFile, config=config, &
2301-
rc=localrc)
2310+
hconfig=hconfig, rc=localrc)
23022311
if (ESMF_LogFoundError(localrc, &
23032312
ESMF_ERR_PASSTHRU, &
23042313
ESMF_CONTEXT, rcToReturn=rc)) return
@@ -2308,7 +2317,7 @@ subroutine ESMF_GridCompSet(gridcomp, keywordEnforcer, grid, gridList, &
23082317
grid=grid, gridList=gridList, mesh=mesh, meshList=meshList, &
23092318
locstream=locstream, locstreamList=locstreamList, xgrid=xgrid, &
23102319
xgridList=xgridList, clock=clock, configFile=configFile, config=config, &
2311-
rc=localrc)
2320+
hconfig=hconfig, rc=localrc)
23122321
if (ESMF_LogFoundError(localrc, &
23132322
ESMF_ERR_PASSTHRU, &
23142323
ESMF_CONTEXT, rcToReturn=rc)) return

src/Superstructure/Component/tests/ESMF_CplCompCreateUTest.F90

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ program ESMF_CplCompCreateUTest
623623
!-------------------------------------------------------------------------
624624
! !
625625
!EX_UTest
626-
write(name, *) "GridCompDestroy Test"
626+
write(name, *) "CplCompDestroy Test"
627627
write(failMsg, *) "Did not return ESMF_SUCCESS"
628628
call ESMF_CplCompDestroy(cpl2, rc=rc)
629629
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
@@ -642,7 +642,7 @@ program ESMF_CplCompCreateUTest
642642
!-------------------------------------------------------------------------
643643
! !
644644
!EX_UTest
645-
write(name, *) "GridCompDestroy Test"
645+
write(name, *) "CplCompDestroy Test"
646646
write(failMsg, *) "Did not return ESMF_SUCCESS"
647647
call ESMF_CplCompDestroy(cpl2, rc=rc)
648648
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
@@ -695,6 +695,58 @@ program ESMF_CplCompCreateUTest
695695

696696
call ESMF_Test((rc.ne.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
697697

698+
!-------------------------------------------------------------------------
699+
! !
700+
!EX_UTest
701+
! ! Test creation of a Component
702+
write(name, *) "Creating a Component Test"
703+
write(failMsg, *) "Did return ESMF_SUCCESS"
704+
705+
cpl2 = ESMF_CplCompCreate(name="TestComp", rc=rc)
706+
707+
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
708+
709+
!-------------------------------------------------------------------------
710+
! !
711+
!EX_UTest
712+
! ! Set a hconfig
713+
write(name, *) "Setting HConfig Test"
714+
write(failMsg, *) "Did return ESMF_SUCCESS"
715+
716+
call ESMF_CplCompSet(cpl2, hconfig=hconfig, rc=rc)
717+
718+
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
719+
720+
!-------------------------------------------------------------------------
721+
! !
722+
!EX_UTest
723+
! ! Set a config
724+
write(name, *) "Setting Config Test"
725+
write(failMsg, *) "Did return ESMF_SUCCESS"
726+
727+
call ESMF_CplCompSet(cpl2, config=config, rc=rc)
728+
729+
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
730+
731+
!-------------------------------------------------------------------------
732+
! !
733+
!EX_UTest
734+
! ! Set a hconfig and config
735+
write(name, *) "Setting HConfig and Config Test"
736+
write(failMsg, *) "Did not return expected return code"
737+
738+
call ESMF_CplCompSet(cpl2, hconfig=hconfig, config=config, rc=rc)
739+
740+
call ESMF_Test((rc.ne.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
741+
742+
!-------------------------------------------------------------------------
743+
! !
744+
!EX_UTest
745+
write(name, *) "CplCompDestroy Test"
746+
write(failMsg, *) "Did not return ESMF_SUCCESS"
747+
call ESMF_CplCompDestroy(cpl2, rc=rc)
748+
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
749+
698750
!-------------------------------------------------------------------------
699751
! !
700752
!EX_UTest

src/Superstructure/Component/tests/ESMF_GridCompCreateUTest.F90

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,58 @@ program ESMF_GridCompCreateUTest
902902

903903
call ESMF_Test((rc.ne.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
904904

905+
!-------------------------------------------------------------------------
906+
! !
907+
!EX_UTest
908+
! ! Test creation of a Component
909+
write(name, *) "Creating a Component Test"
910+
write(failMsg, *) "Did return ESMF_SUCCESS"
911+
912+
gcomp2 = ESMF_GridCompCreate(name="TestComp", rc=rc)
913+
914+
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
915+
916+
!-------------------------------------------------------------------------
917+
! !
918+
!EX_UTest
919+
! ! Set a hconfig
920+
write(name, *) "Setting HConfig Test"
921+
write(failMsg, *) "Did return ESMF_SUCCESS"
922+
923+
call ESMF_GridCompSet(gcomp2, hconfig=hconfig, rc=rc)
924+
925+
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
926+
927+
!-------------------------------------------------------------------------
928+
! !
929+
!EX_UTest
930+
! ! Set a config
931+
write(name, *) "Setting Config Test"
932+
write(failMsg, *) "Did return ESMF_SUCCESS"
933+
934+
call ESMF_GridCompSet(gcomp2, config=config, rc=rc)
935+
936+
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
937+
938+
!-------------------------------------------------------------------------
939+
! !
940+
!EX_UTest
941+
! ! Set a hconfig and config
942+
write(name, *) "Setting HConfig and Config Test"
943+
write(failMsg, *) "Did not return expected return code"
944+
945+
call ESMF_GridCompSet(gcomp2, hconfig=hconfig, config=config, rc=rc)
946+
947+
call ESMF_Test((rc.ne.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
948+
949+
!-------------------------------------------------------------------------
950+
! !
951+
!EX_UTest
952+
write(name, *) "GridCompDestroy Test"
953+
write(failMsg, *) "Did not return ESMF_SUCCESS"
954+
call ESMF_GridCompDestroy(gcomp2, rc=rc)
955+
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
956+
905957
!-------------------------------------------------------------------------
906958
! !
907959
!EX_UTest

0 commit comments

Comments
 (0)