source: trunk/private/script_correc.sh @ 23

Last change on this file since 23 was 19, checked in by pinsard, 15 years ago

add tool to run script_correc.m and save stdout, stderr and figures

  • Property svn:executable set to *
File size: 3.2 KB
Line 
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#-
79system=$(uname)
80case "${system}" in
81AIX|IRIX64)
82  echo " www : no specific posix checking"
83;;
84*)
85  set -o posix
86;;
87esac
88#
89command=$(basename ${0})
90log_date=$(date -u +"%Y%m%dT%H%M%SZ")
91#
92#
93TP_MLP_AEROSOLS_LOG=/usr/temp/${LOGNAME}/
94mkdir -p ${TP_MLP_AEROSOLS_LOG}
95TP_MLP_AEROSOLS=/usr/temp/fplod/tp_mlp_aerosols_ws/
96#
97usage=" Usage : ${command} -a application"
98#
99# default
100application=octave
101minargcount=2
102if [ ${#} -lt ${minargcount} ]
103then
104  echo "eee : not enought arguments"
105  echo "${usage}"
106  exit 1
107fi
108#
109while [ ! -z "${1}" ]
110do
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
122done
123#
124set -u
125#
126log=${TP_MLP_AEROSOLS_LOG}/$(basename ${command} .sh).log.${log_date}
127echo "command = ${command}" 1>> ${log}
128echo "runtime = ${log_date}" 1>> ${log}
129echo "hostname = $(hostname)" 1>> ${log}
130echo "application = ${application}" 1>> ${log}
131# test if application available
132tool=${application}
133type ${tool} 1> /dev/null 2>&1
134status=${?}
135if [ ${status} -ne 0 ]
136then
137 echo " eee : ${tool} not found"
138 exit 1
139fi
140unset status
141#
142script_base=${TP_MLP_AEROSOLS}/private/script_correc.m
143script=${TP_MLP_AEROSOLS_LOG}/script.m
144#
145rm ${script} 2> /dev/null
146#
147{
148echo "addpath('../toolbox')"
149echo "tp_mlp_aerosols_startup"
150echo "more off"
151echo "script_correc"
152echo "quit"
153} > ${script}
154#
155cd $(dirname ${script_base})
156#
157case ${application} in
158matlab)
159 time matlab -nojvm -nosplash -nodisplay <  ${script}  1>> ${log} 2>&1
160;;
161octave)
162 time octave --silent ${script} 1>> ${log} 2>&1
163;;
164esac
165#
166for file in ./*.eps
167do
168 mv ${file} ${TP_MLP_AEROSOLS_LOG}/${file}.${application}_$(hostname)_${log_date}.eps
169done
170#
171rm ${script} 2> /dev/null
172exit
Note: See TracBrowser for help on using the repository browser.