Skip to content

Commit

Permalink
Merge PR #1963 (Add fixes for single-species carbon simulation )
Browse files Browse the repository at this point in the history
This merge brings PR #1963 (Add fixes to allow carbon simulations
to run with a single advected species, by @yantosca) into the
GEOS-Chem 14.2.1 development stream.

This PR adds a script (run/shared/singleCarbonSpecies.sh) that is
called from the run-directory creation scripts run/GCClassic/createRundir.sh
and run/GCHP/createRunDir.sh to remove entries from rundir configuration
files for all species except the one that is being advected.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
  • Loading branch information
yantosca committed Sep 19, 2023
2 parents 34bbd82 + c273374 commit 5d6b1f5
Show file tree
Hide file tree
Showing 12 changed files with 512 additions and 205 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- GCClassic integration tests now display proper commit info in `results.compile.log`
- Stopped OCEAN_CONC from needlessly being pushed through vertical regridding for Hg simulations
- Added warning in GCHP HISTORY.rc about outputting area-dependent variables on custom grids
- Added option to use a single advected species in the carbon simulation

### Changed
- Update `DiagnFreq` in GCClassic integration tests to ensure HEMCO diagnostic output
Expand Down Expand Up @@ -101,7 +102,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Change RTOL value from 0.5e-3 back to 0.5e-2 to address model slowdown
- Allow the use of OFFLINE_SEASALT for seasalt alkalinity, Cl, and Br in GEOS-Chem within CESM
- Renamed TransportTracer species for consistency with GMAO's TR_GridComp
- See `KPP/fullchem/CHANGELOG_fullchem.md` for fullchem-mechanism changes
- See `KPP/fullchem/CHANGELOG_fullchem.md` for fullchem-mechanism
changes
- Update template `HEMCO_Config.rc.carbon` files to allow running the carbon simulation with only a single species.

