Skip to content

Commit 7b5175d

Browse files
Merge pull request #1142 from GEOS-ESM/borescan/catchCN_clm_5.1_fix
2 parents 5bd2d2e + 0a15ba1 commit 7b5175d

File tree

3 files changed

+45
-40
lines changed

3 files changed

+45
-40
lines changed

GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatchCN_GridComp/GEOS_CatchCNGridComp.F90

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
! It is a proxy of clm 4.0 and clm 4.5
1+
! It is a proxy of CNCLM40 and CNCLM51
22

33
#include "MAPL_Generic.h"
44

@@ -86,33 +86,39 @@ subroutine SetServices ( GC, RC )
8686
call MAPL_GetResource ( MAPL, CATCHCN_INTERNAL_STATE%CATCH_SPINUP, Label="CATCHMENT_SPINUP:", DEFAULT=0, RC=STATUS)
8787
VERIFY_(STATUS)
8888

89-
! resource variables from GEOS_SurfaceGridComp.rc
89+
! put resource variables from rc file into SCF config object (GCM: SURFRC=GEOS_SurfaceGridComp.rc, LDAS: SURFRC=LDAS.rc)
9090
call MAPL_GetResource ( MAPL, SURFRC, label = 'SURFRC:', default = 'GEOS_SurfaceGridComp.rc', RC=STATUS) ; VERIFY_(STATUS)
9191
SCF = ESMF_ConfigCreate(rc=status) ; VERIFY_(STATUS)
9292
call ESMF_ConfigLoadFile(SCF,SURFRC,rc=status) ; VERIFY_(STATUS)
9393

94+
! assemble internal state from SCF config object
9495
call surface_params_to_wrap_state(statePtr, SCF, _RC)
9596

9697
call ESMF_ConfigDestroy(SCF, _RC)
97-
98-
call MAPL_Get (MAPL, CF=CF, _RC)
99-
100-
call ESMF_ConfigSetAttribute(CF, value=CATCHCN_INTERNAL_STATE%CN_CLM51_NML_FILE, Label='CN_CLM51_NML_FILE:', _RC)
101-
call ESMF_ConfigSetAttribute(CF, value=CATCHCN_INTERNAL_STATE%ATM_CO2, Label='ATM_CO2:', _RC)
102-
call ESMF_ConfigSetAttribute(CF, value=CATCHCN_INTERNAL_STATE%N_CONST_LAND4SNWALB, Label='N_CONST_LAND4SNWALB:', _RC)
103-
call ESMF_ConfigSetAttribute(CF, value=CATCHCN_INTERNAL_STATE%RUN_IRRIG, Label='RUN_IRRIG:', _RC)
104-
call ESMF_ConfigSetAttribute(CF, value=CATCHCN_INTERNAL_STATE%PRESCRIBE_DVG, Label='PRESCRIBE_DVG:', _RC)
105-
call ESMF_ConfigSetAttribute(CF, value=CATCHCN_INTERNAL_STATE%SNOW_ALBEDO_INFO, Label='SNOW_ALBEDO_INFO:', _RC)
106-
call MAPL_Set (MAPL, CF=CF, _RC)
107-
98+
10899
call MAPL_GetResource ( MAPL, LSM_CHOICE, Label="LSM_CHOICE:", DEFAULT=2, RC=STATUS)
109100
VERIFY_(STATUS)
101+
102+
! Add select rc variables to [the CF config object within] MAPL so that the Children GridComps (CNCLM40 and CNCLM51) can get
103+
! them in SetServices() from MAPL. In the Children's SetServices(), "catchcn_internal" is not yet available.
104+
call MAPL_Get (MAPL, CF=CF, _RC)
105+
call ESMF_ConfigSetAttribute(CF, value=CATCHCN_INTERNAL_STATE%ATM_CO2, Label='ATM_CO2:', _RC)
106+
call ESMF_ConfigSetAttribute(CF, value=CATCHCN_INTERNAL_STATE%N_CONST_LAND4SNWALB, Label='N_CONST_LAND4SNWALB:', _RC)
107+
call ESMF_ConfigSetAttribute(CF, value=CATCHCN_INTERNAL_STATE%SNOW_ALBEDO_INFO, Label='SNOW_ALBEDO_INFO:', _RC)
108+
if (LSM_CHOICE==2) then
109+
call ESMF_ConfigSetAttribute(CF, value=CATCHCN_INTERNAL_STATE%RUN_IRRIG, Label='RUN_IRRIG:', _RC)
110+
call ESMF_ConfigSetAttribute(CF, value=CATCHCN_INTERNAL_STATE%PRESCRIBE_DVG, Label='PRESCRIBE_DVG:', _RC)
111+
elseif (LSM_CHOICE==4) then
112+
call ESMF_ConfigSetAttribute(CF, value=CATCHCN_INTERNAL_STATE%MOSFC_EXTRA_DERIVS_OFFL_LAND, Label='MOSFC_EXTRA_DERIVS_OFFL_LAND:', _RC)
113+
end if
114+
call MAPL_Set (MAPL, CF=CF, _RC)
110115

