Skip to content

Conversation

@mvertens
Copy link
Collaborator

@mvertens mvertens commented Jan 12, 2026

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:
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:
  • 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

mvertens added 30 commits May 12, 2025 10:26
…d_stream_usage' into feature/refactor_stream_usage
…al_streams' into feature/refactor_stream_usage
@NickSzapiro-NOAA
Copy link
Contributor

Thanks @mvertens ! dice cplhist test is ok in UFS with refactor

UFS RTs pass, except for datm_cdeps_lnd_era5_intel and its restart. These fail in run with

(datm_init_pointers): ERROR: strm_Sa_tdew must be associated for era5 datamode

Especially since this was PR from @uturuncoglu in ufs-community/ufs-weather-model#1845 , tagging here. Currently in this test, I think tdew needs to be calculated in datm/datm_datamode_era5_mod.F90

@NickSzapiro-NOAA
Copy link
Contributor

Also - do you run docn in CPL hist mode? If not - I am wondering what the use case for it is - since I really cannot see how it would be used in either CESM or NorESM.

For UFS, I think docn cplhist and sstdata can be the same, if can add units_CToK

@uturuncoglu
Copy link
Collaborator

@NickSzapiro-NOAA @mvertens
Here is some background. ERA5 mode is initially developed for HAFS application and then used for testing land component and also UFS Land DA. The dew point is used to calculate the humidity since ERA5 does not provide it directly. Also, in general all data modes getting lsize (the length of the stream, tdew for ERA5) from some variable and it seems there is no any consensus about it and the data component always fails when that particular variable not provided.

I wonder if there is a way to get rid of lsize completely such as querying mesh dimensions etc. It would be better solution and stream will not depend on any particular variable.

@mvertens
Copy link
Collaborator Author

@NickSzapiro-NOAA- thanks for your testing!

@NickSzapiro-NOAA @uturuncoglu - I think I am missing something in datm_datamode_era5_mod.F90.

In the the original code for this:

if (first_time)
     ! determine t2max (see below for use)
      if (associated(Sa_t2m)) then
        rtmp(1) = maxval(Sa_t2m(:))

        call ESMF_VMAllReduce(vm, rtmp, rtmp(2:), 1, ESMF_REDUCE_MAX, rc=rc)
        t2max = rtmp(2)
        if (mainproc) write(logunit,*) subname,' t2max = ',t2max
      end if

      ! determine tdewmax (see below for use)
      rtmp(1) = maxval(strm_tdew(:))
      call ESMF_VMAllReduce(vm, rtmp, rtmp(2:), 1, ESMF_REDUCE_MAX, rc=rc)
      td2max = rtmp(2)
      if (mainproc) write(logunit,*) subname,' td2max = ',td2max
      ! reset first_time
      first_time = .false.
endif
  • Since Sa_t2m is being advertised and a pointer to it is set as a module pointer, that pointer will always be associated. So I propose removing the if (associated(Sa_t2m)) query.
  • The original call shr_strdata_get_stream_pointer( sdat, 'Sa_tdew', strm_tdew , rc) simply keeps the pointer strm_tdew to null() if 'Sa_tdew' is not an import stream field. However, ifstrm_tdew is not associated - then the call to maxval(strm_tdew(:)) should throw an error. So I don't see how strm_tdew is ever calculated going into the first_time if clause.

In the new code:

  • The call to shr_strdata_get_stream_pointer( sdat,'Sa_tdew', strm_Sa_tdew , rc=rc) is the same as in the original code (other than renaming strm_tdew to strm_Sa_tdew).
  • There are a lot of other error checks I've put in place in the refactored datm_datamode_era5_mod.F90 - and I am wondering if all of them would potentially fail?

What does the ESMF configuration file look like for this datamode?

@uturuncoglu
Copy link
Collaborator

@NickSzapiro-NOAA It would be also nice to see actual error.

@uturuncoglu
Copy link
Collaborator

