Changeset 389 for trunk


Ignore:
Timestamp:
01/27/09 09:59:35 (15 years ago)
Author:
smasson
Message:

small improvements

Location:
trunk/SRC
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/SRC/ReadWrite/ncdf_gettime.pro

    r370 r389  
    1111; the name of the ncdf_file 
    1212; 
    13 ; @param cdfid {in}{required}{type=scalar} 
    14 ; the ID of the ncdf_file, which is already open 
     13; @param cdfid {in}{optional}{type=scalar} 
     14; the ID of the ncdf_file, if the file is already open.  
     15; if not provided, ncdf_gettime open the file defined by filename 
    1516; 
    1617; @keyword TIMEVAR {type=string} 
     
    5354;- 
    5455FUNCTION ncdf_gettime, filename, cdfid $ 
    55                      , TIMEVAR=timevar, CALLER=caller, ERR=err, _EXTRA=ex 
     56                       , TIMEVAR = timevar, CALLER = caller, ERR = err, _EXTRA = ex 
    5657; 
    5758  compile_opt idl2, strictarrsubs 
     
    5960  @cm_4cal                      ;   needed for key_caltype 
    6061; 
     62  IF n_elements(cdfid) EQ 0 THEN BEGIN 
     63    cdfid = ncdf_open(isafile(filename, title = 'which file must be open by ncdf_gettime?', _extra = ex)) 
     64    tobeclosed = 1 
     65  ENDIF 
    6166  inq = ncdf_inquire(cdfid) 
    6267;---------------------------------------------------- 
     
    6671  IF keyword_set(timevar) THEN BEGIN 
    6772    timeid = ncdf_varid(cdfid, timevar) 
    68     IF timeid EQ -1 THEN BEGIN   ;   the variable is not found 
     73    IF timeid EQ -1 THEN BEGIN  ;   the variable is not found 
    6974      CASE caller OF 
    7075        'read_ncdf':err = 'No variable ' + timevar + 'found in '+filename+'. Use the TIMESTEP keyword' 
    7176        'scanfile':err = 'No variable ' + timevar + 'found in '+filename+'. We create a fake calendar' 
    7277      ENDCASE 
     78      IF keyword_set(tobeclosed) THEN ncdf_close, cdfid 
    7379      return, -1 
    7480    ENDIF 
     
    8490        'scanfile':err = 'the file '+filename+' as no infinite dimension. We create a fake calendar' 
    8591      ENDCASE 
     92      IF keyword_set(tobeclosed) THEN ncdf_close, cdfid 
    8693      return, -1 
    8794    ENDIF 
     
    9097; we look for the first variable having for only dimension inq.recdim 
    9198    timeid = 0 
    92     REPEAT BEGIN                ; As long as we have not find a variable having only one dimension: the infinite one 
     99    REPEAT BEGIN                           ; As long as we have not find a variable having only one dimension: the infinite one 
    93100      timeinq = ncdf_varinq(cdfid, timeid) ; that the variable contain. 
    94101      timeid = timeid+1 
     
    100107        'scanfile':err = 'the file '+fullname+' has no time axis.!C we create a fake calendar ...' 
    101108      ENDCASE 
     109      IF keyword_set(tobeclosed) THEN ncdf_close, cdfid 
    102110      return, -jpt 
    103111    ENDIF 
     
    113121      'scanfile':err = 'the variable '+timeinq.name+' has no attribute.!C we create a fake calendar ...' 
    114122    ENDCASE 
     123    IF keyword_set(tobeclosed) THEN ncdf_close, cdfid 
    115124    return, -jpt 
    116125  ENDIF 
     
    124133      'scanfile':err = 'Attribute ''units'' not found for the variable '+timeinq.name+'!C we create a fake calendar ...' 
    125134    ENDCASE 
     135    IF keyword_set(tobeclosed) THEN ncdf_close, cdfid 
    126136    return, -jpt 
    127137  ENDIF 
     
    158168      'scanfile':err = 'time units does not start with seconds/hours/days/months/years !C we create a fake calendar ...' 
    159169    ENDCASE 
     170    IF keyword_set(tobeclosed) THEN ncdf_close, cdfid 
    160171    return, -jpt 
    161172  ENDIF 
     
    165176      'scanfile':err = 'attribute units of time has not the good format: [^ ]* since ([0-9]){1,4}-([0-9]){1,2}-([0-9]){1,2}.*!C we create a fake calendar ...' 
    166177    ENDCASE 
     178    IF keyword_set(tobeclosed) THEN ncdf_close, cdfid 
    167179    return, -jpt 
    168180  ENDIF 
     
    192204  time = double(time) 
    193205; 
     206  IF keyword_set(tobeclosed) THEN ncdf_close, cdfid 
    194207  return, time 
    195208END 
  • trunk/SRC/Utilities/undefine.pro

    r375 r389  
    3838  compile_opt idl2, strictarrsubs 
    3939; 
    40   tempvar = SIZE(TEMPORARY(varname)) 
     40  IF n_elements(varname) NE 0 THEN tempvar = SIZE(TEMPORARY(varname)) 
    4141END 
Note: See TracChangeset for help on using the changeset viewer.