forked from NOAA-PSL/land-offline_workflow
-
Notifications
You must be signed in to change notification settings - Fork 1
/
do_submit_cycle.sh
executable file
·121 lines (94 loc) · 2.81 KB
/
do_submit_cycle.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
############################
# load config file
if [[ $# -gt 0 ]]; then
config_file=$1
else
config_file=settings
fi
if [[ ! -e $config_file ]]; then
echo 'Config file does not exist. Exiting. '
echo $config_file
exit
fi
echo "reading cycle settings from $config_file"
source $config_file
export KEEPWORKDIR="YES"
############################
# load modules
source cycle_mods_bash
export CYCLEDIR=$(pwd)
############################
# set executables
export vec2tileexec=${CYCLEDIR}/vector2tile/vector2tile_converter.exe
export LSMexec=${CYCLEDIR}/ufs-land-driver/run/ufsLand.exe
export DADIR=${CYCLEDIR}/DA_update/
export DAscript=${DADIR}/do_landDA.sh
export analdate=${CYCLEDIR}/analdates.sh
export incdate=${CYCLEDIR}/incdate.sh
############################
# read in dates
export logfile=${CYCLEDIR}/cycle.log
touch $logfile
echo "***************************************" >> $logfile
echo "cycling from $STARTDATE to $ENDDATE" >> $logfile
sYYYY=`echo $STARTDATE | cut -c1-4`
sMM=`echo $STARTDATE | cut -c5-6`
sDD=`echo $STARTDATE | cut -c7-8`
sHH=`echo $STARTDATE | cut -c9-10`
# compute the restart frequency, run_days and run_hours
export FREQ=$(( 3600 * $FCSTHR ))
export RDD=$(( $FCSTHR / 24 ))
export RHH=$(( $FCSTHR % 24 ))
############################
# set up directories
#workdir
if [[ -e ${WORKDIR} ]]; then
rm -rf ${WORKDIR}
fi
mkdir ${WORKDIR}
#outdir for model
if [[ ! -e ${OUTDIR} ]]; then
mkdir -p ${OUTDIR}
fi
###############################
# create dirs and copy in ICS if needed
mem_ens="mem000" # single member, us ensemble 0
MEM_WORKDIR=${WORKDIR}/${mem_ens}
if [[ ! -e $MEM_WORKDIR ]]; then
mkdir $MEM_WORKDIR
fi
# ensemble outdir (model only)
MEM_MODL_OUTDIR=${OUTDIR}/${mem_ens}
if [[ ! -e $MEM_MODL_OUTDIR ]]; then #ensemble outdir
mkdir -p $MEM_MODL_OUTDIR
fi
# outdir subdirs
if [[ ! -e ${MEM_MODL_OUTDIR}/restarts/ ]]; then # subdirectories
mkdir -p ${MEM_MODL_OUTDIR}/restarts/vector/
mkdir ${MEM_MODL_OUTDIR}/restarts/tile/
mkdir -p ${MEM_MODL_OUTDIR}/noahmp/
fi
ln -sf ${MEM_MODL_OUTDIR}/noahmp ${MEM_WORKDIR}/noahmp_output
# copy ICS into restarts, if needed
rst_in=${ICSDIR}/${mem_ens}/restarts/vector/ufs_land_restart.${sYYYY}-${sMM}-${sDD}_${sHH}-00-00.nc
rst_out=${MEM_MODL_OUTDIR}/restarts/vector/ufs_land_restart_back.${sYYYY}-${sMM}-${sDD}_${sHH}-00-00.nc
# if restart not in experiment out directory, copy the restarts from the ICSDIR
if [[ ! -e ${rst_out} ]]; then
echo "Looking for ICS: ${rst_in}"
if [[ -e ${rst_in} ]]; then
echo "ICS found, copying"
cp ${rst_in} ${rst_out}
else
echo "ICS not found. Exiting"
exit 10
fi
fi
# create dates file
touch analdates.sh
cat << EOF > analdates.sh
STARTDATE=$STARTDATE
ENDDATE=$ENDDATE
EOF
# submit script
sbatch submit_cycle.sh