source: trunk/getmodelout.sh @ 48

Last change on this file since 48 was 48, checked in by pinsard, 10 years ago

fix thanks to coding rules

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