Skip to content

Commit f948214

Browse files
authored
Merge pull request #376 from mvertens/feature/refactor_stream_usage_escomp
major refactor stream of stream usage ### Description of changes Major refactor of stream usage ### Specific notes All data mode files across the data components(except for `datm_datamode_gefs_mod.F90 `and `dice_datamode_cplhist_mod.F90`) now have explicit setting of streams rather than using the implicit copy used by `dfields`. Copies that used to be done implicitly using the naming convention assumed by dfields are now done explictly. This makes it clear what export fields are direct copies and what export fields are derived fields that have no corresponding stream field. In each datamode module - there are now two sections in the module variable list: `export (and sometimes import) state pointers` and `stream pointer`. The following changes have been made throughout the code: `character(*) => character(len=*)`,` trim(subname) => subname` (the latter is done since parameters, e.g. `subname`, don't need trim functions) The following new routines have been introduced or deleted: - **dwav** - dwav_datamode_copyall.F90: new - **drof** - drof_datamode_copyall.F90: new - introduction of new datatype (stream_pointer_type) for multilevel stream pointers - expanded list of stream fields needed for drof.cplhist and added new functionality (e.g. `drof_datamode_cplhist_mod.F90`) to support this addition. - **docn** - combined `docn_datamode_copyall_mod.F90` and `docn_datamode_iaf_mod.F90` into a new file `docn_datamode_sstdata_mod.F90`. The two files `docn_datamode_copyall_mod.F90` and `docn_datamode_iaf_mod.F90` were effectively the same and two different datamodes are not needed since in both cases prescribed SST data was read in. (In addition, docn_datamode_iaf_mod.F90` set pointers to importState data which was never used and not needed). - ocn_comp_nuopc.F90: the datamode copyall is now sstdata and the datamode iaf is removed - changed cplhist and multilev_cplhist taxmode from extend to cycle - **dlnd** - introduction of new datatype (stream_pointer_type) for multilevel stream pointers - **dice** - dice_cplhist_data_mod.F90: still uses dfields since it is used by UFS - **dglc** - introduction of new datatype (stream_pointer_type) for multilevel stream pointers **NOTE**: This PR also provides a new mapfile algorithm as a new option for mapping the streams input to the component model resolution. The new scheme does not have a default but is enabled via adding the following in the appropriate user_nl_XXX_streams where the user needs to fill in the entries in <> below: <stream_name>:mapalgo = "mapfile:<path to mapping file> As an example: `rof.ryf8485_jra:mapalgo="mapfile:/cluster/shared/noresm/inputdata/cpl/cpl6/map_JRA025_to_tnx1v4_e1000r300_170928.nc"`. This new capability enables a significant speedup in stand-alone ocean simulations. See NorESMhub/BLOM#686 (comment). **NOTE***: Contributors other than yourself, if any: None CDEPS Issues Fixed: #377 Are there dependencies on other component PRs (if so list): Are changes expected to change answers (bfb, different to roundoff, more substantial): - docn cplhist mode can change answers due to changing taxmode from extend to cycle Any User Interface Changes (namelist or namelist defaults changes): Testing performed (will describe the noresm testing here) - aux_cdeps_noresm: - compared to baseline cdeps1.0.87_noresm_v1 - all passed (#377) and generated new baseline cdeps1.0.87_noresm_v2) - prealpha_noresm - compared to noresm3_0_beta09 - the only difference is SMS_Lm13.f19_f19_mtn14.I1850Clm50SpG.betzy_intel where atmImp_Faxa_ndep1 and atmImp_Faxa_ndep2 are different due to new new tag cdeps1.0.87_noresm_v2. Hashes used for testing: noresm3_0_beta09 plus this CDEPS branch Also tested with CESM prealpha tests and a few additional tests (see #376 for details.)
2 parents d9afc04 + 9d88ca5 commit f948214

54 files changed

