source: trunk/procs/meshes/mesh_from_file.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: 2.7 KB
Line 
1PRO mesh_from_file, model, file_name, ncdf_db, var_name
2@common
3@com_eg
4;
5; init grid, sf from file_name
6; masks made in data_read
7;
8   IF debug_w THEN print, '  ENTER mesh_from_file...'
9
10   IF strpos(ncdf_db, ':') GE 1 THEN directory = (str_sep(ncdf_db, ':'))[1] $
11    ELSE directory = ncdf_db
12
13   s_file = directory+file_name
14
15   print,'   Model inits for ', model, ' from file: ', s_file
16
17   sm_file = hom_idl+'grids/grids_'+model+'.nc'
18   res = find(sm_file)
19   varexpp = varexp
20   IF res NE 'NOT FOUND' THEN BEGIN
21
22      initncdf, s_file, GLAMBOUNDARY = glamboundary_box
23
24      print, '    Found mask from ',sm_file
25
26      tmask = byte(read_ncdf('sftlf', 0, 0, /timestep, file = sm_file, /nostruct))
27     
28      idx = where(tmask EQ valmask)
29
30      IF idx(0) NE -1 THEN tmask(idx) = 0.
31      idx =  where(tmask LE 50.)
32      tmask(idx) = 0.
33      tmask =  tmask < 1
34      tmask =  1-tmask
35      triangles=triangule()
36
37   ENDIF ELSE BEGIN
38      CASE var_name OF
39         '@@voenergy': var_local = 'so'
40         ELSE: var_local = var_read_grd_file
41      ENDCASE
42      IF strpos(var_local, '=f(next)') NE -1 THEN BEGIN
43         idx = strpos(var_local, '=f(')
44         var_local = strmid(var_local, 0, idx)
45      ENDIF
46
47      IF debug_w THEN print, '   var_local = ', var_local
48
49      ; find valmask
50      cdfidl=ncdf_open(s_file)
51      contient=ncdf_inquire(cdfidl)
52      varidl = ncdf_varid(cdfidl, var_local)
53      varcontient=ncdf_varinq(cdfidl, var_local)
54      valmask = 1.e20
55      FOR i = 0, varcontient.natts-1 DO BEGIN
56         att_txt = ncdf_attname(cdfidl, varidl, i)
57         IF att_txt EQ 'missing_value' OR att_txt EQ 'mask value' OR att_txt EQ '_FillValue' THEN BEGIN
58            ncdf_attget, cdfidl, varidl, att_txt, valmask
59            IF debug_w THEN print, '     valmask found = ',valmask, ' in attribute ', att_txt
60         ENDIF
61      ENDFOR
62      ncdf_close, cdfidl
63      ; build grid
64      CASE mesh_type of
65         'atm': initncdf, s_file, GLAMBOUNDARY = glamboundary_box, ZAXISNAME = name_level
66         ELSE: initncdf, s_file, USEASMASK = var_local, missing_value = valmask, GLAMBOUNDARY = glamboundary_box, ZAXISNAME = 'depth'
67      ENDCASE
68      IF debug_w THEN print,  '     Grid info after initncdf :'
69      IF debug_w THEN print,  '     glamt :', size(glamt)
70      IF debug_w THEN print,  '     gphit :', size(gphit)
71      IF debug_w THEN print,  '     gdept :', size(gdept)
72     
73   ENDELSE
74
75   varexp = varexpp
76
77   key_offset = [0, 0, 0]
78;
79; indice i pour grille j moyenne zonale
80;
81   diaznl_idx = 1
82   IF debug_w THEN print, '     model, vargrid, varexp at exit = ',model, ' ', vargrid,' ',  varexp
83   IF debug_w THEN print, '  ...EXIT mesh_from_file'
84   IF debug_w THEN print, '  '
85
86  return
87END
88
Note: See TracBrowser for help on using the repository browser.