-
Notifications
You must be signed in to change notification settings - Fork 0
/
ressac_install.ksh
executable file
·133 lines (115 loc) · 4.08 KB
/
ressac_install.ksh
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
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/ksh
# This script is used to create a Working space where to work for writing a run report, based on the RESSAC help tools.
# $Id$
usage() {
echo " USAGE : $(basename $0 ) [-h] -c confif-case "
echo " Purpose:"
echo " Build a working space under \$RESSAC_WORKDIR for the config-case report edition"
echo " "
echo " Arguments:"
echo " -c config-case : give the name of the config-case to qork with"
echo " "
echo " Options:"
echo " [ -h ] : print this help message "
echo " [ -f ] : force creation even if the directory already exists."
echo " In this case, old directory will be renamed."
echo " "
echo " Remarks:"
echo " 1. Environment variable RESSAC_ROOT must be set to a directory where the "
echo " RESSAC package is check out from svn server"
echo " 2. Environment variable RESSAC_WORKDIR must be set to a directory where the "
echo " workspace will be created."
exit 0
}
print_error() {
echo " ============== "
echo " * E R R O R * "
echo " ============== "
echo " $@"
echo " ---"
echo " "
echo " "
usage
}
# replace <JOKERS> by their value
filter() {
file=$1
cat $file | sed -e "s/<CONFIG_CASE>/$CONFIG_CASE/g" \
-e "s/<CONFIG>/$CONFIG/g" \
-e "s/<CASE>/$CASE/g" > ztmp
mv ztmp $file
}
# ------------------------------------------------------------------------------------------------
force=0
if [ $# = 0 ] ; then usage ; fi
while getopts :hc:f V ; do
case $V in
(h) usage ;;
(c) CONFIG_CASE=${OPTARG} ;;
(f) force=1 ;;
(:) echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2;
exit 2;;
(\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2;
exit 2;;
esac
done
if [ ! $RESSAC_ROOT ] ; then
print_error "You must set RESSAC_ROOT environment variable (see remarks below) !"
fi
if [ ! $RESSAC_WORKDIR ] ; then
print_error "You must set RESSAC_WORKDIR environment variable (see remarks below) !"
fi
REPORT_DIR=$RESSAC_WORKDIR/REPORT_${CONFIG_CASE}
if [ -d $REPORT_DIR -a $force == 0 ] ; then
print_error " $REPORT_DIR already exist. Use -f option if you want to overwrite. (Old will be renamed.)"
else
if [ -d $REPORT_DIR ] ; then
cd $REPORT_DIR
echo " Directory renamed before creation of a new one with same name" > README_rename
echo $(date) >> README_rename
cd ../
mv $REPORT_DIR ${REPORT_DIR}.$$
fi
mkdir -p $REPORT_DIR
fi
mkdir -p $REPORT_DIR/INPUT_DATA
mkdir -p $REPORT_DIR/TexFiles/Namelist
mkdir -p $REPORT_DIR/TexFiles/Figures
mkdir -p $REPORT_DIR/TexFiles/Biblio
cp $RESSAC_ROOT/TexFiles/ametsoc.bst $RESSAC_ROOT/TexFiles/*.tex $REPORT_DIR/TexFiles
cp $RESSAC_ROOT/Report_template.tex $REPORT_DIR/${CONFIG_CASE}_report.tex
cp $RESSAC_ROOT/Makefile.tmpl $REPORT_DIR/Makefile
cp $RESSAC_ROOT/TexFiles/Figures/*eps $REPORT_DIR/TexFiles/Figures/
cp $RESSAC_ROOT/TexFiles/Figures/*jpg $REPORT_DIR/TexFiles/Figures/
# customize copied files
cd $REPORT_DIR/
CONFIG=${CONFIG_CASE%-*} ; CONFIGnoDOT=$(echo $CONFIG | tr -d '.')
CASE=${CONFIG_CASE#*-} ; CASEnoDOT=$(echo $CASE | tr -d '.')
CONFIG_CASEnoDOT=${CONFIGnoDOT}-${CASEnoDOT}
filter Makefile
filter ${CONFIG_CASE}_report.tex
cd TexFiles
for f in *.tex ; do
filter $f
done
cd Figures
for typ in shlat2d bfr_bering bfr_torres ; do
for ext in eps jpg ; do
ln -sf workInProgress.jpg ${CONFIG_CASEnoDOT}_$typ.$ext
done
done
echo "===================================="
echo "* $REPORT_DIR has been installed *"
echo "===================================="
echo " "
echo " You must copy intput files in $REPORT_DIR/INPUT_DATA"
echo
echo " Input files are :"
echo " CPP_KEYS"
echo " namelist_oce"
echo " namelist_ice"
echo " includefile.ksh"
echo " journal.txt [ optional ]"
echo " config-case-MONITOR/*nc [ optional ]"
echo " install_history"
echo " ---"