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_1Y.sh in NEMO/branches/2019/dev_r11842_SI3-10_EAP/cfgs/ORCA2_ICE_PISCES/IDL_scripts – NEMO

source: NEMO/branches/2019/dev_r11842_SI3-10_EAP/cfgs/ORCA2_ICE_PISCES/IDL_scripts/std_main_1Y.sh @ 11843

Last change on this file since 11843 was 7732, checked in by flavoni, 7 years ago

commit idl scripts deleted

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