-
Notifications
You must be signed in to change notification settings - Fork 207
Expand file tree
/
Copy pathexgfs_wave_init.sh
More file actions
executable file
·85 lines (73 loc) · 2.9 KB
/
exgfs_wave_init.sh
File metadata and controls
executable file
·85 lines (73 loc) · 2.9 KB
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
#! /usr/bin/env bash
################################################################################
#
# UNIX Script Documentation Block
# Script name: exwave_init.sh
# Script description: Creates model definition files for WW3
#
# Abstract: This script is the init config for the global multi_grid wave model.
# It creates model definition files with all configurations of spatial
# and spectral grids, as well as physics parameters and time steps.
#
# $Id$
#
# Attributes:
# Language: Bourne-again (BASH) shell
#
###############################################################################
#
# --------------------------------------------------------------------------- #
# 1. Get files that are used by most child scripts
cat << EOF
Preparing input files :
-----------------------
EOF
# 1.a Model definition files
# Eliminate duplicate grids
# Use an associative array, since they don't allow duplicate keys
declare -A grdALL
for grd in ${WAVECUR_FID} ${WAVEICE_FID} ${WAVEWND_FID} ${waveuoutpGRD} ${waveGRD} ${wavepostGRD} ${waveinterpGRD}; do
# For ease of access, make the value the same as the key
grdALL["${grd}"]="${grd}"
done
for grdID in "${grdALL[@]}"; do
echo "INFO: Setting up to generate mod_def file for ${grdID}"
if [[ -f "${FIXglobal}/wave/ww3_grid.inp.${grdID}" ]]; then
cpreq "${FIXglobal}/wave/ww3_grid.inp.${grdID}" "ww3_grid.inp.${grdID}"
echo "INFO: ww3_grid.inp.${grdID} copied (${FIXglobal}/wave/ww3_grid.inp.${grdID})."
else
export err=2
err_exit "No inp file for model definition file for grid ${grdID}"
fi
if [[ -f "${FIXglobal}/wave/${grdID}.msh" ]]; then
cpreq "${FIXglobal}/wave/${grdID}.msh" "${grdID}.msh"
fi
#TODO: how do we say "it's unstructured, and therefore need to have error check here"
echo "${USHglobal}/wave_grid_moddef.sh ${grdID}" >> mpmd_script
done
# 1.a.1 Execute MPMD or process serially
"${USHglobal}/run_mpmd.sh" "${DATA}/mpmd_script" && true
export err=$?
if [[ ${err} -ne 0 ]]; then
err_exit "run_mpmd.sh failed!"
fi
# 1.a.3 File check
for grdID in "${grdALL[@]}"; do
if [[ -f "${COMOUT_WAVE_PREP}/${RUN}.t${cyc}z.mod_def.${grdID}.bin" ]]; then
echo "INFO: mod_def.${grdID} succesfully created/copied"
else
export err=3
err_exit "No model definition file for grid ${grdID}"
fi
done
# Copy to other members if needed
if [[ "${NET}" == "gefs" && ${NMEM_ENS} -gt 0 ]]; then
for mem in $(seq -f "%03g" 1 "${NMEM_ENS}"); do
declare -x COMOUT_WAVE_PREP_MEM="${ROTDIR}/${RUN}.${PDY}/${cyc}/mem${mem}/model/wave/prep"
mkdir -p "${COMOUT_WAVE_PREP_MEM}"
for grdID in "${grdALL[@]}"; do
cpfs "${COMOUT_WAVE_PREP}/${RUN}.t${cyc}z.mod_def.${grdID}.bin" "${COMOUT_WAVE_PREP_MEM}/${RUN}.t${cyc}z.mod_def.${grdID}.bin"
done
done
fi
# End of MWW3 init config script ------------------------------------------- #