### Fixed
- Fixed typo in `GCClassic/createRunDir.sh` preventing benchmark run script from being copied to the run directory
Expand Down
22 changes: 20 additions & 2 deletions GeosCore/carbon_gases_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ END SUBROUTINE Emiss_Carbon_Gases
! !INTERFACE:
!
SUBROUTINE Chem_Carbon_Gases( Input_Opt, State_Met, State_Chm, &
State_Grid, State_Diag, RC )
State_Grid, State_Diag, RC )
!
! !USES:
!
Expand Down Expand Up @@ -684,7 +684,16 @@ SUBROUTINE Chem_Carbon_Gases( Input_Opt, State_Met, State_Chm, &
! Update reaction rates
!===================================================================

! Start timer
! Stop KPP timer
IF ( Input_Opt%useTimers ) THEN
CALL Timer_End( &
timerName = " -> KPP", &
inLoop = .TRUE., &
threadNum = ThreadNum, &
RC = RC )
ENDIF

! Start RCONST timer
IF ( Input_Opt%useTimers ) THEN
CALL Timer_Start( &
timerName = " RCONST", &
Expand Down Expand Up @@ -756,6 +765,15 @@ SUBROUTINE Chem_Carbon_Gases( Input_Opt, State_Met, State_Chm, &
! Trap potential errors
IF ( IERR /= 1 ) failed = .TRUE.

! Start KPP timer
IF ( Input_Opt%useTimers ) THEN
CALL Timer_End( &
timerName = " -> KPP", &
inLoop = .TRUE., &
threadNum = ThreadNum, &
RC = RC )
ENDIF

!=====================================================================
! HISTORY: Archive KPP solver diagnostics
!=====================================================================
Expand Down
20 changes: 20 additions & 0 deletions GeosCore/chemistry_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,11 @@ SUBROUTINE Do_Chemistry( Input_Opt, State_Chm, State_Diag, &
!=====================================================================
ELSE IF ( Input_Opt%ITS_A_CARBON_SIM ) THEN

! Start "FlexChem" timer
IF ( Input_Opt%useTimers ) THEN
CALL Timer_Start( "=> FlexChem", RC )
ENDIF

! Do carbon chemistry
CALL Chem_Carbon_Gases( Input_Opt = Input_Opt, &
State_Met = State_Met, &
Expand All @@ -1003,11 +1008,21 @@ SUBROUTINE Do_Chemistry( Input_Opt, State_Chm, State_Diag, &
RETURN
ENDIF

! Stop "FlexChem" timer
IF ( Input_Opt%useTimers ) THEN
CALL Timer_End( "=> FlexChem", RC )
ENDIF

!====================================================================
! Mercury (configure with -DMECH=Hg)
!=====================================================================
ELSE IF ( Input_Opt%ITS_A_MERCURY_SIM ) THEN

! Start "FlexChem" timer
IF ( Input_Opt%useTimers ) THEN
CALL Timer_Start( "=> FlexChem", RC )
ENDIF

! Do Hg chemistry
CALL ChemMercury( Input_Opt = Input_Opt, &
State_Chm = State_Chm, &
Expand All @@ -1023,6 +1038,11 @@ SUBROUTINE Do_Chemistry( Input_Opt, State_Chm, State_Diag, &
RETURN
ENDIF

! Stop "FlexChem" timer
IF ( Input_Opt%useTimers ) THEN
CALL Timer_End( "=> FlexChem", RC )
ENDIF

!=====================================================================
! POPs (only used when compiled with BPCH_DIAG=y)
!=====================================================================
Expand Down
28 changes: 16 additions & 12 deletions run/GCClassic/HEMCO_Config.rc.templates/HEMCO_Config.rc.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,6 @@ ${RUNDIR_GLOBAL_OH}
#------------------------------------------------------------------------------
# --- Quantities needed for CH4 chemistry ---
#------------------------------------------------------------------------------
(((USE_CH4_DATA
# --- Global CH4 loss frequencies [1/s] -----------
(((CH4_LOSS_FREQ
Expand All @@ -1319,12 +1318,9 @@ ${RUNDIR_CH4_LOSS}
${RUNDIR_GLOBAL_Cl}
)))GLOBAL_CL
)))USE_CH4_DATA
#------------------------------------------------------------------------------
# --- Quantities needed for CO chemistry ---
#------------------------------------------------------------------------------
(((USE_CO_DATA
# -- P(CO) from CH4 and NMVOC from the last 10-yr benchmark [molec/cm3/s] ---
(((PROD_CO_CH4
Expand All @@ -1336,28 +1332,33 @@ ${RUNDIR_PCO_NMVOC}
# --- GMI chemistry: prod/loss rates (for strato-/mesosphere) ---
# --- Units: prod [v/v/s]; loss [1/s] ---
(((USE_CO_DATA
(((GMI_PROD_LOSS
${RUNDIR_GMI_LOSS_CO}
${RUNDIR_GMI_PROD_CO}
* GMI_LOSS_CO $ROOT/GMI/v2022-11/gmi.clim.CO.geos5.2x25.nc loss 2005/1-12/1/0 C xyz s-1 CO - 1 1
* GMI_PROD_CO $ROOT/GMI/v2022-11/gmi.clim.CO.geos5.2x25.nc prod 2005/1-12/1/0 C xyz v/v/s CO - 1 1
)))GMI_PROD_LOSS
)))USE_CO_DATA
# If CO is not an advected species, then just read as a chemistry input
(((.not.USE_CO_DATA
(((GMI_PROD_LOSS
* GMI_LOSS_CO $ROOT/GMI/v2022-11/gmi.clim.CO.geos5.2x25.nc loss 2005/1-12/1/0 C xyz s-1 * - 1 1
* GMI_PROD_CO $ROOT/GMI/v2022-11/gmi.clim.CO.geos5.2x25.nc prod 2005/1-12/1/0 C xyz v/v/s * - 1 1
)))GMI_PROD_LOSS
))).not.USE_CO_DATA
#------------------------------------------------------------------------------
# --- Quantities needed for CO2 chemistry ---
#------------------------------------------------------------------------------
# --- CHEMICAL PRODUCTION FROM CO OXIDATION ------
# --- Recommended for use in forward modelling ---
# --- Optional for inversion/assimilation --------
(((USE_CO2_DATA
(((CO2_COPROD
${RUNDIR_CO2_COPROD}
)))CO2_COPROD
)))USE_CO2_DATA
)))CHEMISTRY_INPUT
### END SECTION BASE EMISSIONS ###
Expand Down Expand Up @@ -1690,12 +1691,15 @@ ${RUNDIR_CO2_COPROD}
2008 AFRICA_MASK $ROOT/MASKS/v2018-09/AF_LANDMASK.geos.05x0666.global.nc LANDMASK 1985/1/1/0 C xy 1 1 -20/-37/54/40
)))DICE_Africa
)))USE_CO_DATA.or.USE_CO2_DATA
#==============================================================================
# --- Masks used for CH4, CO and CO2 simulation emissions ---
#==============================================================================
(((CEDSv2.or.CEDS_GBDMAPS.or.CEDS_GBDMAPS_byFuelType
2009 CHINA_MASK $ROOT/MASKS/v2018-09/China_mask.generic.1x1.nc MASK 2000/1/1/0 C xy 1 1 70/10/150/60
)))CEDSv2.or.CEDS_GBDMAPS.or.CEDS_GBDMAPS_byFuelType
)))USE_CO_DATA.or.USE_CO2_DATA
)))EMISSIONS
### END SECTION MASKS ###
Expand Down
87 changes: 3 additions & 84 deletions run/GCClassic/HEMCO_Diagn.rc.templates/HEMCO_Diagn.rc.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
# Name Spec ExtNr Cat Hier Dim OutUnit LongName

