Skip to content

Commit

Permalink
Add sflux to post output
Browse files Browse the repository at this point in the history
Adds the creation of surface flux files to the post job. Working
directories have 'atm' or 'sflux' added to the path so each has
its own for debugging purposes.

Copying of files into the working directory has been changed to
symlinks to prevent the increase in resources by multiple copies
of the model output.

Refs: NOAA-EMC#270
  • Loading branch information
WalterKolczynski-NOAA committed Dec 9, 2022
1 parent d99a5dd commit 901df8f
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 37 deletions.
4 changes: 2 additions & 2 deletions parm/post/atm_post.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
work_dir: !ENV ${DATA}
work_dir: !ENV ${DATA}/atm
tmpl_file: !ENV ${PARMpost}/post.nml.j2
mp_file: !ENV ${PARMpost}/nam_micro_lookup.dat
grib_out: !ENV ${COMOUT}/${RUN}.${cycle}.master.grb2f${fhr}
grib_idx_out: !ENV ${COMOUT}/${RUN}.${cycle}.master.grb2if${fhr}
exe_log_file: !ENV ${pgmout}
exe_log_file: !ENV ${DATA}/${pgmout}
out_form: 'netcdfpara'
cdate: !ENV ${CDATE}
fhr: !ENV ${fhr}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ trigger_file: !ENV ${COMIN}/${RUN}.${cycle}.atmanl.nc

igen: anal_gfs
flat_file: !ENV ${PARMpost}/postxconfig-NT-GFS-ANL.txt
ctrl_file: !ENV ${PARMpost}/postcntrl_gfs_anl.xml
grib2_table: !ENV ${g2tmpl_ROOT}/share/params_grib2_tbl_new

dbn_signals:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,4 @@ trigger_file: !ENV ${COMIN}/${CDUMP}.t${cyc}z.logf000.txt

igen: gfs_avn
flat_file: !ENV ${PARMpost}/postxconfig-NT-GFS-F00.txt
ctrl_file: !ENV ${PARMpost}/postcntrl_gfs_f00.xml
grib2_table: !ENV ${g2tmpl_ROOT}/share/params_grib2_tbl_new

dbn_signals:
GFS_SA: !ENV ${COMIN}/${RUN}.${cycle}.atmf000.nc
GFS_MSC_sfcanal: !ENV ${COMIN}/${RUN}.${cycle}.sfcf000.nc
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ trigger_file: !ENV ${COMIN}/${CDUMP}.t${cyc}z.logf${fhr}.txt

igen: gfs_avn
flat_file: !ENV ${PARMpost}/postxconfig-NT-GFS.txt
ctrl_file: !ENV ${PARMpost}/postcntrl_gfs.xml
grib2_table: !ENV ${g2tmpl_ROOT}/share/params_grib2_tbl_new
grib2_table: !ENV ${g2tmpl_ROOT}/share/params_grib2_tbl_new
20 changes: 20 additions & 0 deletions parm/post/sflux_post.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
work_dir: !ENV ${DATA}/sflux
tmpl_file: !ENV ${PARMpost}/post.nml.j2
mp_file: !ENV ${PARMpost}/nam_micro_lookup.dat
grib_out: !ENV ${COMOUT}/${RUN}.${cycle}.sfluxgrbf${fhr}.grb2
grib_idx_out: !ENV ${COMOUT}/${RUN}.${cycle}.sfluxgrbf${fhr}.grb2.idx
exe_log_file: !ENV ${pgmout}
out_form: 'netcdfpara'
cdate: !ENV ${CDATE}
fhr: !ENV ${fhr}
grib_version: 'grib2'
grib_table: !ENV ${g2tmpl_ROOT}/share/params_grib2_tbl_new
post_variables: 'KPO=57,PO=1000.,975.,950.,925.,900.,875.,850.,825.,800.,775.,750.,725.,700.,675.,650.,625.,600.,575.,550.,525.,500.,475.,450.,425.,400.,375.,350.,325.,300.,275.,250.,225.,200.,175.,150.,125.,100.,70.,50.,40.,30.,20.,15.,10.,7.,5.,3.,2.,1.,0.7,0.4,0.2,0.1,0.07,0.04,0.02,0.01,'
post_exe: !ENV ${HOMEgfs}/exec/upp.x
grib_idx_exe: !ENV ${GRB2INDEX}
mpi_run: !ENV ${APRUNP}
sleep_max: 900
sleep_interval: 5
send_com: !ENV ${SENDCOM}
send_dbn: !ENV ${SENDDBN}
dbn_alert: !ENV ${DBNROOT}/bin/dbn_alert
10 changes: 10 additions & 0 deletions parm/post/sflux_post_anl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include:
- !INC ${PARMpost}/sflux_post.yaml

