Skip to content

Conversation

@mvertens
Copy link
Collaborator

@mvertens mvertens commented Dec 31, 2025

Description of changes

This PR fixes a CDEPS bug that was found using stream input ne16pg3 with 58 vertical levels using NorESM. CDEPS aborted trying to read this in.

Specific notes

This PR also does the following:

  • new error checking for most allocations
  • cleanup of stdout formatting
  • replacement of character(*) with character(len=*)
  • introduction logunit and mainproc in shr_strdata_type and both logunit and mainproc in shr_stream_streamType. This is needed since the inline interface was not always writing all log output consistently.
  • new expanded API for setting stream pointers with optional arguments in dshr_strdata_mod.F90 for
    shr_strdata_get_stream_pointer_1d and shr_strdata_get_stream_pointer_2d
 subroutine shr_strdata_get_stream_pointer_1d(sdat, strm_fld, strm_ptr, rc, requirePointer, errmsg) 
    type(shr_strdata_type)     , intent(in)    :: sdat
    character(len=*)           , intent(in)    :: strm_fld
    real(r8)                   , pointer       :: strm_ptr(:)
    integer                    , intent(out)   :: rc
    logical,          optional , intent(in)    :: requirePointer
    character(len=*), optional , intent(in)    :: errmsg

and

 subroutine shr_strdata_get_stream_pointer_2d(sdat, strm_fld, strm_ptr, rc, requirePointer, errmsg) 
    type(shr_strdata_type)     , intent(in)    :: sdat
    character(len=*)           , intent(in)    :: strm_fld
    real(r8)                   , pointer       :: strm_ptr(:,:)
    integer                    , intent(out)   :: rc
    logical,          optional , intent(in)    :: requirePointer
    character(len=*), optional , intent(in)    :: errmsg

If requirePointer is not provided - then if the pointer is not found, the subroutine returns without an error. If requirePointer is an argument and is true, than normally an errmsg is provided that describes why the pointer is required. Also - now if the pointer is required and is found - then the pointer is initialized to NaN.
The new setting of NaNs in the stream and state pointers resulted in the following additional changes that needed to be brought in:

  • refactored dlnd code to remove presence of present nans in stream pointers
  • fixed problem in drof that came up due to presence of presence of nans
  • fixed problem in datm/cplhist that cam up due to presence of nans

Contributors other than yourself, if any: None

CDEPS Issues Fixed:

Are there dependencies on other component PRs: None

Are changes expected to change answers (bfb, different to roundoff, more substantial): bfb

Any User Interface Changes (namelist or namelist defaults changes): None

Copy link
Contributor

@jedwards4b jedwards4b left a comment

Choose a reason for hiding this comment

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

I had a couple of minor comments, but this looks good overall. Thank you.

