1 | ;+ |
---|
2 | ; |
---|
3 | ; |
---|
4 | ; @param FILENAME {in}{required}{type=string} |
---|
5 | ; filename to examin. |
---|
6 | ; Must be an NetCDF file |
---|
7 | ; |
---|
8 | ; @keyword IODIRECTORY |
---|
9 | ; @keyword _EXTRA |
---|
10 | ; |
---|
11 | ; @returns |
---|
12 | ; -1 in case of error |
---|
13 | ; |
---|
14 | ; @examples |
---|
15 | ; |
---|
16 | ; IDL> filename='ginette' |
---|
17 | ; IDL> result = find_jptmax(filename) |
---|
18 | ; IDL> print,result |
---|
19 | ; |
---|
20 | ; @uses |
---|
21 | ; <pro>common</pro> |
---|
22 | ; <propost_it>com_eg</propost_it> |
---|
23 | ; |
---|
24 | ; <pro>isafile</pro> |
---|
25 | ; |
---|
26 | ; @todo |
---|
27 | ; error handling |
---|
28 | ; check keywords |
---|
29 | ; |
---|
30 | ; @history |
---|
31 | ; - fplod 20091210T075903Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
32 | ; |
---|
33 | ; * check parameters |
---|
34 | ; |
---|
35 | ; @version |
---|
36 | ; $Id$ |
---|
37 | ; |
---|
38 | ;- |
---|
39 | FUNCTION find_jptmax, filename $ |
---|
40 | , IODIRECTORY=iodirectory $ |
---|
41 | , _EXTRA=extra |
---|
42 | ; |
---|
43 | compile_opt idl2, strictarrsubs |
---|
44 | ; |
---|
45 | @common |
---|
46 | @com_eg |
---|
47 | ; |
---|
48 | ; Return to caller if errors |
---|
49 | ON_ERROR, 2 |
---|
50 | ; |
---|
51 | usage='result=find_jptmax(filename ' $ |
---|
52 | + ' , IODIRECTORY=iodirectory' $ |
---|
53 | + ' , _EXTRA=extra)' |
---|
54 | |
---|
55 | nparam = N_PARAMS() |
---|
56 | IF (nparam LT 1) THEN BEGIN |
---|
57 | ras = report(['Incorrect number of arguments.' $ |
---|
58 | + '!C' $ |
---|
59 | + 'Usage : ' + usage]) |
---|
60 | return, -1 |
---|
61 | ENDIF |
---|
62 | arg_type = size(filename,/type) |
---|
63 | IF (arg_type NE 7) THEN BEGIN |
---|
64 | ras = report(['Incorrect arg type filename' $ |
---|
65 | + '!C' $ |
---|
66 | + 'Usage : ' + usage]) |
---|
67 | return, -1 |
---|
68 | ENDIF |
---|
69 | |
---|
70 | jptmax = -1 |
---|
71 | ;------------------------------------------------------------ |
---|
72 | ; we find the filename and open the file |
---|
73 | ;------------------------------------------------------------ |
---|
74 | IF keyword_set(iodirectory) THEN BEGIN |
---|
75 | filename_tmp = isafile(FILENAME = filename, IODIRECTORY = iodirectory, _EXTRA=extra) |
---|
76 | ENDIF ELSE BEGIN |
---|
77 | filename_tmp = isafile(FILENAME = filename, _EXTRA=extra) |
---|
78 | ENDELSE |
---|
79 | cdfid = ncdf_open(filename_tmp) |
---|
80 | inq = ncdf_inquire(cdfid) |
---|
81 | ;------------------------------------------------------------ |
---|
82 | ; we look for the record dimension |
---|
83 | ;------------------------------------------------------------ |
---|
84 | IF inq.recdim NE -1 THEN BEGIN |
---|
85 | ncdf_diminq, cdfid, inq.recdim, timedimname, jptmax |
---|
86 | ENDIF ELSE BEGIN |
---|
87 | print, $ |
---|
88 | report('the file '+filename+' has no infinite dimension !!!') |
---|
89 | ENDELSE |
---|
90 | |
---|
91 | ncdf_close, cdfid |
---|
92 | |
---|
93 | return, jptmax |
---|
94 | |
---|
95 | END |
---|