atm_file: !ENV ${COMIN}/${RUN}.${cycle}.atmanl.nc
sfc_file: !ENV ${COMIN}/${RUN}.${cycle}.sfcanl.nc
trigger_file: !ENV ${COMIN}/${RUN}.${cycle}.atmanl.nc

igen: anal_gfs
flat_file: !ENV ${PARMpost}/postxconfig-NT-GFS-FLUX-ANL.txt
grib2_table: !ENV ${g2tmpl_ROOT}/share/params_grib2_tbl_new
14 changes: 14 additions & 0 deletions parm/post/sflux_post_f000.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
include:
- !INC ${PARMpost}/sflux_post.yaml

atm_file: !ENV ${COMIN}/${RUN}.${cycle}.atmf000.nc
sfc_file: !ENV ${COMIN}/${RUN}.${cycle}.sfcf000.nc
trigger_file: !ENV ${COMIN}/${CDUMP}.t${cyc}z.logf000.txt

igen: gfs_avn
flat_file: !ENV ${PARMpost}/postxconfig-NT-GFS-FLUX-F00.txt
grib2_table: !ENV ${g2tmpl_ROOT}/share/params_grib2_tbl_new

dbn_signals:
GFS_SGB_GB2: $(include[0].grib_out)
GFS_SGB_GB2_WIDX: $(include[0].grib_idx_out)
14 changes: 14 additions & 0 deletions parm/post/sflux_post_fhr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
include:
- !INC ${PARMpost}/sflux_post.yaml

atm_file: !ENV ${COMIN}/${RUN}.${cycle}.atmf${fhr}.nc
sfc_file: !ENV ${COMIN}/${RUN}.${cycle}.sfcf${fhr}.nc
trigger_file: !ENV ${COMIN}/${CDUMP}.t${cyc}z.logf${fhr}.txt

igen: gfs_avn
flat_file: !ENV ${PARMpost}/postxconfig-NT-GFS-FLUX.txt
grib2_table: !ENV ${g2tmpl_ROOT}/share/params_grib2_tbl_new

dbn_signals:
GFS_SGB_GB2: !ENV ${COMOUT}/${RUN}.${cycle}.sfluxgrbf${fhr}.grb2
GFS_SGB_GB2_WIDX: !ENV ${COMOUT}/${RUN}.${cycle}.sfluxgrbf${fhr}.grb2.idx
28 changes: 17 additions & 11 deletions scripts/exglobal_atmos_post.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@

source "${HOMEgfs}/ush/preamble.sh"

# Determine which yaml file to use
case ${fhr} in
anl) yaml_cat='anl' ;;
000) yaml_cat='f000';;
*) yaml_cat='fhr' ;;
esac
post_settings="${PARMpost}/atm_post_${CDUMP}_${yaml_cat}.yaml"
for type in "atm" "sflux"; do
# Determine which yaml file to use
case ${fhr} in
anl) yaml_cat='anl' ;;
000) yaml_cat='f000';;
*) yaml_cat='fhr' ;;
esac
post_settings="${PARMpost}/${type}_post_${yaml_cat}.yaml"

# Run post
"${HOMEgfs}/ush/atm_post.py" "${post_settings}"
err=$?
# Run post
"${HOMEgfs}/ush/atm_post.py" "${post_settings}"
err=$?

