Changeset 174 for trunk/SRC/ToBeReviewed


Ignore:
Timestamp:
09/12/06 09:07:57 (18 years ago)
Author:
smasson
Message:

add keywords in read_ncdf for roms outputs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SRC/ToBeReviewed/LECTURE/read_ncdf.pro

    r172 r174  
    2727; See BEGINNING. 
    2828;  
    29 ; @param COMPATIBILITY {in}{required} 
    30 ; Useless 
     29; @param COMPATIBILITY {in}{optional} 
     30; Useless, defined for compatibility 
    3131 
    3232; @keyword BOXZOOM  
    3333; Contain the boxzoom on which we have to do the reading  
    3434;  
    35 ; @keyword FILENAME {type=string} 
     35; @keyword CALLITSELF {default=0}{type=scalar: 0 or 1} 
     36; For ROMS outputs. Use by read_ncdf itself to access auxilliary data (h and zeta). 
     37;  
     38; @keyword FILENAME {required}{type=string} 
    3639; It contains he file's name. 
    3740;  
    38 ; @keyword INIT 
     41; @keyword INIT {default=0}{type=scalar: 0 or 1} 
    3942; To call automatically initncdf, filename and thus 
    4043; redefine all the grid parameters 
     
    4649; is not found. 
    4750;  
    48 ; @keyword TIMESTEP 
    49 ; We activate to specify that BEGINNING and ENDING refer to indexes 
    50 ; of the time axis and not to dates 
    51 ; 
    52 ; @keyword TOUT 
     51; @keyword TIMESTEP {default=0}{type=scalar: 0 or 1} 
     52; Specify that BEGINNING and ENDING refer to indexes of the time axis and not to dates 
     53; 
     54; @keyword TOUT {default=0}{type=scalar: 0 or 1} 
    5355; We activate it if we want to read the file on the whole domain without  
    5456; considerate the sub-domain defined by the boxzoom or  
    5557; lon1,lon2,lat1,lat2,vert1,vert2. 
    5658;  
    57 ; @keyword NOSTRUCT 
     59; @keyword NOSTRUCT {default=0}{type=scalar: 0 or 1} 
    5860; We activate it if we do not want that read_ncdf send back a structure  
    5961; but only the array referring to the field. 
     
    6466; is no unlimited dimension or if the time axis selected by default 
    6567; (the first 1D array with unlimited dimension) is not the good one. 
     68; 
     69; @keyword HFILENAME {default=FILENAME}{type=string} 
     70; For ROMS outputs. The filename of the file where h vriable should be read 
     71; 
     72; @keyword ZETAFILENAME {default=FILENAME}{type=string} 
     73; For ROMS outputs. The filename of the file where zeta vriable should be read 
     74; 
     75; @keyword ZETAZERO {default=0}{type=scalar: 0 or 1} 
     76; For ROMS outputs. To define zeta to 0. instead of reading it 
    6677; 
    6778; @keyword _EXTRA 
     
    91102                    , PARENTIN = parentin, TIMESTEP = timestep, TIMEVAR = timevar $ 
    92103                    , TOUT = tout, NOSTRUCT = nostruct, CONT_NOFILL = CONT_NOFILL, INIT = init $ 
    93                     , GRID = grid, FBASE2TBASE = fbase2tbase, _EXTRA = ex, CALLITSELF = callitself 
     104                    , GRID = grid, FBASE2TBASE = fbase2tbase, CALLITSELF = callitself $ 
     105                    , HFILENAME = hfilename, ZETAFILENAME = zetafilename, ZETAZERO = zetazero $ 
     106                    , _EXTRA = ex 
    94107;--------------------------------------------------------- 
    95108; 
     
    547560      ncdf_attget, cdfid, 'theta_b', theta_b, /global 
    548561      ncdf_attget, cdfid, 'hc', hc, /global 
    549 ; +++ binder l'exsitance de h et zeta... 
    550 ; +++ mettre zeta a 0 par defaut 
    551       hroms = read_ncdf('h', 0, 0, FILENAME = filename $ 
    552                         , /TIMESTEP, /NOSTRUCT, CONT_NOFILL = CONT_NOFILL $ 
    553                         , GRID = vargrid, /CALLITSELF, _EXTRA = ex) 
    554       zeta = read_ncdf('zeta', firsttps, lasttps, FILENAME = filename $ 
    555                        , /TIMESTEP, /NOSTRUCT, CONT_NOFILL = CONT_NOFILL $ 
    556                        , GRID = vargrid, /CALLITSELF, _EXTRA = ex) 
     562; look for all variables names 
     563      allvarnames = strarr(varcontient.nvars) 
     564      FOR i = 0, varcontient.nvars-1 DO BEGIN 
     565        tmp = ncdf_varinq( cdfid, i) 
     566        allvarnames[i] = tmp.name 
     567      ENDFOR 
     568      CASE 1 OF 
     569        keyword_set(hfilename):  $ 
     570           hroms = read_ncdf('h', 0, 0, FILENAME = hfile $ 
     571                             , /TIMESTEP, /NOSTRUCT, CONT_NOFILL = CONT_NOFILL $ 
     572                             , GRID = vargrid, /CALLITSELF, _EXTRA = ex) 
     573        (where(allvarnames EQ 'h'))[0] NE -1: $ 
     574           hroms = read_ncdf('h', 0, 0, FILENAME = filename $ 
     575                             , /TIMESTEP, /NOSTRUCT, CONT_NOFILL = CONT_NOFILL $ 
     576                             , GRID = vargrid, /CALLITSELF, _EXTRA = ex) 
     577        ELSE:return, report('The variable h was not found in the file, please use the keyword HFILENAME to specify the name of a file containing h') 
     578      ENDCASE 
     579      CASE 1 OF 
     580        keyword_set(zetazero):zeta = fltarr(nx, ny, jpt) 
     581        keyword_set(zetafilename):  $ 
     582           zeta = read_ncdf('zeta', firsttps, lasttps, FILENAME = zetafilename $ 
     583                            , /TIMESTEP, /NOSTRUCT, CONT_NOFILL = CONT_NOFILL $ 
     584                            , GRID = vargrid, /CALLITSELF, _EXTRA = ex) 
     585        (where(allvarnames EQ 'h'))[0] NE -1: $ 
     586           zeta = read_ncdf('zeta', firsttps, lasttps, FILENAME = filename $ 
     587                            , /TIMESTEP, /NOSTRUCT, CONT_NOFILL = CONT_NOFILL $ 
     588                            , GRID = vargrid, /CALLITSELF, _EXTRA = ex) 
     589        ELSE:return, report('The variable zeta was not found in the file, please use the keyword ZETAFILENAME to specify the name of a file containing zeta or use  keyword ZETAZERO to define zeta to 0.') 
     590      ENDCASE 
    557591      romszinfos = {h:temporary(hroms), zeta:temporary(zeta), theta_s:theta_s, theta_b:theta_b, hc:hc} 
    558592    ENDIF ELSE romszinfos = {h:-1, zeta:-1, theta_s:-1, theta_b:-1, hc:-1} 
Note: See TracChangeset for help on using the changeset viewer.