Skip to content

override co2 surface source to send to land/ocean#294

Open
mvertens wants to merge 5 commits into
NorESMhub:noresm_developfrom
mvertens:feature/co2_surface_source
Open

override co2 surface source to send to land/ocean#294
mvertens wants to merge 5 commits into
NorESMhub:noresm_developfrom
mvertens:feature/co2_surface_source

Conversation

@mvertens

@mvertens mvertens commented Jul 14, 2026

Copy link
Copy Markdown

Summary: New ability to have co2 sent to land/ocean be different than used in radiation/chemistry

Purpose of changes: address ability to run the experiments outlined in NorESMhub/NorESM#825

Changes made to build system: None

Changes made to the namelist: New namelist group co2_surface_source_stream_nl
To activate this behavior edit user_nl_clm to have the following:

  • If you want to send latitude dependent 1850 CO2 forcing to land/ocean:
co2_surface_source = .true.
stream_co2_surface_source_mesh_filename = '$DIN_LOC_ROOT/atm/waccm/lb/cmip7_ghg_version20260607/esmf_mesh_20degLon.nc'
stream_co2_surface_source_data_filename = '$DIN_LOC_ROOT/atm/waccm/lb/cmip7_ghg_version20260607/ghg_cmip7_CMIP_CR-CMIP-1-0-0_1850_monthly_gnz_0p5degLat_version20260207_20degLon.nc'
stream_co2_surface_source_data_varname = 'CO2_LBC'
stream_co2_surface_source_taxmode = 'cycle'
stream_co2_surface_source_year_first = 1850
stream_co2_surface_source_year_last = 1850
stream_co2_surface_source_year_align = 1

If you want to send 1pct CO2 to land/ocean:

co2_surface_source = .true.
stream_co2_surface_source_mesh_filename = '$DIN_LOC_ROOT/atm/waccm/lb/cmip7_ghg_version20260607/esmf_mesh_20degLon.nc'
stream_co2_surface_source_data_filename = '$DIN_LOC_ROOT/atm/waccm/lb/cmip7_ghg_version20260607/ghg_cmip7_CMIP-1pctco2_CR-CMIP-1-0-0_0000-0166_monthly_gnz_0p5degLat_version20260207_20degLon.nc
stream_co2_surface_source_data_varname = 'CO2_LBC'
stream_co2_surface_source_taxmode = 'extend'
stream_co2_surface_source_year_first = 0
stream_co2_surface_source_year_last = 166
stream_co2_surface_source_year_align = 1

NOTE: a new namelist was also introduced for nitrogen deposition - stream_ndep_taxmode

Changes to the defaults for the boundary datasets: None

Substantial timing or memory changes: None

Detailed description of changes:
The above custom namelists must be set in user_nl_cam - there are no out of the box defaults.
The 1850 and 1pct CO2 files in $DIN_LOC_ROOT/atm/waccm/lb/cmip7_ghg_version20260607/ only had [lat,time] dimensions - and CDEPS cannot work with such files. As a result - 20deg longitude datasets were created for the above scenarios.
Verified that using the following compset 1

1850_CAM70%LT%NORESM%CAMoslo_CLM60%FATES-NCFB%NORESM_CICE_BLOM%HYB%ECO_MOSART_DGLC%NOEVOLVE_
SWAV_SESP 

at ne16pg3_tn14 - the co2 diag field sent to the ocean had the expected behavior that was different than the co2 being used internally for the radiation in CAM.

@mvertens mvertens requested review from gold2718 and tjiputra July 14, 2026 13:10
@mvertens

Copy link
Copy Markdown
Author

@tjiputra - I think I've implemented the behavior you wanted in NorESMhub/NorESM#825.
Could you please give this a test. I have tested that using the latitude dependent 1850 data (see namelist summary above) gives the latitude dependent data sent to blom - whereas cam is using a global surface mean for the radiation.

@mvertens mvertens changed the title Feature/co2 surface source override co2 surface source to send to land/ocean Jul 14, 2026
@tjiputra

Copy link
Copy Markdown

@mvertens - thank you. Should i test this on beta22 or other specific branch?

Using pr-noresm3_0_beta22 branch, I got this error during case.build:
ERROR: in _validate_pair (package Build::NamelistDefinition): Variable name stream_co2_surface_source_year_align not found in /cluster/work/projects/nn9560k/tjiputra/NorESM/NorESM_beta22/components/cam/bld/namelist_files/namelist_definition.xml

