source: trunk/SRC/Grid/ncdf_meshread.pro @ 103

Last change on this file since 103 was 103, checked in by pinsard, 18 years ago

start to modify headers of Grid .pro files for better idldoc output

  • Property svn:executable set to *
File size: 23.1 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5;
6; @file_comments read NetCDF meshmask file created by OPA
7;
8; @categories grid reading
9;
10; @examples
11; IDL> ncdf_meshread [,' filename']
12;
13;    @param filename {in}{optional} the name of the meshmask file to read. Default is
14;    meshmask.nc. if this name does not contain any / and if
15;    iodirectory keyword is not specify, then the common variable
16;    iodir will be use to define the mesh file path.
17;
18;    @keyword GLAMBOUNDARY a 2 elements vector, {lon1,lon2], the longitute
19;    boundaries that should be used to visualize the data.
20;      lon2 > lon1
21;      lon2 - lon1 le 360
22;    key_shift will be automaticaly defined according to GLAMBOUNDARY.
23;
24;    @keyword /CHECKDAT Suppressed. Use micromeshmask.pro to create an
25;    appropriate meshmask.
26;
27;    @keyword ONEARTH = 0 or 1 to force the manual definition of
28;    key_onearth (to specify if the data are on earth -> use longitude
29;    /latitude etc...). By default, key_onearth = 1.
30;    note that ONEARTH = 0 forces PERIODIC = 0, SHIFT = 0 and is
31;    cancelling GLAMBOUNDARY
32;
33;    @keyword PERIODIC = 0 or 1 to force the manual definition of
34;    key_periodic. By default, key_periodic is automaticaly
35;    computed by using the first line of glamt.
36;
37;    @keyword SHIFT  to force the manual definition of key_shift. By
38;    debault, key_shift is automaticaly computed according to the
39;    glamboundary (when defined) by using the first line of glamt. if
40;    key_periodic=0 then in any case key_shift = 0.
41;
42;    @keyword STRCALLING a string containing the calling command used to call
43;    computegrid (this is used by xxx.pro)
44;
45;    @keyword STRIDE a 3 elements vector to specify the stride in x, y, z
46;    direction. Default definition is key_stride. The resulting value
47;    will be stored in the common (cm_4mesh) variable key_stride
48;
49; @uses cm_4mesh cm_4data cm_4cal
50;
51; @restrictions define and/or use common variables from
52;               cm_4mesh, cm_4data, cm_4cal
53;
54; @restrictions
55;
56;  ixminmesh,ixmaxmesh,iyminmesh,iymaxmesh,izminmesh,izmaxmesh must
57;  be defined febore calling ncdf_meshread. if some of those value
58;  are equal to -1 they will be automatically defined
59;
60; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
61;                      12/1999
62; July 2004, Sebastien Masson: Several modifications (micromeshmask,
63; clean partial steps, clean use of key_stride, automatic definition
64; of key_shift, ...)
65; Oct. 2004, Sebastien Masson: add PERIODIC and SHIFT
66; Aug. 2005, Sebastien Masson: some cleaning + english
67;-
68;------------------------------------------------------------
69;------------------------------------------------------------
70;------------------------------------------------------------
71PRO ncdf_meshread, filename, GLAMBOUNDARY = glamboundary, CHECKDAT = checkdat $
72                  , ONEARTH = onearth, GETDIMENSIONS = getdimensions $
73                  , PERIODIC = periodic, SHIFT = shift, STRIDE = stride $
74                  , STRCALLING = strcalling, _EXTRA = ex
75;
76;---------------------------------------------------------
77@cm_4mesh
78@cm_4data
79@cm_4cal
80  IF NOT keyword_set(key_forgetold) THEN BEGIN
81@updatenew
82@updatekwd
83  ENDIF
84;---------------------------------------------------------
85;
86  tempsun = systime(1)          ; for key_performance
87  IF keyword_set(CHECKDAT) THEN BEGIN
88    print, ' The keyword CHECKDAT has been suppressed (it could create bugs).'
89    print, ' Remove it from the call of ncdf_meshread'
90    print, ' Please use smallmeshmask.pro or micromeshmask.pro to create a'
91    print, ' meshmask that has manageable size'
92    return
93  ENDIF
94;-------------------------------------------------------
95; find meshfile name and open it!
96;-------------------------------------------------------
97; def de filename par defaut
98  IF n_params() EQ 0 then filename = 'meshmask.nc'
99  meshname = isafile(file = filename, iodirectory = iodir, _EXTRA = ex)
100  meshname = meshname[0]
101;
102  noticebase = xnotice('Reading file !C '+meshname+'!C ...')
103; if the meshmask is on tape archive ... get it back
104  IF !version.OS_FAMILY EQ 'unix' THEN spawn, '\file '+meshname+' > /dev/null'
105  cdfid = ncdf_open(meshname)
106  contient = ncdf_inquire(cdfid)
107;------------------------------------------------------------
108; dimensions
109;------------------------------------------------------------
110  ncdf_diminq, cdfid, 'x', name, jpiglo
111  ncdf_diminq, cdfid, 'y', name, jpjglo
112  listdims = strlowcase(ncdf_listdims(cdfid))
113  IF (where(listdims EQ 'z'))[0] NE -1 THEN ncdf_diminq, cdfid, 'z', name, jpkglo ELSE BEGIN
114    dimid = (where(strmid(listdims, 0, 5) EQ 'depth'))[0]
115    IF dimid NE -1 THEN ncdf_diminq, cdfid, dimid, name, jpkglo ELSE BEGIN
116      report, 'We could not find the vertical dimension..., its name must be z or start with depth'
117      stop
118    ENDELSE
119  ENDELSE
120;
121  if keyword_set(getdimensions) then begin
122    widget_control, noticebase, bad_id = nothing, /destroy
123    ncdf_close,  cdfid
124    return
125  endif
126;-------------------------------------------------------
127; check that all i[xyz]min[ax]mesh are well defined
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; definition of jpi,jpj,jpj
142  jpi    = long(ixmaxmesh-ixminmesh+1)
143  jpj    = long(iymaxmesh-iyminmesh+1)
144  jpk    = long(izmaxmesh-izminmesh+1)
145;-------------------------------------------------------
146; check onearth and its consequences
147;-------------------------------------------------------
148  IF n_elements(onearth) EQ 0 THEN key_onearth = 1 $
149  ELSE key_onearth = keyword_set(onearth)
150  IF NOT key_onearth THEN BEGIN
151    periodic = 0
152    shift = 0
153  ENDIF
154;-------------------------------------------------------
155; automatic definition of key_periodic
156;-------------------------------------------------------
157  IF n_elements(periodic) EQ 0 THEN BEGIN
158    IF jpi GT 1 THEN BEGIN
159      varinq = ncdf_varinq(cdfid, 'glamt')
160      CASE varinq.ndims OF
161        2:ncdf_varget, cdfid, 'glamt', xaxis $
162                       , offset = [ixminmesh, iyminmesh], count = [jpi, 1]
163        3:ncdf_varget, cdfid, 'glamt', xaxis $
164                       , offset = [ixminmesh, iyminmesh, 0], count = [jpi, 1, 1]
165        4:ncdf_varget, cdfid, 'glamt', xaxis $
166                       , offset = [ixminmesh, iyminmesh, 0, 0], count = [jpi, 1, 1, 1]
167      ENDCASE
168      xaxis = (xaxis+720) MOD 360
169      xaxis = xaxis[sort(xaxis)]
170      key_periodic = (xaxis[jpi-1]+2*(xaxis[jpi-1]-xaxis[jpi-2])) $
171                     GE (xaxis[0]+360)
172    ENDIF ELSE key_periodic = 0
173  ENDIF ELSE key_periodic = keyword_set(periodic)
174;-------------------------------------------------------
175; automatic definition of key_shift
176;-------------------------------------------------------
177  IF n_elements(shift) EQ 0 THEN BEGIN
178    key_shift = long(testvar(var = key_shift))
179;  key_shift will be defined according to the first line of glamt.
180    if keyword_set(glamboundary) AND jpi GT 1 AND key_periodic EQ 1 $
181    THEN BEGIN
182      varinq = ncdf_varinq(cdfid, 'glamt')
183      CASE varinq.ndims OF
184        2:ncdf_varget, cdfid, 'glamt', xaxis $
185                       , offset = [ixminmesh, iyminmesh], count = [jpi, 1]
186        3:ncdf_varget, cdfid, 'glamt', xaxis $
187                       , offset = [ixminmesh, iyminmesh, 0], count = [jpi, 1, 1]
188        4:ncdf_varget, cdfid, 'glamt', xaxis $
189                       , offset = [ixminmesh, iyminmesh, 0, 0], count = [jpi, 1, 1, 1]
190      ENDCASE
191; xaxis between glamboundary[0] and glamboundary[1]
192      xaxis = xaxis MOD 360
193      smaller = where(xaxis LT glamboundary[0])
194      if smaller[0] NE -1 then xaxis[smaller] = xaxis[smaller]+360
195      bigger = where(xaxis GE glamboundary[1])
196      if bigger[0] NE -1 then xaxis[bigger] = xaxis[bigger]-360
197;
198      key_shift = (where(xaxis EQ min(xaxis)))[0]
199      IF key_shift NE 0 THEN BEGIN
200        key_shift = jpi-key_shift
201        xaxis = shift(xaxis, key_shift)
202      ENDIF
203;
204      IF array_equal(sort(xaxis), lindgen(jpi)) NE 1 THEN BEGIN
205        print, 'the x axis (1st line of glamt) is not sorted in the inceasing order after the automatic definition of key_shift'
206        print, 'please use the keyword shift (and periodic) to suppress the automatic definition of key_shift (and key_periodic) and define by hand a more suitable value...'
207        widget_control, noticebase, bad_id = nothing, /destroy
208        return
209      ENDIF
210;
211    ENDIF ELSE key_shift = 0
212  ENDIF ELSE key_shift = long(shift)*(key_periodic EQ 1)
213;-------------------------------------------------------
214; check key_stride and related things
215;-------------------------------------------------------
216  if n_elements(stride) eq 3 then key_stride = stride
217  if n_elements(key_stride) LE 2 then key_stride = [1, 1, 1]
218  key_stride = 1l > long(key_stride)
219  IF total(key_stride) NE 3  THEN BEGIN
220    IF key_shift NE 0 THEN BEGIN
221; for explanation, see header of read_ncdf_varget.pro
222      jpiright = key_shift
223      jpileft = jpi - key_shift - ( (key_stride[0]-1)-((key_shift-1) MOD key_stride[0]) )
224      jpi = ((jpiright-1)/key_stride[0]+1) + ((jpileft-1)/key_stride[0]+1)
225    ENDIF ELSE jpi = (jpi-1)/key_stride[0]+1
226    jpj = (jpj-1)/key_stride[1]+1
227    jpk = (jpk-1)/key_stride[2]+1
228  ENDIF
229;-------------------------------------------------------
230; default definitions to be able to use read_ncdf_varget
231;-------------------------------------------------------
232; default definitions to be able to use read_ncdf_varget
233  ixmindtasauve = testvar(var = ixmindta)
234  iymindtasauve = testvar(var = iymindta)
235  izmindtasauve = testvar(var = izmindta)
236;
237  ixmindta = 0l
238  iymindta = 0l
239  izmindta = 0l
240;
241  jpt = 1
242  time = 1
243  firsttps = 0
244;
245  firstx = 0
246  lastx = jpi-1
247  firsty = 0
248  lasty = jpj-1
249  firstz = 0
250  lastz = jpk-1
251  nx = jpi
252  ny = jpj
253  nz = 1
254  izminmeshsauve = izminmesh
255  izminmesh = 0
256;-------------------------------------------------------
257; 2d arrays:
258;-------------------------------------------------------
259; list the 2d variables that must be read
260  namevar = ['glamt', 'glamu', 'glamv', 'glamf' $
261             , 'gphit', 'gphiu', 'gphiv', 'gphif' $
262             , 'e1t', 'e1u', 'e1v', 'e1f' $
263             , 'e2t', 'e2u', 'e2v', 'e2f']
264; for the variables related to the partial steps
265  allvarname =  ncdf_listvars(cdfid)
266  IF (where(allvarname EQ 'hdept'))[0] NE -1 THEN BEGIN
267    key_partialstep = 1
268    namevar = [namevar, 'hdept', 'hdepw']
269  ENDIF ELSE BEGIN
270    key_partialstep = 0
271    hdept = -1
272    hdepw = -1
273  ENDELSE
274; for compatibility with old versions of meshmask/partial steps
275  IF (where(allvarname EQ 'e3tp'))[0] NE -1 THEN $
276    namevar = [namevar, 'e3tp', 'e3wp'] ELSE BEGIN
277    e3t_ps = -1
278    e3w_ps = -1
279  ENDELSE
280  IF (where(allvarname EQ 'e3t_ps'))[0] NE -1 $
281  THEN namevar = [namevar, 'e3t_ps', 'e3w_ps' ]ELSE BEGIN
282    e3t_ps = -1
283    e3w_ps = -1
284  ENDELSE
285  IF (where(allvarname EQ 'e3u_ps'))[0] NE -1 $
286  THEN namevar = [namevar, 'e3u_ps', 'e3v_ps'] ELSE BEGIN
287    e3u_ps = -1
288    e3v_ps = -1
289  ENDELSE
290;
291; read all the 2d variables
292;
293  for i = 0, n_elements(namevar)-1 do begin
294    varcontient = ncdf_varinq(cdfid, namevar[i])
295    name = varcontient.name
296@read_ncdf_varget
297    commande = namevar[i]+'=float(res)'
298    rien = execute(commande)
299  ENDFOR
300; for compatibility with old versions of meshmask/partial steps
301; change e3[tw]p to e3[tw]_ps
302  IF n_elements(e3tp) NE 0 THEN e3t_ps = temporary(e3tp)
303  IF n_elements(e3wp) NE 0 THEN e3w_ps = temporary(e3wp)
304; in the kase of key_stride ne [1, 1, 1] redefine f points
305; coordinates: they must be in the middle of 3 T points
306  if key_stride[0] NE 1 OR key_stride[1] NE 1 then BEGIN
307; we must recompute glamf and gphif...
308    IF jpi GT 1 THEN BEGIN
309      if (keyword_set(key_onearth) AND keyword_set(xnotsorted)) $
310        OR (keyword_set(key_periodic) AND key_irregular) then BEGIN
311        stepxf = (glamt + 720) MOD 360
312        stepxf = shift(stepxf, -1, -1) - stepxf
313        stepxf = [ [[stepxf]], [[stepxf + 360]], [[stepxf - 360]] ]
314        stepxf = min(abs(stepxf), dimension = 3)
315        IF NOT keyword_set(key_periodic) THEN $
316          stepxf[jpi-1, *] = stepxf[jpi-2, *]
317      ENDIF ELSE BEGIN
318        stepxf = shift(glamt, -1, -1) - glamt
319        IF keyword_set(key_periodic) THEN $
320          stepxf[jpi-1, *] = 360 + stepxf[jpi-1, *] $
321        ELSE stepxf[jpi-1, *] = stepxf[jpi-2, *]
322      ENDELSE
323      IF jpj GT 1 THEN BEGIN
324        stepxf[*, jpj-1] = stepxf[*, jpj-2]
325        stepxf[jpi-1, jpj-1] = stepxf[jpi-2, jpj-2]
326      ENDIF
327      glamf = glamt + 0.5 * stepxf
328    ENDIF ELSE glamf = glamt + 0.5
329    IF jpj GT 1 THEN BEGIN
330; we must compute stepyf: y distance between T(i,j) T(i+1,j+1)
331      stepyf = shift(gphit, -1, -1) - gphit
332      stepyf[*, jpj-1] = stepyf[*, jpj-2]
333      IF jpi GT 1 THEN BEGIN
334        if NOT keyword_set(key_periodic) THEN $
335          stepyf[jpi-1, *] = stepyf[jpi-2, *]
336        stepyf[jpi-1, jpj-1] = stepyf[jpi-2, jpj-2]
337      ENDIF
338      gphif = gphit + 0.5 * stepyf
339    ENDIF ELSE gphif = gphit + 0.5
340  ENDIF
341;-------------------------------------------------------
342; 3d arrays:
343;-------------------------------------------------------
344  nz = jpk
345  izminmesh = izminmeshsauve
346;
347  listdims = ncdf_listdims(cdfid)
348  micromask = (where(listdims EQ 'y_m'))[0]
349;
350  varcontient = ncdf_varinq(cdfid, 'tmask')
351  name = varcontient.name
352  IF micromask NE -1 THEN BEGIN
353; keep original values
354    iyminmeshtrue = iyminmesh
355    key_stridetrue = key_stride
356    yyy1 = firsty*key_stridetrue[1]+iyminmeshtrue
357    yyy2 = lasty*key_stridetrue[1]+iyminmeshtrue
358; the mask is stored as the bit values of the byte array (along the y
359; dimension, see micromeshmask.pro)...
360; we must modify several parameters...
361    iyminmesh = 0L
362    firsty = yyy1/8
363    lasty = yyy2/8
364    ny = lasty-firsty+1
365    key_stride = [key_stride[0], 1, key_stride[2]]
366@read_ncdf_varget
367    tmask = bytarr(jpi, jpj, jpk)
368; now we must get back the mask
369; loop on the level to save memory (the loop is short and, thus,
370; should be fast enough)
371    FOR k = 0, jpk-1 DO BEGIN
372      zzz = transpose(res[*, *, k])
373      zzz = reform(binary(zzz), 8*ny, nx, /over)
374      zzz = transpose(temporary(zzz))
375      zzz = zzz[*, yyy1 MOD 8: 8*ny - 8 + yyy2 MOD 8]
376      IF key_stridetrue[1] NE 1 THEN BEGIN
377;        IF float(strmid(!version.release,0,3)) LT 5.6 THEN BEGIN
378        nnny = (size(zzz))[2]
379        yind = key_stridetrue[1]*lindgen((nnny-1)/key_stridetrue[1]+1)
380        tmask[*, *, k] = temporary(zzz[*, yind])
381;        ENDIF ELSE tmask[*, *, k] = temporary(zzz[*, 0:*:key_stridetrue[1]])
382      ENDIF ELSE tmask[*, *, k] = temporary(zzz)
383    ENDFOR
384  ENDIF ELSE BEGIN
385@read_ncdf_varget
386    tmask = byte(res)
387  ENDELSE
388; boudary conditions used to compute umask.
389  varcontient = ncdf_varinq(cdfid, 'umask')
390  name = varcontient.name
391  nx = 1L
392  firstx = jpi-1
393  lastx = jpi-1
394  IF micromask NE -1 THEN BEGIN
395@read_ncdf_varget
396    umaskred = reform(binary(res), 8*ny, jpk, /over)
397    umaskred = umaskred[yyy1 MOD 8: 8*ny - 8 + yyy2 MOD 8, *]
398    IF key_stridetrue[1] NE 1 THEN umaskred = temporary(umaskred[yind, *])
399  ENDIF ELSE BEGIN
400@read_ncdf_varget
401    umaskred = reform(byte(res), /over)
402  ENDELSE
403; boudary conditions used to compute fmask (1).
404  varcontient = ncdf_varinq(cdfid, 'fmask')
405  name = varcontient.name
406  IF micromask NE -1 THEN BEGIN
407@read_ncdf_varget
408    fmaskredy = reform(binary(res), 8*ny, jpk, /over)
409    fmaskredy = fmaskredy[yyy1 MOD 8: 8*ny - 8 + yyy2 MOD 8, *]
410    IF key_stridetrue[1] NE 1 THEN fmaskredy = temporary(fmaskredy[yind, *])
411  ENDIF ELSE BEGIN
412@read_ncdf_varget
413    fmaskredy = reform(byte(res), /over)
414    fmaskredy = temporary(fmaskredy) MOD 2
415  ENDELSE
416; boudary conditions used to compute vmask
417  varcontient = ncdf_varinq(cdfid, 'vmask')
418  name = varcontient.name
419  nx = jpi
420  firstx = 0L
421  lastx = jpi-1L
422  ny = 1L
423  firsty = jpj-1
424  lasty = jpj-1
425  IF micromask NE -1 THEN BEGIN
426    yyy1 = firsty*key_stridetrue[1]+iyminmeshtrue
427    yyy2 = lasty*key_stridetrue[1]+iyminmeshtrue
428    iyminmesh = 0L
429    firsty = yyy1/8
430    lasty = yyy2/8
431    ny = lasty-firsty+1
432@read_ncdf_varget
433    IF jpk EQ 1 THEN res = reform(res, jpi, 1, jpk, /over)
434    vmaskred = transpose(temporary(res), [1, 0, 2])
435    vmaskred = reform(binary(vmaskred), 8*ny, nx, nz, /over)
436    vmaskred = transpose(temporary(vmaskred), [1, 0, 2])
437    vmaskred = reform(vmaskred[*, yyy1 MOD 8: 8*ny - 8 + yyy2 MOD 8, *])
438  ENDIF ELSE BEGIN
439@read_ncdf_varget
440    vmaskred = reform(byte(res), /over)
441  ENDELSE
442; boudary conditions used to compute fmask (2).
443  varcontient = ncdf_varinq(cdfid, 'fmask')
444  name = varcontient.name
445  IF micromask NE -1 THEN BEGIN
446@read_ncdf_varget
447    IF jpk EQ 1 THEN res = reform(res, jpi, 1, jpk, /over)
448    fmaskredx = transpose(temporary(res), [1, 0, 2])
449    fmaskredx = reform(binary(fmaskredx), 8*ny, nx, nz, /over)
450    fmaskredx = transpose(temporary(fmaskredx), [1, 0, 2])
451    fmaskredx = reform(fmaskredx[*, yyy1 MOD 8: 8*ny - 8 + yyy2 MOD 8, *])
452;
453    iyminmesh = iyminmeshtrue
454    key_stride = key_stridetrue
455  ENDIF ELSE BEGIN
456@read_ncdf_varget
457    fmaskredx = reform(byte(res), /over)
458    fmaskredx = fmaskredx MOD 2
459  ENDELSE
460;-------------------------------------------------------
461; 1d arrays
462;-------------------------------------------------------
463  namevar = ['e3t', 'e3w', 'gdept', 'gdepw']
464  for i = 0, n_elements(namevar)-1 do begin
465    varcontient = ncdf_varinq(cdfid, namevar[i])
466    CASE n_elements(varcontient.dim) OF
467      4:BEGIN
468        commande = 'ncdf_varget,cdfid,namevar[i],'+namevar[i] $
469                   +',offset = [0,0,izminmesh,0], count = [1,1,jpk,1]'
470        if key_stride[2] NE 1 then commande = commande+', stride=[1,1,key_stride[2],1]'
471      END
472      2:BEGIN
473        commande = 'ncdf_varget,cdfid,namevar[i],'+namevar[i] $
474                   +',offset = [izminmesh,0], count = [jpk,1]'
475        if key_stride[2] NE 1 then commande = commande+', stride=key_stride[2]'
476      END
477      1:BEGIN
478        commande = 'ncdf_varget,cdfid,namevar[i],'+namevar[i] $
479                   +',offset = [izminmesh], count = [jpk]'
480        if key_stride[2] NE 1 then commande = commande+', stride=key_stride[2]'
481      END
482    ENDCASE
483    rien = execute(commande)
484    commande = namevar[i]+'=float('+namevar[i]+')'
485    rien = execute(commande)
486    commande = 'if size('+namevar[i]+', /n_dimension) gt 0 then '+namevar[i]+' = reform('+namevar[i]+', /over)'
487    rien = execute(commande)
488  ENDFOR
489;-------------------------------------------------------
490  ncdf_close,  cdfid
491;-------------------------------------------------------
492; Apply Glamboudary
493;-------------------------------------------------------
494  if keyword_set(glamboundary) AND key_onearth then BEGIN
495    if glamboundary[0] NE glamboundary[1] then BEGIN
496      glamt = glamt MOD 360
497      smaller = where(glamt LT glamboundary[0])
498      if smaller[0] NE -1 then glamt[smaller] = glamt[smaller]+360
499      bigger = where(glamt GE glamboundary[1])
500      if bigger[0] NE -1 then glamt[bigger] = glamt[bigger]-360
501      glamu = glamu MOD 360
502      smaller = where(glamu LT glamboundary[0])
503      if smaller[0] NE -1 then glamu[smaller] = glamu[smaller]+360
504      bigger = where(glamu GE glamboundary[1])
505      if bigger[0] NE -1 then glamu[bigger] = glamu[bigger]-360
506      glamv = glamv MOD 360
507      smaller = where(glamv LT glamboundary[0])
508      if smaller[0] NE -1 then glamv[smaller] = glamv[smaller]+360
509      bigger = where(glamv GE glamboundary[1])
510      if bigger[0] NE -1 then glamv[bigger] = glamv[bigger]-360
511      glamf = glamf MOD 360
512      smaller = where(glamf LT glamboundary[0])
513      if smaller[0] NE -1 then glamf[smaller] = glamf[smaller]+360
514      bigger = where(glamf GE glamboundary[1])
515      if bigger[0] NE -1 then glamf[bigger] = glamf[bigger]-360
516      toosmall = where(glamu EQ glamboundary[0])
517      IF toosmall[0] NE -1 THEN glamu[toosmall] = glamu[toosmall] + 360
518      toosmall = where(glamf EQ glamboundary[0])
519      IF toosmall[0] NE -1 THEN glamf[toosmall] = glamf[toosmall] + 360
520    endif
521  endif
522;-------------------------------------------------------
523; make sure we do have 2d arrays when jpj eq 1
524;-------------------------------------------------------
525  IF jpj EQ 1 THEN BEGIN
526    glamt = reform(glamt, jpi, jpj, /over)
527    gphit = reform(gphit, jpi, jpj, /over)
528    e1t = reform(e1t, jpi, jpj, /over)
529    e2t = reform(e2t, jpi, jpj, /over)
530    glamu = reform(glamu, jpi, jpj, /over)
531    gphiu = reform(gphiu, jpi, jpj, /over)
532    e1u = reform(e1u, jpi, jpj, /over)
533    e2u = reform(e2u, jpi, jpj, /over)
534    glamv = reform(glamv, jpi, jpj, /over)
535    gphiv = reform(gphiv, jpi, jpj, /over)
536    e1v = reform(e1v, jpi, jpj, /over)
537    e2v = reform(e2v, jpi, jpj, /over)
538    glamf = reform(glamf, jpi, jpj, /over)
539    gphif = reform(gphif, jpi, jpj, /over)
540    e1f = reform(e1f, jpi, jpj, /over)
541    e2f = reform(e2f, jpi, jpj, /over)
542    IF keyword_set(key_partialstep) THEN BEGIN
543      hdept = reform(hdept, jpi, jpj, /over)
544      hdepw = reform(hdepw, jpi, jpj, /over)
545      e3t_ps = reform(e3t_ps, jpi, jpj, /over)
546      e3w_ps = reform(e3w_ps, jpi, jpj, /over)
547    ENDIF
548  ENDIF
549;-------------------------------------------------------
550  ixmindta = ixmindtasauve
551  iymindta = iymindtasauve
552  izmindta = izmindtasauve
553;-------------------------------------------------------
554  widget_control, noticebase, bad_id = nothing, /destroy
555;
556  key_yreverse = 0
557  key_zreverse = 0
558  key_gridtype = 'c'
559;
560;====================================================
561; grid parameters used by xxx
562;====================================================
563;
564  IF NOT keyword_set(strcalling) THEN BEGIN
565    IF n_elements(ccmeshparameters) EQ 0 THEN strcalling = 'ncdf_meshread' $
566    ELSE strcalling = ccmeshparameters.filename
567  ENDIF
568  IF n_elements(glamt) GE 2 THEN BEGIN
569    glaminfo = moment(glamt)
570    IF finite(glaminfo[2]) EQ 0 THEN glaminfo = glaminfo[0:1]
571    gphiinfo = moment(gphit)
572    IF finite(gphiinfo[2]) EQ 0 THEN gphiinfo = gphiinfo[0:1]
573  ENDIF ELSE BEGIN
574    glaminfo = glamt
575    gphiinfo = gphit
576  ENDELSE
577  ccmeshparameters = {filename:strcalling  $
578          , glaminfo:float(string(glaminfo, format = '(E11.4)')) $
579          , gphiinfo:float(string(gphiinfo, format = '(E11.4)')) $
580          , jpiglo:jpiglo, jpjglo:jpjglo, jpkglo:jpkglo $
581          , jpi:jpi, jpj:jpj, jpk:jpk $
582          , ixminmesh:ixminmesh, ixmaxmesh:ixmaxmesh $
583          , iyminmesh:iyminmesh, iymaxmesh:iymaxmesh $
584          , izminmesh:izminmesh, izmaxmesh:izmaxmesh $
585          , key_shift:key_shift, key_periodic:key_periodic $
586          , key_stride:key_stride, key_gridtype:key_gridtype $
587          , key_yreverse:key_yreverse, key_zreverse:key_zreverse $
588          , key_partialstep:key_partialstep, key_onearth:key_onearth}
589;
590  if keyword_set(key_performance) THEN $
591    print, 'time ncdf_meshread', systime(1)-tempsun
592
593;-------------------------------------------------------
594   @updateold
595;-------------------------------------------------------
596   return
597 end
Note: See TracBrowser for help on using the repository browser.