@NickSzapiro-NOAA We have just have a short chat with @mvertens about the issue. It seems that UFS WM is using CDEPS develop branch (https://github.com/NOAA-EMC/CDEPS/blob/develop/datm/datm_datamode_era5_mod.F90) and the ERA5 mode in that branch is different from the one found in ESCOMP. So, that was the issue. @mvertens will check the new code found in develop branch and try to fix the issue in ERA5 mode. Then once this PR merged, UFS WM needs to sync with ESCOMP to bring these changes.

@billsacks
Copy link
Member

The new code is missing the following two fields in the cpl hist file: atmImp_Faxa_swdn and atmImp_Faxa_swnet. Is that expected?

You expect to not see these fields anymore. There were no stream entries for either atmImp_Faxa_swdn and atmImp_Faxa_swnet in cplhist mode for datm - and so even though these fields were advertised - they were never filled in. So as part of this refactor I removed them - and as you can see it did not change the answers.

Great, thank you for clarifying that.

@billsacks
Copy link
Member

I have added a new datamode in drof - drof_datamode_cplhist.F90 - along with expanding the set of stream fields needed in cplhist mode. I have added a new testmods directory - cplhist_noresm and a new test that will now test this new functionality. I think we should create a new parallel directoyr cplhist_cesm that points the relevant datafiles that are needed to test this for cesm. All that is needed is a new shell_commands file.

@mvertens - Great, thanks! If the purpose of this is software testing, would it be reasonable for CESM to use the NorESM cplhist files for testing, so that we're running consistent tests and don't need to do double-maintenance on this test?

@fischer-ncar
Copy link
Collaborator

@mvertens @billsacks is this PR about ready for prealpha testing?

if (associated(strm_Forr_rofi)) then
do ni = 1, size(Forr_rofi)
if (abs(strm_Forr_rofi(ni)) < 1.e28_r8) then
Forr_rofi(:) = strm_Forr_rofi(:)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mvertens - you commented that this is fixed (changing the whole-array assignment of Forr_rofi to just Forr_rofi(ni)), but it looks like you haven't yet pushed a commit fixing this? (You fixed other, similar issues.)

@mvertens
Copy link
Collaborator Author

@billsacks - I have pushed the drof change back.

@billsacks
Copy link
Member

I have pushed the drof change back.

It looks like you changed one of the (:) but not the other?

@billsacks
Copy link
Member

It looks like you changed one of the (:) but not the other?

Oh, never mind - I see your second commit.

@billsacks
Copy link
Member

@fischer-ncar - thanks for checking in. I talked to @mvertens and we both feel this is ready for your testing. See #376 (comment) for some notes on testing - specifically a few tests to add beyond the standard prealphas on derecho.

I'm in the midst of a deep dive into the different data model modes to make sure we're running testing covering everything we want to test, so I may come up with a few additional tests in the next day or so, but the prealphas plus the tests noted above should be close to what we want.

Thank you!

@billsacks
Copy link
Member

billsacks commented Jan 22, 2026

@fischer-ncar and @mvertens - I have done a pretty detailed analysis of the different data modes and their coverage in prealpha testing. In addition to the CESM prealpha testing, I want to make sure the following are covered:

@fischer-ncar - can you please add the following two tests to your testing, along with baseline comparisons (these tests are present in the aux_mom or aux_cice test lists but will need baselines for your testing) (I have also updated my testing comment with this request so it's all in one place):

  • SMS_D_Ld2.T62_t232.G.derecho_gnu (to cover DATM%NYF and DROF using a DIATREN mode)
  • ERS_Ld5.TL319_t232.G_IAF.derecho_intel.cice-default (to cover DATM%IAF and DROF using a DIATREN mode)

@mvertens - I don't think we have a way to test the following in CESM, so I wanted to double-check that you have tested these (sorry, you might have answered this before):

  • DLND%GCPL (i.e., T compset with CMEPS-generated forcing)
  • DLND%RCPL
  • DOCN%MULTILEV, DOCN%MULTILEV-CPLHIST and DOCN%MULTILEV-DOM

@mvertens - also, I think you said you have tested DWAV... just wanted to double-check that, since we don't have any DWAV testing in our prealpha test list (there's a test of ADWAV in aux_cmeps). (EDIT: I see that you ran aux_cdeps_noresm, which covers this.)

@wwieder
Copy link
Contributor

wwieder commented Jan 22, 2026

Just flagging this, as we'll want to test with CTSM when we update our submodules, @ekluzek.

@mvertens
Copy link
Collaborator Author

@billsacks

  • DWAV is tested in the following test which passed and had no differences with baselines
    • SMS_Ld2.ww3a.2000_SATM_SLND_SICE_SOCN_SROF_SGLC_DWAV%CLIMO.betzy_intel
  • DLND was tested in the following tests which all passed and had no differences with baselines
    • ERS_D_Ld30.f09_f09_mg17.2000_SATM_DLND%RCPL_SICE_SOCN_SROF_SGLC_SWAV.betzy_intel.dlnd-rof_forcing.GC.cdeps_pr3/
    • ERS_D_Ly4.f09_f09_mg17.1850_SATM_DLND%GCPL_SICE_SOCN_SROF_SGLC_SWAV.betzy_intel.dlnd-glc_forcing.GC.cdeps_pr3/
    • SMS_Ld3.f09_f09_mg17.1850_SATM_DLND%SCPL_SICE_SOCN_SROF_SGLC_SWAV.betzy_intel.GC.cdeps_pr3/

@billsacks
Copy link
Member

@fischer-ncar - can you please add one more test, with baseline comparisons: SMS_D_Ld5.f10_f10_mg37.ISSP245Clm60BgcCropCrujra.derecho_intel.clm-datm_rcp45_anom_forc. (I had asked for a test that includes DATM bias-correction. I forgot that anomaly forcing is a related-but-different thing.)

@fischer-ncar
Copy link
Collaborator

Here's the prealpha test results I have so far. I'm still running the extra tests that @billsacks wanted me to run.

FAIL ERS.TL319_t232.G_JRA.derecho_gnu.cice-default CREATE_NEWCASE
FAIL DIMCSL_Ld1.TL319_t232.G_JRA.derecho_intel.mom-cfc_mods CREATE_NEWCASE
FAIL ERI.TL319_t232.G_JRA.derecho_intel.cice-default CREATE_NEWCASE
FAIL ERS.TL319_t232_wg37.GW_JRA.derecho_intel CREATE_NEWCASE
FAIL SMS_Ld40.TL319_t232.C_JRA.derecho_intel CREATE_NEWCASE
FAIL SMS.TL319_t232.G1850MARBL_JRA.derecho_intel CREATE_NEWCASE
FAIL SMS.TL319_t232.G_JRA.derecho_intel.mom-no_stoch_physics CREATE_NEWCASE

The above tests all failed with no comp_calss for rof.

ERROR: No description found for comp_class rof matching compsetname 
2000_DATM%JRA-1p5-2023_SLND_CICE_MOM6_DROF%JRA-1p5-2023_SGLC_SWAV_SESP
in file /glade/u/home/fischer/code/cesm3_0_alpha08b.cdeps_pr376/components/cdeps/drof/cime_config/config_component.xml,
expected match in ['DROF'] % ['NULL', 'NYF', 'IAF', 'IAFAIS00', 'IAFAIS45', 'IAFAIS55', 'CPLHIST', 'JRA', 'JRA-1p4-2018', 
'JRA-1p4-2018-AIS0ICE', 'JRA-1p4-2018-AIS0LIQ', 'JRA-1p4-2018-AIS0ROF', 'JRA-RYF6162', 'JRA-RYF8485', 'JRA-RYF9091', 'JRA-RYF0304']

Then there was a couple of small answer changes.

FAIL SMS_D_Ld1.ne30pg3_t232.I1850Clm50BgcSpinup.derecho_intel.clm-cplhist--clm-matrixcnOn BASELINE cesm3_0_alpha08b: DIFF
lndExp_Sa_o3   (lndExp_nx,lndExp_ny,time)  t_index =      1     1

  48600    48600  (  4509,     1,     1) ( 27472,     1,     1) (  4509,     1,     1) (     1,     1,     1)
           48600   6.362811278938516E-08   3.042405400211996E-09 6.4E-08  6.362811278938516E-08 1.0E+00  1.110496591496169E-08
           48600   0.000000000000000E+00   0.000000000000000E+00          0.000000000000000E+00          0.000000000000000E+00
           48600  (     1,     1,     1) (     1,     1,     1)
      avg abs field values:    1.529740347654647E-08    rms diff: 1.7E-08   avg rel diff(npos):  1.0E+00
                               0.000000000000000E+00                        avg decimal digits(ndif):  0.0 worst:  0.0
 RMS lndExp_Sa_o3                     1.6669E-08            NORMALIZED  2.1793E+00"


FAIL SMS_D_Ld1.ne30pg3_t232.I1850Clm50BgcSpinup.derecho_intel.clm-cplhist BASELINE cesm3_0_alpha08b: DIFF
 lndExp_Sa_o3   (lndExp_nx,lndExp_ny,time)  t_index =      1     1
  48600    48600  (  4509,     1,     1) ( 27472,     1,     1) (  4509,     1,     1) (     1,     1,     1)
           48600   6.362811278938516E-08   3.042405400211996E-09 6.4E-08  6.362811278938516E-08 1.0E+00  1.110496591496169E-08
           48600   0.000000000000000E+00   0.000000000000000E+00          0.000000000000000E+00          0.000000000000000E+00
           48600  (     1,     1,     1) (     1,     1,     1)
      avg abs field values:    1.529740347654647E-08    rms diff: 1.7E-08   avg rel diff(npos):  1.0E+00
                               0.000000000000000E+00                        avg decimal digits(ndif):  0.0 worst:  0.0
 RMS lndExp_Sa_o3                     1.6669E-08            NORMALIZED  2.1793E+00

@fischer-ncar
Copy link
Collaborator

Here's the three other tests that @billsacks wanted me to do.

PASS SMS_D_Ld2.T62_t232.G.derecho_gnu RUN time=351

FAIL SMS_D_Ld5.f10_f10_mg37.ISSP245Clm60BgcCropCrujra.derecho_intel.clm-datm_rcp45_anom_forc BASELINE cesm3_0_alpha08b: DIFF
lndExp_Sa_co2prog   (lndExp_nx,lndExp_ny,time)  t_index =      1     1
    456      456  (     1,     1,     1) (     1,     1,     1) (     1,     1,     1) (     1,     1,     1)
             456   3.999488830566406E+02   3.999488830566406E+02 4.0E+02  3.999488830566406E+02 1.0E+00  3.999488830566406E+02
             456   0.000000000000000E+00   0.000000000000000E+00          0.000000000000000E+00          0.000000000000000E+00
             456  (     1,     1,     1) (     1,     1,     1)
      avg abs field values:    3.999488830566406E+02    rms diff: 4.0E+02   avg rel diff(npos):  1.0E+00
                               0.000000000000000E+00                        avg decimal digits(ndif):  0.0 worst:  0.0
 RMS lndExp_Sa_co2prog                3.9995E+02            NORMALIZED  2.0000E+00

FAIL ERS_Ld5.TL319_t232.G_IAF.derecho_intel.cice-default CREATE_NEWCASE
ERROR: grid alias TL319_t232 not valid for compset 2000_DATM%IAF_SLND_CICE_MOM6_DROF%IAF_SGLC_SWAV_SESP

@jedwards4b
Copy link
Contributor

jedwards4b commented Jan 22, 2026 via email

@billsacks
Copy link
Member

@fischer-ncar - thanks a lot for this testing report! And @jedwards4b - thanks for your input.

I have just pushed a commit that restores the JRA-1p5-2023 mode for DROF that I think should fix the issues with G_JRA and C_JRA compsets. (@mvertens - I assume your removal of that mode for DROF was accidental? As far as I can tell the mode should still work but it looks like it was accidentally removed from DROF's config_component... but please let us know if there was a reason why you removed it.) @fischer-ncar - can you please retry the failed tests with this latest version?

The changes in lndExp_Sa_o3 and lndExp_Sa_co2prog are expected based on changes from #373 (but are expected not to feedback to cause any other differences in typical configurations).

For the failing G_IAF case, can you instead try ERS_Ld5.T62_t232.G_IAF.derecho_intel.cice-default? If that doesn't work, I'll reach out to some ocean / sea ice folks to see if I can find a similar, working test.

@fischer-ncar - I have poked around in /glade/derecho/scratch/fischer/t/cesm3_0_alpha08b.cdeps_pr376_i, /glade/derecho/scratch/fischer/t/cesm3_0_alpha08b.cdeps_pr376_g and /glade/derecho/scratch/fischer/t/cesm3_0_alpha08b.cdeps_pr376_n; I don't see anything problematic from those test results (assuming that all failures there other than the ones you called out are expected failures). (I was looking for whether there might have been some expected failures that I want to replace with other, passing tests for testing this PR, but I'm not concerned about the tests that are failing.) So if that's complete in terms of derecho prealpha testing, then I think we're good in terms of the standard derecho prealpha tests once we resolve the above issues.

Have you run the extra tests noted in #376 (comment) - the ones under (1), (2), and the additional DTEST and E1850TEST test, in addition to the more recent additions that I copied at the bottom of that comment?

Thanks again for all of your testing of this!

@mvertens
Copy link
Collaborator Author

@billsacks - the removal of JRA-1p5-2023 was a mistake that I made in trying to sync the changes between the PR to NorESMHub and ESCOMP. @jedwards4b - thanks for suggesting the fix. @fischer-ncar - thanks for all of your testing.

@fischer-ncar
Copy link
Collaborator

@billsacks I missed those tests, I'll run them now.

@fischer-ncar
Copy link
Collaborator

All of the tests with the missing JRA-1p5-2023 have passed. So all of the prealpha tests are now good.

For the extra tests @billsacks wanted me to do, the following passed.

   ERI.TL319_t232.DTEST.derecho_intel.cice-default
   ERS_D_Ld5.f19_g17.E1850TEST.derecho_intel.cice-default
   ERS_Ld5.T62_t232.G_IAF.derecho_intel.cice-default
   SMS_D_Ld2.T62_t232.G.derecho_gnu
   SMS_D_Ld3.f10_f10_mg37.I2000Clm50BgcCru.derecho_gnu.clm-default
   SMS_Ld1_PS.f09_g17.I2000Clm50BgcCru.derecho_gnu.clm-datm_bias_correct_cruv7
   SMS_Ld1_PS.nldas2_rnldas2_mnldas2.I2000Ctsm50NwpSpNldas.derecho_gnu.clm-default--clm-nofireemis
   SMS_Ld5.f10_f10_mg37.ISSP245Clm60BgcCropCrujra.derecho_gnu.clm-ciso_dec2050Start

Of the tests that passed, two of the tests failed to generate complete baselines, which is not an issue with this PR.

FAIL ERS_D_Ld5.f19_g17.E1850TEST.derecho_intel.cice-default BASELINE cesm3_0_alpha08b: ERROR BFAIL some baseline files were missing
FAIL SMS_Ld1_PS.f09_g17.I2000Clm50BgcCru.derecho_gnu.clm-datm_bias_correct_cruv7 BASELINE cesm3_0_alpha08b: ERROR BFAIL some baseline files were missing

This test passed, with expected answer difference caused by #373.

SMS_D_Ld5.f10_f10_mg37.ISSP245Clm60BgcCropCrujra.derecho_intel.clm-datm_rcp45_anom_forc

Then this test failed with a missing grid alias.

FAIL ERS_Ld5.TL319_t232.G_IAF.derecho_intel.cice-default CREATE_NEWCASE
ERROR: grid alias TL319_t232 not valid for compset 2000_DATM%IAF_SLND_CICE_MOM6_DROF%IAF_SGLC_SWAV_SESP

I believe I've run all of the extra tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docn-multilev is not reading in ocn input correctly

7 participants