Skip to content

Commit

Permalink
Implement the ICs part to generate ICs for real-time and retro run
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanglikate committed Apr 25, 2024
1 parent 865e71d commit 9765808
Show file tree
Hide file tree
Showing 9 changed files with 356 additions and 0 deletions.
4 changes: 4 additions & 0 deletions env/HERA.env
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ elif [[ "${step}" = "epos" ]]; then
[[ ${NTHREADS_EPOS} -gt ${nth_max} ]] && export NTHREADS_EPOS=${nth_max}
export APRUN_EPOS="${launcher} -n ${npe_epos} --cpus-per-task=${NTHREADS_EPOS}"

elif [[ "${step}" = "init" ]]; then

export APRUN="${launcher} -n ${npe_init}"

elif [[ "${step}" = "postsnd" ]]; then

export CFP_MP="YES"
Expand Down
33 changes: 33 additions & 0 deletions jobs/rocoto/archive_fv3ics.ksh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/ksh -l

# this file archives FV3 ICs to the mass store, /BMC/fim/5year/FV3ICS
# input is operational GFS initial conditions

module load hpss
module list

# initialize
#inpDir=/scratch4/BMC/rtfim/rtruns/FV3GFS/FV3ICS
#mssDir=FV3ICS
#CDUMP=gfs
#CASE=C384
#yyyymmddhh=$1
echo "****************************"
echo ICSDIR: $ICSDIR
echo mssDIR: $mssDir
echo CDUMP: $CDUMP
echo CASE: $CASE
echo DATE: $yyyymmddhh

# for each directory, archive FV3 ICs to mass store in monthly directories
# /scratch4/BMC/rtfim/rtruns/FV3ICS/2017111012/gfs/C384/INPUT
echo "in $ICSDIR....."
echo "Archiving ${yyyymmddhh} to mss"
cd $ICSDIR
cmd="htar -cPvf /BMC/fim/5year/${mssDir}/${yyyymmddhh}_${CASE}.tar ${CDUMP}/${CASE}/INPUT/*"
$cmd
status=$?
if [ $status != 0 ] ; then
printf "Error : [%d] when executing htar command: '$cmd'" $status
exit $status
fi
65 changes: 65 additions & 0 deletions jobs/rocoto/getic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#! /usr/bin/env bash

source "$HOMEgfs/ush/preamble.sh"

## this script makes links to FV3GFS netcdf files under /public
## /home/rtfim/UFS_CAMSUITE/FV3GFSrun/FV3ICS/YYYYMMDDHH/gfs
## gfs.tHHz.sfcanl.nc -> /public/data/grids/gfs/netcdf/YYDDDHH00.gfs.tHHz.sfcanl.nc
## gfs.tHHz.atmanl.nc -> /public/data/grids/gfs/netcdf/YYDDDHH00.gfs.tHHz.atmanl.nc

echo
echo "CDATE = $CDATE"
echo "CDUMP = $CDUMP"
echo "COMPONENT = $COMPONENT"
echo "ICSDIR = $ICSDIR"
echo "PUBDIR = $PUBDIR"
echo "RETRODIR = $RETRODIR"
echo "ROTDIR = $ROTDIR"
echo "PSLOT = $PSLOT"
echo

## initialize
yyyymmdd=`echo $CDATE | cut -c1-8`
hh=`echo $CDATE | cut -c9-10`
yyddd=`date +%y%j -u -d $yyyymmdd`
fv3ic_dir=${ROTDIR}/${CDUMP}.${yyyymmdd}/${hh}/${COMPONENT}

## create links in FV3ICS directory
mkdir -p $fv3ic_dir
cd $fv3ic_dir
echo "making link to netcdf files under $fv3ic_dir"

pubsfc_file=${yyddd}${hh}00.${CDUMP}.t${hh}z.sfcanl.nc
sfc_file=`echo $pubsfc_file | cut -d. -f2-`
pubatm_file=${yyddd}${hh}00.${CDUMP}.t${hh}z.atmanl.nc
atm_file=`echo $pubatm_file | cut -d. -f2-`

echo "pubsfc_file: $pubsfc_file"
echo "pubatm_file: $pubatm_file"

