Ignore:
Timestamp:
09/11/06 09:11:26 (18 years ago)
Author:
smasson
Message:

bugfix + manage roms outputs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SRC/ToBeReviewed/INIT/initncdf.pro

    r167 r172  
    55; 
    66; @file_comments 
    7 ; Initfile for Netcdf file. define all the grid parameters 
     7; Initfile for Netcdf file. define all the grid parameters through 
     8; an appropriate call to computegid 
    89; 
    910; @categories 
    10 ; 
     11; Grid 
    1112;  
    12 ; @param NCFILEIN {in}{required}{type=string} 
     13; @param NCFILEIN {in}{required}{type=scalar string} 
    1314; A string giving the name of the NetCdf file 
    1415; 
    15 ; @keyword INVMASK 
    16 ; To inverse the mask: mask = 1-mask 
     16; @keyword INVMASK {default=0}{type=scalar: 0 or 1} 
     17; Inverse the land/sea mask (that should have 0/1 values for land/sea): mask = 1-mask 
    1718; 
    1819; @keyword MASKNAME {type=string} 
     
    2021; that contains the land/sea mask 
    2122; 
    22 ; @keyword MISSING_VALUE 
     23; @keyword MISSING_VALUE {type=scalar} 
    2324; To define (or redefine if the attribute is 
    2425; already existing) the missing values used with USEASMASK 
    2526; keyword 
    2627; 
    27 ; @keyword START1 
     28; @keyword START1 {default=0}{type=scalar: 0 or 1} 
    2829; Index the axis from 1 instead of 0 when using 
    2930; /xyindex and/or zindex 
    3031; 
    31 ; @keyword USEASMASK {type=string} 
     32; @keyword USEASMASK {type=scalar string} 
    3233; A string giving the name of the variable in the file  
    3334; that will be used to build the land/sea mask. In this case the 
     
    3839;    3 NaN values if existing 
    3940; 
    40 ; @keyword XAXISNAME {default='x', 'longitude', 'nav_lon' or 'lon'}{type=string} 
     41; @keyword XAXISNAME {default='x', 'longitude', 'nav_lon', 'lon', 'lon_rho' or 'NbLongitudes'}{type=scalar string} 
    4142; A string giving the name of the variable in the file  
    4243; that contains the [xyz]axis.  
    4344;       
    44 ; @keyword YAXISNAME {default='y', 'latitude', 'nav_lat' or 'lat'}{type=string} 
     45; @keyword YAXISNAME {default='y', 'latitude', 'nav_lat','lat', 'lat_rho' or 'NbLatitudes'}{type=scalar string} 
    4546; A string giving the name of the variable in the file  
    4647; that contains the [xyz]axis.  
    4748; 
    48 ; @keyword ZAXISNAME {default='z', 'level', 'lev', 'depth...'}{type=string} 
     49; @keyword ZAXISNAME {default='z', 'level', 'lev', 'depth...'}{type=scalar string} 
    4950; A string giving the name of the variable in the file  
    5051; that contains the [xyz]axis.  
    5152; 
    52 ; @keyword XYINDEX 
     53; @keyword XYINDEX {default=0}{type=scalar: 0 or 1} 
    5354; To define the x/y axis with index instead of using 
    5455; the values contained in X/YAXISNAME.  
     
    5657; this forces key_onearth = 0 
    5758; 
    58 ; @keyword ZINDEX 
     59; @keyword ZINDEX {default=0}{type=scalar: 0 or 1} 
    5960; To define the z axis with index instead of using 
    6061; the values contained in ZAXISNAME.  
     
    6263;  
    6364; @keyword _EXTRA 
    64 ; Used to pass your keywords/ 
     65; Used to pass keywords to computegrid 
    6566; 
    6667; @uses 
     
    6869; 
    6970; @restrictions 
    70 ; Change the grid parameters of the common.pro 
     71; Change the grid parameters (see computegrid) 
    7172; 
    7273; @restrictions 
     
    122123; find the xaxis 
    123124  if keyword_set(xaxisname) then xaxisname = strlowcase(xaxisname) ELSE xaxisname = 'x' 
    124   xvarid = where(namevar EQ xaxisname OR namevar EQ 'longitude' $ 
    125                  OR namevar EQ 'nav_lon' OR namevar EQ 'lon' $ 
    126                  OR namevar EQ 'NbLongitudes') 
    127   xvarid = xvarid[0] 
     125  xvarid = (where(namevar EQ xaxisname OR namevar EQ 'longitude' $ 
     126                  OR namevar EQ 'nav_lon' OR namevar EQ 'lon' $ 
     127                  OR namevar EQ 'lon_rho' OR namevar EQ 'NbLongitudes'))[0] 
     128  romsgrid = strmid(namevar[xvarid], 0, 4) EQ 'lon_' 
    128129  if xvarid EQ -1 then begin 
    129130    print, 'the xaxis was not found, check the use of XAXISNAME keyword' 
     
    146147; find the yaxis 
    147148  if keyword_set(yaxisname) then yaxisname = strlowcase(yaxisname) ELSE yaxisname = 'y' 
    148   yvarid = where(namevar EQ yaxisname OR namevar EQ 'latitude' $ 
    149                  OR namevar EQ 'nav_lat' OR namevar EQ 'lat' $ 
    150                  OR namevar EQ 'NbLatitudes') 
     149  yvarid = (where(namevar EQ yaxisname OR namevar EQ 'latitude' $ 
     150                  OR namevar EQ 'nav_lat' OR namevar EQ 'lat' $ 
     151                  OR namevar EQ 'lat_rho' OR namevar EQ 'NbLatitudes'))[0] 
    151152  yvarid = yvarid[0] 
    152153  if yvarid EQ -1 then begin 
     
    177178;---------------------------------------------------------- 
    178179; find the zaxis 
    179   if keyword_set(zaxisname) then zaxisname = strlowcase(zaxisname) ELSE zaxisname = 'z' 
    180   zvarid = where(namevar EQ 'nav_lev' or namevar EQ zaxisname OR namevar EQ 'level' OR namevar EQ 'lev' OR strmid(namevar, 0, 5) EQ 'depth') 
    181   zvarid = zvarid[0] 
    182   if zvarid EQ -1 AND inside.ndims GT 3 then begin 
    183     print, 'initncdf: the zaxis was not found..., check the the use of ZAXISNAME keyword if you whant to find one...' 
     180  IF keyword_set(romsgrid) THEN BEGIN 
     181    FOR i = 0, inside.ndims-1 DO BEGIN  
     182      ncdf_diminq, cdfid, i, name, size 
     183      CASE strlowcase(name) OF 
     184        's_rho':zaxis = reverse(indgen(size)) 
     185        's_u':zaxis = reverse(indgen(size)) 
     186        's_v':zaxis = reverse(indgen(size)) 
     187        's_psi':zaxis = reverse(indgen(size)) 
     188        's_w':zaxis = reverse(indgen(size-1)) 
     189        ELSE: 
     190      ENDCASE 
     191    ENDFOR  
     192    IF (where(namevar EQ 'h'))[0] NE -1 THEN BEGIN 
     193      ncdf_varget, cdfid, 'h', romsh 
     194    ENDIF ELSE romsh = -1 
     195  ENDIF ELSE BEGIN  
     196    if keyword_set(zaxisname) then zaxisname = strlowcase(zaxisname) ELSE zaxisname = 'z' 
     197    zvarid = (where(namevar EQ 'nav_lev' or namevar EQ zaxisname OR namevar EQ 'level' OR namevar EQ 'lev' OR strmid(namevar, 0, 5) EQ 'depth'))[0] 
     198    if zvarid EQ -1 AND inside.ndims GT 3 then begin 
     199      print, 'initncdf: the zaxis was not found..., check the the use of ZAXISNAME keyword if you whant to find one...' 
    184200;     stop 
    185   endif 
     201    endif 
    186202; read the zaxis 
    187   if zvarid NE -1 THEN ncdf_varget, cdfid, zvarid, zaxis 
    188   IF keyword_set(zindex) THEN $ 
    189     zaxis = keyword_set(start1) + findgen(n_elements(zaxis)) 
     203    if zvarid NE -1 THEN ncdf_varget, cdfid, zvarid, zaxis 
     204  ENDELSE  
     205  IF keyword_set(zindex) AND keyword_set(zaxis) THEN $ 
     206     zaxis = keyword_set(start1) + findgen(n_elements(zaxis)) 
    190207;---------------------------------------------------------- 
    191208; mask 
     209  IF NOT (keyword_set(maskname) OR keyword_set(useasmask)) AND keyword_set(romsgrid) THEN maskname = 'mask_rho' 
    192210  CASE 1 OF 
    193211    keyword_set(maskname):BEGIN 
     
    252270            'scale_factor':ncdf_attget, cdfid, mskid, attname, scale_factor 
    253271            'missing_value':IF n_elements(missing_value) EQ 0 THEN $ 
    254               ncdf_attget, cdfid, mskid, attname, missing_value 
     272               ncdf_attget, cdfid, mskid, attname, missing_value 
    255273            ELSE: 
    256274          ENDCASE 
     
    279297    ELSE:tmask  = -1 
    280298  ENDCASE 
     299; 
    281300  ncdf_close, cdfid 
    282301; 
    283302; compute the grid 
    284   if zvarid EQ -1 then BEGIN  
     303  if NOT keyword_set(zaxis) then BEGIN  
    285304    computegrid, xaxis = xaxis, yaxis = yaxis $ 
    286       , mask = tmask, onearth = 1b - keyword_set(xyindex), _EXTRA = ex  
     305                 , mask = tmask, onearth = 1b - keyword_set(xyindex), ROMSH = romsh, _EXTRA = ex  
    287306  ENDIF ELSE BEGIN  
    288307    computegrid, xaxis = xaxis, yaxis = yaxis, zaxis = zaxis $ 
    289       , mask = tmask, onearth = 1b - keyword_set(xyindex), _EXTRA = ex 
     308                 , mask = tmask, onearth = 1b - keyword_set(xyindex), ROMSH = romsh, _EXTRA = ex 
    290309  ENDELSE  
    291310  IF n_elements(time) EQ 0 THEN time = 0 
Note: See TracChangeset for help on using the changeset viewer.