source: trunk/GRILLE/whichgrid.pro @ 2

Last change on this file since 2 was 2, checked in by opalod, 22 years ago

Initial revision

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 15.0 KB
Line 
1;*********************************************************************
2PRO readmesh, filename, filetype, _extra = ex
3;
4   case filetype of
5      'OPA C-Grid.Binary IEEE: Meshmask':BEGIN
6         meshlec, filename, /pasblabla, _extra = ex
7      END
8      'OPA C-Grid.Net Cdf: Meshmask':BEGIN
9         ncdf_meshlec, filename, _extra = ex
10      END
11      'Regular 2D.Binary IEEE: mask':
12      'Regular 2D.Net Cdf: mask':
13      'Regular 3D.Binary IEEE: mask+vertical axis':
14      'Regular 3D.Net Cdf: mask+vertical axis':
15      'Gaussian 2D.T30 truncature.Binary IEEE: mask':
16      'Gaussian 2D.T30 truncature.Net Cdf: mask':
17      'Gaussian 2D.T42 truncature.Binary IEEE: mask':
18      'Gaussian 2D.T42 truncature.Net Cdf: mask':
19      'Gaussian 3D.T30 truncature.Binary IEEE: mask':
20      'Gaussian 3D.T30 truncature.Net Cdf: mask':
21      'Gaussian 3D.T42 truncature.Binary IEEE: mask':
22      'Gaussian 3D.T42 truncature.Net Cdf: mask':
23      ELSE :
24   ENDCASE
25;
26   return
27end
28;*********************************************************************
29FUNCTION getgridparameter, top
30@common
31
32   widget_control, widget_info(top, find_by_uname = 'xmesh'), get_value = answer
33   jpiglo = long(answer[0])
34   jpi = long(answer[1])
35   ixminmesh = long(answer[2])
36   ixmaxmesh = long(answer[3])
37   widget_control, widget_info(top, find_by_uname = 'ymesh'), get_value = answer
38   jpjglo = long(answer[0])
39   jpj = long(answer[1])
40   iyminmesh = long(answer[2])
41   iymaxmesh = long(answer[3])
42   widget_control, widget_info(top, find_by_uname = 'zmesh'), get_value = answer
43   jpkglo = long(answer[0])
44   jpk = long(answer[1])
45   izminmesh = long(answer[2])
46   izmaxmesh = long(answer[3])
47   widget_control, widget_info(top, find_by_uname = 'key_shift') $
48    , get_value = answer
49   key_shift = long(answer[0])
50   widget_control, widget_info(top, find_by_uname = 'key_periodique') $
51    , get_value = answer
52   key_periodique = long(answer[0])
53   widget_control, widget_info(top, find_by_uname = 'triangulation') $
54    , get_value = answer
55   triangulation = answer[0] EQ 'y'
56   widget_control, widget_info(top, find_by_uname = 'Glam Boundary') $
57    , get_value = answer
58   rien = execute('boundary = float('+answer[0]+')')
59   res = {jpiglo:jpiglo, jpjglo:jpjglo, jpkglo:jpkglo, jpi:jpi, jpj:jpj, jpk:jpk $
60          , ixminmesh:ixminmesh, ixmaxmesh:ixmaxmesh $
61          , iyminmesh:iyminmesh, iymaxmesh:iymaxmesh $
62          , izminmesh:izminmesh, izmaxmesh:izmaxmesh $
63          , key_shift:key_shift, key_periodique:key_periodique $
64          , triangulation:triangulation, boundary:boundary}
65
66   return, res
67end
68;*********************************************************************
69pro showgridparameter, basetop, EDITABLE = editable, _EXTRA = ex
70;
71@common
72;------------------------------------------------------------
73;
74   widget_control, basetop, update = 0
75   base=widget_base(basetop, /COLUMN, /align_center, _EXTRA = ex)
76   nothing = cw_fourparameter(base, jpiglo, jpi, ixminmesh, ixmaxmesh, 'x', 'mesh', EDITABLE = editable, CLEAR = editable, uname = 'xmesh')
77   nothing = cw_fourparameter(base, jpjglo, jpj, iyminmesh, iymaxmesh, 'y', 'mesh', EDITABLE = editable, CLEAR = editable, uname = 'ymesh')
78   nothing = cw_fourparameter(base, jpkglo, jpk, izminmesh, izmaxmesh, 'z', 'mesh', EDITABLE = editable, CLEAR = editable, uname = 'zmesh')
79   nothing = widget_label(base, value = 'autres parametres ...')
80   basea=widget_base(base, /row, /align_center)
81   nothing = widget_label(basea, value = 'key_shift')
82   if NOT keyword_set(key_shift) then key_shift = 0
83   nothing = widget_text(basea, value = strtrim(key_shift*(1-keyword_set(editable)),1), uname = 'key_shift', xsize = 4, EDITABLE = editable)
84   nothing = widget_label(basea, value = 'key_periodique')
85   if NOT keyword_set(key_periodique) then key_periodique = 0
86   nothing = widget_text(basea, value = strtrim(key_periodique*(1-keyword_set(editable)),1), uname = 'key_periodique', xsize = 4, EDITABLE = editable)
87   baseb=widget_base(base, /row, /align_center)
88   nothing = widget_label(baseb, value = 'use a triangulation (y/n) ?')
89   nothing = widget_text(baseb, value = 'y', uname = 'triangulation', xsize = 4, EDITABLE = editable)
90   if NOT keyword_set(editable) then begin
91      ming = min(glamt, max = maxg)
92      value = tostr([floor(ming), ceil(maxg)])
93   ENDIF ELSE value = tostr([0, 0])
94   nothing = widget_label(baseb, value = 'Glam Boundary')
95   nothing = widget_text(baseb, value = value, uname = 'Glam Boundary', xsize = 10, EDITABLE = editable)
96   nothing = widget_button(base, value = 'Ok, Get the Mesh parameters!', uvalue = {name:'ok finish'})
97   widget_control, basetop, update = 1
98;
99   return
100END
101;*********************************************************************
102FUNCTION give_file_type_choice, type = type
103   if keyword_set(type) then begin
104      case type of
105         'nc':desc = [ '1\File or Grid type: ' , $
106            '0\OPA C-Grid.Net Cdf: Meshmask' , $
107            '0\Regular 2D.Net Cdf: mask' , $
108            '0\Regular 3D.Net Cdf: mask+vertical axis' , $
109            '1\Gaussian 2D' , $
110            '0\T30 truncature.Net Cdf: mask' , $
111            '2\T42 truncature.Net Cdf: mask' , $
112            '1\Gaussian 3D' , $
113            '0\T30 truncature.Net Cdf: mask+vertical axis' , $
114            '2\T42 truncature.Net Cdf: mask+vertical axis' , $
115            '2\No file' ]
116      endcase
117   ENDIF ELSE BEGIN
118         desc = [ '1\File or Grid type: ' , $
119            '0\OPA C-Grid.Binary IEEE: Meshmask' , $
120            '0\Regular 2D.Binary IEEE: mask' , $
121            '0\Regular 3D.Binary IEEE: mask+vertical axis' , $
122            '1\Gaussian 2D' , $
123            '0\T30 truncature.Binary IEEE: mask' , $
124            '2\T42 truncature.Binary IEEE: mask' , $
125            '1\Gaussian 3D' , $
126            '0\T30 truncature.Binary IEEE: mask+vertical axis' , $
127            '2\T42 truncature.Binary IEEE: mask+vertical axis' , $
128            '2\No file' ]
129;    desc = [ '1\File or Grid type: ' , $
130;             '1\OPA C-Grid' , $
131;             '0\Binary IEEE: Meshmask' , $
132;             '2\Net Cdf: Meshmask' , $
133;             '1\Regular 2D' , $
134;             '0\Binary IEEE: mask' , $
135;             '2\Net Cdf: mask' , $
136;             '1\Regular 3D' , $
137;             '0\Binary IEEE: mask+vertical axis' , $
138;             '2\Net Cdf: mask+vertical axis' , $
139;             '1\Gaussian 2D' , $
140;             '1\T30 truncature' , $
141;             '0\Binary IEEE: mask' , $
142;             '2\Net Cdf: mask' , $
143;             '1\T42 truncature' , $
144;             '0\Binary IEEE: mask' , $
145;             '2\Net Cdf: mask' , $
146;             '2\' , $
147;             '1\Gaussian 3D' , $
148;             '1\T30 truncature' , $
149;             '0\Binary IEEE: mask+vertical axis' , $
150;             '2\Net Cdf: mask+vertical axis' , $
151;             '1\T42 truncature' , $
152;             '0\Binary IEEE: mask+vertical axis' , $
153;             '2\Net Cdf: mask+vertical axis' , $
154;             '2\' , $
155;             '2\No file' ]
156ENDELSE
157   return, desc
158end
159;*********************************************************************
160PRO whichgrid_event, event
161@common
162   widget_control, event.id,  get_uvalue = eventuvalue
163   IF chkstru(eventuvalue,'name') EQ 0 THEN return
164   case eventuvalue.name OF
165      'Cancel':BEGIN
166         widget_control, event.handler, get_uvalue = messenger
167         *messenger = -1
168         widget_control,event.handler,/destroy
169      END
170      'filename':BEGIN
171; on detruit, si il existe deja, ce que l''on va ajouter au widget
172         typebaseid = widget_info(event.handler, find_by_uname = 'typebase')
173         if typebaseid NE 0 then widget_control,typebaseid,/destroy
174         showgridparameterid = widget_info(event.handler, find_by_uname = 'showgridparameter')
175         if showgridparameterid NE 0 then widget_control,showgridparameterid,/destroy
176;
177         widget_control, event.id, get_value = filename
178         filename = filename[0]
179         filename = isafile(filename = filename)
180         if size(filename, /type) NE 7 then return
181         if rstrpos(filename, '.pro') EQ strlen(filename)-4 then begin
182            createpro, '@'+strmid(filename, 0, strlen(filename)-4) $
183          , filename = isadirectory(io = homedir, title = 'Bad definition of Homedir') $
184          +'for_createpro.pro'
185            showgridparameter, event.handler, group_leader = event.handler,/frame, uname = 'showgridparameter'
186         ENDIF ELSE BEGIN
187            basetype=widget_base(event.handler, /row, /align_center, group_leader = event.handler, uname = 'typebase')
188            type = ''
189            if rstrpos(filename, '.nc') EQ strlen(filename)-3 then type = 'nc'
190            nothing = cw_pdmenu(basetype, give_file_type_choice(type = type), /return_full_name, uname = 'file type choice', uvalue = {name:'file type choice'})
191            nothing = widget_text(basetype, value = '', uname = 'file type', uvalue = {name:'file type'})
192         ENDELSE
193      END
194      'browse filename':BEGIN
195; on detruit, si il existe deja, ce que l''on va ajouter au widget
196         typebaseid = widget_info(event.handler, find_by_uname = 'typebase')
197         if typebaseid NE 0 then widget_control,typebaseid,/destroy
198         showgridparameterid = widget_info(event.handler, find_by_uname = 'showgridparameter')
199         if showgridparameterid NE 0 then widget_control,showgridparameterid,/destroy
200;
201         filename = isafile()
202         if size(filename, /type) NE 7 then return
203         widget_control, widget_info(event.handler, find_by_uname = 'Filename'), set_value = filename
204         if rstrpos(filename, '.pro') EQ strlen(filename)-4 then begin
205            createpro, '@'+strmid(filename, 0, strlen(filename)-4) $
206          , filename = isadirectory(io = homedir, title = 'Bad definition of Homedir') $
207          +'for_createpro.pro'
208            showgridparameter, event.handler, group_leader = event.handler,/frame, uname = 'showgridparameter'
209         ENDIF ELSE BEGIN
210            basetype=widget_base(event.handler, /row, /align_center, group_leader = event.handler, uname = 'typebase')
211            type = ''
212            if rstrpos(filename, '.nc') EQ strlen(filename)-3 then type = 'nc'
213            nothing = cw_pdmenu(basetype, give_file_type_choice(type = type), /return_full_name, uname = 'file type choice', uvalue = {name:'file type choice'})
214            nothing = widget_text(basetype, value = '', uname = 'file type', uvalue = {name:'file type'})
215         ENDELSE
216      END
217      'file type choice':BEGIN
218         widget_control, widget_info(event.handler,find_by_uname='Filename'), get_value = filename
219         filename = filename[0]
220         filetype = event.value
221         filetype = strmid(filetype, strpos(filetype, '.')+1)
222         widget_control, widget_info(event.handler, find_by_uname = 'file type'), set_value = filetype
223         case filetype of
224            'OPA C-Grid.Binary IEEE: Meshmask':BEGIN
225               meshlec, filename, /pasblabla, /getdimensions
226               showgridparameter, event.handler, /editable, group_leader = event.handler,/frame, uname = 'showgridparameter'
227            END
228            'OPA C-Grid.Net Cdf: Meshmask':BEGIN
229               ncdf_meshlec, filename, /getdimensions
230               showgridparameter, event.handler, /editable, group_leader = event.handler,/frame, uname = 'showgridparameter'
231            END
232            'Regular 2D.Binary IEEE: mask':
233            'Regular 2D.Net Cdf: mask':
234            'Regular 3D.Binary IEEE: mask+vertical axis':
235            'Regular 3D.Net Cdf: mask+vertical axis':
236            'Gaussian 2D.T30 truncature.Binary IEEE: mask':
237            'Gaussian 2D.T30 truncature.Net Cdf: mask':
238            'Gaussian 2D.T42 truncature.Binary IEEE: mask':
239            'Gaussian 2D.T42 truncature.Net Cdf: mask':
240            'Gaussian 3D.T30 truncature.Binary IEEE: mask':
241            'Gaussian 3D.T30 truncature.Net Cdf: mask':
242            'Gaussian 3D.T42 truncature.Binary IEEE: mask':
243            'Gaussian 3D.T42 truncature.Net Cdf: mask':
244            ELSE :
245         endcase
246
247      END
248      'file type':BEGIN
249         help, event, /struct
250      END
251      'ok finish':BEGIN
252         widget_control, widget_info(event.handler,find_by_uname='Filename'),get_value=filename
253         filename = filename[0]
254         typeid = widget_info(event.handler,find_by_uname='file type')
255         if typeid NE 0 then begin
256            widget_control, typeid, get_value=filetype
257            filetype = filetype[0]
258         ENDIF ELSE filetype = 'batch file'
259         widget_control, event.handler, get_uvalue = messenger
260         *messenger = create_struct('filename', filename, 'filetype', filetype, getgridparameter(event.handler))
261;
262         readmesh, filename, filetype[0], glamboundary = (*messenger).boundary
263;
264         widget_control,event.handler,/destroy
265      END     
266      ELSE:
267   endcase
268   return
269END
270;*********************************************************************
271FUNCTION whichgrid, name, IODIRECTORY = iodirectory, PARENT = parent, _EXTRA = ex
272@common
273;
274;
275   if n_elements(name) NE 0 then begin
276      filename = isafile(filename = name)
277      if size(filename, /type) NE 7 then return, -1
278   ENDIF ELSE filaname = 'no file'
279;
280; pour recuperer les reponses possees lors de l''utilisation de ce
281; widget on cree un pointeur que l''on place dans la uvalue. Comme ca
282; une fois que le widget est detruit dans la procedure ...event.pro,
283; la variable surlaquelle pointait le pointeur (contenue ds la uvalue
284; du widget) n''est pas detruite est on peut recuperer le resultat!
285;
286   messenger = ptr_new(/allocate_heap)
287;
288   if keyword_set(parent) then BEGIN
289   base=widget_base(parent, /COLUMN, title = 'whichgrid', /align_center, uvalue = messenger, _EXTRA = ex)
290   ENDIF ELSE BEGIN
291      base=widget_base(/COLUMN, title = 'whichgrid', /align_center, uvalue = messenger, _EXTRA = ex)
292      nothing = widget_button(base, value = 'Cancel', uvalue = {name:'Cancel'})
293   ENDELSE
294;
295   basemane=widget_base(base, /row, /align_center)
296   nothing = widget_label(basemane, value = 'Mesh Filename or IDL batch file')
297   nothing = widget_text(basemane, value = filename, uname = 'Filename', uvalue = {name:'filename'}, /editable)
298   nothing = widget_button(basemane, value = 'Browse', uvalue = {name:'browse filename'})
299;
300   if filename NE 'no file' then begin
301      if rstrpos(filename, '.pro') EQ strlen(filename)-4 then begin
302         createpro, '@'+strmid(filename, 0, strlen(filename)-4) $
303          , filename = isadirectory(io = homedir, title = 'Bad definition of Homedir') $
304          +'for_createpro.pro'
305         showgridparameter, base, group_leader = base,/frame, uname = 'showgridparameter'
306      ENDIF ELSE BEGIN
307         basetype=widget_base(base, /row, /align_center, group_leader = base, uname = 'typebase')
308         type = ''
309         if rstrpos(filename, '.nc') EQ strlen(filename)-3 then type = 'nc'
310         nothing = cw_pdmenu(basetype, give_file_type_choice(type = type), /return_full_name, uname = 'file type choice', uvalue = {name:'file type choice'})
311         nothing = widget_text(basetype, value = '', uname = 'file type', uvalue = {name:'file type'})
312      ENDELSE
313
314   endif
315;
316   widget_control,base,/realize
317   xmanager,'whichgrid', base,event_handler = 'whichgrid_event', no_block = 0
318   res = *messenger
319   ptr_free, messenger
320
321
322   return, res
323end
Note: See TracBrowser for help on using the repository browser.