116+
! prep CatchCN ensemble and Children
111117
tmp = ''
112118
if (NUM_LDAS_ENSEMBLE >1) then
113-
!catchcn_exxxx
114-
tmp(1:ens_id_width)=COMP_NAME(8:8+ens_id_width-1)
115-
endif
119+
!catchcn_exxxx
120+
tmp(1:ens_id_width)=COMP_NAME(8:8+ens_id_width-1)
121+
endif
116122

117123
if ( LSM_CHOICE == 2 ) then
118124
CATCHCN = MAPL_AddChild('CATCHCNCLM40'//trim(tmp), 'setservices_', parentGC=GC, sharedObj='libGEOScatchCNCLM40_GridComp.so', RC=STATUS)
@@ -131,13 +137,13 @@ subroutine SetServices ( GC, RC )
131137
call MAPL_GridCompSetEntryPoint ( GC, ESMF_METHOD_INITIALIZE, Initialize, RC=STATUS )
132138
VERIFY_(STATUS)
133139

134-
call MAPL_GridCompSetEntryPoint ( GC, ESMF_METHOD_RUN, RUN1, RC=STATUS )
140+
call MAPL_GridCompSetEntryPoint ( GC, ESMF_METHOD_RUN, RUN1, RC=STATUS )
135141
VERIFY_(STATUS)
136142

137-
call MAPL_GridCompSetEntryPoint ( GC, ESMF_METHOD_RUN, RUN2, RC=STATUS )
143+
call MAPL_GridCompSetEntryPoint ( GC, ESMF_METHOD_RUN, RUN2, RC=STATUS )
138144
VERIFY_(STATUS)
139145

140-
call MAPL_GridCompSetEntryPoint ( GC, ESMF_METHOD_FINALIZE, Finalize, RC=status)
146+
call MAPL_GridCompSetEntryPoint ( GC, ESMF_METHOD_FINALIZE, Finalize, RC=status)
141147
VERIFY_(status)
142148

143149
! Set the state variable specs. ( should be the combinations of clm4.0 and clm4.5

GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatchCN_GridComp/GEOScatchCNCLM51_GridComp/GEOS_CatchCNCLM51GridComp.F90

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,10 @@ subroutine SetServices ( GC, RC )
200200
! Local Variables
201201

202202
type(MAPL_MetaComp), pointer :: MAPL=>null()
203-
type(T_CATCHCN_STATE), pointer :: CATCHCN_INTERNAL
204-
class(T_CATCHCN_STATE), pointer :: statePtr
205-
type(CATCHCN_WRAP) :: wrap
206-
integer :: OFFLINE_MODE
207-
integer :: RESTART
208203

204+
integer :: OFFLINE_MODE, ATM_CO2, SNOW_ALBEDO_INFO, MOSFC_EXTRA_DERIVS_OFFL_LAND, N_CONST_LAND4SNWALB
205+
integer :: RESTART
206+
209207
! Begin...
210208
! --------
211209

@@ -221,20 +219,20 @@ subroutine SetServices ( GC, RC )
221219
! it in the private internal state of the GridComp. It is a little
222220
! unusual to read resource file in SetServices, but we need to know
223221
! at this stage where we are running Catch in the offline mode or not
224-
225-
allocate(CATCHCN_INTERNAL, stat=status)
226-
VERIFY_(status)
227-
statePtr => CATCHCN_INTERNAL
228-
222+
229223
! resource variables for offline GEOSldas; for documentation, see GEOSldas/src/Applications/LDAS_App/GEOSldas_LDAS.rc
224+
!
225+
! NOTE: In SetServices(), the internal state ("catchcn_internal") has not yet been passed down from the parent (CatchCN),
226+
! so it should not be used.
227+
230228
call MAPL_GetObjectFromGC(gc, MAPL, rc=status)
231229
VERIFY_(status)
232-
call MAPL_GetResource ( MAPL, CATCHCN_INTERNAL%CATCH_OFFLINE, Label="CATCHMENT_OFFLINE:", DEFAULT=0, RC=STATUS)
233-
VERIFY_(STATUS)
234-
call MAPL_GetResource ( MAPL, CATCHCN_INTERNAL%CATCH_SPINUP, Label="CATCHMENT_SPINUP:", DEFAULT=0, RC=STATUS)
235-
VERIFY_(STATUS)
236230

237-
OFFLINE_MODE = CATCHCN_INTERNAL%CATCH_OFFLINE ! shorthand
231+
call MAPL_GetResource ( MAPL, OFFLINE_MODE, Label="CATCHMENT_OFFLINE:", DEFAULT=0, _RC)
232+
call MAPL_GetResource ( MAPL, ATM_CO2, Label="ATM_CO2:", DEFAULT=2, _RC)
233+
call MAPL_GetResource ( MAPL, N_CONST_LAND4SNWALB, Label="N_CONST_LAND4SNWALB:", DEFAULT=0, _RC)
234+
call MAPL_GetResource ( MAPL, SNOW_ALBEDO_INFO, Label="SNOW_ALBEDO_INFO:", DEFAULT=0, _RC)
235+
call MAPL_GetResource ( MAPL, MOSFC_EXTRA_DERIVS_OFFL_LAND, Label="MOSFC_EXTRA_DERIVS_OFFL_LAND:", DEFAULT=0, _RC) ! 0 is default for GCM only!
238236

239237
! Set the Run entry points
240238
! ------------------------
@@ -436,7 +434,7 @@ subroutine SetServices ( GC, RC )
436434
RC=STATUS )
437435
VERIFY_(STATUS)
438436

439-
IF (catchcn_internal%ATM_CO2 == 4) THEN
437+
IF (ATM_CO2 == 4) THEN
440438
call MAPL_AddImportSpec(GC, &
441439
SHORT_NAME = 'CO2SC', &
442440
LONG_NAME = 'CO2 Surface Concentration Bin 001', &
@@ -1391,7 +1389,7 @@ subroutine SetServices ( GC, RC )
13911389
RC=STATUS )
13921390
VERIFY_(STATUS)
13931391

1394-
if (catchcn_internal%SNOW_ALBEDO_INFO == 1) then
1392+
if (SNOW_ALBEDO_INFO == 1) then
13951393
call MAPL_AddInternalSpec(GC ,&
13961394
LONG_NAME = 'effective_snow_reflectivity',&
13971395
UNITS = '1' ,&
@@ -1459,7 +1457,7 @@ subroutine SetServices ( GC, RC )
14591457
RC=STATUS )
14601458
VERIFY_(STATUS)
14611459

1462-
if (CATCHCN_INTERNAL%MOSFC_EXTRA_DERIVS_OFFL_LAND == 1) then
1460+
if (MOSFC_EXTRA_DERIVS_OFFL_LAND == 1) then
14631461

14641462
! for *analytical* extra derivatives in louissurface
14651463

@@ -1485,7 +1483,7 @@ subroutine SetServices ( GC, RC )
14851483
RC=STATUS )
14861484
VERIFY_(STATUS)
14871485

