source: trunk/SRC/Obsolete/meshlec.pro

Last change on this file was 487, checked in by smasson, 11 years ago

bugfix to be used in batch mode

  • Property svn:keywords set to Id
File size: 14.5 KB
Line 
1;+
2;
3; @file_comments
4; lecture du mask des sorties d'OPA. les sources se trouvent ds les
5; repertoires sur maia du type:
6; /nom_exp/RESTARTS
7;
8; @obsolete
9;
10; @examples
11;
12;   IDL> meshmask[,' nomfich']
13;
14; @param nomfich {in}{required}
15; string, c''est le nom du fichier a lire. Par defaut, c''est meshmask.
16;
17; @keyword GLAMBOUNDARY {in}
18; un vecteur de 2 elements specifaint le min et le
19; max qui doivent etre imposes en longitude (obligatoire si le
20; tableau depasse 360 degres)
21;
22; @keyword PASBLABLA {in}
23; pour supprimer les blablas
24;
25; @keyword DOUBLE {in}
26; pour forcer a lire les tableaux en double
27;        precision. ce Mot clef est maintenant active
28;        automatiquement.
29;
30; @keyword GETDIMENSIONS
31;
32; @uses
33; <pro>common</pro>
34;
35; @restrictions
36;  La definition de ixminmesh,ixmaxmesh,iyminmesh,iymaxmesh
37;  ,izminmesh,izmaxmesh doit etre faite avant l''entree dans cette
38;  routine. pour attribuer automatiquement ces valeurs au maximum
39;  possible les mettre toutes a -1 et meshlec les calculera.
40;
41; @history
42; Sebastien Masson (smasson\@lodyc.jussieu.fr)
43;     Marina Levy : lecture en double precision (cas calcul sur shine)
44;
45; @version
46; $Id$
47;
48;-
49PRO meshlec, nomfich, PASBLABLA=pasblabla, DOUBLE=double $
50           , GLAMBOUNDARY=glamboundary, GETDIMENSIONS=GETDIMENSIONS
51;
52  compile_opt idl2, strictarrsubs, obsolete
53;
54@common
55   tempsun = systime(1)         ; pour key_performance
56;---------------------------------------------------------
57;---------------------------------------------------------
58   jpiglo      = 0L
59   jpjglo      = 0L
60   jpkglo      = 0L
61   tab    = 'aaaaa'
62;---------------------------------------------------------
63;  definition du domaine de la grille sur lequel sont
64;  effectuees les sorties.les indices des tableaux commencant
65;  a 1: cf le fichier wrivr2.F ds WKOPA sur le cray
66;----------------------------------------------------------
67; LECTURE DU MASK trouve ds les fichiers restart
68;----------------------------------------------------------
69;----------------------------------------------------------
70;
71;----------------------------------------------------------
72;       constitution de l'adresse s_fichier et
73;     ouverture du fichier a l'adresse s_fichier
74;-------------------------------------------------------
75
76   IF n_params() EQ 0 then nomfich = 'meshmask'
77   s_fichier = isafile(file = nomfich, iodir = iodir)
78   if not keyword_set(pasblabla) then print, ' '
79   if not keyword_set(pasblabla) then print,'adresse du fichier: ',s_fichier
80
81   openr, numlec, s_fichier, /get_lun, /f77_unformatted, /swap_if_little_endian
82   filepamameters = fstat(numlec)
83;---------------------------------------------------------
84;     lecture
85;---------------------------------------------------------
86   readu, numlec, jpiglo, jpjglo, jpkglo
87   if not keyword_set(pasblabla) then print, 'taille de la grille d''origine: ',jpiglo,', ',jpjglo,', ',jpkglo
88;
89   if keyword_set(getdimensions) then begin
90      free_lun,numlec
91      close, numlec
92      return
93   endif
94
95;---------------------------------------------------------
96; on determine si le fichier a ete ecrit en double precision on non...
97   sizenumber = 8l
98   sizefile8 = 4l+3l*4l+4l $
99    +4l*(4l+jpiglo*jpjglo*sizenumber+4l) $
100    +4l*(4l+jpiglo*jpjglo*sizenumber+4l) $
101    +4l*(4l+jpiglo*jpjglo*sizenumber+4l) $
102    +4l*(4l+jpiglo*jpjglo*sizenumber+4l) $
103    +4l*(4l+jpiglo*jpjglo*jpkglo*sizenumber+4l) $
104    +1l*(4l+jpiglo*jpjglo*sizenumber+4l) $
105    +4l*(4l+jpkglo*sizenumber+4l)
106   if filepamameters.size GE sizefile8 THEN double = 1
107;    sizenumber = 4l
108;    sizefile4 = 4l+3l*4l+4l $
109;     +4l*(4l+jpiglo*jpjglo*sizenumber+4l) $
110;     +4l*(4l+jpiglo*jpjglo*sizenumber+4l) $
111;     +4l*(4l+jpiglo*jpjglo*sizenumber+4l) $
112;     +4l*(4l+jpiglo*jpjglo*sizenumber+4l) $
113;     +4l*(4l+jpiglo*jpjglo*jpkglo*sizenumber+4l) $
114;     +1l*(4l+jpiglo*jpjglo*sizenumber+4l) $
115;     +4l*(4l+jpkglo*sizenumber+4l)
116; print, filepamameters.size,  sizefile4,  sizefile8
117;    case filepamameters.size of
118;       sizefile8:double = 1
119;       sizefile4:double = 0
120;       ELSE:BEGIN
121;          nothing = report('The OPA Mesh file as not the good size!')
122;          free_lun,numlec
123;          close, numlec
124;          return
125;       END
126;    endcase
127;
128;
129   if n_elements(ixminmesh) EQ 0 THEN ixminmesh = 0
130   if n_elements(ixmaxmesh) EQ 0 then ixmaxmesh = jpiglo-1
131   if ixminmesh EQ -1 THEN ixminmesh = 0
132   IF ixmaxmesh EQ -1 then ixmaxmesh = jpiglo-1
133   if n_elements(iyminmesh) EQ 0 THEN iyminmesh = 0
134   IF n_elements(iymaxmesh) EQ 0 then iymaxmesh = jpjglo-1
135   if iyminmesh EQ -1 THEN iyminmesh = 0
136   IF iymaxmesh EQ -1 then iymaxmesh = jpjglo-1
137   if n_elements(izminmesh) EQ 0 THEN izminmesh = 0
138   IF n_elements(izmaxmesh) EQ 0 then izmaxmesh = jpkglo-1
139   if izminmesh EQ -1 THEN izminmesh = 0
140   IF izmaxmesh EQ -1 then izmaxmesh = jpkglo-1
141;
142;
143
144   jpi    = long(ixmaxmesh-ixminmesh+1)
145   jpj    = long(iymaxmesh-iyminmesh+1)
146   jpk    = long(izmaxmesh-izminmesh+1)
147;-------------------------------------------------------
148; doit-on reellement lire la grille?
149;-------------------------------------------------------
150   meshparameters = {jpiglo:jpiglo, jpjglo:jpjglo, jpkglo:jpkglo $
151                     , jpi:jpi, jpj:jpj, jpk:jpk $
152                     , ixminmesh:ixminmesh, ixmaxmesh:ixmaxmesh $
153                     , iyminmesh:iyminmesh, iymaxmesh:iymaxmesh $
154                     , izminmesh:izminmesh, izmaxmesh:izmaxmesh $
155                     , key_shift:key_shift}
156;
157;-------------------------------------------------------
158   noticebase=xnotice('Lecture du fichier !C '+s_fichier+'!C ...')
159;-------------------------------------------------------
160
161   IF NOT keyword_set(double) THEN BEGIN
162      z3d    = fltarr(jpiglo, jpjglo, jpkglo)
163      z2d    = fltarr(jpiglo, jpjglo)
164      z1d    = fltarr(jpkglo)
165   ENDIF ELSE BEGIN
166      z3d    = dblarr(jpiglo, jpjglo, jpkglo)
167      z2d    = dblarr(jpiglo, jpjglo)
168      z1d    = dblarr(jpkglo)
169   ENDELSE
170
171   if not keyword_set(pasblabla) then print, ' '
172   readu, numlec, tab,z2d
173   GLAMT=float(z2d[ixminmesh:ixmaxmesh,iyminmesh:iymaxmesh])
174   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur GLAMT[25,31]: ',GLAMT[25,31]
175   readu, numlec, tab,z2d
176   GLAMU=float(z2d[ixminmesh:ixmaxmesh,iyminmesh:iymaxmesh])
177   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur GLAMU[25,31]: ',GLAMU[25,31]
178   readu, numlec, tab,z2d
179   GLAMV=float(z2d[ixminmesh:ixmaxmesh,iyminmesh:iymaxmesh])
180   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur GLAMV[25,31]: ',GLAMV[25,31]
181   readu, numlec, tab,z2d
182   GLAMF=float(z2d[ixminmesh:ixmaxmesh,iyminmesh:iymaxmesh])
183   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur GLAMF[25,31]: ',z2d[25,31]
184
185   if not keyword_set(pasblabla) then print, ' '
186   readu, numlec, tab, z2d
187   GPHIT=float(z2d[ixminmesh:ixmaxmesh,iyminmesh:iymaxmesh])
188   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur GPHIT[25,31]: ',GPHIT[25,31]
189   readu, numlec, tab, z2d
190   GPHIU=float(z2d[ixminmesh:ixmaxmesh,iyminmesh:iymaxmesh])
191   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur GPHIU[25,31]: ',GPHIU[25,31]
192   readu, numlec, tab, z2d
193   GPHIV=float(z2d[ixminmesh:ixmaxmesh,iyminmesh:iymaxmesh])
194   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur GPHIV[25,31]: ',GPHIV[25,31]
195   readu, numlec, tab, z2d
196   GPHIF=float(z2d[ixminmesh:ixmaxmesh,iyminmesh:iymaxmesh])
197   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur GPHIF[25,31]: ',z2d[25,31]
198
199   if not keyword_set(pasblabla) then print, ' '
200   readu, numlec, tab, z2d
201   E1T=float(z2d[ixminmesh:ixmaxmesh,iyminmesh:iymaxmesh])
202   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur E1T[25,5]: ',z2d[25,5]
203   readu, numlec, tab, z2d
204   E1U=float(z2d[ixminmesh:ixmaxmesh,iyminmesh:iymaxmesh])
205   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur E1U[25,5]: ',z2d[25,5]
206   readu, numlec, tab, z2d
207   E1V=float(z2d[ixminmesh:ixmaxmesh,iyminmesh:iymaxmesh])
208   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur E1V[25,5]: ',z2d[25,5]
209   readu, numlec, tab, z2d
210   E1F=float(z2d[ixminmesh:ixmaxmesh,iyminmesh:iymaxmesh])
211   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur E1F[25,5]: ',z2d[25,5]
212
213   if not keyword_set(pasblabla) then print, ' '
214   readu, numlec, tab, z2d
215   E2T=float(z2d[ixminmesh:ixmaxmesh,iyminmesh:iymaxmesh])
216   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur E2T[25,5]: ',z2d[25,5]
217   readu, numlec, tab, z2d
218   E2U=float(z2d[ixminmesh:ixmaxmesh,iyminmesh:iymaxmesh])
219   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur E2U[25,5]: ',z2d[25,5]
220   readu, numlec, tab, z2d
221   E2V=float(z2d[ixminmesh:ixmaxmesh,iyminmesh:iymaxmesh])
222   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur E2V[25,5]: ',z2d[25,5]
223   readu, numlec, tab, z2d
224   E2F=float(z2d[ixminmesh:ixmaxmesh,iyminmesh:iymaxmesh])
225   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur E2F[25,5]: ',z2d[25,5]
226
227   if not keyword_set(pasblabla) then print, ' '
228   readu, numlec, tab, z3d
229   TMASK=byte(z3d[ixminmesh:ixmaxmesh,iyminmesh:iymaxmesh,izminmesh:izmaxmesh])
230   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur TMASK[25,5,0]: ',TMASK[25,5,0]
231   readu, numlec, tab, z3d
232   UMASKred=byte(z3d[ixmaxmesh,iyminmesh:iymaxmesh,izminmesh:izmaxmesh])
233   umaskred = reform(umaskred)
234   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur UMASK[25,5,0]: ',z3d[25,5,0]
235   readu, numlec, tab, z3d
236   VMASKred=byte(z3d[ixminmesh:ixmaxmesh,iymaxmesh,izminmesh:izmaxmesh])
237   vmaskred = reform(vmaskred)
238   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur VMASK[25,5,0]: ',z3d[25,5,0]
239   readu, numlec, tab, z3d
240   fmaskredy=byte(z3d[ixmaxmesh,iyminmesh:iymaxmesh,izminmesh:izmaxmesh])
241   coast = where(fmaskredy NE 0 and fmaskredy NE 1)
242   IF coast[0] NE -1 THEN fmaskredy[coast] = 0b
243   fmaskredx=byte(z3d[ixminmesh:ixmaxmesh,iymaxmesh,izminmesh:izmaxmesh])
244   coast = where(fmaskredx NE 0 and fmaskredx NE 1)
245   IF coast[0] NE -1 THEN fmaskredx[coast] = 0b
246   fmaskredx = reform(fmaskredx)
247   fmaskredy = reform(fmaskredy)
248   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur FMASK[25,5,0]: ',z3d[25,5,0]
249;
250   if not keyword_set(pasblabla) then print, ' '
251   readu, numlec, tab, z2d
252;FF=z2d[ixminmesh:ixmaxmesh,iyminmesh:iymaxmesh]
253   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur FF[25,5]: ',z2d[25,5]
254   readu, numlec, tab, z1d
255   GDEPT=float(z1d[izminmesh:izmaxmesh])
256   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur GDEPT[1]: ',GDEPT[1]
257   readu, numlec, tab, z1d
258   GDEPW=float(z1d[izminmesh:izmaxmesh])
259   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur GDEPW[1]: ',GDEPW[1]
260   readu, numlec, tab, z1d
261   E3T=float(z1d[izminmesh:izmaxmesh])
262   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur E3T[3]: ',E3T[3]
263   readu, numlec, tab, z1d
264   E3W=float(z1d[izminmesh:izmaxmesh])
265   if not keyword_set(pasblabla) then print, 'tableau: ',tab,' exemple de valeur E3W[3]: ',E3W[3]
266;-------------------------------------------------------
267   free_lun,numlec
268   close, numlec
269;-------------------------------------------------------
270;-------------------------------------------------------
271; bornes de glam qui ne doivent pas depasser 360 degres..
272;-------------------------------------------------------
273;    minglam = min(glamt, max = maxglam)
274;    if maxglam-minglam GE 360 AND NOT keyword_set(glamboundary) then $
275;     nothing = execute('glamboundary = '+xquestion('What are the longitudes boundary?', '[-180,180]',/chkwidget))
276;-------------------------------------------------------
277   if keyword_set(glamboundary) then begin
278      if glamboundary[0] NE glamboundary[1] then begin
279         glamt = glamt MOD 360
280         smaller = where(glamt LT glamboundary[0])
281         if smaller[0] NE -1 then glamt[smaller] = glamt[smaller]+360
282         bigger = where(glamt GE glamboundary[1])
283         if bigger[0] NE -1 then glamt[bigger] = glamt[bigger]-360
284         glamu = glamu MOD 360
285         smaller = where(glamu LT glamboundary[0])
286         if smaller[0] NE -1 then glamu[smaller] = glamu[smaller]+360
287         bigger = where(glamu GE glamboundary[1])
288         if bigger[0] NE -1 then glamu[bigger] = glamu[bigger]-360
289         glamv = glamv MOD 360
290         smaller = where(glamv LT glamboundary[0])
291         if smaller[0] NE -1 then glamv[smaller] = glamv[smaller]+360
292         bigger = where(glamv GE glamboundary[1])
293         if bigger[0] NE -1 then glamv[bigger] = glamv[bigger]-360
294         glamf = glamf MOD 360
295         smaller = where(glamf LT glamboundary[0])
296         if smaller[0] NE -1 then glamf[smaller] = glamf[smaller]+360
297         bigger = where(glamf GE glamboundary[1])
298         if bigger[0] NE -1 then glamf[bigger] = glamf[bigger]-360
299      endif
300   endif
301;-------------------------------------------------------
302; shift en x
303;-------------------------------------------------------
304   if keyword_set(key_shift) AND jpi NE 1 then begin
305      glamt = shift(glamt,key_shift , 0)
306      gphit = shift(gphit,key_shift , 0)
307      e1t = shift(e1t, key_shift, 0)
308      e2t = shift(e2t,key_shift , 0)
309      glamu = shift(glamu, key_shift, 0)
310      gphiu = shift(gphiu, key_shift, 0)
311      e1u = shift(e1u,key_shift , 0)
312      e2u = shift(e2u, key_shift, 0)
313      glamv = shift(glamv, key_shift, 0)
314      gphiv = shift(gphiv, key_shift, 0)
315      e1v = shift(e1v,key_shift , 0)
316      e2v = shift(e2v, key_shift, 0)
317      glamf = shift(glamf, key_shift, 0)
318      gphif = shift(gphif, key_shift, 0)
319      e1f = shift(e1f, key_shift , 0)
320      e2f = shift(e2f, key_shift, 0)
321      if jpk EQ 1 then begin
322         tmask = shift(tmask, key_shift, 0)
323         vmaskred = shift(vmaskred, key_shift)
324         fmaskredx = shift(fmaskredx, key_shift)
325      ENDIF ELSE BEGIN
326         tmask = shift(tmask, key_shift, 0,0)
327         vmaskred = shift(vmaskred, key_shift, 0)
328         fmaskredx = shift(fmaskredx, key_shift, 0)
329      ENDELSE
330   endif
331;-------------------------------------------------------
332   key_yreverse = 0
333   key_zreverse = 0
334   key_partialstep = 0
335   key_stride = [1, 1, 1]
336   key_gridtype = 'c'
337;
338   if not keyword_set(pasblabla) then print,'lecture '+nomfich+' finie'
339   IF NOT keyword_set(key_batch) then widget_control, noticebase, bad_id = toto, /destroy
340   if keyword_set(key_performance) THEN print, 'temps meshlec', systime(1)-tempsun
341
342   return
343end
344
345
346
347
Note: See TracBrowser for help on using the repository browser.