Skip to content

Commit

Permalink
Merge pull request ESCOMP#484 from CESM-GC/CESM-GC_rebased_on_cam6_0_034
Browse files Browse the repository at this point in the history
cam6_3_147: GEOS-Chem chemistry and four new compsets that use it
  • Loading branch information
fvitt committed Feb 2, 2024
2 parents 11900b3 + 86720cc commit 74018ee
Show file tree
Hide file tree
Showing 47 changed files with 10,078 additions and 79 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ src/physics/carma/base
src/physics/clubb
src/physics/cosp2/src
src/physics/silhs
src/chemistry/geoschem/geoschem_src
src/physics/pumas
src/physics/pumas-frozen
src/dynamics/fv3/atmos_cubed_sphere
Expand Down
7 changes: 7 additions & 0 deletions Externals_CAM.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ sparse = ../.mpas_sparse_checkout
hash = b8c33daa
required = True

[geoschem]
local_path = src/chemistry/geoschem/geoschem_src
protocol = git
repo_url = https://github.com/geoschem/geos-chem.git
tag = 14.1.2
required = True

[hemco]
local_path = src/hemco
tag = hemco-cesm1_2_1_hemco3_6_3_cesm
Expand Down
108 changes: 95 additions & 13 deletions bld/build-namelist
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ my $rad_prog_bcarb = (($prog_species =~ "BC" or $aero_chem) and !($chem_rad_pa
my $rad_prog_sulf = (($prog_species =~ "SO4" or $aero_chem) and !($chem_rad_passive));
my $rad_prog_dust = (($prog_species =~ "DST" or $aero_chem) and !($chem_rad_passive));
my $rad_prog_sslt = (($prog_species =~ "SSLT" or $aero_chem) and !($chem_rad_passive));
my $rad_prog_ozone = (($chem =~ "mozart" or $chem =~ "waccm_ma" or $chem =~ "tsmlt" or $chem =~ "trop_strat") and !($chem_rad_passive));
my $rad_prog_ozone = (($chem =~ "mozart" or $chem =~ "waccm_ma" or $chem =~ "tsmlt" or $chem =~ "trop_strat" or $chem =~ /geoschem/) and !($chem_rad_passive));

# Check for eruptive volcano emissions. These will be radiatively active by default, but
# only if using BAM and the camrt radiation package
Expand Down Expand Up @@ -576,12 +576,13 @@ if ( ($chem ne 'none') or ( $prog_species ) ){

my ( $gas_wetdep_list, $aer_wetdep_list, $aer_sol_facti, $aer_sol_factb, $aer_scav_coef,
$aer_drydep_list, $gas_drydep_list ) =
set_dep_lists( $cfgdir, $chem_proc_src, $chem_src_dir, $nl, $print );
set_dep_lists( $chem, $cfgdir, $chem_proc_src, $chem_src_dir, $nl, $print );

if (length($gas_wetdep_list)>2){
add_default($nl, 'gas_wetdep_method' );
add_default($nl, 'gas_wetdep_list', 'val'=>$gas_wetdep_list );
}

if (length($aer_wetdep_list)>2){
# determine if prescribed aerosols are not needed ...
if ($aer_wetdep_list =~ /so4/i &&
Expand Down Expand Up @@ -862,7 +863,7 @@ my $radval = "'A:Q:H2O'";
if (($chem =~ /waccm_ma/ or $chem =~ /waccm_tsmlt/) and !$chem_rad_passive) {
$radval .= ",'A:O2:O2','A:CO2:CO2'";
}
elsif ($chem =~ /trop_strat/ and !$chem_rad_passive) {
elsif (($chem =~ /trop_strat/ or $chem =~ /geoschem/) and !$chem_rad_passive) {
$radval .= ",'N:O2:O2','A:CO2:CO2'";
}
elsif (($co2_cycle and !$co2_cycle_rad_passive) or ($chem =~ /ghg_mam4/)) {
Expand Down Expand Up @@ -897,6 +898,8 @@ if ((($chem =~ /ghg_mam4/) or ($chem =~ /waccm_ma/) or ($chem =~ /waccm_sc_mam/)
$radval .= ",'A:N2O:N2O','A:CH4:CH4','A:CFC11:CFC11','A:CFC12:CFC12'";
} elsif ($prog_ghg1 and !$prog_ghg2 and !$chem_rad_passive ) {
$radval .= ",'A:N2O:N2O','A:CH4:CH4','N:CFC11:CFC11','N:CFC12:CFC12'";
} elsif ($chem =~ /geoschem/) {
$radval .= ",'A:N2O:N2O','A:CH4:CH4','A:CFC11:CFC11','A:CFC12:CFC12'";
} else {
$radval .= ",'N:N2O:N2O','N:CH4:CH4','N:CFC11:CFC11','N:CFC12:CFC12'";
}
Expand Down Expand Up @@ -2018,6 +2021,34 @@ if (($chem =~ /trop_mozart/ or $chem =~ /trop_strat/ or $chem =~ /waccm_tsmlt/)
}
}

if ($chem =~ /geoschem/) {

my $val;

# Species with fixed lower boundary
$val = "'CCL4','CH4','N2O','CO2','CFC11','CFC12','CH3BR','CH3CCL3','CH3CL'"
.",'HCFC22','CFC114','CFC115','HCFC141B','HCFC142B','CH2BR2','CHBR3','H2402'";

if ($chem_has_ocs) {
$val .= ",'OCS'";
}
if (chem_has_species($cfg, 'SF6')) {
$val .= ",'SF6'";
}
add_default($nl, 'flbc_list', 'val'=>$val);
unless (defined $nl->get_value('flbc_type')) {
add_default($nl, 'flbc_type', 'val'=>'CYCLICAL');
add_default($nl, 'flbc_cycle_yr', 'val'=>'2000');
}

my @files;
# Datasets
@files = ( 'soil_erod_file', 'flbc_file' );
foreach my $file (@files) {
add_default($nl, $file);
}
}

if ($chem =~ /trop_mozart/ or $chem =~ /trop_strat/ or $chem =~ /waccm_tsmlt/) {

my $val;
Expand Down Expand Up @@ -2364,10 +2395,12 @@ if (($chem =~ /_mam4/ or $chem =~ /_mam5/) and ($phys =~ /cam6/ or $phys =~ /cam
}
}
}
add_default($nl, 'srf_emis_specifier', 'val'=>$val);
unless (defined $nl->get_value('srf_emis_type')) {
add_default($nl, 'srf_emis_type', 'val'=>'CYCLICAL');
add_default($nl, 'srf_emis_cycle_yr', 'val'=>2000);
if ($chem !~ /geoschem/) {
add_default($nl, 'srf_emis_specifier', 'val'=>$val);
unless (defined $nl->get_value('srf_emis_type')) {
add_default($nl, 'srf_emis_type', 'val'=>'CYCLICAL');
add_default($nl, 'srf_emis_cycle_yr', 'val'=>2000);
}
}

# Vertical emission datasets:
Expand Down Expand Up @@ -2433,10 +2466,12 @@ if (($chem =~ /_mam4/ or $chem =~ /_mam5/) and ($phys =~ /cam6/ or $phys =~ /cam
$first = 0;
}
}
add_default($nl, 'ext_frc_specifier', 'val'=>$val);
unless (defined $nl->get_value('ext_frc_type')) {
add_default($nl, 'ext_frc_type', 'val'=>"'CYCLICAL'");
add_default($nl, 'ext_frc_cycle_yr', 'val'=>2000);
if ($chem !~ /geoschem/) {
add_default($nl, 'ext_frc_specifier', 'val'=>$val);
unless (defined $nl->get_value('ext_frc_type')) {
add_default($nl, 'ext_frc_type', 'val'=>"'CYCLICAL'");
add_default($nl, 'ext_frc_cycle_yr', 'val'=>2000);
}
}

# MEGAN emissions
Expand Down Expand Up @@ -2482,6 +2517,30 @@ if (($chem =~ /_mam4/ or $chem =~ /_mam5/) and ($phys =~ /cam6/ or $phys =~ /cam
add_default($nl, 'megan_factors_file');
add_default($nl, 'megan_mapped_emisfctrs', 'val'=>'.false.');
}
if ($chem =~ /geoschem/) {
my $val = "'ISOP = isoprene',"
. "'MOH = methanol',"
. "'EOH = ethanol',"
. "'CH2O = formaldehyde',"
. "'ALD2 = acetaldehyde',"
. "'ACTA = acetic_acid',"
. "'ACET = acetone',"
. "'HCOOH = formic_acid',"
. "'HCN = hydrogen_cyanide',"
. "'CO = carbon_monoxide',"
. "'C2H6 = ethane',"
. "'C2H4 = ethene',"
. "'C3H8 = propane',"
. "'ALK4 = pentane + hexane + heptane + tricyclene',"
. "'PRPE = propene + butene',"
. "'TOLU = toluene',"
. "'LIMO = limonene',"
. "'MTPA = pinene_a + pinene_b + sabinene + carene_3',"
. "'MTPO = terpinene_g + terpinene_a + terpinolene + myrcene + ocimene_al + ocimene_t_b + ocimene_c_b + thujene_a + 2met_styrene + cymene_p + cymene_o + bornene + fenchene_a + camphene + phellandrene_a + phellandrene_b'";
add_default($nl, 'megan_specifier', 'val'=>$val);
add_default($nl, 'megan_factors_file');
add_default($nl, 'megan_mapped_emisfctrs', 'val'=>'.false.');
}
if ($chem =~ /trop_strat_mam4_vbs/ or $chem =~ /trop_strat_mam5_vbs/) {
my $val = "'ISOP = isoprene',"
. "'MTERP = carene_3 + pinene_a + thujene_a + bornene + terpineol_4 + terpineol_a + terpinyl_ACT_a "
Expand Down Expand Up @@ -2897,6 +2956,29 @@ if ($nl->get_value('use_hemco') =~ m/$TRUE/io) {
# ignored at runtime when HEMCO is used.
$nl->delete_variable('chem_inparm', 'ext_frc_specifier');
$nl->delete_variable('chem_inparm', 'srf_emis_specifier');

if ($chem =~ /geoschem/) {

# For now, HEMCO config and diagnostic configuration files are always used from
# the case directory. Exit if user has specified other paths in the user namelist
# because it will not work.
if ($nl->get_value('hemco_config_file') ne "'" . $inputdata_rootdir . "/HEMCO_Config.rc'") {
die "CAM Namelist ERROR: When running with GEOS-Chem chemistry, hemco_config_file\n".
"must not be manually set in the namelist. Instead, modify (or symlink from) the HEMCO_Config.rc\n".
"in the case directory, which will be copied to the run directory when submitting.\n".
"Then remove the hemco_config_file option from the user namelist.\n";
}

if ($nl->get_value('hemco_diagn_file') ne "'" . $inputdata_rootdir . "/HEMCO_Diagn.rc'") {
die "CAM Namelist ERROR: When running with GEOS-Chem chemistry, hemco_diagn_file\n".
"must not be manually set in the namelist. Instead, modify (or symlink from) the HEMCO_Diagn.rc\n".
"in the case directory, which will be copied to the run directory when submitting.\n".
"Then remove the hemco_diagn_file option from the user namelist.\n";
}

$nl->set_variable_value('hemco_nl', 'hemco_config_file', "'HEMCO_Config.rc'");
$nl->set_variable_value('hemco_nl', 'hemco_diagn_file', "'HEMCO_Diagn.rc'");
}
}

# Physics options
Expand Down Expand Up @@ -3025,7 +3107,7 @@ if (!$simple_phys) {
}

# tropopause level used in gas-phase / aerosol processes
if (($chem ne 'none') and ($chem ne 'terminator')) {
if (($chem ne 'none') and ($chem ne 'terminator') and !($chem =~ /geoschem/)) {
add_default($nl, 'chem_use_chemtrop');
}

Expand Down Expand Up @@ -3562,7 +3644,7 @@ if ( length($nl->get_value('soil_erod_file'))>0 ) {
add_default($nl, 'dust_emis_fact', 'tms'=>'1');
}
else {
if ($chem =~ /trop_strat/ or $chem =~ /waccm_ma/ or $chem =~ /waccm_tsmlt/ or $chem =~ /trop_mozart/) {
if ($chem =~ /trop_strat/ or $chem =~ /geoschem/ or $chem =~ /waccm_ma/ or $chem =~ /waccm_tsmlt/ or $chem =~ /trop_mozart/) {
add_default($nl, 'dust_emis_fact', 'ver'=>'chem');
}
else {
Expand Down
4 changes: 2 additions & 2 deletions bld/config_files/definition.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ meteor_smoke (Meteor Smoke), mixed_sulfate (Meteor Smoke and Sulfate), pmc (Pola
sulfate (Sulfate Aerosols), tholin (early earth haze), test_detrain (Detrainment), test_growth (Particle Growth), test_passive (Passive Dust),
test_radiative (Radiatively Active Dust), test_swelling (Sea Salt), test_tracers (Asian Monsoon), test_tracers2 (Guam).
</entry>
<entry id="chem" valid_values="none,ghg_mam4,terminator,trop_mam3,trop_mam4,trop_mam7,trop_mozart,trop_strat_mam4_ts2,trop_strat_mam4_vbs,trop_strat_mam4_vbsext,trop_strat_mam5_ts2,trop_strat_mam5_vbs,trop_strat_mam5_vbsext,waccm_ma,waccm_mad,waccm_ma_sulfur,waccm_sc,waccm_sc_mam4,waccm_mad_mam4,waccm_ma_mam4,waccm_tsmlt_mam4,waccm_tsmlt_mam4_vbsext,waccm_mad_mam5,waccm_ma_mam5,waccm_tsmlt_mam5,waccm_tsmlt_mam5_vbsext" value="">
Chemistry package: none,ghg_mam4,terminator,trop_mam3,trop_mam4,trop_mam7,trop_mozart,trop_strat_mam4_ts2,trop_strat_mam4_vbs,trop_strat_mam4_vbsext,trop_strat_mam5_ts2,trop_strat_mam5_vbs,trop_strat_mam5_vbsext,waccm_ma,waccm_mad,waccm_ma_sulfur,waccm_sc,waccm_sc_mam4,waccm_mad_mam4,waccm_ma_mam4,waccm_tsmlt_mam4,waccm_tsmlt_mam4_vbsext,waccm_mad_mam5,waccm_ma_mam5,waccm_tsmlt_mam5,waccm_tsmlt_mam5_vbsext
<entry id="chem" valid_values="none,ghg_mam4,terminator,trop_mam3,trop_mam4,trop_mam7,trop_mozart,trop_strat_mam4_ts2,trop_strat_mam4_vbs,trop_strat_mam4_vbsext,trop_strat_mam5_ts2,trop_strat_mam5_vbs,trop_strat_mam5_vbsext,waccm_ma,waccm_mad,waccm_ma_sulfur,waccm_sc,waccm_sc_mam4,waccm_mad_mam4,waccm_ma_mam4,waccm_tsmlt_mam4,waccm_tsmlt_mam4_vbsext,waccm_mad_mam5,waccm_ma_mam5,waccm_tsmlt_mam5,waccm_tsmlt_mam5_vbsext,geoschem_mam4" value="">
Chemistry package: none,ghg_mam4,terminator,trop_mam3,trop_mam4,trop_mam7,trop_mozart,trop_strat_mam4_ts2,trop_strat_mam4_vbs,trop_strat_mam4_vbsext,trop_strat_mam5_ts2,trop_strat_mam5_vbs,trop_strat_mam5_vbsext,waccm_ma,waccm_mad,waccm_ma_sulfur,waccm_sc,waccm_sc_mam4,waccm_mad_mam4,waccm_ma_mam4,waccm_tsmlt_mam4,waccm_tsmlt_mam4_vbsext,waccm_mad_mam5,waccm_ma_mam5,waccm_tsmlt_mam5,waccm_tsmlt_mam5_vbsext,geoschem_mam4
</entry>
<entry id="prog_species" valid_values="DST,SSLT,SO4,GHG,OC,BC,CARBON16" value="" list="1">
Prognostic mozart species packages: list of any subset of the following: DST,SSLT,SO4,GHG,OC,BC,CARBON16
Expand Down
47 changes: 36 additions & 11 deletions bld/configure
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ OPTIONS
trop_strat_mam4_vbs | trop_strat_mam4_vbsext | trop_strat_mam5_ts2 | trop_strat_mam5_vbs |
trop_strat_mam5_vbsext | waccm_ma | waccm_mad | waccm_ma_sulfur | waccm_sc | waccm_sc_mam4 |
waccm_mad_mam4 | waccm_ma_mam4 | waccm_tsmlt_mam4 | waccm_tsmlt_mam4_vbsext | waccm_mad_mam5 |
waccm_ma_mam5 | waccm_tsmlt_mam5 | waccm_tsmlt_mam5_vbsext ].
waccm_ma_mam5 | waccm_tsmlt_mam5 | waccm_tsmlt_mam5_vbsext | geoschem_mam4 ].
Default: trop_mam4 for cam6 and trop_mam3 for cam5.
-[no]clubb_sgs Switch on [off] CLUBB_SGS. Default: on for cam6, otherwise off.
-clubb_opts <list> Comma separated list of CLUBB options to turn on/off. By default they are all off.
Expand Down Expand Up @@ -592,7 +592,6 @@ if (defined $opts{'chem'}) {

# If the user has specified a simple physics package...
if ($simple_phys) {
# the only valid chemistry options are 'none' and 'terminator'
if (($chem_pkg ne 'none') and ($chem_pkg ne 'terminator')) {
die "configure ERROR: -phys=$phys_pkg -chem=$chem_pkg\n".
" -chem can only be set to 'none' or 'terminator'.\n";
Expand Down Expand Up @@ -1360,7 +1359,11 @@ my $chem_cppdefs = '';
my $chem_src_dir = '';

if (!$prog_species) {
$chem_src_dir = "$cam_dir/src/chemistry/pp_$chem_pkg";
if ($chem_pkg =~ 'geoschem') {
$chem_src_dir = "$cam_dir/src/chemistry/geoschem";
} else {
$chem_src_dir = "$cam_dir/src/chemistry/pp_$chem_pkg";
}
$cfg_ref->set('chem_src_dir', $chem_src_dir);
}

Expand All @@ -1387,10 +1390,10 @@ if ($customize) {
}
if ($print>=2) { print "Chem preprocessor compiler: $chemproc_fc $eol"; }
($chem_nadv) = chem_preprocess($cfg_ref,$print,$chemproc_fc);
} elsif ($chem_pkg ne 'none') {
} elsif ($chem_pkg ne 'none' and $chem_pkg !~ 'geoschem') {
# copy over chem docs
copy("$chem_src_dir/chem_mech.doc",$cam_bld) or die "copy failed $! \n";
copy("$chem_src_dir/chem_mech.in" ,$cam_bld) or die "copy failed $! \n";
copy("$chem_src_dir/chem_mech.doc",$cam_bld) or die "copy of chem_mec.doc failed $! \n";
copy("$chem_src_dir/chem_mech.in" ,$cam_bld) or die "copy of chem_mech.in failed $! \n";
($chem_nadv) = chem_number_adv($chem_src_dir);
}

Expand All @@ -1404,6 +1407,13 @@ if ($chem_pkg =~ '_mam3') {
$chem_cppdefs = ' -DMODAL_AERO -DMODAL_AERO_7MODE ';
}

# Customize GEOS-Chem advected species and chemistry CPP definitions
if ($chem_pkg =~ 'geoschem') {
$chem_cppdefs .= ' -DEXTERNAL_GRID -DEXTERNAL_FORCING ';
if ($chem_pkg =~ '_mam4') {
$chem_nadv = 267; # includes GC advected species (233), CO2 (1), and MAM aerosols (33)
}
}
# CARMA sectional microphysics
#
# New CARMA models need to define the number of advected constituents.
Expand Down Expand Up @@ -1565,8 +1575,6 @@ else {
$nadv = $cfg_ref->get('nadv');
if ($print>=2) { print "Total advected constituents: $nadv$eol"; }

#-----------------------------------------------------------------------------------------------

#-----------------------------------------------------------------------------------------------
# Makefile configuration #######################################################################
#-----------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -1675,7 +1683,7 @@ elsif ($fc =~ /nvfor/) { $fc_type = 'nvhpc'; }

# User override for Fortran compiler type
if (defined $opts{'fc_type'}) { $fc_type = $opts{'fc_type'}; }
if ($fc_type == "oneapi") {$fc_type = 'intel'; }
if ($fc_type eq "oneapi") {$fc_type = 'intel'; }
if ($fc_type) {
$cfg_ref->set('fc_type', $fc_type);
if ($print>=2) { print "Fortran compiler type: $fc_type$eol"; }
Expand Down Expand Up @@ -1941,6 +1949,12 @@ if ($unicon) { $cfg_cppdefs .= ' -DUSE_UNICON'; }
# HEMCO_CESM - indicates CESM model environment. Deprecated, will be removed soon.
$cfg_cppdefs .= ' -DMODEL_ -DMODEL_CESM -DHEMCO_CESM -DUSE_REAL8 ';

# Compiler CPP definitions for GEOS-Chem
if ($chem_pkg =~ 'geoschem') {
if ($fc_type eq 'intel') { $cfg_cppdefs .= ' -DLINUX_IFORT'; }
elsif ($fc_type eq 'gnu') { $cfg_cppdefs .= ' -DLINUX_GFORTRAN'; }
}

#-----------------------------------------------------------------------------------------------
# CPP defines to put on Makefile

Expand Down Expand Up @@ -2161,10 +2175,21 @@ sub write_filepath
if ($chem_src_dir) {
print $fh "$chem_src_dir\n";
}

# GEOS-Chem must be prior to Mozart
if ($chem_pkg =~ 'geoschem') {
print $fh "$chem_src_dir/geoschem_src/GeosCore\n";
print $fh "$chem_src_dir/geoschem_src/GeosUtil\n";
print $fh "$chem_src_dir/geoschem_src/Headers\n";
print $fh "$chem_src_dir/geoschem_src/ISORROPIA\n";
print $fh "$chem_src_dir/geoschem_src/KPP/fullchem\n";
print $fh "$camsrcdir/src/chemistry/pp_none\n";
}

if ($chem =~ /_mam/) {
print $fh "$camsrcdir/src/chemistry/modal_aero\n";
print $fh "$camsrcdir/src/chemistry/modal_aero\n";
} else {
print $fh "$camsrcdir/src/chemistry/bulk_aero\n";
print $fh "$camsrcdir/src/chemistry/bulk_aero\n";
}
print $fh "$camsrcdir/src/chemistry/aerosol\n";

Expand Down
Loading

0 comments on commit 74018ee

Please sign in to comment.