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

add initial jobs and parm #47

Merged
merged 5 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions jobs/JLAND_PREP_BMAT
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/sh

set -ex

############################
# copy restarts to workdir, convert to UFS tile for DA (all members)

if [[ ${EXP_NAME} == "openloop" ]]; then
do_jedi="NO"
else
do_jedi="YES"
SAVE_TILE="YES"
LANDDADIR=${CYCLEDIR}/DA_update/
fi

TPATH=${LANDDA_INPUTS}/forcing/${ATMOS_FORC}/orog_files/
YYYY=${CTIME:0:4}
MM=${CTIME:4:2}
DD=${CTIME:6:2}
HH=${CTIME:8:2}

mem_ens="mem000"

MEM_WORKDIR=${WORKDIR}/${mem_ens}
MEM_MODL_OUTDIR=${OUTDIR}/${mem_ens}
RSTRDIR=${MEM_WORKDIR}
JEDIWORKDIR=${WORKDIR}/mem000/jedi
FILEDATE=${YYYY}${MM}${DD}.${HH}0000

cd $MEM_WORKDIR

# load modulefiles
module use modulefiles; module load modules.landda
PYTHON=$(/usr/bin/which python)

#fv3bundle_vn=psl_develop
#DAtype=letkfoi_snow
#SNOWDEPTHVAR=snwdph
YAML_DA=construct
GFSv17="NO"
B=30 # back ground error std for LETKFOI
cd $JEDIWORKDIR

################################################
# 4. CREATE BACKGROUND ENSEMBLE (LETKFOI)
################################################

if [[ ${DAtype} == 'letkfoi_snow' ]]; then

JEDI_EXEC="fv3jedi_letkf.x"

if [ $GFSv17 == "YES" ]; then
SNOWDEPTHVAR="snodl"
# field overwrite file with GFSv17 variables.
cp ${LANDDADIR}/jedi/fv3-jedi/yaml_files/${fv3bundle_vn}/gfs-land-v17.yaml ${JEDIWORKDIR}/gfs-land-v17.yaml
else
SNOWDEPTHVAR="snwdph"
fi
# FOR LETKFOI, CREATE THE PSEUDO-ENSEMBLE
for ens in pos neg
do
if [ -e $JEDIWORKDIR/mem_${ens} ]; then
rm -r $JEDIWORKDIR/mem_${ens}
fi
mkdir -p $JEDIWORKDIR/mem_${ens}
for tile in 1 2 3 4 5 6
do
cp ${JEDIWORKDIR}/${FILEDATE}.sfc_data.tile${tile}.nc ${JEDIWORKDIR}/mem_${ens}/${FILEDATE}.sfc_data.tile${tile}.nc
done
cp ${JEDIWORKDIR}/${FILEDATE}.coupler.res ${JEDIWORKDIR}/mem_${ens}/${FILEDATE}.coupler.res
done

echo 'do_landDA: calling create ensemble'

# using ioda mods to get a python version with netCDF4
${PYTHON} ${LANDDADIR}/letkf_create_ens.py $FILEDATE $SNOWDEPTHVAR $B
if [[ $? != 0 ]]; then
echo "letkf create failed"
exit 10
fi

fi
174 changes: 174 additions & 0 deletions jobs/JLAND_PREP_EXP
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
#!/bin/sh

set -ex

############################
# copy restarts to workdir, convert to UFS tile for DA (all members)

if [[ ${EXP_NAME} == "openloop" ]]; then
do_jedi="NO"
else
do_jedi="YES"
SAVE_TILE="YES"
LANDDADIR=${CYCLEDIR}/DA_update/
fi

echo ${LANDDA_INPUTS}, ${ATMOS_FORC}
TPATH=${LANDDA_INPUTS}/forcing/${ATMOS_FORC}/orog_files/
YYYY=${CTIME:0:4}
MM=${CTIME:4:2}
DD=${CTIME:6:2}
HH=${CTIME:8:2}
YYYP=${PTIME:0:4}
MP=${PTIME:4:2}
DP=${PTIME:6:2}
HP=${PTIME:8:2}
mem_ens="mem000"

MEM_WORKDIR=${WORKDIR}/${mem_ens}
MEM_MODL_OUTDIR=${OUTDIR}/${mem_ens}
RSTRDIR=${MEM_WORKDIR}
JEDIWORKDIR=${WORKDIR}/mem000/jedi
FILEDATE=${YYYY}${MM}${DD}.${HH}0000

if [[ ! -e ${MEM_WORKDIR} ]]; then
mkdir -p ${MEM_WORKDIR}
fi
if [[ ! -e ${MEM_MODL_OUTDIR} ]]; then
mkdir -p ${MEM_MODL_OUTDIR}
fi

