source: trunk/procs/def_file_name.pro @ 216

Last change on this file since 216 was 216, checked in by ericg, 14 years ago

Integration of large_domain option in ybinx (from James)

  • Property svn:keywords set to Id
File size: 5.8 KB
Line 
1;+
2;
3; define file name following
4; <expid>_<timeave>_<date1>_<date2>[_<spec>]_<grid> convention
5;
6; @param CMD {in}{required}{type=structure}
7;
8; @param NCDF_DB {in}{required}{type=string}
9; <location>:<path> or just <path>
10;
11; @param FILE_NAME {out}{type=string}
12;
13; @param DELTA_T1 {out}{type=integer}
14;
15; @examples
16;
17; IDL> cmd={timave:'1m',date1:'199201',plt:'xy',spec:'-',exp:'HH1'}
18; IDL> ncdf_db = 'local:./'
19; IDL> mesh_type2=''
20; IDL> suff_domain=''
21; IDL> file_suff_var=''
22; IDL> def_file_name, cmd, ncdf_db, file_name, delta_t1
23; IDL> print,file_name,delta_t1
24;
25; @uses
26; <pro>common</pro>
27; <propost_it>com_eg</propost_it>
28;
29; @todo
30;
31; explication sur mesh_type2,  suff_domain, file_suff_var
32;
33; realistic example
34;
35; @history
36;
37; - fplod 20100114T132123Z aedon.locean-ipsl.upmc.fr (Darwin)
38;
39;   * delta_t1 is an output parameter
40;
41; - fplod 20091209T094630Z aedon.locean-ipsl.upmc.fr (Darwin)
42;
43;   * check parameters
44;
45; @version
46; $Id$
47;
48;-
49PRO def_file_name, cmd, ncdf_db, file_name, delta_t1
50;
51  compile_opt idl2, strictarrsubs
52;
53@common
54@com_eg
55;
56; Return to caller if errors
57 ON_ERROR, 2
58;
59   IF debug_w THEN BEGIN
60    info = report('enter ...')
61    print, '       cmd at top of proc = ', cmd
62   ENDIF
63
64 usage='def_file_name, cmd, ncdf_db, file_name, delta_t1'
65;
66 nparam = N_PARAMS()
67 IF (nparam LT 3) THEN BEGIN
68    ras = report(['Incorrect number of arguments.' $
69          + '!C' $
70          + 'Usage : ' + usage])
71    stop
72 ENDIF
73
74 arg_type = size(cmd,/type)
75 IF (arg_type NE 8) THEN BEGIN
76   ras = report(['Incorrect arg type cmd' $
77          + '!C' $
78          + 'Usage : ' + usage])
79    stop
80 ENDIF
81
82 arg_struct_tags=TAG_NAMES(cmd)
83
84 tag=WHERE(STRMATCH(arg_struct_tags, 'TIMAVE'))
85 IF (tag EQ -1) THEN BEGIN
86   ras = report(['Incorrect arg tag TIMAVE cmd' $
87          + '!C' $
88          + 'Usage : ' + usage])
89    stop
90 ENDIF
91 arg_type = size(cmd.timave,/type)
92 IF (arg_type NE 7) THEN BEGIN
93   ras = report(['Incorrect arg type cmd.timave' $
94          + '!C' $
95          + 'Usage : ' + usage])
96    stop
97 ENDIF
98
99 tag=WHERE(STRMATCH(arg_struct_tags, 'DATE1'))
100 IF (tag EQ -1) THEN BEGIN
101   ras = report(['Incorrect arg tag DATE1 cmd' $
102          + '!C' $
103          + 'Usage : ' + usage])
104    stop
105 ENDIF
106 arg_type = size(cmd.date1,/type)
107 IF (arg_type NE 7) THEN BEGIN
108   ras = report(['Incorrect arg type cmd.date1' $
109          + '!C' $
110          + 'Usage : ' + usage])
111    stop
112 ENDIF
113 tag=WHERE(STRMATCH(arg_struct_tags, 'PLT'))
114 IF (tag EQ -1) THEN BEGIN
115   ras = report(['Incorrect arg tag PLT cmd' $
116          + '!C' $
117          + 'Usage : ' + usage])
118    stop
119 ENDIF
120
121 arg_type = size(cmd.plt,/type)
122 IF (arg_type NE 7) THEN BEGIN
123   ras = report(['Incorrect arg type cmd.plt' $
124          + '!C' $
125          + 'Usage : ' + usage])
126    stop
127 ENDIF
128
129 tag=WHERE(STRMATCH(arg_struct_tags, 'SPEC'))
130 IF (tag EQ -1) THEN BEGIN
131   ras = report(['Incorrect arg tag SPEC cmd' $
132          + '!C' $
133          + 'Usage : ' + usage])
134    stop
135 ENDIF
136 arg_type = size(cmd.spec,/type)
137 IF (arg_type NE 7) THEN BEGIN
138   ras = report(['Incorrect arg type cmd.spec' $
139          + '!C' $
140          + 'Usage : ' + usage])
141    stop
142 ENDIF
143 tag=WHERE(STRMATCH(arg_struct_tags, 'EXP'))
144 IF (tag EQ -1) THEN BEGIN
145   ras = report(['Incorrect arg tag EXP cmd' $
146          + '!C' $
147          + 'Usage : ' + usage])
148    stop
149 ENDIF
150 arg_type = size(cmd.exp,/type)
151 IF (arg_type NE 7) THEN BEGIN
152   ras = report(['Incorrect arg type cmd.exp' $
153          + '!C' $
154          + 'Usage : ' + usage])
155    stop
156 ENDIF
157 arg_type = size(ncdf_db,/type)
158 IF (arg_type NE 7) THEN BEGIN
159   ras = report(['Incorrect arg type ncdf_db' $
160          + '!C' $
161          + 'Usage : ' + usage])
162    stop
163 ENDIF
164 common_type=size(mesh_type2,/type)
165 IF (common_type NE 7) THEN BEGIN
166   ras = report(['Incorrect common type mesh_type2' $
167          + '!C' $
168          + 'Usage : ' + usage])
169   stop
170 ENDIF
171 common_type=size(suff_domain,/type)
172 IF (common_type NE 7) THEN BEGIN
173   ras = report(['Incorrect common type suff_domain' $
174          + '!C' $
175          + 'Usage : ' + usage])
176   stop
177 ENDIF
178 common_type=size(file_suff_var,/type)
179 IF (common_type NE 7) THEN BEGIN
180   ras = report(['Incorrect common type file_suff_var' $
181          + '!C' $
182          + 'Usage : ' + usage])
183   stop
184 ENDIF
185
186; define date1 and date2
187
188   timavef = cmd.timave
189   date1 = cmd.date1
190
191   suffix = '_'+mesh_type2+suff_domain+file_suff_var
192
193   base_suffix = '_'+mesh_type2
194
195   f_suffix = suffix
196
197   IF debug_w THEN BEGIN
198    print, '     suffix before search_time_file = ', suffix
199   ENDIF
200
201   CASE strmid(cmd.plt, 0, 2) OF
202      'xt': search_time_file, cmd, ncdf_db, suffix, date1, date2, delta_t1, timavef
203      'yt': search_time_file, cmd, ncdf_db, suffix, date1, date2, delta_t1, timavef
204      'zt': search_time_file, cmd, ncdf_db, suffix, date1, date2, delta_t1, timavef
205      't_': search_time_file, cmd, ncdf_db, suffix, date1, date2, delta_t1, timavef
206      ELSE: BEGIN
207         CASE strmid(cmd.plt, 0, 3) OF
208             'xyt': search_time_file, cmd, ncdf_db, suffix, date1, date2, delta_t1, timavef
209             ELSE: BEGIN
210                 cmdspec_b = cmd.spec
211                 cmd.spec = cmd.date1
212                 search_time_file, cmd, ncdf_db, suffix, date1, date2, delta_t1, timavef
213                 cmd.spec = cmdspec_b
214             END
215         ENDCASE
216      END
217   ENDCASE
218   IF debug_w THEN BEGIN
219    print, '     suffix after search_time_file = ', suffix
220    print, '     date1, date2 = ', date1, ' ', date2
221   ENDIF
222
223   IF date1 EQ '???' THEN BEGIN
224      print, ' *** File not found: check dates in post_it.pro line !'
225      stop
226   ENDIF
227
228   file_name = cmd.exp+'_'+timavef+'_'+date1+'_'+date2+suffix+'.nc'
229   base_file_name = cmd.exp+'_'+timavef+'_'+date1+'_'+date2
230
231   IF debug_w THEN BEGIN
232    print, '     vargrid = ', vargrid
233    print, '     file_name = ',file_name
234    info = report('leaving ...')
235   ENDIF
236
237END
Note: See TracBrowser for help on using the repository browser.