if [[ -f $RETRODIR/${pubatm_file} ]]; then
echo "linking $RETRODIR...."
echo "pubsfc_file: $pubsfc_file"
echo "pubatm_file: $pubatm_file"
ln -fs $RETRODIR/${pubsfc_file} $sfc_file
ln -fs $RETRODIR/${pubatm_file} $atm_file
elif [[ -f $PUBDIR/${pubatm_file} ]]; then
echo "linking $PUBDIR...."
ln -fs $PUBDIR/${pubsfc_file} $sfc_file
ln -fs $PUBDIR/${pubatm_file} $atm_file
elif [[ -f $EMCDIR/${CDUMP}.${yyyymmdd}/${hh}/${COMPONENT}/${atm_file} ]]; then
echo "linking $EMCDIR/${CDUMP}.${yyyymmdd}/${hh}/${COMPONENT}..."
echo "sfc_file: $sfc_file"
echo "atm_file: $atm_file"
ln -s $EMCDIR/${CDUMP}.${yyyymmdd}/${hh}/${COMPONENT}/${sfc_file}
ln -s $EMCDIR/${CDUMP}.${yyyymmdd}/${hh}/${COMPONENT}/${atm_file}
elif [[ -f $RETRODIR/${CDUMP}.${yyyymmdd}/${hh}/${COMPONENT}/${atm_file} ]]; then
echo "linking $RETRODIR/${CDUMP}.${yyyymmdd}/${hh}/${COMPONENT}..."
echo "sfc_file: $sfc_file"
echo "atm_file: $atm_file"
ln -s $RETRODIR/${CDUMP}.${yyyymmdd}/${hh}/${COMPONENT}/${sfc_file}
ln -s $RETRODIR/${CDUMP}.${yyyymmdd}/${hh}/${COMPONENT}/${atm_file}
else
echo "missing input files!"
exit 1
fi
85 changes: 85 additions & 0 deletions jobs/rocoto/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#! /usr/bin/env bash

source "$HOMEgfs/ush/preamble.sh"

###############################################################
## Abstract:
## Get GFS intitial conditions
## RUN_ENVIR : runtime environment (emc | nco)
## HOMEgfs : /full/path/to/workflow
## EXPDIR : /full/path/to/config/files
## CDATE : current date (YYYYMMDDHH)
## CDUMP : cycle name (gdas / gfs)
## PDY : current date (YYYYMMDD)
## cyc : current cycle (HH)
###############################################################

###############################################################
# Source FV3GFS workflow modules
#. $HOMEgfs/ush/load_fv3gfs_modules.sh
#status=$?
#[[ $status -ne 0 ]] && exit $status

#JKH load ufs-utils modules
#module use /scratch1/BMC/gsd-fv3/rtruns/modulefiles
#module load build.hera.intel.lua.gfsinit
module purge
module use $HOMEgfs/sorc/ufs_utils.fd/modulefiles
module load build.hera.intel
module list

###############################################################
# Source relevant configs
configs="base getic init"
for config in $configs; do
. $EXPDIR/config.${config}
status=$?
[[ $status -ne 0 ]] && exit $status
done

###############################################################
# Source machine runtime environment
. $BASE_ENV/${machine}.env init
status=$?
[[ $status -ne 0 ]] && exit $status

###############################################################
# Set script and dependency variables

export yy=$(echo $CDATE | cut -c1-4)
export mm=$(echo $CDATE | cut -c5-6)
export dd=$(echo $CDATE | cut -c7-8)
export hh=${cyc:-$(echo $CDATE | cut -c9-10)}

export DATA=${DATA:-${DATAROOT}/init_$CDATE}
export EXTRACT_DIR=${EXTRACT_DIR:-$ROTDIR}
export WORKDIR=${WORKDIR:-$DATA}
export OUTDIR=${OUTDIR:-$ROTDIR}
export COMPONENT="atmos"
export gfs_ver=${gfs_ver:-"v16"}
export OPS_RES=${OPS_RES:-"C768"}
export RUNICSH=${RUNICSH:-${GDASINIT_DIR}/run_v16.chgres.sh}

# Check if init is needed and run if so
if [[ $gfs_ver = "v16" && $EXP_WARM_START = ".true." && $CASE = $OPS_RES ]]; then
echo "Detected v16 $OPS_RES warm starts, will not run init. Exiting..."

else
# Run chgres_cube
if [ ! -d $OUTDIR ]; then mkdir -p $OUTDIR ; fi
sh ${RUNICSH} ${CDUMP}
status=$?
[[ $status -ne 0 ]] && exit $status
fi

##########################################
# Remove the Temporary working directory
##########################################
cd $DATAROOT
[[ $KEEPDATA = "NO" ]] && rm -rf $DATA