@mvertens

mvertens commented Jul 15, 2026

Copy link
Copy Markdown
Author

@tjiputra - yes - please test this on beta22. However, this code is still in a PR status #294. For you to test this - you need to do the following

> git clone https://github.com/NorESMhub/NorESM
> cd NorESM
> git checkout pr-noresm3_0_beta22

edit .gitmodules to have the following

[submodule "cam"]
path = components/cam
#url = https://github.com/NorESMhub/CAM.git
#fxtag = noresm3_0_039_cam6_4_121
url = https://github.com/mvertens/CAM.git
fxtag = c07bbfc9
fxrequired = ToplevelRequired
fxDONOTUSEurl = https://github.com/NorESMhub/CAM.git

Then you can run the following

> ./bin/git-fleximod update

That should give you the CAM code you need. Please let me know if this is working for you.

@tjiputra

tjiputra commented Jul 15, 2026

Copy link
Copy Markdown

@mvertens -
in user_nl_cam:
stream_co2_surface_source_mesh_filename = '$DIN_LOC_ROOT/atm/waccm/lb/cmip7_ghg_version20260607/esmf_mesh_20degLon.nc'
should be:
stream_co2_surface_source_mesh_filename = '$DIN_LOC_ROOT/atm/waccm/lb/cmip7_ghg_version20260607/esmf_mesh_20deglon.nc'

But the run crashes:
/cluster/work/projects/nn9560k/tjiputra/noresm/n1pctCO2-BGC.ne16pg3_tn14.beta22.2026-07-15/run/atm.log.1585890.260715-111118

(shr_stream_verifyTCoord) ERROR: calendar dates must be increasing
(shr_stream_verifyTCoord) date(n), date(n+1) = 11216 10116
(shr_stream_verifyTCoord) ERROR: calendar dates must be increasing

Case directory (Olivia):
/cluster/projects/nn9560k/tjiputra/NorESM/cases-noresm3dev/n1pctCO2-BGC.ne16pg3_tn14.beta22.2026-07-15

@mvertens

Copy link
Copy Markdown
Author

@tjiputra - I had not tested the 1pctCO2 and I have you the wrong namelist:
can your try the following:

stream_co2_surface_source_year_first = 1
stream_co2_surface_source_year_last = 166
stream_co2_surface_source_year_align = 1

If this does not work - I'll try to duplicate the problem and resolve it.

@tjiputra

Copy link
Copy Markdown

@mvertens - the same error occurs again. It seems that it tries to read and cycle the first year even if I set

stream_co2_surface_source_year_first = 0
stream_co2_surface_source_year_last = 166
stream_co2_surface_source_year_align = 0

@mvertens

Copy link
Copy Markdown
Author

@tjiputra - that's very odd. I'll track this down. Sorry you ran into this.

@mvertens

Copy link
Copy Markdown
Author

@tjiputra - the problem is not in the code - it's in the dataset. I generated a time coordinate for this dataset and it seems to have duplicated the first year:
time = "0001-01-16", // time(1)
"0001-02-15", // time(2)
"0001-03-16", // time(3)
......
"0001-12-16", // time(12)
"0001-01-16", // time(13)
"0001-02-15", // time(14)
"0001-03-16", // time(15)
....
"0001-12-16", // time(24)
The problem was that the dataset started from year 0 - and I wanted to start from year 1. I'll go back to the year0 data and see if that works.

@mvertens

mvertens commented Jul 15, 2026

Copy link
Copy Markdown
Author

@tjiputra - I have fixed this file on olivia and tested that the following user_nl_cam works:

co2_surface_source = .true.
stream_co2_surface_source_mesh_filename = '$DIN_LOC_ROOT/atm/waccm/lb/cmip7_ghg_version20260607/esmf_mesh_20deglon.nc'
stream_co2_surface_source_data_filename = '$DIN_LOC_ROOT/atm/waccm/lb/cmip7_ghg_version20260607/ghg_cmip7_CMIP-1pctco2_CR-CMIP-1-0-0_0000-0166_monthly_gnz_0p5degLat_version20260207_20degLon.nc'
stream_co2_surface_source_data_varname = 'CO2_LBC'
stream_co2_surface_source_taxmode = 'extend'
stream_co2_surface_source_year_first = 0
stream_co2_surface_source_year_last = 166
stream_co2_surface_source_year_align = 1

