source: trunk/SRC/ToBeReviewed/WIDGET/AUTOUR_de_XXX/buildreadcmd.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:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 7.0 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5; NAME:buildreadcmd
6;
7; PURPOSE:
8;
9; CATEGORY:
10;
11; CALLING SEQUENCE:
12;
13; INPUTS:
14;
15; KEYWORD PARAMETERS:
16;
17; OUTPUTS:
18;
19; COMMON BLOCKS:common.pro
20;
21; SIDE EFFECTS:
22;
23; RESTRICTIONS:
24;
25; EXAMPLE:
26;
27; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr)
28;
29;-
30;------------------------------------------------------------
31;------------------------------------------------------------
32;------------------------------------------------------------
33FUNCTION buildreadcmd, base, snameexp, procedure, type, BOXZOOM = boxzoom $
34                       , COMPLETE = complete, NAMEFIELD = namefield
35;
36;
37  compile_opt idl2, strictarrsubs
38;
39@cm_4cal ; for key_caltype
40;------------------------------------------------------------
41; get back widgets IDs
42;------------------------------------------------------------
43  vlstid = widget_info(base, find_by_uname = 'varlist')
44  date1id = widget_info(base, find_by_uname = 'calendar1')
45  date2id = widget_info(base, find_by_uname = 'calendar2')
46  domainid = widget_info(base, find_by_uname = 'domain')
47;   optionid = widget_info(base, find_by_uname = 'option')
48;------------------------------------------------------------
49  widget_control, base, get_uvalue = top_uvalue
50  numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1
51  numdessinout = (extractatt(top_uvalue, 'smallout'))[2]-1
52;---------------
53; name of the file
54;---------------
55  currentfile = extractatt(top_uvalue, 'currentfile')
56  filelist = extractatt(top_uvalue, 'filelist')
57  filename = filelist[currentfile]
58  sfilename = ''''+filename+''''
59;---------------
60; name of the variable
61;---------------
62  if keyword_set(namefield) then namevar = namefield $
63  ELSE namevar = widget_info(vlstid, /combobox_gettext)
64  snamevar = ''''+namevar+''''
65;
66; get the options
67;
68  options = extractatt(top_uvalue, 'options')   
69  flags = extractatt(top_uvalue, 'optionsflag')
70  flags = flags[*, numdessinin]
71  xindex = (flags[where(options EQ 'Longitude / x index')])[0]
72  yindex = (flags[where(options EQ 'Latitude / y index')])[0]
73;
74  extra = extractatt(top_uvalue, 'extra')
75  if xindex NE 0 then extra = create_struct(extra, 'xindex', xindex)
76  if yindex NE 0 then extra = create_struct(extra, 'yindex', yindex)
77  exextra = cw_specifie_get_value(base)
78  exextra = extractstru(exextra, ['min', 'max', 'inter', 'lct'])
79  if size(exextra, /type) EQ 8 then extra = mixstru(exextra, extra)
80  sextra = struct2string(extra)
81;---------------
82; find date1 and date2
83;---------------
84  key_caltype = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).caltype
85  widget_control, date1id, get_value = date1
86  widget_control, date2id, get_value = date2
87
88  if procedure EQ 'pltt' AND date1 EQ date2 then BEGIN
89; we redefine the dates to the begining and end of the calendar
90    calendar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).time_counter
91    date1 = jul2date(calendar[0])
92    date2 = jul2date(calendar[n_elements(calendar)-1])
93    widget_control, date1id, set_value = date1
94    widget_control, date2id, set_value = date2
95  endif
96;
97  fakecal = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).fakecal
98  IF keyword_set(fakecal) THEN BEGIN
99    date1 = date2jul(date1) - fakecal
100    date2 = date2jul(date2) - fakecal
101  ENDIF
102  sdate1 = strtrim(date1, 1) & sdate2 = strtrim(date2, 1)
103;---------------
104; find boxzoom
105;---------------
106  if NOT keyword_set(boxzoom) then widget_control, domainid, get_value = boxzoom
107; put boxzoom into a string
108  box = '['+strtrim(boxzoom[0], 1)
109  for i = 1, (n_elements(boxzoom)-1) < (3+2*(strpos(type, 'z') EQ -1)) do $
110     box = box+', '+strtrim(boxzoom[i], 1)
111  if strpos(type, 'z') NE -1 then BEGIN
112      @common
113      min = min([gdept, gdepw], max = max)
114      box = box+','+strtrim(floor(min), 1)+','+strtrim(ceil(max), 1)
115    endif
116  box = box+']'
117  IF strpos(type, ' diag up') NE -1 THEN BEGIN
118    sendpoints = '[' + strtrim(boxzoom[0], 1) + ', ' + strtrim(boxzoom[2], 1) + $
119                ', ' + strtrim(boxzoom[1], 1) + ', ' + strtrim(boxzoom[3], 1) + ']'
120  ENDIF
121  IF strpos(type, ' diag dn') NE -1 THEN BEGIN
122    sendpoints = '[' + strtrim(boxzoom[0], 1) + ', ' + strtrim(boxzoom[3], 1) + $
123                ', ' + strtrim(boxzoom[1], 1) + ', ' + strtrim(boxzoom[2], 1) + ']'
124  ENDIF
125;---------------
126; find funclec_name, readparameters, meshparameters
127;---------------
128  readparameters = *(extractatt(top_uvalue, 'readparameters'))[currentfile]
129  funclec_name = readparameters.funclec_name
130  if keyword_set(complete) then begin
131    sreadparameters = struct2string(readparameters)
132    meshparameters = *(extractatt(top_uvalue, 'meshparameters'))[currentfile]
133    smeshparameters = struct2string(meshparameters)
134;------------------------------------------------------------
135;------------------------------------------------------------
136;------------------------------------------------------------
137; on va definir le string qui contiendra la commande a executer pour
138; la lecture
139;------------------------------------------------------------
140    Cmd = ['; Definition of extra structure:', 'extra = '+sextra $
141           , '; Definition of readparameters structure:', 'readparameters = '+sreadparameters $
142           , '; Do we change of reading?:', 'dummy = changeread(readparameters)' $
143           , '; Definition of meshparameters structure:', 'meshparameters = '+smeshparameters $
144           , '; Do we change the grid?:', 'dummy = changegrid(meshparameters)' $
145           , '; Read the data...' $
146           , 'if n_elements(date1in) ne 0 then date1 = date1in else date1 = ' + sdate1 $
147           , 'if n_elements(date2in) ne 0 then date2 = date2in else date2 = ' + sdate2 $
148           , funclec_name+'('+snamevar+', date1, date2, '+snameexp $
149           + ', timestep = '+strtrim(keyword_set(fakecal), 1)+', parent = '+strtrim(base, 2) $
150           + ', boxzoom = '+box+', /findalways $' $
151           , '    , filename = '+sfilename+' $']
152    if n_elements(sendpoints) NE 0 then $
153       Cmd = [Cmd, '    , endpoints = ' + sendpoints + ', type = ''' + type  + ''' $']
154    Cmd = [Cmd, '    , _extra = mixstru(ex, extra), /nostruct)']
155    (*top_uvalue[1, findline(top_uvalue, 'varinfo')])[*, numdessinout] = [filename, namevar]
156    (*top_uvalue[1, findline(top_uvalue, 'dates')])[*, numdessinout] = [date1, date2]
157  ENDIF ELSE BEGIN
158    Cmd = [funclec_name+'('+snamevar+', date1, date2, '+snameexp $
159           +', parent = '+strtrim(base, 1)+', boxzoom = '+box+' $' $
160           , '    , filename = '+sfilename+' $']
161    if n_elements(sendpoints) NE 0 then $
162       Cmd = [Cmd, '    , endpoints = ' + sendpoints + ', type = ''' + type  + ''' $']
163    Cmd = [Cmd, '    , _extra = mixstru(ex, extra), /nostruct)']
164  ENDELSE
165;    print, '::::::::::::::::::::::'
166;    for i = 0, n_elements(Cmd)-1 do print, Cmd[i]
167;    print, '::::::::::::::::::::::'
168;------------------------------------------------------------
169
170;------------------------------------------------------------
171  return, cmd
172end
Note: See TracBrowser for help on using the repository browser.