Skip to content
Merged
19 changes: 18 additions & 1 deletion bld/build-namelist
Original file line number Diff line number Diff line change
Expand Up @@ -717,13 +717,17 @@ if (!($simple_phys or $aqua_mode)) {
add_default($nl, 'co2_surface_source');
if ($nl->get_value('co2_surface_source') =~ /$TRUE/io) {
if ( !(defined $nl->get_value('stream_co2_surface_source_mesh_filename') and
defined $nl->get_value('stream_co2_surface_source_data_filename') and
defined $nl->get_value('stream_co2_surface_source_data_filename') and
defined $nl->get_value('stream_co2_surface_source_data_varname') and
defined $nl->get_value('stream_co2_surface_source_year_first') and
defined $nl->get_value('stream_co2_surface_source_year_last') and
defined $nl->get_value('stream_co2_surface_source_year_align') and
defined $nl->get_value('stream_co2_surface_source_mapalgo') and
defined $nl->get_value('stream_co2_surface_source_lat_dimname') and
defined $nl->get_value('stream_co2_surface_source_taxmode') ) ) {
die "$ProgName - ERROR: if co2_surface_source is .true. then the following must be defined:
stream_co2_surface_source_mapalgo,
stream_co2_surface_source_lat_dimname,
stream_co2_surface_source_mesh_filename,
stream_co2_surface_source_data_filename,
stream_co2_surface_source_data_varname,
Expand All @@ -732,6 +736,19 @@ if (!($simple_phys or $aqua_mode)) {
stream_co2_surface_source_year_last,
stream_co2_surface_source_year_align\n";
}
# get_value preserves the quotes from the namelist, so strip them before comparing
my $mapalgo = $nl->get_value('stream_co2_surface_source_mapalgo');
my $mesh = $nl->get_value('stream_co2_surface_source_mesh_filename');
$mapalgo =~ s/^['"]+|['"]+$//g;
$mesh =~ s/^['"]+|['"]+$//g;
if (($mapalgo eq 'nearest_lat') and ($mesh ne 'none')) {
die "$ProgName - ERROR: stream_co2_surface_source_mesh_filename must be set to 'none' " .
"when stream_co2_surface_source_mapalgo is 'nearest_lat'\n";
}
if (($mapalgo ne 'nearest_lat') and ($mesh eq 'none')) {
die "$ProgName - ERROR: stream_co2_surface_source_mesh_filename must be a valid mesh file " .
"when stream_co2_surface_source_mapalgo is '$mapalgo'\n";
Comment thread
gold2718 marked this conversation as resolved.
}
}
}

Expand Down
18 changes: 16 additions & 2 deletions bld/namelist_files/namelist_definition.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10297,10 +10297,24 @@ Default: path
If TRUE, set co2_diag sent to land and ocean to value read from co2_surface_source_data_filename
Default: FALSE
</entry>
<entry id="stream_co2_surface_source_mapalgo" type="char*256" category="CO2 surface source"
group="co2_surface_source_stream_nl" valid_values="nearest_lat,bilinear,consf" >
Mapping algorithm to map co2 data to model grid. Nearest lat assumes
that a mesh file is not needed and that the forcing data is lat/time or lat/lev/time.
In this case the mesh is set to none.
Default: nearest_lat
</entry>
<entry id="stream_co2_surface_source_lat_dimname" type="char*256" category="CO2 surface source"
group="co2_surface_source_stream_nl" valid_values="" >
Latitude dimension name on stream_co2_surface_source_data_filename.
Only used if stream_co2_surface_source_mapalgo is 'nearest_lat'
Default: Must be set by user
</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 stream_co2_surface_source_data_filename.
Must be set by user.
Grid mesh file corresponding to stream_co2_surface_source_data_filename. If stream_co2_surface_source_map
If stream_co2_surface_source_mapalgo is 'nearest_lat' then this must be set to 'none'
Comment thread
mvertens marked this conversation as resolved.
Outdated
Default: Must be set by user.
</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="" >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<solar_data_type> FIXED </solar_data_type>

<!-- LBC Files : -->
<flbc_file>atm/waccm/lb/cmip7_ghg_version20260607/ghg_cmip7_CMIP_CR-CMIP-1-0-0_1850_monthly_gnz_0p5degLat_version20260207.nc</flbc_file>
<flbc_file>atm/waccm/lb/cmip7_ghg_version20260727/ghg_cmip7_CMIP_CR-CMIP-1-0-0_1850_monthly_gnz_0p5degLat_version20260727.nc</flbc_file>
<flbc_cycle_yr>1850</flbc_cycle_yr>
<flbc_type>'CYCLICAL'</flbc_type>
<flbc_list>'CO2','CH4','N2O','CFC11','CFC12','CFC11eq'</flbc_list>
Expand Down
2 changes: 1 addition & 1 deletion bld/namelist_files/use_cases/1850_camnor_lt_osloaero.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<solar_data_type> FIXED </solar_data_type>

<!-- LBC Files : -->
<flbc_file>atm/waccm/lb/cmip7_ghg_version20260607/ghg_cmip7_CMIP_CR-CMIP-1-0-0_1850_monthly_gnz_0p5degLat_version20260207.nc</flbc_file>
<flbc_file>atm/waccm/lb/cmip7_ghg_version20260727/ghg_cmip7_CMIP_CR-CMIP-1-0-0_1850_monthly_gnz_0p5degLat_version20260727.nc</flbc_file>
<flbc_cycle_yr>1850</flbc_cycle_yr>
<flbc_type>'CYCLICAL'</flbc_type>
<flbc_list>'CO2','CH4','N2O','CFC11','CFC12','CFC11eq'</flbc_list>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<solar_irrad_data_file>atm/cam/solar/SolarForcingCMIP7-4.6_18491230-20240101_sumEPP_c20250630.nc</solar_irrad_data_file>

<!-- LBC Files -->
<flbc_file>atm/waccm/lb/cmip7_ghg_version20260607/ghg_cmip7_CMIP_CR-CMIP-1-0-0_1750-2023_monthly_gnz_0p5degLat_version20260207.nc</flbc_file>
<flbc_file>atm/waccm/lb/cmip7_ghg_version20260727/ghg_cmip7_CMIP_CR-CMIP-1-0-0_1750-2023_monthly_gnz_0p5degLat_version20260727.nc</flbc_file>
<flbc_type>'SERIAL'</flbc_type>
<flbc_list>'CO2','CH4','N2O','CFC11','CFC12','CFC11eq'</flbc_list>

Expand Down
2 changes: 1 addition & 1 deletion bld/namelist_files/use_cases/hist_camnor_lt_osloaero.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<solar_irrad_data_file>atm/cam/solar/SolarForcingCMIP7-4.6_18491230-20240101_sumEPP_c20250630.nc</solar_irrad_data_file>

<!-- LBC Files -->
<flbc_file>atm/waccm/lb/cmip7_ghg_version20260607/ghg_cmip7_CMIP_CR-CMIP-1-0-0_1750-2023_monthly_gnz_0p5degLat_version20260207.nc</flbc_file>
<flbc_file>atm/waccm/lb/cmip7_ghg_version20260727/ghg_cmip7_CMIP_CR-CMIP-1-0-0_1750-2023_monthly_gnz_0p5degLat_version20260727.nc</flbc_file>
<flbc_type>'SERIAL'</flbc_type>
<flbc_list>'CO2','CH4','N2O','CFC11','CFC12','CFC11eq'</flbc_list>

Expand Down
21 changes: 19 additions & 2 deletions src/cpl/nuopc/atm_stream_co2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ module atm_stream_co2
type(shr_strdata_type) :: sdat_co2_surface_source ! input data stream

! namelist variables
character(len=CS) :: stream_co2_surface_source_mapalgo
character(len=CS) :: stream_co2_surface_source_lat_dimname
character(len=CL) :: stream_co2_surface_source_mesh_filename
character(len=CL) :: stream_co2_surface_source_data_filename
character(len=CL) :: stream_co2_surface_source_data_varname ! variable name for co2_surface_source on stream file(s)
Expand Down Expand Up @@ -62,6 +64,8 @@ subroutine stream_co2_surface_source_readnl(nlfile)

namelist /co2_surface_source_stream_nl/ &
co2_surface_source, &
stream_co2_surface_source_mapalgo, &
stream_co2_surface_source_lat_dimname, &
stream_co2_surface_source_mesh_filename, &
stream_co2_surface_source_data_filename, &
stream_co2_surface_source_data_varname, &
Expand All @@ -72,8 +76,10 @@ subroutine stream_co2_surface_source_readnl(nlfile)

! Default values for namelist
co2_surface_source = .false.
stream_co2_surface_source_mapalgo = 'nearest_lat'
stream_co2_surface_source_lat_dimname = 'lat'
stream_co2_surface_source_mesh_filename = 'none'
Comment thread
gold2718 marked this conversation as resolved.
Outdated
stream_co2_surface_source_data_filename = ' '
stream_co2_surface_source_mesh_filename = ' '
stream_co2_surface_source_data_varname = ' '
stream_co2_surface_source_taxmode = 'unset'
stream_co2_surface_source_year_first = -999 ! first year in stream to use
Expand Down Expand Up @@ -111,6 +117,12 @@ subroutine stream_co2_surface_source_readnl(nlfile)
if (ierr /= 0) call endrun(trim(subname)//": FATAL: mpi_bcast: co2_surface_source")

if (co2_surface_source) then
call mpi_bcast(stream_co2_surface_source_mapalgo, &
len(stream_co2_surface_source_mapalgo), mpi_character, masterprocid, mpicom, ierr)
if (ierr /= 0) call endrun(trim(subname)//": FATAL: mpi_bcast: stream_co2_surface_source_mapalgo")
call mpi_bcast(stream_co2_surface_source_lat_dimname, &
len(stream_co2_surface_source_lat_dimname), mpi_character, masterprocid, mpicom, ierr)
if (ierr /= 0) call endrun(trim(subname)//": FATAL: mpi_bcast: stream_co2_surface_source_lat_dimname")
call mpi_bcast(stream_co2_surface_source_mesh_filename, &
len(stream_co2_surface_source_mesh_filename), mpi_character, masterprocid, mpicom, ierr)
if (ierr /= 0) call endrun(trim(subname)//": FATAL: mpi_bcast: stream_co2_surface_source_mesh_filename")
Expand All @@ -137,6 +149,10 @@ subroutine stream_co2_surface_source_readnl(nlfile)
write(iulog,'(a)') ' '
if (co2_surface_source) then
write(iulog,'(2a)') subname,' co2 surface source override settings::'
write(iulog,'(3a)') subname,' stream_co2_surface_source_mapalgo = ',&
trim(stream_co2_surface_source_mapalgo)
write(iulog,'(3a)') subname,' stream_co2_surface_source_lat_dimname = ',&
trim(stream_co2_surface_source_lat_dimname)
write(iulog,'(3a)') subname,' stream_co2_surface_source_data_filename = ',&
trim(stream_co2_surface_source_data_filename)
write(iulog,'(3a)') subname,' stream_co2_surface_source_mesh_filename = ',&
Expand Down Expand Up @@ -188,12 +204,13 @@ subroutine stream_co2_surface_source_init(rc)
stream_fldlistFile = (/stream_co2_surface_source_data_varname/), &
stream_fldListModel = (/stream_co2_surface_source_data_varname/), &
stream_lev_dimname = 'null', &
stream_mapalgo = 'bilinear', &
stream_mapalgo = trim(stream_co2_surface_source_mapalgo), &
stream_offset = 0, &
stream_taxmode = trim(stream_co2_surface_source_taxmode), &
stream_dtlimit = 1.0e30_r8, &
stream_tintalgo = 'linear', &
stream_name = 'CO2_SURFACE_SOURCE data ', &
stream_lat_dimname = trim(stream_co2_surface_source_lat_dimname), &
rc = rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down
Loading