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.sh in branches/2013/dev_MERGE_2013/NEMOGCM/CONFIG/ORCA2_LIM/IDL_scripts – NEMO

source: branches/2013/dev_MERGE_2013/NEMOGCM/CONFIG/ORCA2_LIM/IDL_scripts/std_main.sh @ 4320

Last change on this file since 4320 was 4320, checked in by flavoni, 10 years ago

update IDL_scripts for ORCA2_LIM and ORCA2_LIM3, add plot of max_mld output 5days, see ticket: #724

  • Property svn:executable set to *
File size: 6.2 KB
RevLine 
[2709]1#!/bin/sh
[2751]2#+
[2709]3#
[2751]4# .. program:: std_main.sh
[2709]5#
[2751]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#
[2709]19# DESCRIPTION
20# ===========
21#
[2751]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#
[2709]33# EXAMPLES
34# ========
[2751]35# $ ./std_main.sh -ts html
36# $ ./std_main.sh -ts pdf -noidl
[2709]37#
[2751]38# $ ./std_main.sh -plot -pdf -vm
[2709]39#
[2751]40# AUTHOR - date
41# ===========
42# Françoise Pinsard - 01/2010 - LOCEAN
43# Simona Flavoni    - 01/2010 - LOCEAN
44# Sebastien Masson  - 04/2011 - LOCEAN
[2709]45#
[2751]46#-----------------------------------------------------------
47# Usage...
48#-----------------------------------------------------------
[2709]49#
[2751]50#-
51system=$(uname)
52case "${system}" in
53   AIX|IRIX64)
54      echo " www : no specific posix checking"
55   ;;
56   *)
57      set -o posix
58   ;;
59esac
[2709]60#
[2751]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"
[2709]71#
[2751]72vm=0
73noidl=0
74format=ps
75while [ ! -z "${1}" ]
[2709]76do
[2751]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
[2709]95done
96#
[2751]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#
[2709]105set -u
106#
[2751]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#-----------------------------------------------------------
[2709]119# define output directory for POSTCRIPT files
[2751]120#-----------------------------------------------------------
[2709]121#
[2751]122. ./std_${PLOTTYPE}_vardef.sh
123[ ! -d ${PS_DIR} ] && mkdir -p ${PS_DIR}
[2709]124#
[2751]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
[2709]147fi
148#
[2751]149#-----------------------------------------------------------
150# produce the final document
151#-----------------------------------------------------------
[2709]152#
[2751]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#
[2709]156case ${format} in
[2751]157#__________________________________________________________
158# PDF
[2709]159    pdf)
[2751]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
[2709]174   done
[4320]175#pdfjam needed to use pdfjoin
176   pdfjoin ${pdflist} --outfile $PDF_DIR/${filepdf}
[2751]177   texexec --pdfarrange --result=$PDF_DIR/$filepdf $pdflist
178   rm -f $PDF_DIR/$( basename $filepdf .pdf ).aux $PDF_DIR/$( basename $filepdf .pdf ).log
[4320]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
[2709]186#commented because convert gives images of bad quality
[2751]187#  convert ${PS_DIR}/*.ps /tmp/all_${PLOTTYPE}.pdf
188#       convert -resize 800x600 ${PS_DIR}/${exp1}_${exp2}/ps/*.ps /tmp/all_${PLOTTYPE}.pdf
[2709]189   ;;
[2751]190#__________________________________________________________
191# HTML
[2709]192    html)
[2751]193   filehtml=all_${PLOTTYPE}.html
194   [ ! -d ${HTML_DIR} ] && mkdir -p ${HTML_DIR}
[2709]195# check if convert available
[2751]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
[2709]201   done
[2751]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>
[2709]210EOF
[2751]211   cat ${PS_DIR}/std_${PLOTTYPE}_html_body.txt >>  ${HTML_DIR}/$filehtml
212   cat << EOF >> ${HTML_DIR}/$filehtml
213<hr>
214</body>
215</html>
[2709]216EOF
[2751]217   echo ${HTML_DIR}/$filehtml done
[2709]218   ;;
[2751]219    ps)  ;; # nothing to do...
[2709]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
[2751]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
[2709]236#EOF
237#=====================
238# end
239exit 0
Note: See TracBrowser for help on using the repository browser.