Skip to content

Commit d2250e6

Browse files
Merge branch 'rrfs-mpas-jedi' into mpasv8.3.1_L65
2 parents ae7b903 + a7004eb commit d2250e6

19 files changed

Lines changed: 839 additions & 4 deletions

jobs/JRRFS_FCST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ else
3232
export UMBRELLA_PREP_IC_DATA=${UMBRELLA_PREP_IC_DATA:-${DATAROOT}/${RUN}_prep_ic_${cyc}_${rrfs_ver}/${WGF}${MEMDIR}}
3333
export UMBRELLA_FCST_DATA=${UMBRELLA_FCST_DATA:-${DATAROOT}/${RUN}_fcst_${cyc}_${rrfs_ver}/${WGF}${MEMDIR}}
3434
fi
35+
export UMBRELLA_PREP_CHEM_DATA=${UMBRELLA_PREP_CHEM_DATA:-${DATAROOT}/${RUN}_prep_chem_${cyc}_${rrfs_ver}/${WGF}${MEMDIR}}
3536
export DATA=${DATA:-${UMBRELLA_FCST_DATA}/${jobid}}
3637

3738
if [[ -d "${DATA}" ]]; then # remove the "${DATA}" directory if existed

jobs/JRRFS_PREP_CHEM

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env bash
2+
declare -rx PS4='+ $(basename ${BASH_SOURCE[0]:-${FUNCNAME[0]:-"Unknown"}})[${LINENO}]: '
3+
set -x
4+
date
5+
#
6+
#-----------------------------------------------------------------------
7+
# Specify Execution Areas
8+
#-----------------------------------------------------------------------
9+
#
10+
export HOMErrfs=${HOMErrfs} #comes from the workflow at runtime
11+
export EXECrrfs=${EXECrrfs:-${HOMErrfs}/exec}
12+
export FIXrrfs=${FIXrrfs:-${HOMErrfs}/fix}
13+
export PARMrrfs=${PARMrrfs:-${HOMErrfs}/parm}
14+
export USHrrfs=${USHrrfs:-${HOMErrfs}/ush}
15+
#
16+
#-----------------------------------------------------------------------
17+
# Obtain unique process id (pid) and create the run directory (DATA).
18+
#-----------------------------------------------------------------------
19+
#
20+
export pid=${pid:-$$}
21+
export UMBRELLA_PREP_CHEM_DATA=${UMBRELLA_PREP_CHEM_DATA:-${DATAROOT}/${RUN}_prep_chem_${cyc}_${rrfs_ver}/${WGF}${MEMID}}
22+
if [[ "${SPINUP_MODE:-0}" == "1" ]]; then
23+
prep_ic_str="prep_ic_spinup"
24+
else
25+
prep_ic_str="prep_ic"
26+
fi
27+
export UMBRELLA_PREP_IC_DATA=${UMBRELLA_PREP_IC_DATA:-${DATAROOT}/${RUN}_${prep_ic_str}_${cyc}_${rrfs_ver}/${WGF}${MEMDIR}}
28+
29+
export jobid=${jobid:-prep_chem_${cyc}}
30+
export DATA=${DATA:-${UMBRELLA_PREP_CHEM_DATA}/${jobid}}_${EMIS_SECTOR_TO_PROCESS}
31+
32+
if [[ -d "${DATA}" ]]; then # remove the "${DATA}" directory if existed
33+
rm -rf "${DATA}"
34+
fi
35+
mkdir -p "${DATA}"
36+
#
37+
#-----------------------------------------------------------------------
38+
# Define COM directories
39+
#-----------------------------------------------------------------------
40+
#
41+
export COMINrrfs=${COMINrrfs:-$(compath.py "$envir/rrfs/$rrfs_ver")}
42+
export COMOUT=${COMOUT:-$(compath.py -o "${NET}/${rrfs_ver}/${RUN}.${PDY}/${cyc}")}
43+
#
44+
#----------------------------------------
45+
# Execute the script.
46+
#----------------------------------------
47+
export pgmout="${DATA}/OUTPUT.$$"
48+
"${HOMErrfs}"/scripts/exrrfs_prep_chem.sh
49+
export err=$?; err_chk
50+
51+
if [[ -e "${pgmout}" ]]; then
52+
cat "${pgmout}"
53+
fi
54+
#
55+
#----------------------------------------
56+
# Remove the Temporary working directory
57+
#----------------------------------------
58+
if [[ "${KEEPDATA^^}" == "NO" ]] && [[ ${CREATE_OWN_DATA^^} == "FALSE" ]]; then
59+
rm -rf "${DATA}"
60+
fi
61+
#
62+
date
63+
echo "JOB ${jobid:-} HAS COMPLETED NORMALLY!"
64+
exit 0

