1 | #!/bin/sh |
---|
2 | #+ |
---|
3 | # |
---|
4 | # NAME |
---|
5 | # ==== |
---|
6 | # |
---|
7 | # ``script_correc.sh`` - run ``script_correc.m`` in batch mode either with ``octave`` or ``matlab`` |
---|
8 | # |
---|
9 | # DESCRIPTION |
---|
10 | # =========== |
---|
11 | # |
---|
12 | # script_correc.sh run script_correc.m in batch mode either with ``octave`` or ``matlab`` using ``-a`` option. |
---|
13 | # |
---|
14 | # At the end of ``script_correc.m`` execution, output files are renamed from |
---|
15 | # \*.eps to *application*\ _*hostname*\ _*YYYYMMDDTHHMMSSZ*.eps and moved to ${TP_MLP_AEROSOLS_LOG}. |
---|
16 | # |
---|
17 | # This might be usefull to compare results on the same or different machine |
---|
18 | # with different applications or releases of application. |
---|
19 | # |
---|
20 | # Log file is written on |
---|
21 | # ${TP_MLP_AEROSOLS_LOG}/script_correc.log.\ *YYYYMMDDTHHMMSSZ* |
---|
22 | # |
---|
23 | # In this log, you can see stdout and stderr of ``script_correc.m`` and |
---|
24 | # timing statistics of the run. |
---|
25 | # |
---|
26 | # EXAMPLES |
---|
27 | # ======== |
---|
28 | # |
---|
29 | # To run ``script_correc.m`` with matlab : |
---|
30 | # |
---|
31 | # :: |
---|
32 | # |
---|
33 | # $ ./script_correc.sh -a matlab |
---|
34 | # |
---|
35 | # |
---|
36 | # To run script_correc.m with octave |
---|
37 | # |
---|
38 | # :: |
---|
39 | # |
---|
40 | # $ ./script_correc.sh -a octave |
---|
41 | # |
---|
42 | # |
---|
43 | # SEE ALSO |
---|
44 | # ======== |
---|
45 | # |
---|
46 | # tp_mlp_aerosols_profile.sh_ |
---|
47 | # |
---|
48 | # .. _tp_mlp_aerosols_profile.sh: tp_mlp_aerosols_profile.sh.html |
---|
49 | # |
---|
50 | # script_correc.m_ |
---|
51 | # |
---|
52 | # .. _script_correc.m: script_correc.m.html |
---|
53 | # |
---|
54 | # |
---|
55 | # TODO |
---|
56 | # ==== |
---|
57 | # |
---|
58 | # suppress figure on screen using octave |
---|
59 | # |
---|
60 | # use init_file option with tp_mlp_aerosols_startup.m (or check link |
---|
61 | # on .octaverc or .matlabrc) |
---|
62 | # |
---|
63 | # move this tool in an administration part |
---|
64 | # |
---|
65 | # write tp_mlp_aerosols_profile.sh |
---|
66 | # |
---|
67 | # ok on windows ? |
---|
68 | # |
---|
69 | # EVOLUTIONS |
---|
70 | # ========== |
---|
71 | # |
---|
72 | # $Id$ |
---|
73 | # |
---|
74 | # - fplod 2009-08-19T14:58:54Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
75 | # |
---|
76 | # * creation |
---|
77 | # |
---|
78 | #- |
---|
79 | system=$(uname) |
---|
80 | case "${system}" in |
---|
81 | AIX|IRIX64) |
---|
82 | echo " www : no specific posix checking" |
---|
83 | ;; |
---|
84 | *) |
---|
85 | set -o posix |
---|
86 | ;; |
---|
87 | esac |
---|
88 | # |
---|
89 | command=$(basename ${0}) |
---|
90 | log_date=$(date -u +"%Y%m%dT%H%M%SZ") |
---|
91 | # |
---|
92 | # |
---|
93 | TP_MLP_AEROSOLS_LOG=/usr/temp/${LOGNAME}/ |
---|
94 | mkdir -p ${TP_MLP_AEROSOLS_LOG} |
---|
95 | TP_MLP_AEROSOLS=/usr/temp/fplod/tp_mlp_aerosols_ws/ |
---|
96 | # |
---|
97 | usage=" Usage : ${command} -a application" |
---|
98 | # |
---|
99 | # default |
---|
100 | application=octave |
---|
101 | minargcount=2 |
---|
102 | if [ ${#} -lt ${minargcount} ] |
---|
103 | then |
---|
104 | echo "eee : not enought arguments" |
---|
105 | echo "${usage}" |
---|
106 | exit 1 |
---|
107 | fi |
---|
108 | # |
---|
109 | while [ ! -z "${1}" ] |
---|
110 | do |
---|
111 | case ${1} in |
---|
112 | -a) |
---|
113 | application=${2} |
---|
114 | shift |
---|
115 | ;; |
---|
116 | *) # anything else |
---|
117 | echo "eee : ${usage}" |
---|
118 | exit 1 |
---|
119 | ;; |
---|
120 | esac |
---|
121 | shift # next flag |
---|
122 | done |
---|
123 | # |
---|
124 | set -u |
---|
125 | # |
---|
126 | log=${TP_MLP_AEROSOLS_LOG}/$(basename ${command} .sh).log.${log_date} |
---|
127 | echo "command = ${command}" 1>> ${log} |
---|
128 | echo "runtime = ${log_date}" 1>> ${log} |
---|
129 | echo "hostname = $(hostname)" 1>> ${log} |
---|
130 | echo "application = ${application}" 1>> ${log} |
---|
131 | # test if application available |
---|
132 | tool=${application} |
---|
133 | type ${tool} 1> /dev/null 2>&1 |
---|
134 | status=${?} |
---|
135 | if [ ${status} -ne 0 ] |
---|
136 | then |
---|
137 | echo " eee : ${tool} not found" |
---|
138 | exit 1 |
---|
139 | fi |
---|
140 | unset status |
---|
141 | # |
---|
142 | script_base=${TP_MLP_AEROSOLS}/private/script_correc.m |
---|
143 | script=${TP_MLP_AEROSOLS_LOG}/script.m |
---|
144 | # |
---|
145 | rm ${script} 2> /dev/null |
---|
146 | # |
---|
147 | { |
---|
148 | echo "addpath('../toolbox')" |
---|
149 | echo "tp_mlp_aerosols_startup" |
---|
150 | echo "more off" |
---|
151 | echo "script_correc" |
---|
152 | echo "quit" |
---|
153 | } > ${script} |
---|
154 | # |
---|
155 | cd $(dirname ${script_base}) |
---|
156 | # |
---|
157 | case ${application} in |
---|
158 | matlab) |
---|
159 | time matlab -nojvm -nosplash -nodisplay < ${script} 1>> ${log} 2>&1 |
---|
160 | ;; |
---|
161 | octave) |
---|
162 | time octave --silent ${script} 1>> ${log} 2>&1 |
---|
163 | ;; |
---|
164 | esac |
---|
165 | # |
---|
166 | for file in ./*.eps |
---|
167 | do |
---|
168 | mv ${file} ${TP_MLP_AEROSOLS_LOG}/${file}.${application}_$(hostname)_${log_date}.eps |
---|
169 | done |
---|
170 | # |
---|
171 | rm ${script} 2> /dev/null |
---|
172 | exit |
---|