-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_template_OIFS.sh
executable file
·72 lines (57 loc) · 2.22 KB
/
create_template_OIFS.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
#!/bin/ksh
#
# Feb 2011: Implementation of the command sequence for
# the preparation of template files for ECHAM
# S. Rast, A. Voigt, U. Schulzweida
#
# Oct 2021: Adaptation of the command sequence for the
# preparation of template files for OpenIFS
# M. Athanase, H. Goessling
#
# Jul 2022: Consolidation into single script
# J. Streffing
# Usage and subroutines description in README
########################################################
set -xuve
RES=$1 # Requested OpenIFS resolution e.g. TCO159L91
EXPID=$2 # Corresponding experiment ID e.g. h9wu
FESOM_MESH=$3 # Part of file names that signifies IFS files modified for FESOM
INPATH=$4 # Path to your ICM* OpenIFS initial state files
OUTPATH=$5 # Path for output of template files
CDO=$6 # Path to specific CDO binary
mkdir -p $OUTPATH
rm -f tmp1$$ tmp2$$ tmp3$$ tmp4$$
if [ "${FESOM_MESH}" != "-" ]; then
${CDO} seltimestep,1 ${INPATH}/ICMGG${EXPID}INIT_${FESOM_MESH} tmp1$$
else
${CDO} seltimestep,1 ${INPATH}/ICMGG${EXPID}INIT tmp1$$
fi
${CDO} seltimestep,1 ${INPATH}/ICMGG${EXPID}INIUA tmp1a$$
${CDO} seltimestep,1 ${INPATH}/ICMSH${EXPID}INIT tmp2$$
if [ "${EXPID}" == "ECE3" ]; then
${CDO} --eccodes -f grb2 -selcode,172 -setgridtype,regular tmp1$$ tmp3a$$
${CDO} -f grb2 -selcode,133 tmp1a$$ tmp3b$$
${CDO} -f grb2 -selcode,130 tmp2$$ tmp4b$$
${CDO} -f grb2 -selcode,129 tmp2$$ tmp4a$$
else
${CDO} --eccodes -f grb2 -selcode,172 -setgridtype,regular tmp1$$ tmp3a$$
${CDO} -f grb2 -chparam,0.1.0,133.128 -selname,q tmp1a$$ tmp3b$$
# this fix needed for TL159, because z is in grb2 not grb1
if [[ "${RES}" == TL* ]] ; then
grib_copy -w paramId=129 tmp2$$ tmp4a1$$
grib_set -s edition=1 tmp4a1$$ tmp4a2$$
${CDO} -f grb2 -selcode,129 tmp4a2$$ tmp4a$$
rm -f tmp4a1$$ tmp4a2$$
else
${CDO} -f grb2 -selcode,129 tmp2$$ tmp4a$$
fi
${CDO} -f grb2 -chparam,0.0.0,130.128 -selname,t tmp2$$ tmp4b$$
fi
${CDO} merge tmp4a$$ tmp4b$$ tmp3a$$ tmp3b$$ tmp_$$
${CDO} -O copy tmp_$$ ${OUTPATH}/template.oifs${RES}
rm -f tmp*$$
if [ -f "${OUTPATH}/template.oifs${RES}" ]; then
echo "Template file template.oifs${RES} was created"
else
echo "Creation of template file failed"
fi