mkdir -p $MEM_WORKDIR/modulefiles; cp ${CYCLEDIR}/modulefiles/landda_${MACHINE}.intel.lua $MEM_WORKDIR/modulefiles/modules.landda.lua
cd $MEM_WORKDIR

# load modulefiles
module use modulefiles; module load modules.landda

if [[ $do_jedi == "YES" && $ATMOS_FORC == "era5" ]]; then

# copy restarts into work directory
rst_in=${MEM_MODL_OUTDIR}/restarts/vector/ufs_land_restart_back.${YYYY}-${MM}-${DD}_${HH}-00-00.nc
if [[ ! -e ${rst_in} ]]; then
rst_in=${LANDDA_INPUTS}/restarts/${ATMOS_FORC}/ufs_land_restart.${YYYY}-${MM}-${DD}_${HH}-00-00.nc
fi
rst_out=${MEM_WORKDIR}/ufs_land_restart.${YYYY}-${MM}-${DD}_${HH}-00-00.nc
cp ${rst_in} ${rst_out}

echo '************************************************'
echo 'calling vector2tile'

export MEM_WORKDIR

# update vec2tile and tile2vec namelists
cp ${CYCLEDIR}/template.vector2tile vector2tile.namelist

sed -i "s|LANDDA_INPUTS|${LANDDA_INPUTS}|g" vector2tile.namelist
sed -i -e "s/XXYYYY/${YYYY}/g" vector2tile.namelist
sed -i -e "s/XXMM/${MM}/g" vector2tile.namelist
sed -i -e "s/XXDD/${DD}/g" vector2tile.namelist
sed -i -e "s/XXHH/${HH}/g" vector2tile.namelist
sed -i -e "s/XXHH/${HH}/g" vector2tile.namelist
sed -i -e "s/MODEL_FORCING/${ATMOS_FORC}/g" vector2tile.namelist
sed -i -e "s/XXRES/${RES}/g" vector2tile.namelist
sed -i -e "s/XXTSTUB/${TSTUB}/g" vector2tile.namelist
sed -i -e "s#XXTPATH#${TPATH}#g" vector2tile.namelist

# submit vec2tile
echo '************************************************'
echo 'calling vector2tile'

${BUILDDIR}/vector2tile_converter.exe vector2tile.namelist
if [[ $? != 0 ]]; then
echo "vec2tile failed"
exit
fi
fi # vector2tile for DA

if [[ $do_jedi == "YES" && $ATMOS_FORC == "gswp3" ]]; then

echo '************************************************'
echo 'calling tile2tile'

export MEM_WORKDIR

# copy restarts into work directory
for tile in 1 2 3 4 5 6
do
rst_in=${MEM_MODL_OUTDIR}/restarts/tile/ufs_land_restart_back.${YYYY}-${MM}-${DD}_${HH}-00-00.nc
if [[ ! -e ${rst_in} ]]; then
rst_in=${LANDDA_INPUTS}/restarts/${ATMOS_FORC}/ufs.cpld.lnd.out.${YYYY}-${MM}-${DD}-00000.tile${tile}.nc
fi
rst_out=${MEM_WORKDIR}/ufs_land_restart.${YYYY}-${MM}-${DD}_${HH}-00-00.tile${tile}.nc
cp ${rst_in} ${rst_out}
done

# update tile2tile namelist
cp ${CYCLEDIR}/template.ufs2jedi ufs2jedi.namelist

sed -i "s|LANDDA_INPUTS|${LANDDA_INPUTS}|g" ufs2jedi.namelist
sed -i -e "s/XXYYYY/${YYYY}/g" ufs2jedi.namelist
sed -i -e "s/XXMM/${MM}/g" ufs2jedi.namelist
sed -i -e "s/XXDD/${DD}/g" ufs2jedi.namelist
sed -i -e "s/XXHH/${HH}/g" ufs2jedi.namelist
sed -i -e "s/XXHH/${HH}/g" ufs2jedi.namelist
sed -i -e "s/MODEL_FORCING/${ATMOS_FORC}/g" ufs2jedi.namelist
sed -i -e "s/XXRES/${RES}/g" ufs2jedi.namelist
sed -i -e "s/XXTSTUB/${TSTUB}/g" ufs2jedi.namelist
sed -i -e "s#XXTPATH#${TPATH}#g" ufs2jedi.namelist

# submit tile2tile
${BUILDDIR}/tile2tile_converter.exe ufs2jedi.namelist
if [[ $? != 0 ]]; then
echo "tile2tile failed"
exit
fi
fi # tile2tile for DA

if [[ $do_jedi == "YES" ]]; then
if [[ ! -e ${OUTDIR}/DA ]]; then
mkdir -p ${OUTDIR}/DA/jedi_incr
mkdir -p ${OUTDIR}/DA/logs
mkdir -p ${OUTDIR}/DA/hofx
fi
if [[ ! -e $JEDIWORKDIR ]]; then
mkdir -p $JEDIWORKDIR
fi
cd $JEDIWORKDIR