exit ${err}
if ((err > 0)); then
exit "${err}"
fi
done

exit
32 changes: 16 additions & 16 deletions ush/atm_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

import os
import shutil
import glob
import subprocess
import time
from datetime import timedelta
from argparse import ArgumentParser
from python.pygw.src.pygw import timetools
from python.pygw.src.pygw.template import Template, TemplateConstants
from python.pygw.src.pygw.fsutils import mkdir, chdir, rm_p
from python.pygw.src.pygw.fsutils import mkdir
from python.pygw.src.pygw.yaml_file import YAMLFile
from pprint import pprint
from functools import partial
Expand Down Expand Up @@ -61,7 +60,7 @@ def run_post(settings: dict) -> None:
'''
)
os.environ['PGBOUT'] = 'pgbfile'
subprocess.run(f"{settings['mpi_run']} upp.x > {settings['exe_log_file']}", shell=True, check=True)
subprocess.run(f"{settings['mpi_run']} upp.x >> {settings['exe_log_file']}", shell=True, check=True)
subprocess.run(f"{settings['grib_idx_exe']} pgbfile pgifile >> {settings['exe_log_file']}",
shell=True, check=True)

Expand Down Expand Up @@ -171,21 +170,21 @@ def stage_post(settings: dict, nml_filename: str = 'itag') -> None:
work_dir : str
The temporary working directory to use
atm_file : str
Raw atmosphere model output in NetCDF format. Will be copied
Raw atmosphere model output in NetCDF format. Will be linked
to work_dir as atm_file.
sfc_file : str
Raw atmosphere flux output in NetCDF format. Will be copied
Raw atmosphere flux output in NetCDF format. Will be linked
to work_dir as sfc_file.
flat_file : str
Post 'flat' file. Will be copied to work_dir as
Post 'flat' file. Will be linked to work_dir as
postxconfig-NT.txt.
grib_table : str
Grib2 table. Will be copied to work_dir.
Grib2 table. Will be linked to work_dir.
mp_file : str
Microphysics .dat file. Will be copied to work_dir as
Microphysics .dat file. Will be linked to work_dir as
eta_micro_lookup.dat.
post_exe : str
Path to the post executable. Will be copied to work_dir as
Path to the post executable. Will be linked to work_dir as
upp.x
Additionally, the following key/value pair may be defined:
Expand All @@ -199,18 +198,18 @@ def stage_post(settings: dict, nml_filename: str = 'itag') -> None:
'''
work_dir = settings['work_dir']
mkdir(work_dir)
chdir(work_dir)
os.chdir(work_dir)

namelist = make_namelist(settings)
with open(nml_filename, 'w') as file:
file.write(namelist)

shutil.copy(settings['flat_file'], 'postxconfig-NT.txt')
shutil.copy(settings['grib_table'], './')
shutil.copy(settings['mp_file'], 'eta_micro_lookup.dat')
shutil.copy(settings['atm_file'], 'atm_file')
shutil.copy(settings['sfc_file'], 'sfc_file')
shutil.copy(settings['post_exe'], 'upp.x')
os.symlink(settings['flat_file'], 'postxconfig-NT.txt')
os.symlink(settings['grib_table'], os.path.basename(settings['grib_table']))
os.symlink(settings['mp_file'], 'eta_micro_lookup.dat')
os.symlink(settings['atm_file'], 'atm_file')
os.symlink(settings['sfc_file'], 'sfc_file')
os.symlink(settings['post_exe'], 'upp.x')

if settings.get('is_ens', False):
# TODO replace negatively_post_fcst with ${ens_pert_type} in postxconfig-NT.txt
Expand Down Expand Up @@ -293,6 +292,7 @@ def send_dbn(settings: dict) -> None:
stage_post(settings=settings)
wait_for_model_output(settings=settings)
run_post(settings=settings)

if settings['send_com'] in ["YES"]:
send_com(settings)

Expand Down

0 comments on commit 901df8f

Please sign in to comment.