###############################################################
# Exit out cleanly


exit 0
66 changes: 66 additions & 0 deletions parm/config/gfs/config.getic
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#! /usr/bin/env bash

########## config.getic ##########
# Fetching GFS initial conditions specific

echo "BEGIN: config.getic"

# Get task specific resources
. $EXPDIR/config.resources getic

export RETRO="NO" # YES = Pull v16 inputs from retrospective parallels; NO = use operational inputs
export gfs_ver="v16" # Default = v16
export OPS_RES=${OPS_RES:-"C768"} # Operational resolution

export UFS_DIR=${HOMEgfs}/sorc/ufs_utils.fd
export GDAS_INIT_DIR=${UFS_DIR}/util/gdas_init

export PRODHPSSDIR=/NCEPPROD/hpssprod/runhistory
export GETICSH=${GDAS_INIT_DIR}/get_v16.data.sh

if [ ${RETRO:-"NO"} = "YES" ]; then # Retrospective parallel input
export GETICSH=${GDAS_INIT_DIR}/get_v16retro.data.sh
if [[ "$CDATE" -lt "2019060106" ]]; then
HPSSDIR=/NCEPDEV/emc-global/5year/emc.glopara/WCOSS_D/gfsv16/v16retro0e
elif [[ "$CDATE" -lt "2019090100" ]]; then
HPSSDIR=/NCEPDEV/emc-global/5year/emc.glopara/WCOSS_D/gfsv16/v16retro1e
elif [[ "$CDATE" -lt "2019101706" ]]; then
HPSSDIR=/NCEPDEV/emc-global/5year/emc.glopara/WCOSS_D/gfsv16/v16retro2e
elif [[ "$CDATE" -lt "2020122200" ]]; then
HPSSDIR=/NCEPDEV/emc-global/5year/emc.glopara/WCOSS_D/gfsv16/v16rt2
elif [[ "$CDATE" -le "2021032506" ]]; then
HPSSDIR=/NCEPDEV/emc-global/5year/emc.glopara/WCOSS_D/gfsv16/v16rt2n
else
set +x
echo NO DATA FOR $CDATE
exit 3
fi
elif [ ${RETRO:-"NO"} = "NO" ]; then # Operational input
# No ENKF data prior to 2012/05/21/00z
if [[ "$CDATE" -lt "2012052100" ]]; then
set +x
echo FATAL ERROR: SCRIPTS DO NOT SUPPORT OLD GFS DATA
elif [[ "$CDATE" -lt "2016051000" ]]; then
export gfs_ver=v12
export GETICSH=${GDAS_INIT_DIR}/get_pre-v14.data.sh
elif [[ "$CDATE" -lt "2017072000" ]]; then
export gfs_ver=v13
export GETICSH=${GDAS_INIT_DIR}/get_pre-v14.data.sh
elif [[ "$CDATE" -lt "2019061200" ]]; then
export gfs_ver=v14
export GETICSH=${GDAS_INIT_DIR}/get_${gfs_ver}.data.sh
elif [[ "$CDATE" -lt "2021032100" ]]; then
export gfs_ver=v15
export GETICSH=${GDAS_INIT_DIR}/get_${gfs_ver}.data.sh
elif [[ "$CDATE" -lt "2021032106" ]]; then
# The way the v16 switch over was done, there is no complete
# set of v16 or v15 data for 2021032100. And although
# v16 was officially implemented 2021032212, the v16 prod
# tarballs were archived starting 2021032106.
set +x
echo FATAL ERROR: NO V15 OR V16 DATA FOR 2021032100
exit 1
fi
fi

echo "END: config.getic"
55 changes: 55 additions & 0 deletions parm/config/gfs/config.init
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#! /usr/bin/env bash

########## config.init ##########
# Prepare initial conditions

echo "BEGIN: config.init"

# Get task specific resources
. $EXPDIR/config.resources init

# Get task specific resources
. $EXPDIR/config.getic

export UFS_DIR=${HOMEgfs}/sorc/ufs_utils.fd
export GDAS_INIT_DIR=${UFS_DIR}/util/gdas_init
export EXEC_DIR=${UFS_DIR}/exec

export CRES_HIRES=$CASE
export CRES_ENKF=""
export FRAC_ORO="yes"

export RUNICSH=${GDAS_INIT_DIR}/run_v16.chgres.sh
if [ "${RETRO:-"NO"}" = "YES" ] || [ "$CDUMP" = "gdas" ]; then
export RUNICSH=${GDAS_INIT_DIR}/run_v16retro.chgres.sh
fi