###############################################################################
##### CH4 sources #####
##### CH4 sources #####
###############################################################################

EmisCH4_Total CH4 -1 -1 -1 2 kg/m2/s CH4_emissions_from_all_sectors
EmisCH4_Oil CH4 0 1 -1 2 kg/m2/s CH4_emissions_from_oil
EmisCH4_Gas CH4 0 2 -1 2 kg/m2/s CH4_emissions_from_gas
Expand All @@ -42,7 +41,7 @@ EmisCH4_Reservoirs CH4 0 15 -1 2 kg/m2/s CH4_emissions_from_hydr
EmisCO_Total CO -1 -1 -1 3 kg/m2/s CO_emission_flux_from_all_sectors
EmisCO_Aircraft CO 0 20 -1 3 kg/m2/s CO_emission_flux_from_aircraft
EmisCO_Anthro CO 0 1 -1 3 kg/m2/s CO_emission_flux_from_anthropogenic
EmisCO_BioBurn CO 0 5 -1 2 kg/m2/s CO_emission_flux_from_biomass_burning
EmisCO_BiomassBurn CO 111 -1 -1 2 kg/m2/s CO_emission_flux_from_biomass_burning
EmisCO_Ship CO 0 10 -1 2 kg/m2/s CO_emission_flux_from_ships

###############################################################################
Expand All @@ -56,13 +55,7 @@ EmisCO2_NetTerrExch CO2 0 5 -1 2 kg/m2/s CO2_net_terrestrial_exc
EmisCO2_Ship CO2 0 6 -1 2 kg/m2/s CO2_ship_emissions
EmisCO2_Aviation CO2 0 7 -1 3 kg/m2/s CO2_aviation_emissions
EmisCO2_CO2SurfCorr CO2 0 8 -1 2 kg/m2/s CO2_surface_correction_for_CO_oxidation

#NOTE: Biomass burning doesn't seem to work. Keep here for now.
# Uncomment this if GFED is used
#EmisCO2_Biomass_GFED CO2 111 1 1 2 kg/m2/s CO2_biomass_burning_emissions_from_GFED4

# Uncomment this if FINN is used
#EmisCO2_Biomass_FINN CO2 114 1 1 2 kg/m2/s CO2_biomass_burning_emissions_from_FINN
EmisCO2_BiomassBurn CO2 111 -1 -1 2 kg/m2/s CO2_biomass_burning_emissions_from_GFED4

###############################################################################
##### OCS sources #####
Expand All @@ -72,77 +65,3 @@ EmisOCS_Anthro OCS 0 1 -1 2 kg/m2/s OCS_emission_flux_from_
EmisOCS_Bioburn OCS 0 2 -1 2 kg/m2/s OCS_emission_flux_from_biomass_burning
EmisOCS_MissingOcean OCS 0 3 -1 2 kg/m2/s OCS_emission_flux_from_missing_ocean
EmisOCS_Ocean OCS 0 4 -1 2 kg/m2/s OCS_emission_flux_from_ocean

