Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to allow testing of ExtData2G #331

Merged
merged 8 commits into from
Jul 11, 2022
Merged
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ set (programs
scm_setup
gcm_quickstat.j
scm_run.j
construct_extdata_yaml_list.py
)

install (
Expand Down
87 changes: 87 additions & 0 deletions construct_extdata_yaml_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/usr/bin/env python3
import yaml
import argparse
import os

def parse_args():
p = argparse.ArgumentParser(description='create extdata master file')
p.add_argument('rc_file',type=str,help='GEOS_ChemGridComp.rc file')
return vars(p.parse_args())

if __name__ == '__main__':

args = parse_args()
rc_file = args['rc_file']

f = open(rc_file,"r")
temp_text = f.readlines()
f.close()

component_yaml_files = yaml.safe_load("""
GOCART:
- CFC_GridComp_ExtData.yaml
- CH4_GridComp_ExtData.yaml
- CO2_GridComp_ExtData.yaml
- CO_GridComp_ExtData.yaml
- O3_GridComp_ExtData.yaml
- Rn_GridComp_ExtData.yaml
GOCART2G:
- CA2G_GridComp_ExtData.yaml
- DU2G_GridComp_ExtData.yaml
- NI2G_GridComp_ExtData.yaml
- SS2G_GridComp_ExtData.yaml
- SU2G_GridComp_ExtData.yaml
GAAS:
- GAAS_GridComp_ExtData.yaml
STRATCHEM:
- StratChem_ExtData.yaml
GMICHEM:
- GMI_ExtData.yaml
CARMA:
- CARMAchem_GridComp_ExtData.yaml
MAM:
- MAM7_ExtData.yaml
ACHEM:
- GEOSachem_ExtData.yaml
TR:
- TR_ExtData.yaml
DNA:
- DNA_ExtData.yaml
HEMCO:
- HEMCOgmi_ExtData.yaml
- HEMCOgocart2g_ExtData.yaml
Extras:
- ChemEnv_ExtData.yaml
- WSUB_ExtData.yaml
""")
components = {}
for line in temp_text:
if "ENABLE" in line:
entry = line.split(":")
if ".TRUE." in entry[1]:
component_on = True
if ".FALSE." in entry[1]:
component_on = False
key_name = entry[0]
component_name = key_name.replace("ENABLE_","")
component_name = component_name.lstrip()
components[component_name] = component_on

files_to_use = []
for key in components:
if key in component_yaml_files and components[key]:
files = component_yaml_files[key]
for single_file in files:
files_to_use.append(single_file)

extra_files = component_yaml_files["Extras"]
for single_file in extra_files:
files_to_use.append(single_file)

f = open("extdata.yaml","w")
f.write("subconfigs:\n")
for single_file in files_to_use:
f.write(" - "+single_file+"\n")
f.close()


60 changes: 41 additions & 19 deletions gcm_forecast.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -598,28 +598,36 @@ endif
set yearc = `echo $nymdc | cut -c1-4`
set yearf = `echo $nymdf | cut -c1-4`

# Which ExtData are we using
set EXTDATA2G_TRUE = `grep -i '^\s*USE_EXTDATA2G:\s*\.TRUE\.' CAP.rc | wc -l

# Select proper AMIP GOCART Emission RC Files
# -------------------------------------------
if( ${EMISSIONS} == AMIP_EMISSIONS) then
set AMIP_Transition_Date = 20000301

if( $nymdc < ${AMIP_Transition_Date} ) then
set AMIP_EMISSIONS_DIRECTORY = $EXPDIR/RC/AMIP.20C
if( $nymdf > ${AMIP_Transition_Date} ) then
set nymdf = ${AMIP_Transition_Date}
set oldstring = `grep '^\s*END_DATE:' CAP.rc`
set newstring = "END_DATE: $nymdf $nhmsf"
/bin/mv CAP.rc CAP.tmp
cat CAP.tmp | sed -e "s?$oldstring?$newstring?g" > CAP.rc
endif
if( $EXTDATA2G_TRUE == 0 ) then
if( $nymdc < ${AMIP_Transition_Date} ) then
set AMIP_EMISSIONS_DIRECTORY = $EXPDIR/RC/AMIP.20C
if( $nymdf > ${AMIP_Transition_Date} ) then
set nymdf = ${AMIP_Transition_Date}
set oldstring = `grep '^\s*END_DATE:' CAP.rc`
set newstring = "END_DATE: $nymdf $nhmsf"
/bin/mv CAP.rc CAP.tmp
cat CAP.tmp | sed -e "s?$oldstring?$newstring?g" > CAP.rc
endif
else
set AMIP_EMISSIONS_DIRECTORY = $EXPDIR/RC/AMIP
endif
else
set AMIP_EMISSIONS_DIRECTORY = $EXPDIR/RC/AMIP
set AMIP_EMISSIONS_DIRECTORY = $EXPDIR/RC/AMIP
endif


if( $AGCM_LM == 72 ) then
cp ${AMIP_EMISSIONS_DIRECTORY}/*.rc .
cp ${AMIP_EMISSIONS_DIRECTORY}/*.yaml .
else
set files = `/bin/ls -1 ${AMIP_EMISSIONS_DIRECTORY}/*.rc`
set files = `/bin/ls -1 ${AMIP_EMISSIONS_DIRECTORY}/*.rc ${AMIP_EMISSIONS_DIRECTORY}/*.yaml`
foreach file ($files)
/bin/rm -f `basename $file`
/bin/rm -f dummy
Expand Down Expand Up @@ -655,8 +663,13 @@ if ( $GOCART_DATA_TRUE == 0 && -e GOCARTdata_ExtData.rc ) /bin/mv

@MP_NO_USE_WSUB# 1MOM and GFDL microphysics do not use WSUB_NATURE
@MP_NO_USE_WSUB# -------------------------------------------------
@MP_NO_USE_WSUB/bin/mv WSUB_ExtData.rc WSUB_ExtData.tmp
@MP_NO_USE_WSUBcat WSUB_ExtData.tmp | sed -e '/^WSUB_NATURE/ s#ExtData.*#/dev/null#' > WSUB_ExtData.rc
if ($EXTDATA2G_TRUE == 0 ) then
@MP_NO_USE_WSUB/bin/mv WSUB_ExtData.rc WSUB_ExtData.tmp
@MP_NO_USE_WSUBcat WSUB_ExtData.tmp | sed -e '/^WSUB_NATURE/ s#ExtData.*#/dev/null#' > WSUB_ExtData.rc
else
@MP_NO_USE_WSUB/bin/mv WSUB_ExtData.yaml WSUB_ExtData.tmp
@MP_NO_USE_WSUBcat WSUB_ExtData.tmp | sed -e '/collection:/ s#WSUB_Wvar_positive_05hrdeg.*#/dev/null#' > WSUB_ExtData.yaml
endif
@MP_NO_USE_WSUB/bin/rm WSUB_ExtData.tmp

# Generate the complete ExtData.rc
Expand All @@ -665,11 +678,20 @@ if(-e ExtData.rc ) /bin/rm -f ExtData.rc
set extdata_files = `/bin/ls -1 *_ExtData.rc`

# Switch to MODIS v6.1 data after Nov 2021
set MODIS_Transition_Date = 20211101
if ( ${EMISSIONS} == OPS_EMISSIONS && ${MODIS_Transition_Date} <= $nymdc ) then
cat $extdata_files | sed 's|\(qfed2.emis_.*\).006.|\1.061.|g' > ExtData.rc
else
cat $extdata_files > ExtData.rc
if( $EXTDATA2G_TRUE == 0 ) then
set MODIS_Transition_Date = 20211101
if ( ${EMISSIONS} == OPS_EMISSIONS && ${MODIS_Transition_Date} <= $nymdc ) then
cat $extdata_files | sed 's|\(qfed2.emis_.*\).006.|\1.061.|g' > ExtData.rc
else
cat $extdata_files > ExtData.rc
endif
endif

if( $EXTDATA2G_TRUE == 1 ) then

$GEOSBIN/construct_extdata_yaml_list.py GEOS_ChemGridComp.rc
touch ExtData.rc

endif

# Move GOCART to use RRTMGP Bands
Expand Down
46 changes: 34 additions & 12 deletions gcm_regress.j
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ cd $HOMDIR
cd $EXPDIR/regress

cp $EXPDIR/RC/*.rc $EXPDIR/regress
cp $EXPDIR/RC/*.yaml $EXPDIR/regress
cp $EXPDIR/GEOSgcm.x $EXPDIR/regress
cp $EXPDIR/linkbcs $EXPDIR/regress
cp $HOMDIR/*.yaml $EXPDIR/regress
Expand Down Expand Up @@ -209,22 +210,29 @@ set date = `cat cap_restart`
set nymd0 = $date[1]
set nhms0 = $date[2]

set EXTDATA2G_TRUE = `grep -i '^\s*USE_EXTDATA2G:\s*\.TRUE\.' CAP.rc | wc -l`

# Select proper AMIP GOCART Emission RC Files
# -------------------------------------------
setenv EMISSIONS @EMISSIONS
if( @EMISSIONS == AMIP_EMISSIONS ) then
set AMIP_Transition_Date = 20000301
if( $EXTDATA2G_TRUE == 0 ) then
set AMIP_Transition_Date = 20000301

if( $nymd0 < ${AMIP_Transition_Date} ) then
set AMIP_EMISSIONS_DIRECTORY = $EXPDIR/RC/AMIP.20C
if( $nymd0 < ${AMIP_Transition_Date} ) then
set AMIP_EMISSIONS_DIRECTORY = $EXPDIR/RC/AMIP.20C
else
set AMIP_EMISSIONS_DIRECTORY = $EXPDIR/RC/AMIP
endif
else
set AMIP_EMISSIONS_DIRECTORY = $EXPDIR/RC/AMIP
set AMIP_EMISSIONS_DIRECTORY = $EXPDIR/RC/AMIP
endif

if( $LM == 72 ) then
cp ${AMIP_EMISSIONS_DIRECTORY}/*.rc .
cp ${AMIP_EMISSIONS_DIRECTORY}/*.yaml .
else
set files = `/bin/ls -1 ${AMIP_EMISSIONS_DIRECTORY}/*.rc`
set files = `/bin/ls -1 ${AMIP_EMISSIONS_DIRECTORY}/*.rc ${AMIP_EMISSIONS_DIRECTORY}/*.yaml`
foreach file ($files)
/bin/rm -f `basename $file`
/bin/rm -f dummy
Expand All @@ -236,8 +244,13 @@ endif

@MP_NO_USE_WSUB# 1MOM and GFDL microphysics do not use WSUB_NATURE
@MP_NO_USE_WSUB# -------------------------------------------------
@MP_NO_USE_WSUB/bin/mv WSUB_ExtData.rc WSUB_ExtData.tmp
@MP_NO_USE_WSUBcat WSUB_ExtData.tmp | sed -e '/^WSUB_NATURE/ s#ExtData.*#/dev/null#' > WSUB_ExtData.rc
if ($EXTDATA2G_TRUE == 0 ) then
@MP_NO_USE_WSUB/bin/mv WSUB_ExtData.rc WSUB_ExtData.tmp
@MP_NO_USE_WSUBcat WSUB_ExtData.tmp | sed -e '/^WSUB_NATURE/ s#ExtData.*#/dev/null#' > WSUB_ExtData.rc
else
@MP_NO_USE_WSUB/bin/mv WSUB_ExtData.yaml WSUB_ExtData.tmp
@MP_NO_USE_WSUBcat WSUB_ExtData.tmp | sed -e '/collection:/ s#WSUB_Wvar_positive_05hrdeg.*#/dev/null#' > WSUB_ExtData.yaml
endif
@MP_NO_USE_WSUB/bin/rm WSUB_ExtData.tmp

# Generate the complete ExtData.rc
Expand All @@ -246,11 +259,20 @@ if(-e ExtData.rc ) /bin/rm -f ExtData.rc
set extdata_files = `/bin/ls -1 *_ExtData.rc`

# Switch to MODIS v6.1 data after Nov 2021
set MODIS_Transition_Date = 20211101
if ( ${EMISSIONS} == OPS_EMISSIONS && ${MODIS_Transition_Date} <= $nymd0 ) then
cat $extdata_files | sed 's|\(qfed2.emis_.*\).006.|\1.061.|g' > ExtData.rc
else
cat $extdata_files > ExtData.rc
if( $EXTDATA2G_TRUE == 0 ) then
set MODIS_Transition_Date = 20211101
if ( ${EMISSIONS} == OPS_EMISSIONS && ${MODIS_Transition_Date} <= $nymd0 ) then
cat $extdata_files | sed 's|\(qfed2.emis_.*\).006.|\1.061.|g' > ExtData.rc
else
cat $extdata_files > ExtData.rc
endif
endif

if( $EXTDATA2G_TRUE == 1 ) then

$GEOSBIN/construct_extdata_yaml_list.py GEOS_ChemGridComp.rc
touch ExtData.rc

endif

# Move GOCART to use RRTMGP Bands
Expand Down
78 changes: 51 additions & 27 deletions gcm_run.j
Original file line number Diff line number Diff line change
Expand Up @@ -578,35 +578,43 @@ if( @OCEANtag != DE0360xPE0180 ) then
endif
endif

# Which ExtData are we using
set EXTDATA2G_TRUE = `grep -i '^\s*USE_EXTDATA2G:\s*\.TRUE\.' CAP.rc | wc -l`

# Select proper AMIP GOCART Emission RC Files
# -------------------------------------------
if( ${EMISSIONS} == AMIP_EMISSIONS ) then
set AMIP_Transition_Date = 20000301

# Before 2000-03-01, we need to use AMIP.20C which has different
# emissions (HFED instead of QFED) valid before 2000-03-01. Note
# that if you make a change to anything in $EXPDIR/RC/AMIP or
# $EXPDIR/RC/AMIP.20C, you might need to make a change in the other
# directory to be consistent. Some files in AMIP.20C are symlinks to
# that in AMIP but others are not.

if( $nymdc < ${AMIP_Transition_Date} ) then
set AMIP_EMISSIONS_DIRECTORY = $EXPDIR/RC/AMIP.20C
if( $nymdf > ${AMIP_Transition_Date} ) then
set nymdf = ${AMIP_Transition_Date}
set oldstring = `grep '^\s*END_DATE:' CAP.rc`
set newstring = "END_DATE: $nymdf $nhmsf"
/bin/mv CAP.rc CAP.tmp
cat CAP.tmp | sed -e "s?$oldstring?$newstring?g" > CAP.rc
endif
if( $EXTDATA2G_TRUE == 0 ) then
set AMIP_Transition_Date = 20000301

# Before 2000-03-01, we need to use AMIP.20C which has different
# emissions (HFED instead of QFED) valid before 2000-03-01. Note
# that if you make a change to anything in $EXPDIR/RC/AMIP or
# $EXPDIR/RC/AMIP.20C, you might need to make a change in the other
# directory to be consistent. Some files in AMIP.20C are symlinks to
# that in AMIP but others are not.

if( $nymdc < ${AMIP_Transition_Date} ) then
set AMIP_EMISSIONS_DIRECTORY = $EXPDIR/RC/AMIP.20C
if( $nymdf > ${AMIP_Transition_Date} ) then
set nymdf = ${AMIP_Transition_Date}
set oldstring = `grep '^\s*END_DATE:' CAP.rc`
set newstring = "END_DATE: $nymdf $nhmsf"
/bin/mv CAP.rc CAP.tmp
cat CAP.tmp | sed -e "s?$oldstring?$newstring?g" > CAP.rc
endif
else
set AMIP_EMISSIONS_DIRECTORY = $EXPDIR/RC/AMIP
endif
else
set AMIP_EMISSIONS_DIRECTORY = $EXPDIR/RC/AMIP
set AMIP_EMISSIONS_DIRECTORY = $EXPDIR/RC/AMIP
endif

if( $AGCM_LM == 72 ) then
cp ${AMIP_EMISSIONS_DIRECTORY}/*.rc .
cp ${AMIP_EMISSIONS_DIRECTORY}/*.yaml .
else
set files = `/bin/ls -1 ${AMIP_EMISSIONS_DIRECTORY}/*.rc`
set files = `/bin/ls -1 ${AMIP_EMISSIONS_DIRECTORY}/*.rc ${AMIP_EMISSIONS_DIRECTORY}/*.yaml`
foreach file ($files)
/bin/rm -f `basename $file`
/bin/rm -f dummy
Expand Down Expand Up @@ -636,21 +644,37 @@ if ( $GOCART_DATA_TRUE == 0 && -e GOCARTdata_ExtData.rc ) /bin/mv

@MP_NO_USE_WSUB# 1MOM and GFDL microphysics do not use WSUB_NATURE
@MP_NO_USE_WSUB# -------------------------------------------------
@MP_NO_USE_WSUB/bin/mv WSUB_ExtData.rc WSUB_ExtData.tmp
@MP_NO_USE_WSUBcat WSUB_ExtData.tmp | sed -e '/^WSUB_NATURE/ s#ExtData.*#/dev/null#' > WSUB_ExtData.rc
if ($EXTDATA2G_TRUE == 0 ) then
@MP_NO_USE_WSUB/bin/mv WSUB_ExtData.rc WSUB_ExtData.tmp
@MP_NO_USE_WSUBcat WSUB_ExtData.tmp | sed -e '/^WSUB_NATURE/ s#ExtData.*#/dev/null#' > WSUB_ExtData.rc
else
@MP_NO_USE_WSUB/bin/mv WSUB_ExtData.yaml WSUB_ExtData.tmp
@MP_NO_USE_WSUBcat WSUB_ExtData.tmp | sed -e '/collection:/ s#WSUB_Wvar_positive_05hrdeg.*#/dev/null#' > WSUB_ExtData.yaml
endif
@MP_NO_USE_WSUB/bin/rm WSUB_ExtData.tmp



# Generate the complete ExtData.rc
# --------------------------------
if(-e ExtData.rc ) /bin/rm -f ExtData.rc
set extdata_files = `/bin/ls -1 *_ExtData.rc`

# Switch to MODIS v6.1 data after Nov 2021
set MODIS_Transition_Date = 20211101
if ( ${EMISSIONS} == OPS_EMISSIONS && ${MODIS_Transition_Date} <= $nymdc ) then
cat $extdata_files | sed 's|\(qfed2.emis_.*\).006.|\1.061.|g' > ExtData.rc
else
cat $extdata_files > ExtData.rc
if( $EXTDATA2G_TRUE == 0 ) then
set MODIS_Transition_Date = 20211101
if ( ${EMISSIONS} == OPS_EMISSIONS && ${MODIS_Transition_Date} <= $nymdc ) then
cat $extdata_files | sed 's|\(qfed2.emis_.*\).006.|\1.061.|g' > ExtData.rc
else
cat $extdata_files > ExtData.rc
endif
endif

if( $EXTDATA2G_TRUE == 1 ) then

$GEOSBIN/construct_extdata_yaml_list.py GEOS_ChemGridComp.rc
touch ExtData.rc
Copy link
Member

Choose a reason for hiding this comment

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

@bena-nasa Should this be touch extdata.yaml?


endif

# Move GOCART to use RRTMGP Bands
Expand Down
Loading