Skip to content

Commit

Permalink
GDAS Init utility - consolidate the copy of coldstart files (#773)
Browse files Browse the repository at this point in the history
Place the copy of the coldstart files in a common script called
copy_coldstart_files.sh.

Fixes #772.
  • Loading branch information
GeorgeGayno-NOAA authored Mar 8, 2023
1 parent 26167e3 commit 9cf134a
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 156 deletions.
6 changes: 5 additions & 1 deletion util/gdas_init/config
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ OUTDIR=/lfs/h2/emc/stmp/$USER/gdas.init/output
#---------------------------------------------------------
# Dont touch anything below here.
#---------------------------------------------------------

GDAS_INIT_DIR=$UFS_DIR/util/gdas_init
EXEC_DIR=$UFS_DIR/exec

if [ "$use_v16retro" = "yes" ]; then

gfs_ver=v16retro
Expand Down Expand Up @@ -113,4 +117,4 @@ else
fi

export EXTRACT_DIR yy mm dd hh UFS_DIR OUTDIR CRES_HIRES CRES_ENKF FRAC_ORO
export LEVS gfs_ver
export LEVS gfs_ver EXEC_DIR GDAS_INIT_DIR
72 changes: 72 additions & 0 deletions util/gdas_init/copy_coldstart_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/bash

# Copy files from the working directory to the
# output directory.

copy_data()
{

set -x

mkdir -p $SAVEDIR
cp gfs_ctrl.nc $SAVEDIR

for tile in 'tile1' 'tile2' 'tile3' 'tile4' 'tile5' 'tile6'
do
cp out.atm.${tile}.nc ${SAVEDIR}/gfs_data.${tile}.nc
cp out.sfc.${tile}.nc ${SAVEDIR}/sfc_data.${tile}.nc
done
}

set -x

MEMBER=$1
OUTDIR=$2
yy=$3
mm=$4
dd=$5
hh=$6
INPUT_DATA_DIR=$7

if [ ${MEMBER} == 'hires' ]; then
MEMBER='gdas'
fi

set +x
echo 'COPY DATA TO OUTPUT DIRECTORY'
set -x

if [ ${MEMBER} == 'gdas' ] || [ ${MEMBER} == 'gfs' ]; then
SUBDIR=$OUTDIR/${MEMBER}.${yy}${mm}${dd}/${hh}
rm -fr $SUBDIR
SAVEDIR=$SUBDIR/atmos/INPUT
copy_data
if [ ${MEMBER} == 'gdas' ]; then
cp ${INPUT_DATA_DIR}/*abias* $SAVEDIR/..
cp ${INPUT_DATA_DIR}/*radstat $SAVEDIR/..
fi
touch $SAVEDIR/../${MEMBER}.t${hh}z.loginc.txt
elif [ ${MEMBER} == 'enkf' ]; then # v16 retro data only.
MEMBER=1
while [ $MEMBER -le 80 ]; do
if [ $MEMBER -lt 10 ]; then
MEMBER_CH="00${MEMBER}"
else
MEMBER_CH="0${MEMBER}"
fi
SUBDIR=$OUTDIR/enkfgdas.${yy}${mm}${dd}/${hh}/mem${MEMBER_CH}
rm -fr $SUBDIR
SAVEDIR=$SUBDIR/atmos/INPUT
copy_data
touch $SAVEDIR/../enkfgdas.t${hh}z.loginc.txt
MEMBER=$(( $MEMBER + 1 ))
done
else
SUBDIR=$OUTDIR/enkfgdas.${yy}${mm}${dd}/${hh}/mem${MEMBER}
rm -fr $SUBDIR
SAVEDIR=$SUBDIR/atmos/INPUT
copy_data
touch $SAVEDIR/../enkfgdas.t${hh}z.loginc.txt
fi

exit 0
30 changes: 3 additions & 27 deletions util/gdas_init/run_pre-v14.chgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ WORKDIR=${WORKDIR:-$OUTDIR/work.${MEMBER}}
if [ "${MEMBER}" = "gdas" ] || [ "${MEMBER}" = "gfs" ]; then
CTAR=${CRES_HIRES}
INPUT_DATA_DIR="${EXTRACT_DIR}/${MEMBER}.${yy}${mm}${dd}/${hh}"
RADSTAT_DATA_DIR="${EXTRACT_DIR}/${MEMBER}.${yy}${mm}${dd}/${hh}"
OUTDIR=$OUTDIR/${MEMBER}.${yy}${mm}${dd}/${hh}/atmos
if [ "${MEMBER}" = "gdas" ]; then
ATMFILE="gdas1.t${hh}z.sanl"
SFCFILE="gdas1.t${hh}z.sfcanl"
Expand All @@ -30,8 +28,6 @@ if [ "${MEMBER}" = "gdas" ] || [ "${MEMBER}" = "gfs" ]; then
else
CTAR=${CRES_ENKF}
INPUT_DATA_DIR="${EXTRACT_DIR}/enkf.${yy}${mm}${dd}/${hh}/mem${MEMBER}"
RADSTAT_DATA_DIR="${EXTRACT_DIR}/enkf.${yy}${mm}${dd}/${hh}/mem${MEMBER}"
OUTDIR=$OUTDIR/enkfgdas.${yy}${mm}${dd}/${hh}/mem${MEMBER}/atmos
ATMFILE="siganl_${yy}${mm}${dd}${hh}_mem${MEMBER}"
SFCFILE="sfcanl_${yy}${mm}${dd}${hh}_mem${MEMBER}"
fi
Expand All @@ -40,11 +36,7 @@ rm -fr $WORKDIR
mkdir -p $WORKDIR
cd $WORKDIR

rm -fr $OUTDIR
mkdir -p $OUTDIR
mkdir -p $OUTDIR/INPUT

source $UFS_DIR/util/gdas_init/set_fixed_files.sh
source $GDAS_INIT_DIR/set_fixed_files.sh

cat << EOF > fort.41
Expand All @@ -69,30 +61,14 @@ cat << EOF > fort.41
/
EOF

$APRUN $UFS_DIR/exec/chgres_cube
$APRUN $EXEC_DIR/chgres_cube
rc=$?

if [ $rc != 0 ]; then
exit $rc
fi

mv gfs_ctrl.nc ${OUTDIR}/INPUT

for tile in 'tile1' 'tile2' 'tile3' 'tile4' 'tile5' 'tile6'
do
mv out.atm.${tile}.nc ${OUTDIR}/INPUT/gfs_data.${tile}.nc
mv out.sfc.${tile}.nc ${OUTDIR}/INPUT/sfc_data.${tile}.nc
done

if [ "${MEMBER}" = "gdas" ]; then
cp ${RADSTAT_DATA_DIR}/*radstat* $OUTDIR
cp ${RADSTAT_DATA_DIR}/*abias* $OUTDIR
touch $OUTDIR/gdas.t${hh}z.loginc.txt
elif [ "${MEMBER}" = "gfs" ]; then
touch $OUTDIR/gfs.t${hh}z.loginc.txt
else
touch $OUTDIR/enkfgdas.t${hh}z.loginc.txt
fi
$GDAS_INIT_DIR/copy_coldstart_files.sh $MEMBER $OUTDIR $yy $mm $dd $hh $INPUT_DATA_DIR

rm -fr $WORKDIR

Expand Down
30 changes: 3 additions & 27 deletions util/gdas_init/run_v14.chgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,12 @@ WORKDIR=${WORKDIR:-$OUTDIR/work.${MEMBER}}
if [ "${MEMBER}" = "gdas" ] || [ "${MEMBER}" = "gfs" ]; then
CTAR=${CRES_HIRES}
INPUT_DATA_DIR="${EXTRACT_DIR}/${MEMBER}.${yy}${mm}${dd}/${hh}"
RADSTAT_DATA_DIR="${EXTRACT_DIR}/${MEMBER}.${yy}${mm}${dd}/${hh}"
OUTDIR=$OUTDIR/${MEMBER}.${yy}${mm}${dd}/${hh}/atmos
ATMFILE="${MEMBER}.t${hh}z.atmanl.nemsio"
SFCFILE="${MEMBER}.t${hh}z.sfcanl.nemsio"
NSTFILE="${MEMBER}.t${hh}z.nstanl.nemsio"
else
CTAR=${CRES_ENKF}
INPUT_DATA_DIR="${EXTRACT_DIR}/enkf.${yy}${mm}${dd}/${hh}/mem${MEMBER}"
RADSTAT_DATA_DIR="${EXTRACT_DIR}/enkf.${yy}${mm}${dd}/${hh}/mem${MEMBER}"
OUTDIR=$OUTDIR/enkfgdas.${yy}${mm}${dd}/${hh}/mem${MEMBER}/atmos
ATMFILE="gdas.t${hh}z.ratmanl.mem${MEMBER}.nemsio"
SFCFILE="gdas.t${hh}z.sfcanl.mem${MEMBER}.nemsio"
NSTFILE="gdas.t${hh}z.nstanl.mem${MEMBER}.nemsio"
Expand All @@ -36,11 +32,7 @@ rm -fr $WORKDIR
mkdir -p $WORKDIR
cd $WORKDIR

rm -fr $OUTDIR
mkdir -p $OUTDIR
mkdir -p $OUTDIR/INPUT

source $UFS_DIR/util/gdas_init/set_fixed_files.sh
source $GDAS_INIT_DIR/set_fixed_files.sh

cat << EOF > fort.41
Expand All @@ -66,30 +58,14 @@ cat << EOF > fort.41
/
EOF

$APRUN $UFS_DIR/exec/chgres_cube
$APRUN $EXEC_DIR/chgres_cube
rc=$?

if [ $rc != 0 ]; then
exit $rc
fi

mv gfs_ctrl.nc ${OUTDIR}/INPUT

for tile in 'tile1' 'tile2' 'tile3' 'tile4' 'tile5' 'tile6'
do
mv out.atm.${tile}.nc ${OUTDIR}/INPUT/gfs_data.${tile}.nc
mv out.sfc.${tile}.nc ${OUTDIR}/INPUT/sfc_data.${tile}.nc
done

if [ "${MEMBER}" = "gdas" ]; then
cp ${RADSTAT_DATA_DIR}/*radstat* $OUTDIR
cp ${RADSTAT_DATA_DIR}/*abias* $OUTDIR
touch $OUTDIR/gdas.t${hh}z.loginc.txt
elif [ "${MEMBER}" = "gfs" ]; then
touch $OUTDIR/gfs.t${hh}z.loginc.txt
else
touch $OUTDIR/enkfgdas.t${hh}z.loginc.txt
fi
$GDAS_INIT_DIR/copy_coldstart_files.sh $MEMBER $OUTDIR $yy $mm $dd $hh $INPUT_DATA_DIR

rm -fr $WORKDIR

Expand Down
19 changes: 3 additions & 16 deletions util/gdas_init/run_v15.chgres.gfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,14 @@ WORKDIR=${WORKDIR:-$OUTDIR/work.gfs}

CTAR=${CRES_HIRES}
INPUT_DATA_DIR="${EXTRACT_DIR}/gfs.${yy}${mm}${dd}/${hh}"
OUTDIR=$OUTDIR/gfs.${yy}${mm}${dd}/${hh}/atmos
ATMFILE="gfs.t${hh}z.atmanl.nemsio"
SFCFILE="gfs.t${hh}z.sfcanl.nemsio"

rm -fr $WORKDIR
mkdir -p $WORKDIR
cd $WORKDIR

rm -fr $OUTDIR
mkdir -p $OUTDIR
mkdir -p $OUTDIR/INPUT

source $UFS_DIR/util/gdas_init/set_fixed_files.sh
source $GDAS_INIT_DIR/set_fixed_files.sh

cat << EOF > fort.41
Expand All @@ -52,22 +47,14 @@ cat << EOF > fort.41
/
EOF

$APRUN $UFS_DIR/exec/chgres_cube
$APRUN $EXEC_DIR/chgres_cube
rc=$?

if [ $rc != 0 ]; then
exit $rc
fi

mv gfs_ctrl.nc ${OUTDIR}/INPUT

for tile in 'tile1' 'tile2' 'tile3' 'tile4' 'tile5' 'tile6'
do
mv out.atm.${tile}.nc ${OUTDIR}/INPUT/gfs_data.${tile}.nc
mv out.sfc.${tile}.nc ${OUTDIR}/INPUT/sfc_data.${tile}.nc
done

touch $OUTDIR/gfs.t${hh}z.loginc.txt
$GDAS_INIT_DIR/copy_coldstart_files.sh gfs $OUTDIR $yy $mm $dd $hh $INPUT_DATA_DIR

rm -fr $WORKDIR

Expand Down
25 changes: 3 additions & 22 deletions util/gdas_init/run_v15.chgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,18 @@ if [ ${MEMBER} == 'gdas' ]; then
CTAR=${CRES_HIRES}
INPUT_DATA_DIR="${EXTRACT_DIR}/gdas.${yy_d}${mm_d}${dd_d}/${hh_d}/RESTART"
RADSTAT_DATA_DIR="${EXTRACT_DIR}/gdas.${yy}${mm}${dd}/${hh}"
OUTDIR=$OUTDIR/gdas.${yy}${mm}${dd}/${hh}/atmos
else
CINP=${CINP:-"C384"}
CTAR=${CRES_ENKF}
INPUT_DATA_DIR="${EXTRACT_DIR}/enkfgdas.${yy_d}${mm_d}${dd_d}/${hh_d}/mem${MEMBER}/RESTART"
RADSTAT_DATA_DIR="${EXTRACT_DIR}/enkfgdas.${yy}${mm}${dd}/${hh}/mem${MEMBER}"
OUTDIR=$OUTDIR/enkfgdas.${yy}${mm}${dd}/${hh}/mem${MEMBER}/atmos
fi

rm -fr $WORKDIR
mkdir -p $WORKDIR
cd $WORKDIR

rm -fr $OUTDIR
mkdir -p $OUTDIR
mkdir -p $OUTDIR/INPUT

source $UFS_DIR/util/gdas_init/set_fixed_files.sh
source $GDAS_INIT_DIR/set_fixed_files.sh

cat << EOF > fort.41
Expand Down Expand Up @@ -72,27 +66,14 @@ cat << EOF > fort.41
/
EOF

$APRUN $UFS_DIR/exec/chgres_cube
$APRUN $EXEC_DIR/chgres_cube
rc=$?

if [ $rc != 0 ]; then
exit $rc
fi

mv gfs_ctrl.nc ${OUTDIR}/INPUT

for tile in 'tile1' 'tile2' 'tile3' 'tile4' 'tile5' 'tile6'
do
mv out.atm.${tile}.nc ${OUTDIR}/INPUT/gfs_data.${tile}.nc
mv out.sfc.${tile}.nc ${OUTDIR}/INPUT/sfc_data.${tile}.nc
done

if [ ${MEMBER} == 'gdas' ]; then
cp ${RADSTAT_DATA_DIR}/* $OUTDIR
touch $OUTDIR/gdas.t${hh}z.loginc.txt
else
touch $OUTDIR/enkfgdas.t${hh}z.loginc.txt
fi
$GDAS_INIT_DIR/copy_coldstart_files.sh $MEMBER $OUTDIR $yy $mm $dd $hh $RADSTAT_DATA_DIR

rm -fr $WORKDIR

Expand Down
31 changes: 3 additions & 28 deletions util/gdas_init/run_v16.chgres.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
#!/bin/bash

copy_data()
{

mkdir -p $SAVEDIR
cp gfs_ctrl.nc $SAVEDIR

for tile in 'tile1' 'tile2' 'tile3' 'tile4' 'tile5' 'tile6'
do
cp out.atm.${tile}.nc ${SAVEDIR}/gfs_data.${tile}.nc
cp out.sfc.${tile}.nc ${SAVEDIR}/sfc_data.${tile}.nc
done
}

#---------------------------------------------------------------------------
# Run chgres using v16 netcdf history data as input. These history
# files are part of the OPS v16 gfs/gdas/enkf tarballs, and the
Expand Down Expand Up @@ -59,7 +46,7 @@ rm -fr $WORKDIR
mkdir -p $WORKDIR
cd $WORKDIR

source $UFS_DIR/util/gdas_init/set_fixed_files.sh
source $GDAS_INIT_DIR/set_fixed_files.sh

cat << EOF > fort.41
Expand All @@ -84,26 +71,14 @@ cat << EOF > fort.41
/
EOF

$APRUN $UFS_DIR/exec/chgres_cube
$APRUN $EXEC_DIR/chgres_cube
rc=$?

if [ $rc != 0 ]; then
exit $rc
fi

if [ ${MEMBER} == 'gdas' ] || [ ${MEMBER} == 'gfs' ]; then
SAVEDIR=$OUTDIR/${MEMBER}.${yy}${mm}${dd}/${hh}/atmos/INPUT
copy_data
touch $SAVEDIR/../${MEMBER}.t${hh}z.loginc.txt
if [ ${MEMBER} == 'gdas' ]; then
cp ${INPUT_DATA_DIR}/*abias* $SAVEDIR/..
cp ${INPUT_DATA_DIR}/*radstat $SAVEDIR/..
fi
else
SAVEDIR=$OUTDIR/enkfgdas.${yy}${mm}${dd}/${hh}/mem${MEMBER}/atmos/INPUT
copy_data
touch $SAVEDIR/../enkfgdas.t${hh}z.loginc.txt
fi
$GDAS_INIT_DIR/copy_coldstart_files.sh $MEMBER $OUTDIR $yy $mm $dd $hh $INPUT_DATA_DIR

rm -fr $WORKDIR

Expand Down
Loading

0 comments on commit 9cf134a

Please sign in to comment.