new_lines.append(new_line)
else:
print(f" WARNING:not adding missing file {new_file}")
print(f" WARNING:not adding missing file {new_line}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this message be changed from "missing file" to "missing line"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It actually should be new_line - where new_line actually represents the file that is looked for. I can try to update this more generally in the next cdeps PR coming up soon.

integer :: mpicom ! mpi communicator
integer :: my_task ! my task in mpi communicator mpicom
logical :: mainproc ! true if my_task == main_task
logical :: mainproc ! true of my_task == main_task
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be 'true if' not 'true of'

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@mvertens mvertens changed the title merge of noresm cdeps1.0.83_noresm_v3 to fix conflicts bugfix for reading in multi-level unstructured data plus additional cleanup Jan 3, 2026
Copy link
Member

@billsacks billsacks left a comment

Choose a reason for hiding this comment

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

Thank you very much for all of this great cleanup, @mvertens ! Thank you also for your detailed description of the changes in the PR comment.

I have a number of minor questions and fixes below, but overall this looks great!

call shr_lnd2rof_tracers_readnl('drv_flds_in', lnd2rof_tracers)
if (lnd2rof_tracers /= ' ') then
ntracers_nonh2o = shr_string_listGetNum(lnd2rof_tracers)
if (ntracers_nonh2o > 99) then
Copy link
Member

Choose a reason for hiding this comment

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

I appreciate this error check, but I'm assuming that this 99 corresponds to a hard-coded 99 somewhere else? If so, can you turn this into a parameter that is shared between these different locations?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oGood point. I have introduced a new module variable - ntracers_nonh2o_max.

@mvertens
Copy link
Collaborator Author

mvertens commented Jan 6, 2026

@billsacks - thanks so much for your review and comments. I believe I have addressed all of them.

@mvertens mvertens requested review from billsacks January 6, 2026 11:33
Copy link
Member

@billsacks billsacks left a comment

Choose a reason for hiding this comment

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

Looks good now - thank you very much! I do have one comment/question below, but I'm happy to approve this regardless. Thanks again!!

Copy link
Member

@billsacks billsacks left a comment

Choose a reason for hiding this comment

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

As we just discussed: can you please just add a comment describing why there's a limit of 99 tracers?

@mvertens
Copy link
Collaborator Author

mvertens commented Jan 6, 2026

As we just discussed: can you please just add a comment describing why there's a limit of 99 tracers?

Done.

Copy link
Member

@billsacks billsacks left a comment

Choose a reason for hiding this comment

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

Thanks - looks good now!

@billsacks billsacks merged commit 85ef371 into ESCOMP:main Jan 7, 2026
1 check passed
billsacks added a commit that referenced this pull request Jan 8, 2026
…l_streams2

new datm optional streams 

### Description of changes

This introduces the following new stream modules that are optional and can be added to the datamode streams already in place:

### Specific notes
The following new modules have been added
 - datm_pres_aero_mod.F90,  datm_pres_co2_mod.F90,  datm_pres_ndep_mod.F90,  datm_pres_o3_mod.F90

For datm_pres_ndep_mod.F90:
- added new streams clim_1850_cmip7, clim_2000_cmip7, clim_2010_cmip7, and hist_cmip7 (currently these are only used by NorESM)
- renamed the following streams
   - clim_1850 -> clim_1850_cmip6
   - clim_2000 -> clim_2000_cmip6
   - ciim_2010 -> clim_2010_cmip6
   - hist -> hist_cmip6
  by default for CESM, the following cmip6 streams will be used (whereas for NorESM, the cmip7 streams are used)
Note that for the cmip7 data, no unit conversion is done whereas for the default cmip6 data the input data is converted from` g/m2/sec` to `kg/m2/sec`.

For datm_pres_co2_mod.F90:   
- added the following logic which will change answers for non-CPLHIST mode
```F90
  if (datamode == 'CPLHIST') then
       Sa_co2diag(:) = strm_Sa_co2diag(:)
       Sa_co2prog(:) = strm_Sa_co2prog(:)
  else
       ! This is intentional since we don't have any Sa_co2prog - but for now
       ! will set Sa_co2prog equal to Sa_co2diag
       Sa_co2diag(:) = strm_Sa_co2diag(:)
       Sa_co2prog(:) = strm_Sa_co2diag(:)
  end if
```

Also 
- removed references to water isotopes in DATM modules since this will be refactored in upcoming work.
- removed style sheet references in all component namelist_definition_dXXX.xml and stream_definition_dXXX.xml since they are not used.

Contributors other than yourself, if any: None

CDEPS Issues Fixed: #370 
The following tests now have correct values of o3 sent to 
```
ERI_D_Ld11.ne30pg3_ne30pg3_mtn14.I1850Clm60FatesNocompSpinup.betzy_gnu.clm-FatesColdSpinupAD
ERS_D_Ld11.ne30pg3_ne30pg3_mtn14.I1850Clm60FatesNocompSpinup.betzy_intel.clm-FatesColdSpinup
SMS_D_Ld1000_P1536.ne30pg3_ne30pg3_mtn14.I1850Clm60FatesNocompSpinup.betzy_gnu.clm-FatesColdSpinup
```
Are there dependencies on other component PRs: This PR contains all the changes from CDEPS PR #368.

Are changes expected to change answers (bfb): bfb except for Sa_o3 bug fix and when DATM_PRES_CO2 is used.

Any User Interface Changes: add new options for DATM_PRESNDEP

Testing performed: Successfully carried out aux_cdeps_noresm, aux_blom_noresm and aux_clm_noresm with a corresonding PR in NorESMhub (see testing description in NorESMhub#27).

Hashes used for testing:
@mvertens mvertens deleted the feature/escomp_merge_of_cdeps1.0.83_noresm_v3 branch January 9, 2026 17:36
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.

3 participants