Lines changed: 2612 additions & 2042 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cime_config/stream_cdeps.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,8 @@ def create_stream_xml(
344344

345345
# Check that key is valid
346346
expect(
347-
mod_dict[var_key] in valid_values[var_key],
347+
(mod_dict[var_key] in valid_values[var_key]) or
348+
(var_key == 'mapalgo' and 'mapfile:' in mod_dict[var_key]),
348349
"{} can only have values of {} for stream {} in file {}".format(
349350
var_key,
350351
valid_values[var_key],

datm/atm_comp_nuopc.F90

Lines changed: 61 additions & 134 deletions
Large diffs are not rendered by default.

datm/cime_config/config_component.xml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,7 @@
102102

103103
<entry id="DATM_PRESNDEP">
104104
<type>char</type>
105-
<valid_values>none,
106-
clim_1850_cmip7,clim_2000_cmip7,clim_2010_cmip7,hist_cmip7,
107-
clim_1850_cmip6,clim_2000_cmip6,clim_2010_cmip6,hist_cmip6,
108-
SSP1-2.6,SSP2-4.5,SSP3-7.0,SSP5-3.4,SSP5-8.5,cplhist
109-
</valid_values>
105+
<valid_values>none,clim_1850_cmip7,clim_2000_cmip7,clim_2010_cmip7,hist_cmip7,clim_1850_cmip6,clim_2000_cmip6,clim_2010_cmip6,hist_cmip6,SSP1-2.6,SSP2-4.5,SSP3-7.0,SSP5-3.4,SSP5-8.5,cplhist</valid_values>
110106
<default_value>clim_2000</default_value>
111107
<values match="last">
112108
<value compset="^1850[CE]?_" >clim_1850_cmip6</value>

datm/cime_config/namelist_definition_datm.xml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
<value datm_mode="CLM_QIAN$">
1515
CLM_QIAN.Solar,CLM_QIAN.Precip,CLM_QIAN.TPQW
1616
</value>
17-
<value datm_mode="CLM_QIAN_WISO">
18-
CLM_QIAN_WISO.Solar,CLM_QIAN_WISO.Precip,CLM_QIAN_WISO.TPQW
19-
</value>
2017
<value datm_mode="CLMCRUJRA2024">
2118
CLMCRUJRA2024.Solar,CLMCRUJRA2024.Precip,CLMCRUJRA2024.TPQW
2219
</value>
@@ -329,19 +326,6 @@
329326
</values>
330327
</entry>
331328

332-
<entry id="flds_wiso">
333-
<type>logical</type>
334-
<category>datm</category>
335-
<group>datm_nml</group>
336-
<desc>
337-
If true, prescribed water isotopes are sent from datm (must be true for running with CLM).
338-
</desc>
339-
<values>
340-
<value>.false.</value>
341-
<!-- <value datm_mode="CLM_QIAN_WISO">.true.</value> -->
342-
</values>
343-
</entry>
344-
345329
<entry id="iradsw">
346330
<type>integer</type>
347331
<category>datm</category>

datm/datm_datamode_clmncep_mod.F90

Lines changed: 215 additions & 186 deletions
Large diffs are not rendered by default.

datm/datm_datamode_core2_mod.F90

Lines changed: 91 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module datm_datamode_core2_mod
4545
real(r8), pointer :: Sa_shum(:) => null()
4646
real(r8), pointer :: Sa_pbot(:) => null()
4747
real(r8), pointer :: Sa_pslv(:) => null()
48-
real(r8), pointer :: Faxa_lwdn(:) => null()
48+
real(r8), pointer :: Sa_dens(:) => null()
4949
real(r8), pointer :: Faxa_rainc(:) => null()
5050
real(r8), pointer :: Faxa_rainl(:) => null()
5151
real(r8), pointer :: Faxa_snowc(:) => null()
@@ -55,13 +55,22 @@ module datm_datamode_core2_mod
5555
real(r8), pointer :: Faxa_swvdr(:) => null()
5656
real(r8), pointer :: Faxa_swvdf(:) => null()
5757
real(r8), pointer :: Faxa_swnet(:) => null()
58+
real(r8), pointer :: Faxa_swdn(:) => null()
59+
real(r8), pointer :: Faxa_lwdn(:) => null()
5860

59-
! stream data
60-
real(r8), pointer :: strm_prec(:) => null()
61-
real(r8), pointer :: strm_swdn(:) => null()
62-
real(r8), pointer :: strm_tarcf(:) => null()
63-
64-
! othe module arrays
61+
! required stream data points
62+
real(r8), pointer :: strm_Faxa_prec(:) => null()
63+
real(r8), pointer :: strm_Faxa_swdn(:) => null()
64+
real(r8), pointer :: strm_Faxa_lwdn(:) => null()
65+
real(r8), pointer :: strm_Sa_pslv(:) => null()
66+
real(r8), pointer :: strm_Sa_tbot(:) => null()
67+
real(r8), pointer :: strm_Sa_shum(:) => null()
68+
real(r8), pointer :: strm_Sa_dens(:) => null()
69+
real(r8), pointer :: strm_Sa_u(:) => null()
70+
real(r8), pointer :: strm_Sa_v(:) => null()
71+
real(r8), pointer :: strm_tarcf(:) => null()
72+
73+
! other module arrays
6574
real(R8), pointer :: windFactor(:)
6675
real(R8), pointer :: winddFactor(:)
6776
real(R8), pointer :: qsatFactor(:)
@@ -159,31 +168,6 @@ subroutine datm_datamode_core2_init_pointers(exportState, sdat, datamode, factor
159168

160169
rc = ESMF_SUCCESS
161170

162-
lsize = sdat%model_lsize
163-
164-
! allocate module arrays
165-
allocate(windFactor(lsize))
166-
allocate(winddFactor(lsize))
167-
allocate(qsatFactor(lsize))
168-
169-
call ESMF_MeshGet(sdat%model_mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc)
170-
if (ChkErr(rc,__LINE__,u_FILE_u)) return
171-
allocate(ownedElemCoords(spatialDim*numOwnedElements))
172-
allocate(yc(numOwnedElements))
173-
call ESMF_MeshGet(sdat%model_mesh, ownedElemCoords=ownedElemCoords)
174-
if (ChkErr(rc,__LINE__,u_FILE_u)) return
175-
do n = 1,numOwnedElements
176-
yc(n) = ownedElemCoords(2*n)
177-
end do
178-
179-
! get stream pointers
180-
call shr_strdata_get_stream_pointer( sdat, 'Faxa_prec' , strm_prec , rc)
181-
if (ChkErr(rc,__LINE__,u_FILE_u)) return
182-
call shr_strdata_get_stream_pointer( sdat, 'Faxa_swdn' , strm_swdn , rc)
183-
if (ChkErr(rc,__LINE__,u_FILE_u)) return
184-
call shr_strdata_get_stream_pointer( sdat, 'tarcf' , strm_tarcf , rc)
185-
if (ChkErr(rc,__LINE__,u_FILE_u)) return
186-
187171
! get export state pointers
188172
call dshr_state_getfldptr(exportState, 'Sa_z' , fldptr1=Sa_z , rc=rc)
189173
if (ChkErr(rc,__LINE__,u_FILE_u)) return
@@ -205,6 +189,8 @@ subroutine datm_datamode_core2_init_pointers(exportState, sdat, datamode, factor
205189
if (ChkErr(rc,__LINE__,u_FILE_u)) return
206190
call dshr_state_getfldptr(exportState, 'Sa_shum' , fldptr1=Sa_shum , rc=rc)
207191
if (ChkErr(rc,__LINE__,u_FILE_u)) return
192+
call dshr_state_getfldptr(exportState, 'Sa_dens' , fldptr1=Sa_dens , rc=rc)
193+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
208194
call dshr_state_getfldptr(exportState, 'Faxa_rainc' , fldptr1=Faxa_rainc , rc=rc)
209195
if (ChkErr(rc,__LINE__,u_FILE_u)) return
210196
call dshr_state_getfldptr(exportState, 'Faxa_rainl' , fldptr1=Faxa_rainl , rc=rc)
@@ -223,22 +209,63 @@ subroutine datm_datamode_core2_init_pointers(exportState, sdat, datamode, factor
223209
if (ChkErr(rc,__LINE__,u_FILE_u)) return
224210
call dshr_state_getfldptr(exportState, 'Faxa_swnet' , fldptr1=Faxa_swnet , rc=rc)
225211
if (ChkErr(rc,__LINE__,u_FILE_u)) return
212+
call dshr_state_getfldptr(exportState, 'Faxa_swdn' , fldptr1=Faxa_swdn , rc=rc)
213+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
226214
call dshr_state_getfldptr(exportState, 'Faxa_lwdn' , fldptr1=Faxa_lwdn , rc=rc)
227215
if (ChkErr(rc,__LINE__,u_FILE_u)) return
228216

229-
if (.not. associated(strm_prec) .or. .not. associated(strm_swdn)) then
230-
call shr_log_error(subname//'ERROR: prec and swdn must be in streams for CORE2', rc=rc)
217+
! get required stream pointers
218+
call shr_strdata_get_stream_pointer( sdat, 'Faxa_prec' , strm_Faxa_prec , requirePointer=.true., &
219+
errmsg=subname//'ERROR: strm_Faxa_prec must be associated for core2 datamode', rc=rc)
220+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
221+
call shr_strdata_get_stream_pointer( sdat, 'Faxa_swdn' , strm_Faxa_swdn , requirePointer=.true., &
222+
errmsg=subname//'ERROR: strm_Faxa_swdn must be associated for core2 datamode', rc=rc)
223+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
224+
call shr_strdata_get_stream_pointer( sdat, 'Faxa_lwdn' , strm_Faxa_lwdn , requirePointer=.true., &
225+
errmsg=subname//'ERROR: strm_Faxa_lwdn must be associated for core2 datamode', rc=rc)
226+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
227+
call shr_strdata_get_stream_pointer( sdat, 'Sa_pslv' , strm_Sa_pslv , requirePointer=.true., &
228+
errmsg=subname//'ERROR: strm_Sa_pslv must be associated for core2 datamode', rc=rc)
229+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
230+
call shr_strdata_get_stream_pointer( sdat, 'Sa_tbot' , strm_Sa_tbot , requirePointer=.true., &
231+
errmsg=subname//'ERROR: strm_Sa_tbot must be associated for core2 datamode', rc=rc)
232+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
233+
call shr_strdata_get_stream_pointer( sdat, 'Sa_u' , strm_Sa_u , requirePointer=.true., &
234+
errmsg=subname//'ERROR: strm_Sa_u must be associated for core2 datamode', rc=rc)
235+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
236+
call shr_strdata_get_stream_pointer( sdat, 'Sa_v' , strm_Sa_v , requirePointer=.true., &
237+
errmsg=subname//'ERROR: strm_Sa_v must be associated for core2 datamode', rc=rc)
238+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
239+
call shr_strdata_get_stream_pointer( sdat, 'Sa_shum' , strm_Sa_shum , requirePointer=.true., &
240+
errmsg=subname//'ERROR: strm_Sa_shum must be associated for core2 datamode', rc=rc)
241+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
242+
call shr_strdata_get_stream_pointer( sdat, 'Sa_dens' , strm_Sa_dens , requirePointer=.true., &
243+
errmsg=subname//'ERROR: strm_Sa_dens must be associated for core2 datamode', rc=rc)
244+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
245+
call shr_strdata_get_stream_pointer( sdat, 'tarcf', strm_tarcf, rc) ! required for CORE2_IAF
246+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
247+
if (trim(datamode) == 'CORE2_IAF' .and. .not. associated(strm_tarcf)) then
248+
call shr_log_error(subname//'tarcf must be associated for CORE2_IAF', rc=rc)
231249
return
232250
endif
233251

234-
if (trim(datamode) == 'CORE2_IAF' ) then
235-
if (.not. associated(strm_tarcf)) then
236-
call shr_log_error(subname//'tarcf must be in an input stream for CORE2_IAF', rc=rc)
237-
return
238-
endif
239-
endif
252+
! create yc
253+
call ESMF_MeshGet(sdat%model_mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc)
254+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
255+
allocate(ownedElemCoords(spatialDim*numOwnedElements))
256+
allocate(yc(numOwnedElements))
257+
call ESMF_MeshGet(sdat%model_mesh, ownedElemCoords=ownedElemCoords)
258+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
259+
do n = 1,numOwnedElements
260+
yc(n) = ownedElemCoords(2*n)
261+
end do
262+
deallocate(ownedElemCoords)
240263

241264
! create adjustment factor arrays
265+
lsize = sdat%model_lsize
266+
allocate(windFactor(lsize))
267+
allocate(winddFactor(lsize))
268+
allocate(qsatFactor(lsize))
242269
call datm_get_adjustment_factors(sdat, factorFn_mesh, factorFn_data, windFactor, winddFactor, qsatFactor, rc)
243270
if (ChkErr(rc,__LINE__,u_FILE_u)) return
244271

@@ -278,11 +305,13 @@ subroutine datm_datamode_core2_advance(datamode, target_ymd, target_tod, target_
278305
cosfactor = cos((2.0_R8*SHR_CONST_PI*rday)/365 - phs_c0)
279306

280307
do n = 1,lsize
308+
309+
!--- set Sa_z to a constant ---
281310
Sa_z(n) = 10.0_R8
282311

283312
!--- correction to NCEP winds based on QSCAT ---
284-
uprime = Sa_u(n)*windFactor(n)
285-
vprime = Sa_v(n)*windFactor(n)
313+
uprime = strm_Sa_u(n)*windFactor(n)
314+
vprime = strm_Sa_v(n)*windFactor(n)
286315
Sa_u(n) = uprime*cos(winddFactor(n)*degtorad) - vprime*sin(winddFactor(n)*degtorad)
287316
Sa_v(n) = uprime*sin(winddFactor(n)*degtorad) + vprime*cos(winddFactor(n)*degtorad)
288317

@@ -291,9 +320,12 @@ subroutine datm_datamode_core2_advance(datamode, target_ymd, target_tod, target_
291320
Sa_v10m(n) = Sa_v(n)
292321

293322
!--- density and pslv taken directly from input stream, set pbot ---
323+
Sa_pslv(n) = strm_Sa_pslv(n)
324+
Sa_dens(n) = strm_Sa_dens(n)
294325
Sa_pbot(n) = Sa_pslv(n)
295326

296327
!--- correction to NCEP Arctic & Antarctic air T & potential T ---
328+
Sa_tbot(n) = strm_Sa_tbot(n)
297329
if ( yc(n) < -60.0_R8 ) then
298330
tMin = (avg_c0 + avg_c1*yc(n)) + (amp_c0 + amp_c1*yc(n))*cosFactor + tKFrz
299331
Sa_tbot(n) = max(Sa_tbot(n), tMin)
@@ -304,7 +336,7 @@ subroutine datm_datamode_core2_advance(datamode, target_ymd, target_tod, target_
304336
Sa_ptem(n) = Sa_tbot(n)
305337

306338
!--- correction to NCEP relative humidity for heat budget balance ---
307-
Sa_shum(n) = Sa_shum(n) + qsatFactor(n)
339+
Sa_shum(n) = strm_Sa_shum(n) + qsatFactor(n)
308340

309341
!--- Dupont correction to NCEP Arctic air T ---
310342
!--- don't correct during summer months (July-September)
@@ -315,34 +347,37 @@ subroutine datm_datamode_core2_advance(datamode, target_ymd, target_tod, target_
315347
end if
316348

317349
! PRECIPITATION DATA
318-
strm_prec(n) = strm_prec(n)/86400.0_R8 ! convert mm/day to kg/m^2/s
350+
strm_Faxa_prec(n) = strm_Faxa_prec(n)/86400.0_R8 ! convert mm/day to kg/m^2/s
319351
! only correct satellite products, do not correct Serreze Arctic data
320352
if ( yc(n) < 58. ) then
321-
strm_prec(n) = strm_prec(n)*1.14168_R8
353+
strm_Faxa_prec(n) = strm_Faxa_prec(n)*1.14168_R8
322354
endif
323355
if ( yc(n) >= 58. .and. yc(n) < 68. ) then
324356
factor = MAX(0.0_R8, 1.0_R8 - 0.1_R8*(yc(n)-58.0_R8) )
325-
strm_prec(n) = strm_prec(n)*(factor*(1.14168_R8 - 1.0_R8) + 1.0_R8)
357+
strm_Faxa_prec(n) = strm_Faxa_prec(n)*(factor*(1.14168_R8 - 1.0_R8) + 1.0_R8)
326358
endif
327359
Faxa_rainc(n) = 0.0_R8 ! default zero
328360
Faxa_snowc(n) = 0.0_R8
329361
if (Sa_tbot(n) < tKFrz ) then ! assign precip to rain/snow components
330362
Faxa_rainl(n) = 0.0_R8
331-
Faxa_snowl(n) = strm_prec(n)
363+
Faxa_snowl(n) = strm_Faxa_prec(n)
332364
else
333-
Faxa_rainl(n) = strm_prec(n)
365+
Faxa_rainl(n) = strm_Faxa_prec(n)
334366
Faxa_snowl(n) = 0.0_R8
335367
endif
336368

337369
! RADIATION DATA
338370
!--- fabricate required swdn components from net swdn ---
339-
Faxa_swvdr(n) = strm_swdn(n)*(0.28_R8)
340-
Faxa_swndr(n) = strm_swdn(n)*(0.31_R8)
341-
Faxa_swvdf(n) = strm_swdn(n)*(0.24_R8)
342-
Faxa_swndf(n) = strm_swdn(n)*(0.17_R8)
371+
Faxa_swdn(n) = strm_Faxa_swdn(n)
372+
Faxa_swvdr(n) = strm_Faxa_swdn(n)*(0.28_R8)
373+
Faxa_swndr(n) = strm_Faxa_swdn(n)*(0.31_R8)
374+
Faxa_swvdf(n) = strm_Faxa_swdn(n)*(0.24_R8)
375+
Faxa_swndf(n) = strm_Faxa_swdn(n)*(0.17_R8)
376+
343377
!--- compute net short-wave based on LY08 latitudinally-varying albedo ---
344378
avg_alb = ( 0.069 - 0.011*cos(2.0_R8*yc(n)*degtorad ) )
345-
Faxa_swnet(n) = strm_swdn(n)*(1.0_R8 - avg_alb)
379+
Faxa_swnet(n) = strm_Faxa_swdn(n)*(1.0_R8 - avg_alb)
380+
346381
!--- corrections to GISS sswdn for heat budget balancing ---
347382
factor = 1.0_R8
348383
if ( -60.0_R8 < yc(n) .and. yc(n) < -50.0_R8 ) then
@@ -357,10 +392,12 @@ subroutine datm_datamode_core2_advance(datamode, target_ymd, target_tod, target_
357392
Faxa_swndr(n) = Faxa_swndr(n)*factor
358393
Faxa_swvdf(n) = Faxa_swvdf(n)*factor
359394
Faxa_swndf(n) = Faxa_swndf(n)*factor
395+
360396
!--- correction to GISS lwdn in Arctic ---
397+
Faxa_lwdn(n) = strm_Faxa_lwdn(n)
361398
if ( yc(n) > 60._R8 ) then
362399
factor = MIN(1.0_R8, 0.1_R8*(yc(n)-60.0_R8) )
363-
Faxa_lwdn(n) = Faxa_lwdn(n) + factor * dLWarc
400+
Faxa_lwdn(n) = strm_Faxa_lwdn(n) + factor * dLWarc
364401
endif
365402

366403
enddo ! lsize

0 commit comments

Comments
 (0)