if [ ${RETRO:-"NO"} = "NO" ]; then # Operational input
# No ENKF data prior to 2012/05/21/00z
if [[ "$CDATE" -lt "2012052100" ]]; then
set +x
echo FATAL ERROR: SCRIPTS DO NOT SUPPORT OLD GFS DATA
elif [[ "$CDATE" -lt "2016051000" ]]; then
export gfs_ver=v12
export RUNICSH=${GDAS_INIT_DIR}/run_pre-v14.chgres.sh
elif [[ "$CDATE" -lt "2017072000" ]]; then
export gfs_ver=v13
export RUNICSH=${GDAS_INIT_DIR}/run_pre-v14.chgres.sh
elif [[ "$CDATE" -lt "2019061200" ]]; then
export gfs_ver=v14
export RUNICSH=${GDAS_INIT_DIR}/run_${gfs_ver}.chgres.sh
elif [[ "$CDATE" -lt "2021032100" ]]; then
export gfs_ver=v15
export RUNICSH=${GDAS_INIT_DIR}/run_${gfs_ver}.chgres.gfs.sh
elif [[ "$CDATE" -lt "2021032106" ]]; then
# The way the v16 switch over was done, there is no complete
# set of v16 or v15 data for 2021032100. And although
# v16 was officially implemented 2021032212, the v16 prod
# tarballs were archived starting 2021032106.
set +x
echo FATAL ERROR: NO V15 OR V16 DATA FOR 2021032100
exit 1
fi
fi

echo "END: config.init"
4 changes: 4 additions & 0 deletions sorc/link_workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ do
${LINK_OR_COPY} "${FIX_DIR}/${dir}/${!fix_ver}" "${dir}"
done

if [[ -d "${HOMEgfs}/sorc/ufs_utils.fd" ]]; then
cd "${HOMEgfs}/sorc/ufs_utils.fd/fix" || exit 1
./link_fixdirs.sh "${RUN_ENVIR}" "${machine}" 2> /dev/null
fi

#---------------------------------------
#--add files from external repositories
Expand Down
22 changes: 22 additions & 0 deletions workflow/ccpp-chem-C384-ics.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
USER=Kate.Zhang


BASEDIR=/scratch2/BMC/gsd-fv3-dev/lzhang/UFS-dev/global-workflow
STMP=/scratch1/NCEPDEV/stmp2/$USER/RUNDIRS
IDATE=2024040500
EDATE=2016040500
APP=ATM
PSLOT=rt_c384ics
RES=384
GFS_CYC=1
START=cold
COMROT=/scratch1/BMC/gsd-fv3-dev/NCEPDEV/global/$USER/fv3gfs/comrot
EXPDIR=/scratch2/BMC/gsd-fv3-dev/NCEPDEV/global/$USER/fv3gfs/expdir
ICSDIR=$COMROT/$PSLOT


./setup_expt.py gfs forecast-only --idate $IDATE --edate $EDATE --app $APP --gfs_cyc $GFS_CYC --resdetatmos $RES --pslot $PSLOT --comroot $COMROT --expdir $EXPDIR


./setup_xml.py $EXPDIR/$PSLOT

22 changes: 22 additions & 0 deletions workflow/ccpp-chem-C96-ics.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
USER=Kate.Zhang


BASEDIR=/scratch2/BMC/gsd-fv3-dev/lzhang/UFS-dev/global-workflow
STMP=/scratch1/NCEPDEV/stmp2/$USER/RUNDIRS
IDATE=2016071500
EDATE=2016071500
APP=ATM
PSLOT=CAT_C96_CCPP
RES=96
GFS_CYC=1
START=cold
COMROT=/scratch1/BMC/gsd-fv3-dev/NCEPDEV/global/$USER/fv3gfs/comrot
EXPDIR=/scratch2/BMC/gsd-fv3-dev/NCEPDEV/global/$USER/fv3gfs/expdir
ICSDIR=$COMROT/$PSLOT


./setup_expt.py gfs forecast-only --idate $IDATE --edate $EDATE --app $APP --gfs_cyc $GFS_CYC --resdetatmos $RES --pslot $PSLOT --comroot $COMROT --expdir $EXPDIR


./setup_xml.py $EXPDIR/$PSLOT

0 comments on commit 9765808

Please sign in to comment.