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

Last change on this file since 114 was 114, checked in by smasson, 18 years ago

new compilation options (compile_opt idl2, strictarrsubs) in each routine

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