source: trunk/procs/nc_read.pro @ 41

Last change on this file since 41 was 41, checked in by ericg, 16 years ago

Misc modifs, incl. read_from_grid in yfx, debug_w prints, removal of mesh_lmdz and small bug corrections

File size: 22.1 KB
Line 
1;--------------------------- 
2; Reading ORCA netcdf files
3; EG 24/2/99
4;--------------------------- 
5FUNCTION nc_read, file_name, var_name, ncdf_db,  TIME_1 = time_1,  TIME_2 =  time_2, ALL_DATA = all_data, NO_MEAN = no_mean
6
7; arguments = file_name, varname
8; ncdf_db=<location>:<path> or just <path>
9; mot clef = iodir time_1 time_2
10
11@common
12@com_eg
13
14;;   print,  'key_yreverse : ', key_yreverse 
15
16; inits
17   IF debug_w THEN print, ' '
18   IF debug_w THEN print, '  ENTER nc_read'
19
20   IF NOT keyword_set(TIME_1) THEN time_1 =  1
21   IF NOT keyword_set(TIME_2) THEN time_2 =  time_1
22;
23; decide which subdomain of data to read
24;
25
26   IF debug_w THEN print, '     keyword_set(ALL_DATA) : ', keyword_set(ALL_DATA)
27
28   IF keyword_set(ALL_DATA) THEN BEGIN
29      print, '    Reading whole domain'
30      firstx = 0
31      firsty = 0
32      firstz = 0
33      nx = jpi
34      ny = jpj
35      nz = jpk
36      lastx = jpi-1
37      lasty = jpj-1
38      lastz = jpk-1
39;Rajout MK
40;Trouver une meilleure place
41      ixminmesh = 0
42      iyminmesh = 0
43      ixmaxmesh = jpi-1
44      iymaxmesh = jpj-1
45;Fin rajout
46   ENDIF ELSE BEGIN
47      grille,mask,glam,gphi,gdep,nx,ny,nz,firstx,firsty,firstz,lastx,lasty,lastz
48      mask = 1
49   ENDELSE
50
51   IF debug_w THEN print, '     nx,ny,nz,firstx,firsty,firstz,lastx,lasty,lastz'
52   IF debug_w THEN print, '     ', nx,ny,nz,firstx,firsty,firstz,lastx,lasty,lastz
53
54   IF debug_w THEN print,  '     key_offset =', key_offset
55   IF debug_w THEN print,  '     jpi, jpj, jpk =',  jpi, jpj, jpk
56
57
58; define reading boundaries
59
60   x_count = nx
61   y_count = ny
62   z_count = nz
63
64   IF debug_w THEN print,  '     nx,ny,nz =', nx,ny,nz
65
66; force izmaxmesh to lastz
67   jpk = lastz+1
68
69; dealing with longitude periodicity
70   IF x_count NE jpi THEN BEGIN
71      key_shift_read = 0
72   ENDIF ELSE key_shift_read = key_shift
73   IF debug_w THEN print,  '     key_shift_read=', key_shift_read
74
75   x_offset = key_offset[0]+ firstx+(key_shift_read-key_shift)
76   y_offset = key_offset[1]+ firsty
77   z_offset = key_offset[2]+ firstz
78   IF debug_w THEN print,  '     offset =', x_offset, y_offset, z_offset
79
80; pour trouver un fichier, tu as
81; findfile (tres pratique) et dialog_pickfile (interactif)
82
83; pour verifier si il y a une variable je fais
84
85; inq=ncdf_inquire(cdfid)
86; for varid=0,inq.nvars-1 do BEGIN
87;    varinq=ncdf_varinq(cdfid,varid)
88;    if varinq.name eq nom then goto, variabletrouvee
89; endfor
90; return, -1
91; variabletrouvee:
92
93; local directory
94
95   IF strpos(ncdf_db, ':') GE 1 THEN directory = (str_sep(ncdf_db, ':'))[1] $
96    ELSE directory = ncdf_db
97
98; existence of file
99
100   list = findfile(directory+file_name, count = nb_file)
101   
102   IF nb_file EQ 0 THEN BEGIN
103      print, ''
104      print, '   ***** file ', file_name, ' not found in ', $
105       directory
106      print, ''
107      field = {data: -1.0}
108      return,  field
109   ENDIF
110
111; ouverture fichier netCDF + contenu
112   cdfid=ncdf_open(directory+file_name)
113   inq=ncdf_inquire(cdfid)
114; que contient la variable
115   varid = ncdf_varid(cdfid, var_name)
116
117   name_suff = ''
118
119   IF varid EQ -1 THEN BEGIN
120      print, ''
121      print, '   ***** field ', var_name, ' not found in file ', $
122       file_name
123      print, ''
124      field = {data: -1.0}
125      return,  field
126   ENDIF
127   varinq=ncdf_varinq(cdfid, var_name)
128
129; test sur la dimension
130   err_mess = ''
131   field_dim = n_elements(varinq.dim)
132
133; get unlimited record variable
134   IF inq.recdim NE -1 THEN BEGIN
135      ncdf_diminq, cdfid,  inq.recdim,  name_time, nb_time
136      ;;ncdf_varget, cdfid, inq.recdim, time_array
137      ;;nb_time = (size(time_array))(1)
138   ENDIF ELSE BEGIN
139      ; Look for a potential record dimension
140      IF debug_w THEN print, '    Warning : no unlimited record in netCDF file'
141      ; Look for the names of all dimensions and all variables
142      list_dims = ncdf_listdims(cdfid)
143      list_vars = ncdf_listvars(cdfid)
144      ; Propose all the names and make the user choose the right one
145      ; for the record dimension
146      print, 'In the file ',  file_name,  ', the dimensions are named :'
147      print, list_dims
148      print, 'In the file ',  file_name,  ', the variables are named :'
149      print, list_vars
150      name_time = xquestion('Among the preceding names, which one could refer to the record dimension ?',  /chkwid)
151      IF name_time NE '-' THEN BEGIN
152         dimidt = ncdf_dimid(cdfid, name_time)
153         ncdf_diminq, cdfid,  dimidt,  name_time, nb_time
154         print, 'You chose ', name_time,  ' as a record dimension and its size is ',  nb_time
155         inq.recdim = dimidt
156      ENDIF ELSE BEGIN
157         print, 'No record dimension considered in the file'
158         nb_time =  0
159      ENDELSE
160
161      IF varinq.dim[varinq.ndims-1] NE dimidt THEN STOP,  $
162       'Post_it cannot handle variables whose record dimension is not the last one'
163
164;      ncdf_diminq,cdfid,(n_elements(varinq.dim)-1), name_time, nb_time     
165;      dimidl = ncdf_dimid(cdfid, name_time)
166;      ncdf_diminq,cdfid,dimidl, name_time, nb_time
167;      varidl = ncdf_varid(cdfid, name_time)
168;      ncdf_varget, cdfid, varidl, time_array
169
170   ENDELSE
171
172   IF jpt GT nb_time THEN BEGIN
173      jpt =  nb_time
174      print, 'Warning : the specified jpt does not correspond to the real time dimension in the file !'
175      print, 'New jpt =',  jpt
176   ENDIF
177   ; defs for @read_ncdf_varget
178
179;   key_stride = time_stride
180   key_stride = 1
181   if n_elements(key_stride) LE 2 then key_stride = [1, 1, 1]
182   key_stride = 1l > long(key_stride)
183   jpitotal = long(ixmaxmesh-ixminmesh+1)
184   key_shift = long(testvar(var = key_shift))
185   
186   key = long(key_shift MOD jpitotal)
187   if key LT 0 then key = key+jpitotal
188   ixmin = ixminmesh-ixmindta
189   iymin = iyminmesh-iymindta
190   firsttps = time_1-1
191   lasttps = time_2-1
192
193   name = varid
194
195   IF debug_w THEN print, '     '
196   IF debug_w THEN print, '     key=', key
197   IF debug_w THEN print, '     jpitotal=', jpitotal
198   IF debug_w THEN print, '     ixmindta,iymindta,izmindta  =', ixmindta,iymindta,izmindta
199   IF debug_w THEN print, '     ixminmesh,iyminmesh=', ixminmesh,iyminmesh
200   IF debug_w THEN print, '     ixmaxmesh,iymaxmesh=', ixmaxmesh,iymaxmesh
201   IF debug_w THEN print, '     izminmesh,izmaxmesh=', izminmesh,izmaxmesh
202   IF debug_w THEN print, '     ixmin,iymin=', ixmin,iymin
203   IF debug_w THEN print, '     firsttps,lasttps=', firsttps, lasttps
204   IF debug_w THEN print, '     key_shift in nc_read=', key_shift
205   IF debug_w THEN print, '     key_yreverse, firsty, lasty',key_yreverse, firsty, lasty
206   IF debug_w THEN print, '     '
207
208   CASE n_elements(varinq.dim) OF
209
210      ;; fichier 2d : surface
211      2: BEGIN
212         print, '    Reading ', var_name, ' (2D data)   from ', file_name
213         @read_ncdf_varget
214         lec_data = res
215         data_direc = 'xy'
216         niveau = 1
217         END
218
219      ;; fichier 3d : 2 cas = 1/ 2d espace + temps 2/ 3d espace
220      3: BEGIN
221         ;; si varinq.dim contient la dim infinie (no 3) -> temps
222         dim_3 = '3d'
223         IF nb_time GE 1 THEN dim_3 = '2d'
224         IF dim_3 EQ '2d' THEN BEGIN
225         
226            IF time_2 EQ time_1 THEN BEGIN
227               print, '    Reading ', var_name, ' (2D data - index ', strcompress(string(time_1)),') from ', file_name
228               @read_ncdf_varget
229               lec_data = res
230               data_direc = 'xy'
231            ENDIF ELSE BEGIN
232               print, '    Reading ', var_name, ' (2D data time serie)', strcompress(string(time_1)),'-', strtrim(string(time_2), 2), ' [every ',strtrim(string(time_stride), 2), ']   from ', file_name
233               IF debug_w THEN print,  '     x_offset et y_offset et time_1 :',  x_offset,  y_offset,  time_1
234               @read_ncdf_varget
235               lec_data = res
236               data_direc = 'xyt'
237            ENDELSE
238
239         ENDIF ELSE BEGIN
240            print, '    Reading ', var_name, ' (3D data)', '   from ', file_name
241            @read_ncdf_varget
242            lec_data = res
243            data_direc = 'xyz'
244         ENDELSE
245      END
246      ;; fichier 4d : volume + temps
247      4: BEGIN
248         IF time_2 EQ time_1 THEN BEGIN
249            print, '    Reading ', var_name, ' (3D data - index ', strcompress(string(time_1)),') from ', file_name
250            ; read vertical levels
251            IF debug_w THEN print, '   mesh_type= ',mesh_type
252            IF mesh_type EQ 'atm' THEN BEGIN
253               ncdf_diminq,cdfid,2, name_level, nb_level
254               IF debug_w THEN print, 'name_level, nb_level = ', name_level, nb_level
255
256               dimidl = ncdf_dimid(cdfid, name_level)
257               ncdf_diminq,cdfid,dimidl, name_level, nb_level
258
259               varidl = ncdf_varid(cdfid, name_level)
260               ; make sure name_level is in hPa
261               ncdf_attget, cdfid, varidl, 'units', val_unit
262               IF string(val_unit) NE 'hPa' AND string(val_unit) NE 'millibar'  AND string(val_unit) NE 'mbar' THEN BEGIN
263                  print, '  vertical levels coordinate not obvious = ', name_level
264                  print, '  ... using <levels> ...'
265                  varidl = ncdf_varid(cdfid, 'levels')
266               ENDIF
267 
268               ncdf_varget, cdfid, varidl, gdept
269               gdept = gdept
270               gdepw = gdept
271               e3t = shift(gdept, 1)-gdept
272               e3t[0] = e3t[1]
273               e3w = e3t
274               jpk = nb_level
275               tmask = reform((reform(tmask(*, *), jpi*jpj)#replicate(1, jpk)), jpi, jpj, jpk)
276            ENDIF
277            IF debug_w THEN print,  ' going into @read_ncdf_varget '
278            @read_ncdf_varget
279            lec_data = res
280;            lec_data =  reform(lec_data,x_count, y_count, z_count)
281            data_direc = 'xyz'
282            IF debug_w THEN help, lec_data
283
284;           vertical average ?
285            IF vert_switch ge 1 AND NOT keyword_set(no_mean) THEN BEGIN
286               old_boite = [lon1, lon2, lat1, lat2, prof1, prof2]
287               print, '      Average in vertical domain ', vert_type, vert_mean
288               IF mesh_type EQ 'atm' THEN BEGIN
289                  CASE atmos_msk OF
290                     0: print, '          [atmos grid : take all points] ' ; take all points
291                     1: BEGIN
292                        ; take ocean points only
293                        idx = where(tmask EQ 0)
294                        lec_data(idx) = 1.e20
295                        print, '          [atmos grid : take ocean points only] '
296                     END
297                     2: BEGIN
298                        ; take land points only
299                        idx = where(tmask GT 0)
300                        lec_data(idx) = 1.e20
301                        print, '          [atmos grid : take land points only] '
302                     END
303                  ENDCASE
304                  CASE vert_type OF
305                     'z': BEGIN ;  depth range
306                        IF debug_w THEN print, ' performing average'
307                        zmean = grossemoyenne(lec_data, 'z', boite = vert_mean)
308                        IF vert_mean[0] EQ vert_mean[1] THEN BEGIN
309                           name_suff = ' at '+strtrim(string(long(gdept(vert_mean(0)))), 2)+' hPa'
310                        ENDIF ELSE BEGIN
311                           name_suff = ' averaged in '+vert_type+'['+strtrim(string(long(vert_mean(0))), 2)+','+strtrim(string(long(vert_mean(1))), 2)+']'
312                        ENDELSE
313                     END
314                     ELSE: BEGIN ; levels range
315                        IF vert_mean[0] EQ vert_mean[1] THEN BEGIN
316                           zmean = lec_data(*, *, vert_mean[0])
317                           name_suff = ' at '+strtrim(string(long(gdept(vert_mean(0)))), 2)+' hPa'
318                        ENDIF ELSE BEGIN
319                           zmean = moyenne(lec_data, 'z', boite = vert_mean, /zindex, NAN =1.e20)
320                           name_suff = ' averaged in '+vert_type+'['+strtrim(string(long(vert_mean(0))), 2)+','+strtrim(string(long(vert_mean(1))), 2)+']'
321                        ENDELSE
322                     END
323                  ENDCASE
324;                  tmask = reform(tmask(*, *, 0), jpi, jpj)
325               ENDIF ELSE BEGIN
326                  ; ocean = always mask
327;                  idx = where(tmask EQ 0)
328;                  lec_data(idx) = 1.e20
329                  CASE vert_type OF
330                     'z': BEGIN
331                        IF vert_mean[0] EQ vert_mean[1] THEN BEGIN
332                           zmean = lec_data ; right depth already selected
333                           name_suff = ' at '+strtrim(string(long(gdept(vert_mean(0))+.1)), 2)+' m'
334                        ENDIF ELSE BEGIN
335                           zmean = moyenne(lec_data, 'z', boite = vert_mean)
336                           name_suff = ' averaged in '+vert_type+'['+strtrim(string(long(vert_mean(0))), 2)+','+strtrim(string(long(vert_mean(1))), 2)+']'
337                        ENDELSE
338                     END
339                     ELSE: BEGIN ; case level (zindex)
340                        IF vert_mean[0] EQ vert_mean[1] THEN BEGIN
341                           zmean = lec_data ; right depth already selected
342                           name_suff = ' at '+strtrim(string(long(gdept(vert_mean(0))+.1)), 2)+' m'
343                        ENDIF ELSE BEGIN
344                           zmean = moyenne(lec_data, 'z', boite = vert_mean, /zindex)
345                           name_suff = ' averaged in '+vert_type+'['+strtrim(string(long(vert_mean(0))), 2)+','+strtrim(string(long(vert_mean(1))), 2)+']'
346                        ENDELSE
347                     END
348                  ENDCASE
349               ENDELSE
350               lec_data = zmean
351               domdef, old_boite
352               field_dim = field_dim - 1
353               data_direc = 'xy'
354               nzt = 1
355               firstz = 0
356               lastz = 0
357            ENDIF
358
359         ENDIF ELSE BEGIN
360            print, '    Reading ', var_name, ' (3D data time serie)',  strcompress(string(time_1)),'-', strtrim(string(time_2), 2), '   from ', file_name
361            ; read vertical levels
362            IF mesh_type EQ 'atm' THEN BEGIN
363               ncdf_diminq,cdfid,2, name_level, nb_level
364
365               ; get name of vertical level from metadata
366               file_grid_config = hom_def+'grid_config.def'
367               spawn, 'grep -i "\ '+meshlec_type+' " '+file_grid_config, line
368               line = strcompress(strtrim(line[0], 2))
369               length = strlen(line)
370   
371               IF length EQ 0 THEN BEGIN
372                  print, '    *** nc_read : define name_level from grid ', meshlec_type, $
373                   ' in file ', file_grid_config
374                  name_level = ''
375                  return, -1
376               ENDIF ELSE BEGIN
377                  argvar = str_sep(line, ' ')
378                  name_level = argvar[1]
379               ENDELSE
380               dimidl = ncdf_dimid(cdfid, name_level)
381               ncdf_diminq,cdfid,dimidl, name_level, nb_level
382
383               varidl = ncdf_varid(cdfid, name_level)
384               ; make sure name_level is in hPa
385               ncdf_attget, cdfid, varidl, 'units', val_unit
386               IF string(val_unit) NE 'hPa' AND string(val_unit) NE 'millibar' AND string(val_unit) NE 'mbar' THEN BEGIN
387                  print, '  vertical levels coordinate not obvious'
388                  print, '  ... using <levels> ...'
389                  varidl = ncdf_varid(cdfid, 'levels')
390               ENDIF
391               ncdf_varget, cdfid, varidl, gdept
392               gdepw = gdept
393               e3t = shift(gdept, 1)-gdept
394               e3t[0] = e3t[1]
395               e3w = e3t
396               jpk = nb_level
397               tmask = reform((reform(tmask(*, *), jpi*jpj)#replicate(1, jpk)), jpi, jpj, jpk)
398            ENDIF
399            @read_ncdf_varget
400            lec_data = res
401            data_direc = 'xyzt'
402
403;           vertical average ?
404            IF vert_switch ge 1  AND NOT keyword_set(no_mean) THEN BEGIN
405               old_boite = [lon1, lon2, lat1, lat2, prof1, prof2]
406               print, '      Average in vertical domain ', vert_type, vert_mean
407               IF mesh_type EQ 'atm' THEN BEGIN
408                  CASE atmos_msk OF
409                     0: print, '          [take all points] ' ; take all points
410                     1: BEGIN
411                        ; take ocean points only
412                        idx = where(tmask EQ 0)
413                        lec_data(idx) = 1.e20
414                        print, '          [take ocean points only] '
415                     END
416                     2: BEGIN
417                        ; take land points only
418                        idx = where(tmask GT 0)
419                        lec_data(idx) = 1.e20
420                        print, '          [take land points only] '
421                     END
422                  ENDCASE
423                  CASE vert_type OF
424                     'z': BEGIN ; levels
425                       
426                        IF vert_mean[0] EQ vert_mean[1] THEN BEGIN
427                           name_suff = ' at '+strtrim(string(long(gdept(vert_mean(0)))), 2)+' hPa'
428                        ENDIF ELSE BEGIN
429                           zmean = grossemoyenne(lec_data, 'z', boite = vert_mean)
430                           name_suff = ' averaged in '+vert_type+'['+strtrim(string(vert_mean(0)), 2)+','+strtrim(string(vert_mean(1)), 2)+']'
431                        ENDELSE
432                     END
433                     ELSE: BEGIN ; levels
434                        IF vert_mean[0] EQ vert_mean[1] THEN BEGIN
435                           zmean = lec_data(*, *, vert_mean[0])
436                           name_suff = ' at '+vert_type+' '+strtrim(string(long(vert_mean(0))), 2)+' ['+strtrim(string(gdept(vert_mean(0))), 2)+' hPa]'
437                        ENDIF ELSE BEGIN
438                           zmean = moyenne(lec_data, 'z', boite = vert_mean, /zindex)
439                           name_suff = ' averaged in '+vert_type+'['+strtrim(string(long(vert_mean(0))), 2)+','+strtrim(string(long(vert_mean(1))), 2)+']'
440                        ENDELSE
441                     END
442                  ENDCASE
443;                  tmask = reform(tmask(*, *, 0), jpi, jpj)
444               ENDIF ELSE BEGIN
445                  ; ocean = always mask
446                  ; idx = where(tmask EQ 0)
447                  ; lec_data(idx) = 1.e20
448                  CASE vert_type OF
449                     'z': BEGIN
450                        IF vert_mean[0] EQ vert_mean[1] THEN BEGIN
451                           zmean = lec_data
452                           name_suff = ' at '+strtrim(string(long(gdept(vert_mean(0))+.1)), 2)+' m'
453                        ENDIF ELSE BEGIN
454                           zmean = grossemoyenne(lec_data, 'z', boite = vert_mean)
455                           name_suff = ' averaged in '+vert_type+'['+strtrim(string(long(vert_mean(0))), 2)+','+strtrim(string(long(vert_mean(1))), 2)+']'
456                        ENDELSE
457                     END
458                     ELSE: BEGIN
459                        IF vert_mean[0] EQ vert_mean[1] THEN BEGIN
460                           zmean = lec_data
461                           name_suff = ' at '+strtrim(string(long(gdept(vert_mean(0))+.1)), 2)+' m'
462                        ENDIF ELSE BEGIN
463                           zmean = moyenne(lec_data, 'z', boite = vert_mean, /zindex, NAN =1.e20)
464                           name_suff = ' averaged in '+vert_type+'['+strtrim(string(long(vert_mean(0))), 2)+','+strtrim(string(long(vert_mean(1))), 2)+']'
465                        ENDELSE
466                     END
467                  ENDCASE
468               ENDELSE
469               lec_data = zmean
470               domdef, old_boite
471               field_dim = field_dim - 1
472               data_direc = 'xyt'
473               nzt = 1
474               firstz = 0
475               lastz = 0
476            ENDIF
477         ENDELSE
478      END
479     ;; erreur si dim > 4
480      ELSE: BEGIN
481         err_mess =  '  *** nc_read : ERROR dimension > 4'
482         lec_data = -1.0
483      END
484   ENDCASE
485
486; scaling ?
487   FOR i = 0, varinq.natts-1 DO BEGIN
488      att_txt = ncdf_attname(cdfid, varid, i)
489      IF att_txt EQ 'scale_factor' THEN BEGIN
490         ncdf_attget, cdfid, varid, att_txt, valscale
491         lec_data = lec_data*valscale
492      ENDIF
493   ENDFOR
494
495; Attribut du champ
496
497   field = {name: '', data: lec_data, legend: '', units: '', origin: '', dim: 0, direc: data_direc}
498   field.name = var_name
499   field.origin = directory+file_name
500;
501; get long name
502;   result = '???'
503   FOR i = 0, varinq.natts-1 DO BEGIN
504      att_txt = ncdf_attname(cdfid, varid, i)
505      IF att_txt EQ 'long_name' OR att_txt EQ 'title' THEN ncdf_attget, cdfid, varid, att_txt, result
506   ENDFOR
507   field.legend = strtrim(string(result),1)+name_suff
508
509; get unit
510; if it exists
511  isunits = ncdf_attinq(cdfid,  varid,  'units')
512  IF isunits.datatype NE 'UNKNOWN' THEN BEGIN
513     ncdf_attget, cdfid, varid, 'units', result
514     field.units = strtrim(string(result),1)
515  ENDIF ELSE BEGIN
516     print,  'No units for the variable ',  field.name
517     print,  ' Or units were forgotten in the file !'
518  ENDELSE
519  field.dim = field_dim
520
521
522;  get valmask (might need valmask = float(string(valmask))
523
524   valmask = 1.e20
525   FOR i = 0, varinq.natts-1 DO BEGIN
526      att_txt = ncdf_attname(cdfid, varid, i)
527      IF att_txt EQ 'missing_value' OR att_txt EQ 'mask value' OR att_txt EQ '_FillValue' THEN ncdf_attget, cdfid, varid, att_txt, valmask
528   ENDFOR
529
530; set valmask to 1.e20
531
532; ensure valmask is positive
533
534   IF valmask LT 0 THEN BEGIN
535      print, '      *** Warning valmask is negative - changing sign: ', valmask
536      idx_t = where (field.data EQ valmask)
537      IF idx_t(0) NE -1 THEN field.data(idx_t) = -valmask
538      valmask = -valmask
539      idx_t=0 ; free memory
540   ENDIF
541
542; min/max
543
544   chardim = ' - dim = '
545   FOR i = 1, (size(field.data))[0] DO BEGIN
546      chardim = chardim+string((size(field.data))[i], format = '(I5)')
547   ENDFOR 
548
549   index_test = (where (field.data NE valmask))
550   IF index_test(0) NE -1 THEN BEGIN
551      minf = min(field.data(where (field.data NE valmask)))
552      maxf = max(field.data(where (field.data NE valmask)))
553   ENDIF ELSE BEGIN
554      minf =  min(field.data)
555      maxf =  max(field.data)
556   ENDELSE
557
558   print, '      = ',field.legend, '    [min/max = ',minf , maxf,'  ', field.units,' - masked values = ',valmask, chardim, ']'
559
560
561   ncdf_close, cdfid
562
563;key_offset = key_offset_orig
564;jpi = jpi_orig
565;jpj = jpj_orig
566;jpk = jpk_orig
567
568   IF keyword_set(key_yreverse) THEN print, '    key_yreverse active : ',  key_yreverse
569
570   IF debug_w THEN print,  '  ...EXIT nc_read'
571   IF debug_w THEN print,  '  '
572
573   return, field
574
575
576END
Note: See TracBrowser for help on using the repository browser.