if [[ ! -e ${JEDIWORKDIR}/output ]]; then
ln -s ${OUTDIR} ${JEDIWORKDIR}/output
fi

if [[ $SAVE_TILE == "YES" ]]; then
for tile in 1 2 3 4 5 6
do
cp ${RSTRDIR}/${FILEDATE}.sfc_data.tile${tile}.nc ${RSTRDIR}/${FILEDATE}.sfc_data_back.tile${tile}.nc
done
fi

#stage restarts for applying JEDI update (files will get directly updated)
for tile in 1 2 3 4 5 6
do
ln -fs ${RSTRDIR}/${FILEDATE}.sfc_data.tile${tile}.nc ${JEDIWORKDIR}/${FILEDATE}.sfc_data.tile${tile}.nc
done

cres_file=${JEDIWORKDIR}/${FILEDATE}.coupler.res

if [[ -e ${RSTRDIR}/${FILEDATE}.coupler.res ]]; then
ln -sf ${RSTRDIR}/${FILEDATE}.coupler.res $cres_file
else # if not present, need to create coupler.res for JEDI
cp ${LANDDADIR}/template.coupler.res $cres_file

sed -i -e "s/XXYYYY/${YYYY}/g" $cres_file
sed -i -e "s/XXMM/${MM}/g" $cres_file
sed -i -e "s/XXDD/${DD}/g" $cres_file
sed -i -e "s/XXHH/${HH}/g" $cres_file

sed -i -e "s/XXYYYP/${YYYP}/g" $cres_file
sed -i -e "s/XXMP/${MP}/g" $cres_file
sed -i -e "s/XXDP/${DP}/g" $cres_file
sed -i -e "s/XXHP/${HP}/g" $cres_file

fi
fi # do_jedi setup

68 changes: 68 additions & 0 deletions jobs/JLAND_PREP_OBS
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/sh

set -ex

############################
# copy restarts to workdir, convert to UFS tile for DA (all members)

if [[ ${EXP_NAME} == "openloop" ]]; then
do_jedi="NO"
else
do_jedi="YES"
SAVE_TILE="YES"
LANDDADIR=${CYCLEDIR}/DA_update/
fi

TPATH=${LANDDA_INPUTS}/forcing/${ATMOS_FORC}/orog_files/
YYYY=${CTIME:0:4}
MM=${CTIME:4:2}
DD=${CTIME:6:2}
HH=${CTIME:8:2}
YYYP=${PTIME:0:4}
MP=${PTIME:4:2}
DP=${PTIME:6:2}
HP=${PTIME:8:2}

mem_ens="mem000"

MEM_WORKDIR=${WORKDIR}/${mem_ens}
MEM_MODL_OUTDIR=${OUTDIR}/${mem_ens}
RSTRDIR=${MEM_WORKDIR}
JEDIWORKDIR=${WORKDIR}/mem000/jedi
FILEDATE=${YYYY}${MM}${DD}.${HH}0000

cd $JEDIWORKDIR

# load modulefiles
#module use modulefiles; module load modules.landda

OBSDIR=${LANDDA_INPUTS}/DA
################################################
# 2. PREPARE OBS FILES
################################################
for obs in "${OBS_TYPES[@]}"; do
# get the. obs file name
if [ ${obs} == "GTS" ]; then
obsfile=$OBSDIR/snow_depth/GTS/data_proc/${YYYY}${MM}/adpsfc_snow_${YYYY}${MM}${DD}${HH}.nc4
# GHCN are time-stamped at 18. If assimilating at 00, need to use previous day's obs, so that
# obs are within DA window.
elif [ $ATMOS_FORC == "era5" ] && [ ${obs} == "GHCN" ]; then
obsfile=$OBSDIR/snow_depth/GHCN/data_proc/v3/${YYYY}/ghcn_snwd_ioda_${YYYP}${MP}${DP}.nc
elif [ $ATMOS_FORC == "gswp3" ] && [ ${obs} == "GHCN" ]; then
obsfile=$OBSDIR/snow_depth/GHCN/data_proc/v3/${YYYY}/fake_ghcn_snwd_ioda_${YYYP}${MP}${DP}.nc
elif [ ${obs} == "SYNTH" ]; then
obsfile=$OBSDIR/synthetic_noahmp/IODA.synthetic_gswp_obs.${YYYY}${MM}${DD}${HH}.nc
else
echo "do_landDA: Unknown obs type requested ${obs}, exiting"
exit 1
fi

# check obs are available
if [[ -e $obsfile ]]; then
echo "do_landDA: $i observations found: $obsfile"
ln -fs $obsfile ${obs}_${YYYY}${MM}${DD}${HH}.nc
else
echo "${obs} observations not found: $obsfile"
# JEDI_TYPES[$ii]="SKIP"
fi
done
Loading
Loading