New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
std_main_5D.sh in branches/2014/dev_r4650_UKMO14.11_SETTE_OBSASM/NEMOGCM/CONFIG/ORCA2_LIM_OBS/IDL_scripts – NEMO

source: branches/2014/dev_r4650_UKMO14.11_SETTE_OBSASM/NEMOGCM/CONFIG/ORCA2_LIM_OBS/IDL_scripts/std_main_5D.sh @ 4751

Last change on this file since 4751 was 4751, checked in by djlea, 10 years ago

Changes to include an OBS test in SETTE. At the moment this uses an example profile observation.

  • Property svn:executable set to *
File size: 6.2 KB
Line 
1#!/bin/sh
2#+
3#
4# .. program:: std_main_5D.sh
5#
6# ================
7# std_main.sh
8# ================
9#
10# -------------------------------------
11# launch idl scripts to produce graphics diagnostics in Postscript, PDF or HTML document
12# for output of 5days for 1 year run
13# nota: it is like std_main.sh but it calls routins for 5days
14# -------------------------------------
15#
16# SYNOPSIS
17# ========
18#
19# ``std_main_5D.sh -ts`` or ``std_main_5D.sh -plot``
20#
21# DESCRIPTION
22# ===========
23#
24# .. option:: -ts    to produce time series
25# .. option:: -plot  to produce maps and sections
26# .. option:: -html  to produce html document
27# .. option:: -pdf   to produce pdf document
28# .. option:: -noidl to skip the call to IDL and the production of Postscript
29# .. option:: -vm    to use IDL virtual machine (free) instead of IDL
30# .. option:: -help  to get help!
31#
32# variables have to be defined in std_plot_vardef.sh (or std_ts_vardef.sh)
33# before calling std_main_5D.sh -plot
34#
35# EXAMPLES
36# ========
37# $ ./std_main_5D.sh -plot -pdf
38#
39# AUTHOR - date
40# ===========
41# Françoise Pinsard - 01/2010 - LOCEAN
42# Simona Flavoni    - 01/2010 - LOCEAN
43# Sebastien Masson  - 04/2011 - LOCEAN
44#
45#-----------------------------------------------------------
46# Usage...
47#-----------------------------------------------------------
48#
49#-
50system=$(uname)
51case "${system}" in
52   AIX|IRIX64)
53      echo " www : no specific posix checking"
54   ;;
55   *)
56      set -o posix
57   ;;
58esac
59#
60usage="Usage: std_main_5D.sh [OPTION]
61Options
62 -ts    to produce time series
63 -plot  to produce maps and sections
64 -html  to produce html document
65 -pdf   to produce pdf document
66 -noidl to skip the call to IDL and the production of Postscript
67 -vm    to use IDL virtual machine (free) instead of IDL
68 -help  to get this help
69"
70#
71vm=0
72noidl=0
73format=ps
74while [ ! -z "${1}" ]
75do
76    case ${1} in
77   -plot|--plot) PLOTTYPE=plot ;;
78   -ts|--ts) PLOTTYPE=ts ;;
79   -f|-format|--format) format=${2}   shift   ;;
80   -html|--html) format=html ;;
81   -pdf|--pdf) format=pdf ;;
82   -h|-help|--help) 
83       echo "${usage}"
84       exit
85       ;;
86   -ni|--ni|-noidl|--noidl) noidl=1 ;;
87   -vm|--vm|-virtual_machine|--virtual_machine) vm=1 ;;
88   *) # other choice
89       echo "${usage}"
90       exit 1
91       ;;
92    esac
93    shift # next flag
94done
95#
96PLOTTYPE=${PLOTTYPE:-NG}
97if [[ ( "$PLOTTYPE" != "plot" ) && ( "$PLOTTYPE" != "ts" ) ]]
98then
99    echo 'the type of plot must be defined with the option -plot or -ts'
100   exit 1
101fi
102export PLOTTYPE
103#
104set -u
105#
106#
107tstexe () {
108    type ${1}
109    status_type=${?}
110    if [ ${status_type} -ne 0 ]
111    then
112   echo "eee : ${2}"
113   exit 1
114    fi
115}
116#
117#-----------------------------------------------------------
118# define output directory for POSTCRIPT files
119#-----------------------------------------------------------
120#
121. ./std_${PLOTTYPE}_vardef.sh
122[ ! -d ${PS_DIR} ] && mkdir -p ${PS_DIR}
123#
124#-----------------------------------------------------------
125# run IDL
126#-----------------------------------------------------------
127#
128if [ $noidl -eq 0 ]
129then
130    tstexe ${idl_command} "idl not found"
131#
132    if [ $vm -eq 1 ]
133    then
134   ${idl_command} -vm=std_main.sav
135    else 
136   ${idl_command} -IDL_STARTUP 'initenv' << EOF
137std_${PLOTTYPE}_all_last_year_5D, /postscript
138EOF
139    fi
140    status_idl=${?}
141    if [ ${status_idl} -ne 0 ]
142    then
143   echo "eee : error in the execution of IDL"
144   exit 1
145    fi
146fi
147#
148#-----------------------------------------------------------
149# produce the final document
150#-----------------------------------------------------------
151#
152# build the list of ps that has been created by IDL
153pslist=$( grep "img width" ${PS_DIR}/std_${PLOTTYPE}_html_body.txt | sed -e "s/.*src=\(.*\)png.*/\1/" )
154#
155case ${format} in
156#__________________________________________________________
157# PDF
158    pdf)
159# check if ps2pdf available
160   ps2pdf_command=$( which ps2pdf )
161   tstexe ${ps2pdf_command} "ps2pdf not found"
162# check if texexec available
163   texexec_command=$( which texexec )
164   tstexe ${texexec_command} "texexec not found"
165#
166   filepdf=all_${PLOTTYPE}.pdf
167   [ ! -d ${PDF_DIR} ] && mkdir -p ${PDF_DIR}
168   pdflist=''
169   for file in ${pslist} ; do
170       ps2pdf -sPAPERSIZE=a4 ${PS_DIR}/${file}ps ${PDF_DIR}/${file}pdf
171       echo "ps2pdf ${file}ps done"
172       pdflist=${pdflist}' '${PDF_DIR}/${file}pdf
173   done
174#pdfjam needed to use pdfjoin
175   pdfjoin ${pdflist} --outfile $PDF_DIR/${filepdf}
176   texexec --pdfarrange --result=$PDF_DIR/$filepdf $pdflist
177   rm -f $PDF_DIR/$( basename $filepdf .pdf ).aux $PDF_DIR/$( basename $filepdf .pdf ).log
178   if [ ! -e ${PDF_DIR}/$filepdf ]
179   then
180           echo "\n ATTENTION !!!!! \n"
181                echo "${PDF_DIR}/$filepdf do not exist \n"
182        else
183                 echo "${PDF_DIR}/$filepdf done"
184       fi
185#commented because convert gives images of bad quality
186#  convert ${PS_DIR}/*.ps /tmp/all_${PLOTTYPE}.pdf
187#       convert -resize 800x600 ${PS_DIR}/${exp1}_${exp2}/ps/*.ps /tmp/all_${PLOTTYPE}.pdf
188   ;;
189#__________________________________________________________
190# HTML
191    html)
192   filehtml=all_${PLOTTYPE}.html
193   [ ! -d ${HTML_DIR} ] && mkdir -p ${HTML_DIR}
194# check if convert available
195   convert_command=$( which convert )
196   tstexe ${convert_command} "convert not found"
197# convert each ps to png   
198   for file in ${pslist} ; do
199       ${convert_command} -antialias ${PS_DIR}/${file}ps ${HTML_DIR}/${file}png
200   done
201# creation of the HTML file
202   cat << EOF > ${HTML_DIR}/$filehtml
203<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
204<html xmlns="http://www.w3.org/1999/xhtml">
205<head>
206<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
207</head>
208<body>
209EOF
210   cat ${PS_DIR}/std_${PLOTTYPE}_html_body.txt >>  ${HTML_DIR}/$filehtml
211   cat << EOF >> ${HTML_DIR}/$filehtml
212<hr>
213</body>
214</html>
215EOF
216   echo ${HTML_DIR}/$filehtml done
217   ;;
218    ps)  ;; # nothing to do...
219    *)   
220   echo " format ${format} not implemented"
221   exit 1
222   ;;
223esac
224
225    #
226#=====================
227# prepare to put images on dods
228# +++ to finish it
229#LOGIN=xxxx
230#Tag_Name=ORCA2_LIM2
231#rsh ${LOGIN}@gaya.idris.fr exec /bin/ksh <<EOF
232#       cd ${homegaya}/IGCM_OUT/${Tag_Name}/CORE2/INTERAN/${PLOTTYPE}_pdf/${exp1}
233#       /usr/local/bin/dods_rm DODS/pub/${LOGIN}/${Tag_Name}/CORE2/INTERAN/${PLOTTYPE}_pdf/${exp1} > /dev/null 2>&1
234#       /usr/local/bin/dods_cp ${exp1} DODS/pub/${LOGIN}/${Tag_Name}/CORE2/INTERAN/${PLOTTYPE}_pdf/${exp1} > /dev/null 2>&1
235#EOF
236#=====================
237# end
238exit 0
Note: See TracBrowser for help on using the repository browser.