source: trunk/getmodelout.sh @ 42

Last change on this file since 42 was 42, checked in by pinsard, 14 years ago

improvements of headers and unset in shell scripts

  • Property svn:executable set to *
  • Property svn:keyword set to Id
File size: 2.6 KB
Line 
1#! /bin/sh
2#
3#+
4# ==============
5# getmodelout.sh
6# ==============
7#
8# ------------------------------------------
9# get model data output file in ${GEOMAG_ID}
10# ------------------------------------------
11#
12# SYNOPSIS
13# ========
14#
15# ::
16#
17#  $ getmodelout.sh -r orcares -exp drakkar_exp -g grid -yearmin yyyy -yearmax yyyy -o list
18#
19# DESCRIPTION
20# ===========
21#
22# get model data output file in ${GEOMAG_ID}
23#
24# EXAMPLES
25# ========
26#
27# To get DRAKKAR G42 experiment output on grid T points beteween year 9 and 10::
28#
29#  $ getmodelout.sh -r ORCA025 -exp G42 -g gridT -yearmin 9 -yearmax 10 -o ${GEOMAG_OD}/list_G42
30#
31# EVOLUTIONS
32# ==========
33#
34# $Id$
35#
36# - fplod 20100318T073947Z aedon.locean-ipsl.upmc.fr (Darwin)
37#
38#   * unset
39#
40# - reee522 2007-11-26T11:21:37Z rhodes (IRIX64)
41#
42#   * creation
43#-
44#
45command=getmodelout.sh
46#
47usage=" Usage : ${command} -r orcares -exp drakkar_exp -g grid -o list"
48#
49while [ ! -z "${1}" ] # ++ pb bash
50do
51 case ${1} in
52 -r)
53    orcares=${2}
54    shift
55 ;;
56 -exp)
57    drakkar_exp=${2}
58    shift
59 ;;
60 -g)
61    grid=${2}
62    shift
63 ;;
64 -yearmin)
65   yearmin=${2}
66   shift
67 ;;
68 -yearmax)
69   yearmax=${2}
70   shift
71 ;;
72 -o)
73   list=${2}
74   shift
75 ;;
76 *) # other choice
77   echo "eee : unknown option ${1}"
78   echo "${usage}"
79 ;;
80 esac
81 shift # next flag
82done
83unset usage
84#
85set -u
86#
87# check GEOMAG environement
88if [ ! -d ${GEOMAG_LOG} ]
89then
90 echo " eee : \${GEOMAG_LOG} not found"
91 exit 1
92fi
93#
94if [ -f ${list} ]
95then
96  echo "eee : ${list} exist"
97  exit 1
98fi
99# ++ blindage en tout genre
100#
101case ${orcares} in
102ORCA025)
103   dirref=/u/rech/cli/rcli002/ # sur l'idris
104;;
105*)
106   echo "eee : pb \${orcares} = ${orcares}"
107;;
108esac
109#
110listfull=${GEOMAG_LOG}/lisfull${$}
111#
112iyear=${yearmin}
113while [ ${iyear} -le ${yearmax} ]
114do
115  cyear=`printf "%4.4d" ${iyear}`
116  ls ${dirref}/${orcares}/${orcares}-${drakkar_exp}-S/${cyear}/${orcares}-${drakkar_exp}_y${cyear}m??d??_${grid}.nc >> ${listfull}
117  unset cyear
118  # ++ calcul taille cf myls dans faq es dods
119  # iyear=$(( ${iyear} + 1 )) ++ pas ok sur rhodes
120  # iyear=$(expr  ${iyear} + 1 )  ++ pas ok sur rhodes
121  iyear=`expr  ${iyear} + 1 `
122done
123unset iyear
124unset dirref
125unset orcares
126unset drakkar_exp
127unset grid
128#
129# print total size of model files
130# ++ pb syntaxe unitsop="1024**2" # Mo
131#ls -l `cat ${listfull}` | \
132#awk 'NF>4 {print $5, $9}' | \
133#awk 'sum=$1/'$unitsop'+sum {printf("%08.3f '$units' -- %s\n",$1/'$unitsop', $2)}
134#
135# put files in ${GEOMAG_ID}
136# ++ ln cp ou scp
137# ++ -f ou test si deja existant
138for file in  `cat ${listfull}`
139do
140  ln -sf ${file} ${GEOMAG_ID}
141  echo ${GEOMAG_ID}/`basename ${file}` >> ${list}
142done
143unset listfull
144#
145# end
146exit 0
Note: See TracBrowser for help on using the repository browser.