@gold2718 gold2718 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I have several clean-up and documentation requests as well as some bug fixes and safety features.

Comment thread bld/namelist_files/namelist_defaults_cam.xml
</entry>
<entry id="stream_ndep_taxmode" type="char*256" category="Nitrogen Deposition"
group="ndep_stream_nl" valid_values="cycle,extend,limit" >
time extrapolation mode.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please add documentation similar to other xxx_taxmode namelist variables:

Suggested change
time extrapolation mode.
Time extrapolation algorithm to use for stream_ndep_data_filename.
- cycle: Simply cycle through the available model data (i.e., start over when the end is reached)
- extend: Use the final value when end of data is reached.
- limit: Halt the model run if the model time exceeds the available data.
Default: extend for transient, otherwise cycle

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done.

</entry>
<entry id="stream_co2_surface_source_mesh_filename" type="char*256" input_pathname="abs" category="CO2 surface source"
group="co2_surface_source_stream_nl" valid_values="" >
Grid mesh file corresponding to sream_co2_surface_source_data_filename.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

typo

Suggested change
Grid mesh file corresponding to sream_co2_surface_source_data_filename.
Grid mesh file corresponding to stream_co2_surface_source_data_filename.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done.

</entry>
<entry id="stream_co2_surface_source_data_filename" type="char*256" input_pathname="abs" category="CO2 surface source"
group="co2_surface_source_stream_nl" valid_values="" >
co2 stream data filename.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
co2 stream data filename.
Data source file for reading CO2 concentrations to be passed to the surface if co2_surface_source=.true.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done.

</entry>
<entry id="stream_co2_surface_source_data_varname" type="char*256" category="CO2 surface source"
group="co2_surface_source_stream_nl" valid_values="" >
co2 varname on stream data file(s).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
co2 varname on stream data file(s).
Variable name for reading CO2 concentrations in stream_co2_surface_source_data_filename.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done.

Comment on lines +128 to +135
! error check
if ( trim(stream_co2_surface_source_taxmode) /= 'cycle' .and. &
trim(stream_co2_surface_source_taxmode) /= 'extend' .and. &
trim(stream_co2_surface_source_taxmode) /= 'limit') then
call endrun(subName//': ERROR stream_co2_surface_source_taxmode '&
//trim(stream_co2_surface_source_taxmode)&
//' must be either cycle, extend or limit')
end if

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Since stream_co2_surface_source_taxmode is broadcast, can this error check be moved into the logic below or inside the if (masterproc) logic where the namelist is read?

integer, intent(out) :: rc

! local variables
character(*), parameter :: subName = "('stream_co2_surface_source_init')"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please use correct syntax:

Suggested change
character(*), parameter :: subName = "('stream_co2_surface_source_init')"
character(len=*), parameter :: subName = "('stream_co2_surface_source_init')"

integer :: nml_error ! namelist i/o error flag
integer :: ierr ! error status
integer :: nf ! field counter
character(*), parameter :: subName = "('stream_co2_surface_source_readnl')"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please use correct syntax:

Suggested change
character(*), parameter :: subName = "('stream_co2_surface_source_readnl')"
character(len=*), parameter :: subName = "('stream_co2_surface_source_readnl')"

integer :: sec ! seconds into current date for nstep+1
integer :: mcdate ! Current model date (yyyymmdd)
real(r8), pointer :: dataptr1d(:)
character(*), parameter :: subName = "('stream_co2_surface_source_interp')"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please use correct syntax:

Suggested change
character(*), parameter :: subName = "('stream_co2_surface_source_interp')"
character(len=*), parameter :: subName = "('stream_co2_surface_source_interp')"

if (ierr /= 0) call endrun(trim(subname)//": FATAL: mpi_bcast: stream_ndep_year_align")

! Determine if ndep stream is active, and if not return
call mpi_bcast(stream_ndep_data_filename, len(stream_ndep_data_filename), mpi_character, 0, mpicom, ierr)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

See comment in atm_stream_co2.F90 but make sure that all broadcasts are happening from the correct MPI task:

Suggested change
call mpi_bcast(stream_ndep_data_filename, len(stream_ndep_data_filename), mpi_character, 0, mpicom, ierr)
call mpi_bcast(stream_ndep_data_filename, len(stream_ndep_data_filename), mpi_character, mstrid, mpicom, ierr)

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