1488-
elseif (CATCHCN_INTERNAL%MOSFC_EXTRA_DERIVS_OFFL_LAND >= 2) then
1486+
elseif (MOSFC_EXTRA_DERIVS_OFFL_LAND >= 2) then
14891487

14901488
! for *numerical* extra derivatives in helfsurface and louissurface
14911489

@@ -1980,7 +1978,7 @@ subroutine SetServices ( GC, RC )
19801978

19811979
!---------- GOSWIM snow impurity related variables ----------
19821980

1983-
if (catchcn_internal%N_CONST_LAND4SNWALB /= 0) then
1981+
if (N_CONST_LAND4SNWALB /= 0) then
19841982

19851983
call MAPL_AddInternalSpec(GC ,&
19861984
LONG_NAME = 'dust_mass_in_snow_bin_1' ,&

GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,12 @@ subroutine SetServices ( GC, RC )
187187

188188
OFFLINE_MODE = CATCH_INTERNAL_STATE%CATCH_OFFLINE ! shorthand
189189

190-
! resource variables from GEOS_SurfaceGridComp.rc
190+
! put resource variables from rc file into SCF config object (GCM: SURFRC=GEOS_SurfaceGridComp.rc, LDAS: SURFRC=LDAS.rc)
191191
call MAPL_GetResource (MAPL, SURFRC, label = 'SURFRC:', default = 'GEOS_SurfaceGridComp.rc', RC=STATUS) ; VERIFY_(STATUS)
192192
SCF = ESMF_ConfigCreate(rc=status) ; VERIFY_(STATUS)
193193
call ESMF_ConfigLoadFile(SCF,SURFRC,rc=status) ; VERIFY_(STATUS)
194194

195+
! assemble internal state from SCF config object
195196
call surface_params_to_wrap_state(statePtr, SCF, _RC)
196197

197198
call ESMF_ConfigDestroy(SCF, _RC)

0 commit comments

Comments
 (0)