# Tagged CO species, uncomment if needed
#
################################################################################
###### COus sources #####
################################################################################
#EmisCOus_Total COus -1 -1 -1 3 kg/m2/s COus_emission_flux_from_all_sectors
#EmisCOus_Aircraft COus 0 20 -1 3 kg/m2/s COus_emission_flux_from_aircraft
#EmisCOus_Anthro COus 0 1 -1 3 kg/m2/s COus_emission_flux_from_anthropogenic
#EmisCOus_BioBurn COus 0 5 -1 2 kg/m2/s COus_emission_flux_from_biomass_burning
#EmisCOus_Ship COus 0 10 -1 2 kg/m2/s COus_emission_flux_from_ships
#
################################################################################
###### COeur sources #####
################################################################################
#EmisCOeur_Total COeur -1 -1 -1 3 kg/m2/s COeur_emission_flux_from_all_sectors
#EmisCOeur_Aircraft COeur 0 20 -1 3 kg/m2/s COeur_emission_flux_from_aircraft
#EmisCOeur_Anthro COeur 0 1 -1 3 kg/m2/s COeur_emission_flux_from_anthropogenic
#EmisCOeur_BioBurn COeur 0 5 -1 2 kg/m2/s COeur_emission_flux_from_biomass_burning
#EmisCOeur_Ship COeur 0 10 -1 2 kg/m2/s COeur_emission_flux_from_ships
#
################################################################################
###### COasia sources #####
################################################################################
#EmisCOasia_Total COasia -1 -1 -1 3 kg/m2/s COasia_emission_flux_from_all_sectors
#EmisCOasia_Aircraft COasia 0 20 -1 3 kg/m2/s COasia_emission_flux_from_aircraft
#EmisCOasia_Anthro COasia 0 1 -1 3 kg/m2/s COasia_emission_flux_from_anthropogenic
#EmisCOasia_BioBurn COasia 0 5 -1 2 kg/m2/s COasia_emission_flux_from_biomass_burning
#EmisCOasia_Ship COasia 0 10 -1 2 kg/m2/s COasia_emission_flux_from_ships
#
################################################################################
###### COoth sources #####
################################################################################
#EmisCOoth_Total COoth -1 -1 -1 3 kg/m2/s COoth_emission_flux_from_all_sectors
#EmisCOoth_Aircraft COoth 0 20 -1 3 kg/m2/s COoth_emission_flux_from_aircraft
#EmisCOoth_Anthro COoth 0 1 -1 3 kg/m2/s COoth_emission_flux_from_anthropogenic
#EmisCOoth_BioBurn COoth 0 5 -1 2 kg/m2/s COoth_emission_flux_from_biomass_burning
#EmisCOoth_Ship COoth 0 10 -1 2 kg/m2/s COoth_emission_flux_from_ships
#
################################################################################
###### COus sources #####
################################################################################
#EmisCOus_Total COus -1 -1 -1 3 kg/m2/s COus_emission_flux_from_all_sectors
#EmisCOus_Aircraft COus 0 20 -1 3 kg/m2/s COus_emission_flux_from_aircraft
#EmisCOus_Anthro COus 0 1 -1 3 kg/m2/s COus_emission_flux_from_anthropogenic
#EmisCOus_BioBurn COus 0 5 -1 2 kg/m2/s COus_emission_flux_from_biomass_burning
#EmisCOus_Ship COus 0 10 -1 2 kg/m2/s COus_emission_flux_from_ships
#
################################################################################
###### COeur sources #####
################################################################################
#EmisCOeur_Total COeur -1 -1 -1 3 kg/m2/s COeur_emission_flux_from_all_sectors
#EmisCOeur_Aircraft COeur 0 20 -1 3 kg/m2/s COeur_emission_flux_from_aircraft
#EmisCOeur_Anthro COeur 0 1 -1 3 kg/m2/s COeur_emission_flux_from_anthropogenic
#EmisCOeur_BioBurn COeur 0 5 -1 2 kg/m2/s COeur_emission_flux_from_biomass_burning
#EmisCOeur_Ship COeur 0 10 -1 2 kg/m2/s COeur_emission_flux_from_ships
#
################################################################################
###### COasia sources #####
################################################################################
#EmisCOasia_Total COasia -1 -1 -1 3 kg/m2/s COasia_emission_flux_from_all_sectors
#EmisCOasia_Aircraft COasia 0 20 -1 3 kg/m2/s COasia_emission_flux_from_aircraft
#EmisCOasia_Anthro COasia 0 1 -1 3 kg/m2/s COasia_emission_flux_from_anthropogenic
#EmisCOasia_BioBurn COasia 0 5 -1 2 kg/m2/s COasia_emission_flux_from_biomass_burning
#EmisCOasia_Ship COasia 0 10 -1 2 kg/m2/s COasia_emission_flux_from_ships
#
################################################################################
###### COoth sources #####
################################################################################
#EmisCOoth_Total COoth -1 -1 -1 3 kg/m2/s COoth_emission_flux_from_all_sectors
#EmisCOoth_Aircraft COoth 0 20 -1 3 kg/m2/s COoth_emission_flux_from_aircraft
#EmisCOoth_Anthro COoth 0 1 -1 3 kg/m2/s COoth_emission_flux_from_anthropogenic
#EmisCOoth_BioBurn COoth 0 5 -1 2 kg/m2/s COoth_emission_flux_from_biomass_burning
#EmisCOoth_Ship COoth 0 10 -1 2 kg/m2/s COoth_emission_flux_from_ships
51 changes: 43 additions & 8 deletions run/GCClassic/createRunDir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ cd ${srcrundir}
# Source common bash functions from scripts in the run/shared folder
. ${gcdir}/run/shared/setupConfigFiles.sh # Config file editing
. ${gcdir}/run/shared/newUserRegistration.sh # 1st-time user registration
. ${gcdir}/run/shared/singleCarbonSpecies.sh # Single carbon species setup

