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_plots.sh in trunk/NEMOGCM/CONFIG/ORCA2_LIM/IDL_scripts – NEMO

source: trunk/NEMOGCM/CONFIG/ORCA2_LIM/IDL_scripts/std_plots.sh @ 2557

Last change on this file since 2557 was 2528, checked in by rblod, 13 years ago

Update NEMOGCM from branch nemo_v3_3_beta

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 5.0 KB
Line 
1#!/bin/sh
2#
3# AUTHOR - date
4# ===========
5# Françoise Pinsard - 01/2010 - LOCEAN
6# Simona Flavoni  - 01/2010 - LOCEAN
7#
8# DESCRIPTION
9# ===========
10# Graphics outputs files are written in ./exp1_exp2/ps/.
11#
12# A global document with all plots in Postscript, PDF or HTML file can be produced.
13#
14# EXAMPLES
15# ========
16# $ ./std_plots.sh -exp1 v32colib -exp2 v32colib -y 19800101_19801231 -format html
17#
18# $ ./std_plots.sh -exp1 core100 -exp2 core100 -y 00910101_01001231 -format pdf
19#
20# PROBLEMS
21# ========
22# no batch processing possible because of SAXO interactiviy Seb is working on it ...
23#
24# TODO
25# ====
26# portability on linux
27# define overriding policy
28# finalize ps and pdf production
29#
30usage=" Usage : ${command} -exp1 exp1 -exp2 exp2 -y start -format html
31 example:  ./std_plots.sh -exp1 core2000 -exp2 core2000 -y 1991 -format pdf
32 exp1 is your experience name
33 exp2 is the reference experience (if you don't have one exp2 = exp1)
34 ystart is the first year of your 10years file output; example: 361 if you want to take file core2000_03610101_03701231_1Y_grid_T.nc"
35#
36minargcount=8
37if [ ${#} -lt ${minargcount} ]; then
38 echo "Not enought arguments"
39 echo "${usage}"
40 exit 1
41fi
42#
43while [ ! -z "${1}" ] # ++ pb bash
44do
45 case ${1} in
46     -exp1)  exp1=${2}        shift  ;;
47     -exp2)  exp2=${2}        shift  ;;
48     -y)  ystart=${2}     shift   ;;
49     -format)   format=${2}     shift   ;;
50     -h) 
51    echo "${usage}"
52    exit
53    ;;
54     *) # other choice
55    echo "${usage}"
56    exit 1
57    ;;
58 esac
59 shift # next flag
60done
61#
62# ++ check parameters
63set -u
64#
65# define output directory for POSTCRIPT files
66#++ change directory
67#===============CHANGE DIRECTORIES==========================
68psdir=~/PS/${exp1}_${exp2}/ps/
69pdfdir=~/PDF/${exp1}_${exp2}/pdf
70htmldir=~/HTML/${exp1}_${exp2}/pdf
71#===============END CHANGE DIRECTORIES=======================
72# test if ${psdir} already exists
73if [ -d ${psdir} ]; then
74 echo "${psdir} already exist"
75 #+++exit 1
76else
77 mkdir -p ${psdir}
78fi 
79# test if ${pdfdir} already exists
80if [ -d ${pdfdir} ]; then
81 echo "${psdir} already exist"
82 #+++exit 1
83else
84 mkdir -p ${pdfdir}
85fi 
86
87# memorize current IDL_STARTUP file
88memo_idl_startup=${IDL_STARTUP}
89
90# generation of IDL commands file to launch several std_plots commands
91# NOTE:  $(( 10#${ystart} )) is used to have decimal, if not the number that start with 0 (for example if you put 0361) would be interpeted like alphanumerical number
92rm /tmp/std_plots_multi.pro 2> /dev/null
93cat << EOF >> /tmp/std_plots_multi.pro
94 psdir='${psdir}'
95 std_plots,'${exp1}','${exp2}', $(( 10#${ystart} )), /postscript
96 exit
97EOF
98#
99idl_command='/Applications/itt/idl64/bin/idl'  # !! only on my mac
100#
101# check if IDL available
102type ${idl_command}
103status_type=${?}
104if [ ${status_type} -ne 0 ]
105then
106 echo "eee : idl not found"
107 exit 1
108fi
109# debug
110more /tmp/std_plots_multi.pro
111#
112# launch IDL
113${idl_command} /tmp/std_plots_multi.pro
114status_idl=${?}
115# test if idl returns ok
116#echo "iii : ${status_idl}"
117#
118# restore IDL_STARTUP file
119IDL_STARTUP=${memo_idl_startup}
120export IDL_STARTUP
121
122# produce the final document
123case ${format} in
124    pdf)
125   rm ${pdfdir}/all_plots.pdf 2> /dev/null
126   for file in ${psdir}/*.ps ; do
127       echo "ps2pdf"
128#           echo "nome file: ${file}"
129      ps2pdf -sPAPERSIZE=a4 ${file}
130   done
131#  echo "dentro pdf"
132   ls ${pdfdir}
133   mv *.pdf ${pdfdir}/.
134   texexec --pdfarrange --result=/tmp/all_plots.pdf ${pdfdir}/*.pdf
135   rm -rf *.aux *.log /tmp/*.log
136   mv /tmp/all_plots.pdf ${pdfdir}
137#commented because convert gives images of bad quality
138#  convert ${psdir}/*.ps /tmp/all_plots.pdf
139#       convert -resize 800x600 ${psdir}/${exp1}_${exp2}/ps/*.ps /tmp/all_plots.pdf
140   ;;
141    html)
142   rm /tmp/std_plots.html 2> /dev/null
143# check if convert available
144   convert_command='/sw/bin/convert'  # !! only on my mac
145   type ${convert_command}
146   status_type=${?}
147   if [ ${status_type} -ne 0 ]
148   then
149       echo "eee : convert not found"
150       exit 1
151   fi
152# debug
153   
154   for file in `ls ${psdir}/*.ps | sed -e "s/\.ps//"` ; do
155       ${convert_command} -antialias  ${file}.ps  ${file}.png
156   done
157    # creation of a HTML file
158   cat << EOF > /tmp/std_plots.html
159   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
160   <html xmlns="http://www.w3.org/1999/xhtml">
161   <head>
162   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
163        <hr>
164         </head>
165   <body>
166EOF
167   cat /tmp/std_plots.txt >>  /tmp/std_plots.html
168   cat << EOF >> /tmp/std_plots.html
169<hr/>
170EOF
171   
172   cat << EOF >> /tmp/std_plots.html
173
174  </body>
175  </html>
176EOF
177   more /tmp/std_plots.html
178   ;;
179    *)   
180   echo " format ${format} not implemented"
181   exit 1
182   ;;
183esac
184
185    #
186#=====================
187# prepare to put images on dods
188# +++ to finish it
189#LOGIN=xxxx
190#Tag_Name=ORCA2_LIM2
191#rsh ${LOGIN}@gaya.idris.fr exec /bin/ksh <<EOF
192#       cd ${homegaya}/IGCM_OUT/${Tag_Name}/CORE2/INTERAN/plots_pdf/${exp1}
193#       /usr/local/bin/dods_rm DODS/pub/${LOGIN}/${Tag_Name}/CORE2/INTERAN/plots_pdf/${exp1} > /dev/null 2>&1
194#       /usr/local/bin/dods_cp ${exp1} DODS/pub/${LOGIN}/${Tag_Name}/CORE2/INTERAN/plots_pdf/${exp1} > /dev/null 2>&1
195#EOF
196#=====================
197# end
198exit 0
Note: See TracBrowser for help on using the repository browser.