scripts/exrrfs_fcst.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ nlevel=$(wc -l < "${zeta_levels}")
4242
ln -snf "${FIXrrfs}/meshes/${MESH_NAME}.invariant.nc_L${nlevel}_${prefix}" ./invariant.nc
4343
mkdir -p graphinfo stream_list
4444
ln -snf "${FIXrrfs}"/graphinfo/* graphinfo/
45-
ln -snf "${FIXrrfs}/stream_list/${PHYSICS_SUITE}"/* stream_list/
45+
${cpreq} "${FIXrrfs}/stream_list/${PHYSICS_SUITE}"/* stream_list/
4646

4747
# generate the namelist on the fly
4848
# do_restart already defined in the above
@@ -72,6 +72,11 @@ sed -e "s/@restart_interval@/${restart_interval}/" -e "s/@history_interval@/${hi
7272
-e "s/@diag_interval@/${diag_interval}/" -e "s/@lbc_interval@/${lbc_interval}/" \
7373
"${PARMrrfs}"/streams.atmosphere > streams.atmosphere
7474
#
75+
# chemistry related processing
76+
if ${DO_CHEMISTRY:-false}; then
77+
source "${USHrrfs}"/chemistry_fcst.sh
78+
fi
79+
#
7580
# prelink the forecast output files to umbrella
7681
history_all=$(seq 0 $((10#${history_interval})) $((10#${fcst_len_hrs_thiscyc} )) )
7782
for fhr in ${history_all}; do

scripts/exrrfs_ic.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ physics_suite=${PHYSICS_SUITE:-'PHYSICS_SUITE_not_defined'}
4040
file_content=$(< "${PARMrrfs}/${physics_suite}/namelist.init_atmosphere") # read in all content
4141
eval "echo \"${file_content}\"" > namelist.init_atmosphere
4242

43+
if ${DO_CHEMISTRY:-false}; then
44+
source "${USHrrfs}"/chemistry_ic_lbc.sh
45+
fi
4346
#
4447
# generate the streams file on the fly
4548
# using sed as this file contains "filename_template='lbc.$Y-$M-$D_$h.$m.$s.nc'"

scripts/exrrfs_lbc.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ physics_suite=${PHYSICS_SUITE:-'PHYSICS_SUITE_not_defined'}
5555
file_content=$(< "${PARMrrfs}/${physics_suite}/namelist.init_atmosphere") # read in all content
5656
eval "echo \"${file_content}\"" > namelist.init_atmosphere
5757

58+
if ${DO_CHEMISTRY:-false}; then
59+
source "${USHrrfs}"/chemistry_ic_lbc.sh
60+
fi
5861
#
5962
# generate the streams file on the fly
6063
# using sed as this file contains "filename_template='lbc.$Y-$M-$D_$h.$m.$s.nc'"

scripts/exrrfs_mpassit.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ ${cpreq} "${FIXrrfs}"/mpassit/histlist_2d histlist_2d
1515
${cpreq} "${FIXrrfs}"/mpassit/histlist_3d histlist_3d
1616
${cpreq} "${FIXrrfs}"/mpassit/histlist_soil histlist_soil
1717
#
18+
if ${DO_CHEMISTRY:-false}; then
19+
source "${USHrrfs}"/chemistry_mpassit.sh
20+
fi
21+
#
1822
nx=${MPASSIT_NX:-480}
1923
ny=${MPASSIT_NY:-280}
2024
dx=${MPASSIT_DX:-12000.0}

scripts/exrrfs_prep_chem.sh

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Author: Jordan Schnell, CIRES/NOAA GSL
4+
#
5+
# This script prepares the emissions for an MPAS Aerosols simulation based on
6+
# user selections/task name, MPAS domain, and time period.
7+
#
8+
# The script first checks to see if emissions are already available
9+
# (regridded for the domain and time period) and links to the ${DATA} (i.e., the main run directory)
10+
# If emissions are not available, the program attempts to create them.
11+
#
12+
## Required Input Arguments
13+
#
14+
# 1. EMIS_SECTOR_TO_PROCESS -- which emission sector is this task performing? (anthro, pollen, dust)
15+
# 2. ANTHRO_EMISINV -- undecided, may merge for custom dataset, or leave option to combine
16+
# 3. DATADIR_CHEM -- location of interpolated files, ready to be used
17+
# 4. MESH_NAME -- name of the MPAS domain, required to know if we have weights or data intepolated to the domain
18+
# 5. FCST_LENGTH -- nhours of forecast
19+
#
20+
# shellcheck disable=SC1091,SC2153,SC2154,SC2034
21+
declare -rx PS4='+ $(basename ${BASH_SOURCE[0]:-${FUNCNAME[0]:-"Unknown"}})[${LINENO}]: '
22+
set -x
23+
nt=${SLURM_NTASKS}
24+
cpreq=${cpreq:-cpreq}
25+
cd "${DATA}" || exit 1
26+
#
27+
# ... Set some date variables
28+
#
29+
timestr=$(date -d "${CDATE:0:8} ${CDATE:8:2}" +%Y-%m-%d_%H.%M.%S)
30+
YYYY=$(date -d "${CDATE:0:8} ${CDATE:8:2}" +%Y)
31+
MM=$(date -d "${CDATE:0:8} ${CDATE:8:2}" +%m)
32+
DD=$(date -d "${CDATE:0:8} ${CDATE:8:2}" +%d)
33+
HH=$(date -d "${CDATE:0:8} ${CDATE:8:2}" +%H)
34+
DOW=$(date -d "${CDATE:0:8} ${CDATE:8:2}" +%u) # 1-7, Monday-Sunday
35+
#
36+
YYYY_END=$(date -d "${CDATE:0:8} ${CDATE:8:2} + ${FCST_LENGTH} hours" +%Y)
37+
MM_END=$(date -d "${CDATE:0:8} ${CDATE:8:2} + ${FCST_LENGTH} hours" +%m)
38+
DD_END=$(date -d "${CDATE:0:8} ${CDATE:8:2} + ${FCST_LENGTH} hours" +%d)
39+
HH_END=$(date -d "${CDATE:0:8} ${CDATE:8:2} + ${FCST_LENGTH} hours" +%H)
40+
DOW_END=$(date -d "${CDATE:0:8} ${CDATE:8:2} + ${FCST_LENGTH} hours " +%A) # 1-7, Monday-Sunday
41+
#
42+
YYYYp=$(date -d "${CDATE:0:8} ${CDATE:8:2} - 1 day" +%Y)
43+
MMp=$(date -d "${CDATE:0:8} ${CDATE:8:2} - 1 day" +%m)
44+
DDp=$(date -d "${CDATE:0:8} ${CDATE:8:2} - 1 day" +%d)
45+
HHp=$(date -d "${CDATE:0:8} ${CDATE:8:2}- 1 day" +%H)
46+
#
47+
current_day=$(date -d "${YYYY}${MM}${DD}")
48+
current_hh=$(date -d "${HH}" +"%H")
49+
#
50+
prev_hh=$(date -d "$current_hh -24 hour" +"%H")
51+
previous_day=$(date '+%C%y%m%d' -d "$current_day-1 days")
52+
previous_day="${previous_day} ${prev_hh}"
53+
#
54+
if [[ ${DOW} -le 5 ]]; then
55+
DOW_STRING=weekdy
56+
elif [[ ${DOW} -eq 6 ]]; then
57+
DOW_STRING=satdy
58+
else
59+
DOW_STRING=sundy
60+
fi
61+
if [[ ${DOW_END} -le 5 ]]; then
62+
DOW_END_STRING=weekdy
63+
elif [[ ${DOW_END} -eq 6 ]]; then
64+
DOW_END_STRING=satdy
65+
else
66+
DOW_END_STRING=sundy
67+
fi
68+
#
69+
MOY=$(date -d "${CDATE:0:8} ${CDATE:8:2}" +%B) # full month name (e.g., January)
70+
MOY_END=$(date -d "${CDATE:0:8} ${CDATE:8:2} + ${FCST_LENGTH} hours" +%B) # full month name (e.g., January)
71+
DOY=$(date -d "${CDATE:0:8} ${CDATE:8:2}" +%j) # Julian day
72+
#
73+
if [[ "${DOY}" -ne 0 ]]; then
74+
DOY_m1=$((DOY-1))
75+
else
76+
DOY_m1=0
77+
fi
78+
#
79+
DOY_END=$(date -d "${CDATE:0:8} ${CDATE:8:2} + ${FCST_LENGTH} hours" +%j) # Julian day
80+
#
81+
# Set the init/mesh file name and link here:\
82+
if [[ -r "${UMBRELLA_PREP_IC_DATA}"/init.nc ]]; then
83+
ln -sf "${UMBRELLA_PREP_IC_DATA}"/init.nc init.nc
84+
INIT_FILE=./${MESH_NAME}.init.nc
85+
else
86+
echo "WARNING: NO Init File available, cannot reinterpolate if files are missing, did you run the task out of order?"
87+
fi
88+
89+
#
90+
SCRIPT=${USHrrfs}/chem_regrid.py
91+
VINTERP_SCRIPT=${USHrrfs}/chem_vinterp.py
92+
INTERP_WEIGHTS_DIR=${DATADIR_CHEM}/grids/interpolation_weights/
93+
#
94+
# Set a few things for the CONDA environment
95+
export REGRID_WRAPPER_LOG_DIR=${DATA}
96+
regrid_wrapper_dir=${REGRID_WRAPPER_DIR} #/lfs5/BMC/rtwbl/rap-chem/mpas_rt/working/ben_interp/regrid-wrapper/
97+
PYTHONDIR=${regrid_wrapper_dir}/src
98+
regrid_conda_env=${REGRID_CONDA_ENV} #CONDAENV=/lfs5/BMC/rtwbl/rap-chem/miniconda/envs/regrid-wrapper
99+
export PATH=${regrid_conda_env}/bin:${PATH}
100+
export ESMFMKFILE=${regrid_conda_env}/lib/esmf.mk
101+
export PYTHONPATH=${PYTHONDIR}:${PYTHONPATH}
102+
#
103+
#==================================================================================================#
104+
if [[ "${EMIS_SECTOR_TO_PROCESS}" == "smoke" ]]; then
105+
source "${USHrrfs}"/prep_smoke.sh
106+
fi
107+
108+
if [[ "${EMIS_SECTOR_TO_PROCESS}" == "rwc" ]]; then
109+
source "${USHrrfs}"/prep_rwc.sh
110+
fi #rwc
111+
112+
if [[ "${EMIS_SECTOR_TO_PROCESS}" == "anthro" ]]; then
113+
source "${USHrrfs}"/prep_anthro.sh
114+
fi # anthro
115+
116+
if [[ "${EMIS_SECTOR_TO_PROCESS}" == "pollen" ]]; then
117+
source "${USHrrfs}"/prep_pollen.sh
118+
fi # bio/pollen
119+
120+
if [[ "${EMIS_SECTOR_TO_PROCESS}" == "dust" ]]; then
121+
source "${USHrrfs}"/prep_dust.sh
122+
fi # dust

scripts/exrrfs_ungrib.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ prefix=${EXTRN_MDL_SOURCE%_NCO} # remove the trailing '_NCO' if any
2020

2121
cd "${DATA}" || exit 1
2222
${cpreq} "${FIXrrfs}/ungrib/Vtable.${prefix}" Vtable
23+
if ${DO_CHEMISTRY:-false} && ${USE_EXTERNAL_CHEM:-false}; then
24+
${cpreq} "${FIXrrfs}/ungrib/Vtable.${prefix}.SD" Vtable
25+
fi
2326
#
2427
# find start and end time
2528
#

ush/chemistry_fcst.sh

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/usr/bin/env bash
2+
# Configure appropriate chemistry settings for the fcst task
3+
#
4+
# shellcheck disable=SC2154,SC2153
5+
6+
num_chem=0
7+
#
8+
# add chemistry information to the namelist and stream_list
9+
cat "${PARMrrfs}/chemistry/namelist.atmosphere" >> namelist.atmosphere
10+
cat "${FIXrrfs}/stream_list/chemistry/stream_list.atmosphere.output" >> ./stream_list/stream_list.atmosphere.output
11+
#
12+
# Biogenic/Pollen
13+
if [[ -r "${UMBRELLA_PREP_CHEM_DATA}/bio.init.nc" ]]; then
14+
sed -i "\$e cat ${PARMrrfs}/chemistry/streams.atmosphere.pollen" streams.atmosphere # append before the last line (i.e. </stream>)
15+
ln -snf "${UMBRELLA_PREP_CHEM_DATA}"/bio.init.nc bio.init.nc
16+
#
17+
if [[ "${CHEM_GROUPS,,}" == *pollen* ]]; then
18+
sed -i "s/config_pollen_scheme\s*=\s*'off'/config_pollen_scheme = 'speciated_pollen_primary'/g" namelist.atmosphere
19+
num_chem=$(( num_chem + 4 ))
20+
fi
21+
fi
22+
# Dust
23+
if [[ -r "${UMBRELLA_PREP_CHEM_DATA}/dust.init.nc" ]]; then
24+
sed -i "\$e cat ${PARMrrfs}/chemistry/streams.atmosphere.dust" streams.atmosphere
25+
ln -snf "${UMBRELLA_PREP_CHEM_DATA}"/dust.init.nc dust.init.nc
26+
#
27+
if [[ "${CHEM_GROUPS,,}" == *dust* ]]; then
28+
sed -i "s/config_dust_scheme\s*=\s*'off'/config_dust_scheme = 'on'/g" namelist.atmosphere
29+
num_chem=$(( num_chem + 2 ))
30+
fi
31+
fi
32+
#
33+
# save current nullglob setting and enable nullglob for this script
34+
save_nullglob=$(shopt -p nullglob)
35+
shopt -s nullglob
36+
37+
# Anthropogenic
38+
files=("${UMBRELLA_PREP_CHEM_DATA}"/anthro.init*)
39+
if (( ${#files[@]} )); then # at least one file exists
40+
sed -i "\$e cat ${PARMrrfs}/chemistry/streams.atmosphere.anthro" streams.atmosphere
41+
ln -snf "${UMBRELLA_PREP_CHEM_DATA}"/anthro.init* ./
42+
#
43+
if [[ "${CHEM_GROUPS,,}" == *anthro* ]]; then
44+
sed -i "s/config_anthro_scheme\s*=\s*'off'/config_anthro_scheme = 'on'/g" namelist.atmosphere
45+
num_chem=$(( num_chem + 6 ))
46+
if [[ "${CHEM_GROUPS,,}" == *dust* ]]; then
47+
num_chem=$(( num_chem - 2 ))
48+
fi
49+
if [[ "${CHEM_GROUPS,,}" == *smoke* ]]; then
50+
num_chem=$(( num_chem - 2 ))
51+
fi
52+
fi
53+
fi
54+
55+
# Smoke/Wildfire
56+
files=("${UMBRELLA_PREP_CHEM_DATA}"/smoke.init*)
57+
if (( ${#files[@]} )); then # at least one file exists
58+
cat "${FIXrrfs}/stream_list/chemistry/stream_list.atmosphere.smoke.output" >> ./stream_list/stream_list.atmosphere.output
59+
#
60+
if [[ "${EBB_DCYCLE}" -eq 1 ]]; then # Diurnal cycle for EBB (Emissions from Biomass Burning)
61+
sed -i "\$e cat ${PARMrrfs}/chemistry/streams.atmosphere.smoke_retro" streams.atmosphere
62+
elif [[ "${EBB_DCYCLE}" -eq 2 ]]; then
63+
sed -i "\$e cat ${PARMrrfs}/chemistry/streams.atmosphere.smoke_forecast" streams.atmosphere
64+
else
65+
echo "Not appending any smoke stream"
66+
fi
67+
# TODO, retro vs. forecast option
68+
ln -snf "${UMBRELLA_PREP_CHEM_DATA}"/smoke.init* ./
69+
#
70+
if [[ "${CHEM_GROUPS,,}" == *smoke* ]]; then
71+
sed -i "s/config_smoke_scheme\s*=\s*'off'/config_smoke_scheme = 'on'/g" namelist.atmosphere
72+
num_chem=$(( num_chem + 2 ))
73+
fi
74+
# Set EBB_DCYCLE
75+
sed -i -e "s/@ebb_dcycle@/${EBB_DCYCLE}/" namelist.atmosphere
76+
fi
77+
78+
# RWC - Residual Wood Combustion
79+
if [[ -r "${UMBRELLA_PREP_CHEM_DATA}/rwc.init.nc" ]]; then
80+
sed -i "\$e cat ${PARMrrfs}/chemistry/streams.atmosphere.rwc" streams.atmosphere
81+
ln -snf "${UMBRELLA_PREP_CHEM_DATA}"/rwc.init.nc rwc.init.nc
82+
# Set namelist
83+
#sed -e "s/@online_rwc_emis@/1/" "${PARMrrfs}"/namelist.atmosphere > namelist.atmosphere
84+
fi
85+
#
86+
# Replace the num_chem value with the correct number
87+
sed -i "s/num_chem\s*=\s*[0-9]*/num_chem = ${num_chem}/" namelist.atmosphere
88+
#
89+
# Restore previous nullglob setting
90+
eval "${save_nullglob}"

ush/chemistry_ic_lbc.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
# Configure appropriate chemistry settings for the ic or lbc task
3+
#
4+
# shellcheck disable=SC2154,SC2153
5+
6+
cat "${PARMrrfs}/chemistry/namelist.init_atmosphere" >> namelist.init_atmosphere
7+
#
8+
# Now adjust the configure options based on activated CHEM_GROUPS
9+
if [[ "${USE_EXTERNAL_CHEM}" == "TRUE" ]]; then
10+
if [[ "${CHEM_GROUPS}" == *smoke* ]]; then
11+
sed -i "s/config_smoke_scheme\s*=\s*'off'/config_smoke_scheme = 'on'/g" namelist.init_atmosphere
12+
fi
13+
if [[ "${CHEM_GROUPS}" == *dust* ]]; then
14+
sed -i "s/config_dust_scheme\s*=\s*'off'/config_dust_scheme = 'on'/g" namelist.init_atmosphere
15+
fi
16+
fi

0 commit comments

Comments
 (0)