# Initialize run directory variables
RUNDIR_VARS=""
Expand Down Expand Up @@ -247,6 +248,34 @@ elif [[ ${sim_name} = "POPs" ]]; then
printf "Invalid POPs type. Try again.\n"
fi
done

# Ask user to specify carbon simulation options
elif [[ "x${sim_name}" == "xcarbon" ]]; then
printf "${thinline}Do you wish to use a single advected species?${thinline}"
printf " 1. Use all species\n"
printf " 2. Use CH4 only\n"
printf " 3. Use CO2 only\n"
printf " 4. Use CO only\n"
printf " 5. Use OCS only\n"
valid=0
while [ "${valid}" -eq 0 ]; do
read -p "${USER_PROMPT}" prompt
valid=1
if [[ "x${prompt}" == "x1" ]]; then
sim_extra_option="none"
elif [[ "x${prompt}" == "x2" ]]; then
sim_extra_option="CH4"
elif [[ "x${prompt}" == "x3" ]]; then
sim_extra_option="CO2"
elif [[ "x${prompt}" == "x4" ]]; then
sim_extra_option="CO"
elif [[ "x${prompt}" == "x5" ]]; then
sim_extra_option="OCS"
else
valid=0
printf "Invalid selection. Try again.\n"
fi
done
fi

RUNDIR_VARS+="RUNDIR_SIM_EXTRA_OPTION=$sim_extra_option\n"
Expand Down Expand Up @@ -725,12 +754,11 @@ while [ "$valid_path" -eq 0 ]; do
exit 1
fi

# Replace ~ with the user's home directory
# NOTE: This is a safe algorithm.
if [[ "${rundir_path}" =~ '~' ]]; then
rundir_path="${rundir_path/#\~/$HOME}"
echo "Expanding to: ${rundir_path}"
fi
# Expand $rundir_path to an absolute path.
# Also replace ~ with $HOME.
rundir_path="${rundir_path/#\~/$HOME}"
rundir_path=$(realpath "${rundir_path}")
echo "Expanding to ${rundir_path}"

# If this is just a new directory within an existing one,
# give the user the option to proceed
Expand Down Expand Up @@ -886,6 +914,7 @@ else
startdate='20190701'
enddate='20190801'
fi

if [[ ${met} = "ModelE2.1" ]] || [[ ${met} = "ModelE2.2" ]]; then
if [[ "$scenario" == "HIST" ]]; then
startdate='20050701'
Expand Down Expand Up @@ -977,6 +1006,7 @@ echo -e "$RUNDIR_VARS" > ${rundir_config_log}
#sort -o ${rundir_config_log} ${rundir_config_log}

# Initialize run directory
# NOTE: This also copies configuration files to the run directory!
${srcrundir}/init_rd.sh ${rundir_config_log}

#--------------------------------------------------------------------
Expand Down Expand Up @@ -1140,9 +1170,14 @@ fi
# input_options.yml and modifies diagnostic output based on simulation type.
if [[ "x${sim_name}" = "xfullchem" ]]; then
set_common_settings "${sim_extra_option}" "GCClassic"
fi
fi

#
# If necessary, edit config files for a carbon single species simulation
if [[ "x${sim_name}" == "xcarbon" ]]; then
if [[ "x${sim_extra_option}" != "xnone" ]]; then
singleCarbonSpecies "${sim_extra_option}" "${rundir}"
fi
fi

#--------------------------------------------------------------------
# Navigate back to source code directory
Expand Down
Loading

0 comments on commit 5d6b1f5

Please sign in to comment.