Changeset 172


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

bugfix + manage roms outputs

Location:
trunk/SRC
Files:
2 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/SRC/Commons/cm_4data.pro

    r157 r172  
    1818common variable_attributs, varname, vargrid, vardate, varexp, varunit, valmask 
    1919; 
     20; variable needed by xxx 
     21; 
     22COMMON xxx_readparameters, ccreadparameters 
    2023 
    2124 
    2225 
    2326 
    24  
  • trunk/SRC/Commons/cm_4mesh.pro

    r157 r172  
    2727COMMON keys_grid, key_shift, key_periodic, key_stride, key_gridtype, key_yreverse, key_zreverse, key_partialstep, key_onearth 
    2828; 
    29 ; variables needed by xxx 
     29; variable needed to compute the depth in roms 
    3030; 
    31 COMMON xxx_parameters, ccmeshparameters, ccreadparameters 
     31COMMON roms, romszinfos 
     32; 
     33; variable needed by xxx 
     34; 
     35COMMON xxx_meshparameters, ccmeshparameters 
    3236; 
    3337; zoom related definitions 
  • trunk/SRC/Grid/computegrid.pro

    r163 r172  
    44;+ 
    55; 
    6 ; @file_comments compute the grid parameters from cm_4mesh common: 
    7 ; 
    8 ;       computegrid, startx, starty, stepx, stepy, nx, ny 
    9 ;       computegrid, startx, starty, stepx, stepy 
    10 ;       computegrid, xaxis = xaxis, yaxis = yaxis 
    11 ;       or a suitable mix... 
    12 ; 
    13 ; glamt 
    14 ; glamf 
    15 ; gphit 
    16 ; gphit 
    17 ; e1t 
    18 ; e2t 
    19 ; horizontal parameters 
    20 ; 
    21 ; glamu {in} 
    22 ; glamv {in} 
    23 ; gphiu {in} 
    24 ; gphiv {in} 
    25 ; e1u {in} 
    26 ; e1v {in} 
    27 ; e1f {in} 
    28 ; e2u {in} 
    29 ; e2v {in} 
    30 ; e2f {in} 
    31 ; horizontal parameters if FULLCGRID keyword is defined 
    32 ; 
    33 ; gdept 
    34 ; gdepw 
    35 ; e3t 
    36 ; e3w 
    37 ; verticals parameters 
    38 ; 
     6; @file_comments  
     7; 
     8; compute the grid parameters (cm_4mesh) common 
     9; 
     10; domains sizes: 
     11;--------------- 
     12; jpi, jpj, jpk, jpiglo, jpjglo, jpkglo, jpidta, jpjdta, jpkdta 
     13; 
     14; domains positions regarding to the original grid: 
     15;-------------------------------------------------- 
     16; ixminmesh, ixmaxmesh, iyminmesh, iymaxmesh, izminmesh, izmaxmesh 
     17; ixmindta, ixmaxdta, iymindta, iymaxdta, izmindta, izmaxdta 
     18; 
     19; horizontal parameters: 
     20; ---------------------- 
     21; glamt, glamf, gphit, gphit, e1t, e2t 
     22; 
     23; additional horizontal parameters if FULLCGRID keyword is defined: 
     24; ----------------------------------------------------------------- 
     25; glamu, glamv, gphiu, gphiv, e1u, e1v, e1f, e2u, e2v, e2f 
     26; 
     27; verticals parameters: 
     28; --------------------- 
     29; gdept, gdepw, e3t, e3w 
     30; 
     31; masks: 
     32; ------ 
    3933; tmask 
    40 ; masks 
    41 ; 
    42 ; umaskred {in} 
    43 ; vmaskred {in} 
    44 ; fmaskredx {in} 
    45 ; fmaskredy {in} 
    46 ; masks if FULLCGRID keyword is defined 
    47 ; 
    48 ; triangles_list 
     34; 
     35; additional masks if FULLCGRID keyword is defined: 
     36; ------------------------------------------------- 
     37; umaskred, vmaskred, fmaskredx, fmaskredy 
     38; 
     39; triangles_list: 
     40; --------------- 
    4941; triangulation 
     42; 
     43; key_* variables: 
     44; ---------------- 
     45; key_onearth, key_periodic, key_shift, key_stride, key_partialstep, 
     46; key_yreverse, key_zreverse, key_gridtype 
     47; 
     48; xxx related variables: 
     49; ---------------------- 
     50; ccmeshparameters, ccreadparameters 
    5051; 
    5152; @categories  
    5253; Grid 
    5354; 
    54 ; @param startx {in}{required} scalar, x starting point 
    55 ; @param starty {in}{required} scalar, y starting point 
    56 ; @param stepxin {in}{required} scalar or vector: x direction step, must be > 0 
    57 ;             if vector nx is not used 
    58 ; @param stepyin {in}{required} scalar or vector: y direction step, 
    59 ;             could be > 0 (south to north) or < 0 (north to south) 
    60 ;             if vector ny is not used 
    61 ; @param nxin {in}{required} scalar, number of points in x direction 
    62 ; @param nyin {in}{required} scalar, number of points in y direction 
    63 ; 
    64 ; @keyword FULLCGRID activate to specify that you want to compute 
    65 ;       all the parameters of a C grid. Computation of glam[uv], 
    66 ;       gphi[uv], e1[uvf], e2[uvf], [uv]maskred and fmaskred[xy] 
    67 ;       will be add to the default computations 
    68 ; 
    69 ; @keyword GLAMBOUNDARY a 2 elements vector, [lon1,lon2], the longitude 
    70 ;       boundaries that should be used to visualize the data. 
    71 ;       we must have lon2 > lon1 and lon2 - lon1 le 360 
    72 ;       key_shift will be defined automaticaly computed according to 
    73 ;       glamboundary by using the FIRST LINE of glamt but 
    74 ;       key_shift will /= 0 only if key_periodic = 1 
    75 ; 
    76 ; @keyword MASK to specify the mask with a 2 or 3 dimension array 
    77 ; 
    78 ; @keyword ONEARTH {default= key_onearth=1} 
    79 ;       = 0 or 1 to force the manual definition of 
    80 ;       key_onearth (to specify if the data are on earth -> use longitude 
    81 ;       /latitude etc...). 
    82 ;       note that ONEARTH = 0 forces PERIODIC = 0, SHIFT = 0, 
    83 ;       and is cancelling GLAMBOUNDARY 
    84 ; 
    85 ; @keyword PERIODIC {default=key_periodic is automatically computed by using the first line of glamt} 
    86 ;       = 0 or 1 to force the manual definition of key_periodic. 
    87 ; 
    88 ; @keyword PLAIN force PERIODIC = 0, SHIFT = 0, STRIDE = [1, 1, 1] and 
     55; @param startx {in}{optional}{type=scalar} 
     56;       x starting point, optional if [XY]AXIS keyword is used 
     57; 
     58; @param starty {in}{optional}{type=scalar} 
     59;       y starting point, optional if [XY]AXIS keyword is used 
     60; 
     61; @param stepxin {in}{optional}{type=scalar or vector} 
     62;       x direction step, optional if [XY]AXIS keyword is used, must be > 0 
     63;       if stepxin is a vector nx is not used 
     64; 
     65; @param stepyin {in}{optional}{type=scalar or vector} 
     66;       y direction step, optional if [XY]AXIS keyword is used, 
     67;       could be > 0 (south to north) or < 0 (north to south) 
     68;       if stepyin is a vector ny is not used 
     69; 
     70; @param nxin {in}{optional}{type=scalar} 
     71;       number of points in x direction, 
     72;       optional if [XY]AXIS keyword is used or stepxin is a vector 
     73; 
     74; @param nyin {in}{optional}{type=scalar}  
     75;       number of points in y direction, 
     76;       optional if [XY]AXIS keyword is used or stepyin is a vector 
     77; 
     78; @keyword FULLCGRID {default=0}{type=scalar: 0 or 1} 
     79;       Activate to specify that you want to compute all the C grid parameters: 
     80;       definition of glam[uv], gphi[uv], e1[uvf], e2[uvf], [uv]maskred and 
     81;       fmaskred[xy] will be add to the default computations 
     82; 
     83; @keyword GLAMBOUNDARY {default=those defined in the file}{type=2 elements vector} 
     84;       Longitude boundaries that should be used to visualize the data. 
     85;         lon2 > lon1 
     86;         lon2 - lon1 le 360 
     87;       By default, the common (cm_4mesh) variable key_shift will be automatically 
     88;       defined according to GLAMBOUNDARY. 
     89; 
     90; @keyword MASK {default=array of 1}{type=2D or 3D array} 
     91;       Specify the land(0)/sea(1) mask 
     92; 
     93; @keyword ONEARTH {default=1}{type=scalar: 0 or 1} 
     94;       Force the manual definition of data localization on the earth or not 
     95;          0) if the data are not on the earth 
     96;          1) if the data are on earth (in that case we can for example use 
     97;             the labels 'longitude', 'latitude' in plots). 
     98;       The resulting value will be stored in the common (cm_4mesh) variable key_onearth 
     99;       ONEARTH = 0 forces PERIODIC = 0, SHIFT = 0 and is cancelling GLAMBOUNDARY 
     100; 
     101; @keyword PERIODIC {default=computed by using the first line of glamt}{type=scalar: 0 or 1} 
     102;       Force the manual definition of the grid zonal periodicity. 
     103;       The resulting value will be stored in the common (cm_4mesh) variable key_periodic 
     104;       PERIODIC = 0 forces SHIFT = 0 
     105; 
     106; @keyword PLAIN {default=0}{type=scalar: 0 or 1} 
     107;       Force PERIODIC = 0, SHIFT = 0, STRIDE = [1, 1, 1] and 
    89108;       suppress the automatic redefinition of the domain in case of 
    90109;       x periodicity overlap, y periodicity overlap (ORCA type only) 
    91110;       and mask border to 0. 
    92111; 
    93 ; @keyword SHIFT = scalar to force the manual definition of key_shift. By 
    94 ;       default, key_shift is automatically computed according to 
    95 ;       glamboundary (when defined) by using the FIRST LINE of glamt. if 
    96 ;       key_periodic=0 then in any case key_shift = 0. 
     112; @keyword SHIFT {default=computed according to glamboundary}{type=scalar} 
     113;       Force the manual definition of the zonal shift that must be apply to the data.  
     114;       The resulting value will be stored in the common (cm_4mesh) variable key_shift 
     115;       Note that if key_periodic=0 then in any case key_shift = 0. 
    97116; 
    98117; @keyword STRCALLING {type=string} 
     
    100119;       call computegrid (this is used by xxx.pro) 
    101120; 
    102 ; @keyword STRIDE {default=[1, 1, 1]} a 3 elements vector to specify the stride in x, y, z 
    103 ;       direction. The resulting value 
    104 ;       will be stored in the common (cm_4mesh) variable key_stride 
    105 ; 
    106 ; @keyword XAXIS to specify longitude1 with a 1 or 2 dimension array, in 
    107 ;       this case startx, stepx and nx are not used but could be 
    108 ;       necessary if the y axis is not defined with yaxis. It must be 
    109 ;       possible to sort the first line of xaxis in the increasing 
    110 ;       order by shifting its elements. 
    111 ; 
    112 ; @keyword YAXIS to specify latitudes with a 1 or 2 dimension array, in 
    113 ;       this case starty, stepy and ny are not used but starty and 
    114 ;       stepy could be necessary if the x axis is not defined with xaxis. 
    115 ;       It must be sorted in the increasing or deceasing order 
    116 ;       (along each column if 2d array). 
     121; @keyword STRIDE {default=[1, 1, 1]}{type=3 elements vector} 
     122;       Specify the stride in x, y and z direction. The resulting 
     123;       value will be stored in the common (cm_4mesh) variable key_stride 
     124; 
     125; @keyword XAXIS {type=1D or 2D array} 
     126;       Specify longitudes in this case startx, stepx and nx are not used but 
     127;       could be necessary if the y axis is not defined with yaxis. It must be 
     128;       possible to sort the first line of xaxis in the increasing order by 
     129;       shifting its elements. 
     130; 
     131; @keyword YAXIS {type=1D or 2D array} 
     132;       Specify latitudes in this case starty, stepy and ny are not used but 
     133;       starty and stepy could be necessary if the x axis is not defined with 
     134;       xaxis. It must be sorted in the increasing or deceasing order (along each column if 2d array). 
    117135; 
    118136; @keyword XYINDEX activate to specify that the horizontal grid should 
     
    121139;       using this keyword forces key_onearth=0 
    122140; 
    123 ; @keyword XMINMESH {default=0L} 
    124 ; @keyword YMINMESH {default=0L} 
    125 ; @keyword ZMINMESH {default=0L} 
    126 ;       to define the common variables i[xyz]minmesh 
    127 ;       used to define the grid only in a zoomed part of the original 
    128 ;       grid. max value is [XYZ]MAXMESH 
    129 ; 
    130 ; @keyword XMAXMESH {default=jpiglo-1} 
    131 ; @keyword YMAXMESH {default=jpjglo-1} 
    132 ; @keyword ZMAXMESH {default=jpkglo-1} 
    133 ;       to define the common variables i[xyz]maxmesh 
    134 ;       used to define the grid only in a zoomed part of the original 
    135 ;       grid. max value is jp[ijk]glo-1. 
    136 ;       if [XYZ]MAXMESH is negative, then we define i[xyz]maxmesh as 
    137 ;       jp[ijk]glo - 1 + [XYZ]MAXMESH instead of [XYZ]MAXMESH    
     141; @keyword XMINMESH {default=0L}{type=scalar} 
     142;       Define common (cm_4mesh) variables ixminmesh used to define the localization 
     143;       of the first point of the grid along the x direction in a zoom of the original grid 
     144; 
     145; @keyword YMINMESH {default=0L}{type=scalar} 
     146;       Define common (cm_4mesh) variables iyminmesh used to define the localization 
     147;       of the first point of the grid along the y direction in a zoom of the original grid 
     148; 
     149; @keyword ZMINMESH {default=0L}{type=scalar} 
     150;       Define common (cm_4mesh) variables izminmesh used to define the localization 
     151;       of the first point of the grid along the z direction in a zoom of the original grid 
     152; 
     153; @keyword XMAXMESH {default=jpiglo-1}{type=scalar} 
     154;       Define common (cm_4mesh) variables ixmaxmesh used to define the localization 
     155;       of the last point of the grid along the x direction in a zoom of the original grid 
     156; 
     157; @keyword YMAXMESH {default=jpjglo-1}{type=scalar} 
     158;       Define common (cm_4mesh) variables iymaxmesh used to define the localization 
     159;       of the last point of the grid along the y direction in a zoom of the original grid 
     160; 
     161; @keyword ZMAXMESH {default=jpkglo-1}{type=scalar} 
     162;       Define common (cm_4mesh) variables izmaxmesh used to define the localization 
     163;       of the last point of the grid along the z direction in a zoom of the original grid 
    138164; 
    139165; @keyword FBASE2TBASE 
    140 ; 
    141 ; @keyword STRCALLING 
    142 ; 
    143 ; @keyword ZAXIS to specify the vertical axis with a 1 dimension 
    144 ;       array. Must be sorted in the increasing or deceasing order 
    145 ; 
    146 ; @keyword _EXTRA used to pass your keywords to the created function. 
     166;       Activate when the model is a C grid based on a F point 
     167;       (with a F point at the bottom-left corner and a T point at the 
     168;       upper-right corner). In this case, we ignore  
     169;         - the first line of F and U points 
     170;         - the first column of F and V points 
     171;         - the last line of T and U points 
     172;         - the last column of T and V points. 
     173;      => we are back to a C grid based on T point as for OPA model. 
     174; 
     175; @keyword ROMSH {type=2D array} 
     176;       This array is the final bathymetry at RHO-points. It is stored in the common 
     177;       variable (cm_4mesh) romszinfos.h 
     178;       Used when the model is a ROMS C-grid with one more point 
     179;       in longitude for T and V grid and one more point in latitude 
     180;       for T and U grid. In this case, we ignore  
     181;         - the last line of T and U points 
     182;         - the last column of T and V points. 
     183;      => we are back to a C grid based on T point as for OPA model. 
     184;       Note that activate ROMSH forces FULLCGRID=1 
     185; 
     186; @keyword STRCALLING {type=scalar string} 
     187;       Used by xxx... 
     188; 
     189; @keyword ZAXIS {type=1D} 
     190;       Specify the vertical axis. Must be sorted in the increasing or deceasing order 
     191; 
     192; @keyword _EXTRA  
     193;    (not used in the present case...) 
    147194; 
    148195; @uses cm_4mesh cm_4data cm_4cal 
     
    156203;    to use cell_fill = 1). 
    157204; 
    158 ; @restrictions FUV points definition... 
     205; @restrictions FUV points definition is not exact if the grid is irregular 
    159206; 
    160207; @history Sebastien Masson (smasson\@lodyc.jussieu.fr) 
     
    179226                 , FULLCGRID = fullcgrid, XYINDEX = xyindex $ 
    180227                 , FBASE2TBASE = fbase2tbase, STRCALLING = strcalling $ 
    181                  , _extra = ex 
     228                 , ROMSH = romsh, _extra = ex 
    182229;--------------------------------------------------------- 
    183230; 
     
    276323  jpjglo = long(ny) 
    277324  jpkglo = long(nz) 
     325  IF keyword_set(romsh) THEN BEGIN 
     326    jpiglo = jpiglo - 1 
     327    jpjglo = jpjglo - 1 
     328    fullcgrid = 1 
     329  ENDIF 
    278330; 
    279331; impact of plain keyword: 
     
    484536                 , FULLCGRID = fullcgrid, XYINDEX = xyindex $ 
    485537                 , FBASE2TBASE = fbase2tbase, STRCALLING = strcalling $ 
    486                  , _extra = ex 
     538                 , ROMSH = romsh, _extra = ex 
    487539    return 
    488540  ENDIF 
     
    910962      gdepw = gdept 
    911963    ENDELSE 
     964    IF keyword_set(romsh) THEN gdepw = gdept  
    912965; 
    913966;==================================================== 
     
    926979; 
    927980; default mask eq 1 
    928   if NOT keyword_set(mask) then mask = -1 
    929 ; 
    930   if mask[0] NE -1 then BEGIN 
    931     tmask = byte(mask[ixminmesh:ixmaxmesh, iyminmesh:iymaxmesh, izminmesh:izmaxmesh]) 
     981  if NOT keyword_set(mask) then tmask = -1 ELSE tmask = mask 
     982  IF keyword_set(romsh) AND tmask[0] NE -1 THEN tmask = tmask[0:jpiglo-1, 0:jpjglo-1] 
     983  IF array_equal(size(tmask, /dimensions), [jpiglo, jpjglo]) EQ 1 AND jpkglo GT 1 THEN BEGIN 
     984    tmask = tmask[*]#replicate(1, jpkglo) 
     985    tmask = reform(tmask, jpiglo, jpjglo, jpkglo, /overwrite) 
     986  ENDIF 
     987; 
     988  if tmask[0] NE -1 then BEGIN 
     989    tmask = byte(tmask[ixminmesh:ixmaxmesh, iyminmesh:iymaxmesh, izminmesh:izmaxmesh]) 
    932990    tmask = reform(tmask, jpi, jpj, jpk, /over) 
    933991    if key_shift NE 0 then tmask = shift(tmask, key_shift, 0, 0) 
     
    9761034                     , FULLCGRID = fullcgrid, XYINDEX = xyindex $ 
    9771035                     , FBASE2TBASE = fbase2tbase, STRCALLING = strcalling $ 
    978                      , _extra = ex 
     1036                     , ROMSH = romsh, _extra = ex 
    9791037        return 
    9801038  ENDIF 
     
    11311189    gphiinfo = gphit 
    11321190  ENDELSE 
     1191  IF keyword_set(romsh) THEN $ 
     1192     romszinfos = {h:romsh[ixminmesh:ixmaxmesh, iyminmesh:iymaxmesh], zeta:replicate(0., jpi, jpj), theta_s:-1, theta_b:-1, hc:-1} $ 
     1193  ELSE romszinfos = {h:-1, zeta:-1, theta_s:-1, theta_b:-1, hc:-1} 
     1194 
    11331195  ccmeshparameters = {filename:strcalling  $ 
    11341196          , glaminfo:float(string(glaminfo, format = '(E11.4)')) $ 
  • trunk/SRC/Grid/ncdf_meshread.pro

    r163 r172  
    1212; IDL> ncdf_meshread [,' filename'] 
    1313; 
    14 ; @param filename {in}{optional}{default=meshmask.nc}  
    15 ;    the name of the meshmask file to read.  
    16 ;    if this name does not contain any "/" and if 
    17 ;    iodirectory keyword is not specify, then the common variable 
     14; @param filename {in}{optional}{default='meshmask.nc'}{type=scalar string} 
     15;    Name of the meshmask file to read. If this name does not contain any "/" 
     16;    and if iodirectory keyword is not specify, then the common variable 
    1817;    iodir will be use to define the mesh file path. 
    1918; 
    20 ; @keyword GLAMBOUNDARY a 2 elements vector, [lon1,lon2], the longitude 
    21 ;    boundaries that should be used to visualize the data. 
     19; @keyword GLAMBOUNDARY {default=those defined in the file}{type=2 elements vector} 
     20;    Longitude boundaries that should be used to visualize the data. 
    2221;      lon2 > lon1 
    2322;      lon2 - lon1 le 360 
    24 ;    key_shift will be automatically defined according to GLAMBOUNDARY. 
     23;    By default, the common (cm_4mesh) variable key_shift will be automatically 
     24;    defined according to GLAMBOUNDARY. 
    2525; 
    2626; @keyword CHECKDAT Suppressed. Use micromeshmask.pro to create an 
    2727;    appropriate meshmask. 
    2828; 
    29 ; @keyword ONEARTH {default=key_onearth=1} 
    30 ;    = 0 or 1 to force the manual definition of 
    31 ;    key_onearth (to specify if the data are on earth -> use longitude 
    32 ;    /latitude etc...). 
    33 ;    note that ONEARTH = 0 forces PERIODIC = 0, SHIFT = 0 and is 
    34 ;    cancelling GLAMBOUNDARY 
    35 ; 
    36 ; @keyword GETDIMENSIONS 
     29; @keyword ONEARTH {default=1}{type=scalar: 0 or 1} 
     30;    Force the manual definition of data localization on the earth or not 
     31;       0) if the data are not on the earth 
     32;       1) if the data are on earth (in that case we can for example use 
     33;          the labels 'longitude', 'latitude' in plots). 
     34;    The resulting value will be stored in the common (cm_4mesh) variable key_onearth 
     35;    ONEARTH = 0 forces PERIODIC = 0, SHIFT = 0 and is cancelling GLAMBOUNDARY 
     36; 
     37; @keyword GETDIMENSIONS {default=0}{type=scalar: 0 or 1} 
    3738;    Activate this keywords if you only want to know the dimension 
    3839;    of the domain stored in the mesh file. This dimensions will be 
    3940;    defined in jpiglo, jpjglo, jpkglo (cm_4mesh common variables) 
    4041; 
    41 ; @keyword PERIODIC {default=key_periodic is automatically 
    42 ;    computed by using the first line of glamt} 
    43 ;    = 0 or 1 to force the manual definition of 
    44 ;    key_periodic. 
    45 ; 
    46 ; @keyword SHIFT {default= key_shift is automatically computed according to the glamboundary} 
    47 ;    to force the manual definition of key_shift. By 
    48 ;    default, key_shift is automatically computed according to the 
    49 ;    glamboundary (when defined) by using the first line of glamt. if 
    50 ;    key_periodic=0 then in any case key_shift = 0. 
    51 ; 
    52 ; @keyword STRCALLING {type=string} 
    53 ;    a string containing the calling command used to call 
    54 ;    computegrid (this is used by xxx.pro) 
    55 ; 
    56 ; @keyword STRIDE {default=key_stride}  
    57 ;    a 3 elements vector to specify the stride in x, y, z direction.  
    58 ;    The resulting value will be stored in the common (cm_4mesh) variable  
    59 ;    key_stride 
    60 ; 
    61 ; @keyword _EXTRA used to pass your keywords to the created function. 
     42; @keyword PERIODIC {default=computed by using the first line of glamt}{type=scalar: 0 or 1} 
     43;    Force the manual definition of the grid zonal periodicity. 
     44;    The resulting value will be stored in the common (cm_4mesh) variable key_periodic 
     45;    PERIODIC = 0 forces SHIFT = 0 
     46; 
     47; @keyword SHIFT {default=computed according to glamboundary}{type=scalar} 
     48;    Force the manual definition of the zonal shift that must be apply to the data.  
     49;    The resulting value will be stored in the common (cm_4mesh) variable key_shift 
     50;    Note that if key_periodic=0 then in any case key_shift = 0. 
     51; 
     52; @keyword STRCALLING {type=scalar string} 
     53;    the calling command used to call computegrid (this is used by xxx.pro) 
     54; 
     55; @keyword STRIDE {default=[1, 1, 1]}{type=3 elements vector} 
     56;    Specify the stride in x, y and z direction. The resulting 
     57;    value will be stored in the common (cm_4mesh) variable key_stride 
     58; 
     59; @keyword _EXTRA used to pass isafile keywords 
    6260; 
    6361; @uses cm_4mesh cm_4data cm_4cal 
    64 ; 
    65 ; @restrictions define and/or use common variables from 
    66 ;               cm_4mesh, cm_4data, cm_4cal 
    6762; 
    6863; @restrictions 
     
    160155  IF izmaxmesh EQ -1 then izmaxmesh = jpkglo-1 
    161156; definition of jpi,jpj,jpj 
    162   jpi    = long(ixmaxmesh-ixminmesh+1) 
    163   jpj    = long(iymaxmesh-iyminmesh+1) 
    164   jpk    = long(izmaxmesh-izminmesh+1) 
     157  jpi = long(ixmaxmesh-ixminmesh+1) 
     158  jpj = long(iymaxmesh-iyminmesh+1) 
     159  jpk = long(izmaxmesh-izminmesh+1) 
    165160;------------------------------------------------------- 
    166161; check onearth and its consequences 
     
    315310    name = varcontient.name 
    316311@read_ncdf_varget 
    317     command = namevar[i]+'=float(res)' 
     312    command = namevar[i]+'=float(temporary(res))' 
    318313    nothing = execute(command) 
    319314  ENDFOR 
     
    514509  if keyword_set(glamboundary) AND key_onearth then BEGIN 
    515510    if glamboundary[0] NE glamboundary[1] then BEGIN 
    516       glamt = glamt MOD 360 
     511      glamt = temporary(glamt) MOD 360 
    517512      smaller = where(glamt LT glamboundary[0]) 
    518513      if smaller[0] NE -1 then glamt[smaller] = glamt[smaller]+360 
    519514      bigger = where(glamt GE glamboundary[1]) 
    520515      if bigger[0] NE -1 then glamt[bigger] = glamt[bigger]-360 
    521       glamu = glamu MOD 360 
     516      glamu = temporary(glamu) MOD 360 
    522517      smaller = where(glamu LT glamboundary[0]) 
    523518      if smaller[0] NE -1 then glamu[smaller] = glamu[smaller]+360 
    524519      bigger = where(glamu GE glamboundary[1]) 
    525520      if bigger[0] NE -1 then glamu[bigger] = glamu[bigger]-360 
    526       glamv = glamv MOD 360 
     521      glamv = temporary(glamv) MOD 360 
    527522      smaller = where(glamv LT glamboundary[0]) 
    528523      if smaller[0] NE -1 then glamv[smaller] = glamv[smaller]+360 
    529524      bigger = where(glamv GE glamboundary[1]) 
    530525      if bigger[0] NE -1 then glamv[bigger] = glamv[bigger]-360 
    531       glamf = glamf MOD 360 
     526      glamf = temporary(glamf) MOD 360 
    532527      smaller = where(glamf LT glamboundary[0]) 
    533528      if smaller[0] NE -1 then glamf[smaller] = glamf[smaller]+360 
     
    595590    gphiinfo = gphit 
    596591  ENDELSE 
     592  romszinfos = {h:-1, zeta:-1, theta_s:-1, theta_b:-1, hc:-1} 
    597593  ccmeshparameters = {filename:strcalling  $ 
    598594          , glaminfo:float(string(glaminfo, format = '(E11.4)')) $ 
  • trunk/SRC/ToBeReviewed/GRILLE/grille.pro

    r163 r172  
    111111;------------------------------------------------------------ 
    112112;------------------------------------------------------------ 
    113 pro grille, mask, glam, gphi, gdep, nx, ny, nz, firstx, firsty, firstz, lastx, lasty, lastz, e1, e2, e3, TRI = tri, NOTRI = notri, TOUT = tout, FORPLT = forplt, IFPLTZ = ifpltz, WDEPTH = wdepth, _EXTRA = ex 
     113pro grille, mask, glam, gphi, gdep, nx, ny, nz, firstx, firsty, firstz, lastx, lasty, lastz, e1, e2, e3, TRI = tri, NOTRI = notri, TOUT = tout, FORPLT = forplt, TYPE = type, WDEPTH = wdepth, _EXTRA = ex 
    114114;------------------------------------------------------------ 
    115115; include commons 
     
    119119@cm_4mesh 
    120120@cm_4data 
     121@cm_4cal ; for jpt 
    121122  IF NOT keyword_set(key_forgetold) THEN BEGIN 
    122123@updatenew 
     
    354355  ENDELSE 
    355356; for the vertical sections with partial steps 
    356   IF keyword_set(ifpltz) AND keyword_set(key_partialstep) THEN BEGIN 
     357  IF keyword_set(type) AND keyword_set(key_partialstep) THEN BEGIN 
    357358    CASE 1 OF 
    358       ifpltz EQ 'xz' AND ny EQ 1:BEGIN 
     359      type EQ 'xz' AND ny EQ 1:BEGIN 
    359360        bottom = total(tmask[firstx:lastx, firsty:lasty, firstz:lastz], 3) 
    360361        good = where(bottom NE 0 AND bottom NE nz+keyword_set(wdepth)) 
     
    370371        ENDIF 
    371372      END 
    372       ifpltz EQ 'yz' AND nx EQ 1:BEGIN 
     373      type EQ 'yz' AND nx EQ 1:BEGIN 
    373374        bottom = total(tmask[firstx:lastx, firsty:lasty, firstz:lastz], 3) 
    374375        good = where(bottom NE 0 AND bottom NE nz+keyword_set(wdepth)) 
     
    387388    ENDCASE 
    388389  ENDIF 
     390; for the vertical sections with roms 
     391  IF keyword_set(type) AND n_elements(romszinfos) NE 0 THEN BEGIN 
     392    romsdp = romsdepth() 
     393    IF romsdp[0] NE -1 THEN BEGIN  
     394      IF jpt EQ 1 THEN BEGIN 
     395        CASE type OF 
     396          'z':gdep = moyenne(temporary(romsdp), 'xy') 
     397          'xz':gdep = moyenne(temporary(romsdp), 'y') 
     398          'yz':gdep = moyenne(temporary(romsdp), 'x') 
     399          'zt':gdep = moyenne(temporary(romsdp), 'xy') 
     400          ELSE: 
     401        ENDCASE 
     402      ENDIF ELSE BEGIN  
     403        CASE type OF 
     404          'z':gdep = moyenne(temporary(romsdp), 'xyt') 
     405          'xz':gdep = grossemoyenne(temporary(romsdp), 'yt') 
     406          'yz':gdep = grossemoyenne(temporary(romsdp), 'xt') 
     407          'zt':gdep = grossemoyenne(temporary(romsdp), 'xy') 
     408          ELSE: 
     409        ENDCASE 
     410      ENDELSE 
     411      IF size(gdep, /n_dimensions) EQ 2 THEN $ 
     412         gdep = remplit(gdep, niter = 32000, mask = gdep LT 1.E19, /basique, /fillxdir) 
     413    ENDIF 
     414  ENDIF 
     415; 
    389416  IF testvar(var = key_performance) EQ 2 THEN $ 
    390417    print, 'temps grille: Variables se rapportant a la dimension verticale ', systime(1)-tempdeux 
  • 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 
  • trunk/SRC/ToBeReviewed/LECTURE/read_ncdf.pro

    r163 r172  
    9191                    , PARENTIN = parentin, TIMESTEP = timestep, TIMEVAR = timevar $ 
    9292                    , TOUT = tout, NOSTRUCT = nostruct, CONT_NOFILL = CONT_NOFILL, INIT = init $ 
    93                     , GRID = grid, FBASE2TBASE = fbase2tbase, _EXTRA = ex 
     93                    , GRID = grid, FBASE2TBASE = fbase2tbase, _EXTRA = ex, CALLITSELF = callitself 
    9494;--------------------------------------------------------- 
    9595; 
     
    129129  ENDIF 
    130130  varcontient = ncdf_varinq(cdfid, name) 
     131  IF varcontient.ndims LT 2 THEN return, report('read_ncdf cannot read scalar or 1D data') 
     132; look for the dimension names 
     133  dimnames = strarr(varcontient.ndims) 
     134  FOR i = 0, varcontient.ndims-1 DO BEGIN 
     135    ncdf_diminq, cdfid, varcontient.dim[i], tmp, dimsize 
     136    dimnames[i] = tmp 
     137  ENDFOR  
    131138;------------------------------------------------------------ 
    132139; shall we redefine the grid parameters 
     
    144151    if n_elements(ending) NE 0 then lasttps = ending[0] ELSE lasttps = firsttps 
    145152    jpt = lasttps-firsttps+1 
    146     time = julday(1, 1, 1) + lindgen(jpt) 
     153    IF NOT keyword_set(callitself) then time = julday(1, 1, 1) + lindgen(jpt) 
    147154  ENDIF ELSE BEGIN 
    148155    if keyword_set(parent) then BEGIN 
     
    236243      mots = str_sep(value, ' ') 
    237244      unite = mots[0] 
     245      IF unite NE 'seconds' AND unite NE 'hours' AND unite NE 'days' $ 
     246         AND unite NE 'months' AND unite NE 'years' THEN BEGIN 
     247        ncdf_close, cdfid 
     248        return, report('time units does not start with seconds/hours/days/months/years') 
     249      ENDIF 
     250      IF stregex(value, '[^ ]* since ([0-9]){4}-([0-9]){2}-([0-9]){2}.*', /boolean) EQ 0 THEN BEGIN 
     251        ncdf_close, cdfid 
     252        return, report('attribut units of time has not the good format: [^ ]* since ([0-9]){4}-([0-9]){2}-([0-9]){2}.*') 
     253      ENDIF 
    238254      depart = str_sep(mots[2], '-') 
    239255      ncdf_varget, cdfid, timeid, time 
     
    260276        ELSE:BEGIN 
    261277          ncdf_close, cdfid 
    262           return, report('The "units" attribu of the time axis must be something like: !C "seconds since 0001-01-01 ..." !C "days since 1979-01-01 ..." !C "months since 1979-01-01 ..." !C "years since 1979-01-01 ..."') 
     278          return, report('The "units" attribute of the time axis must be something like: !C "seconds since 0001-01-01 ..." !C "days since 1979-01-01 ..." !C "months since 1979-01-01 ..." !C "years since 1979-01-01 ..."') 
    263279        end 
    264280      ENDCASE 
     
    291307    vargrid = 'T'               ; default definition 
    292308    IF finite(glamu[0]) EQ 1 THEN BEGIN 
    293       pattern = ['GRID.', 'GRID_', 'GRID', 'UPID_', '30ID_'] 
    294       gdtype = ['T', 'U', 'V', 'W', 'F'] 
    295       fnametest = strupcase(filename) 
    296       FOR i = 0, n_elements(pattern)-1 DO BEGIN 
    297         FOR j = 0, n_elements(gdtype)-1 DO BEGIN 
    298           substr = pattern[i]+gdtype[j] 
    299           pos = strpos(fnametest, substr) 
    300           IF pos NE -1 THEN $ 
    301              vargrid = strmid(fnametest, pos+strlen(substr)-1, 1) 
    302         ENDFOR 
    303       ENDFOR 
    304     ENDIF 
     309; are we in one of the case corresponding to ROMS conventions? 
     310      CASE 1 OF 
     311        dimnames[2 <(varcontient.ndims-1)] EQ 's_w':vargrid = 'W' 
     312        dimnames[0] EQ 'xi_rho' AND dimnames[1] EQ 'eta_rho':vargrid = 'T' 
     313        dimnames[0] EQ 'xi_u'   AND dimnames[1] EQ 'eta_u'  :vargrid = 'U' 
     314        dimnames[0] EQ 'xi_v'   AND dimnames[1] EQ 'eta_v'  :vargrid = 'V' 
     315        dimnames[0] EQ 'xi_psi' AND dimnames[1] EQ 'eta_psi':vargrid = 'F' 
     316        dimnames[0] EQ 'xi_rho' AND dimnames[1] EQ 'eta_v'  :vargrid = 'V' 
     317        dimnames[0] EQ 'xi_u'   AND dimnames[1] EQ 'eta_rho':vargrid = 'U' 
     318        dimnames[0] EQ 'xi_u'   AND dimnames[1] EQ 'eta_v'  :vargrid = 'F' 
     319        ELSE:BEGIN  
     320; could we define the grid type from the file name?? 
     321          pattern = ['GRID.', 'GRID_', 'GRID', 'UPID_', '30ID_'] 
     322          gdtype = ['T', 'U', 'V', 'W', 'F'] 
     323          fnametest = strupcase(filename) 
     324          FOR i = 0, n_elements(pattern)-1 DO BEGIN 
     325            FOR j = 0, n_elements(gdtype)-1 DO BEGIN 
     326              substr = pattern[i]+gdtype[j] 
     327              pos = strpos(fnametest, substr) 
     328              IF pos NE -1 THEN $ 
     329                 vargrid = strmid(fnametest, pos+strlen(substr)-1, 1) 
     330            ENDFOR 
     331          ENDFOR 
     332        END 
     333      ENDCASE 
     334     ENDIF 
    305335  ENDELSE 
    306336;--------------------------------------------------------------- 
     
    380410  ENDIF 
    381411; 
     412  IF n_elements(key_zreverse) EQ 0 THEN key_zreverse = 0 
     413  IF keyword_set(key_zreverse) THEN BEGIN 
     414    tmp = jpk-1-firstz 
     415    firstz = jpk-1-lastz 
     416    lastz = tmp 
     417  ENDIF 
     418; 
    382419  IF keyword_set(fbase2tbase) THEN BEGIN 
    383420    case strupcase(vargrid) of 
     
    419456;--------------------------------------------------------------------- 
    420457; varname 
    421   varname = name 
     458  IF NOT keyword_set(callitself) THEN varname = name 
    422459; varunit 
    423460  if varcontient.natts NE 0 then begin 
     
    428465    found = (where(lowattnames EQ 'units'))[0] 
    429466    IF found NE -1 then ncdf_attget, cdfid, name, attnames[found], value ELSE value = '' 
    430     varunit = strtrim(string(value), 2) 
     467    IF NOT keyword_set(callitself) THEN varunit = strtrim(string(value), 2) 
    431468; 
    432469    found = (where(lowattnames EQ 'add_offset'))[0] 
     
    443480; 
    444481  ENDIF ELSE BEGIN  
    445     varunit = '' 
     482    IF NOT keyword_set(callitself) THEN varunit = '' 
    446483    add_offset = 0. 
    447484    scale_factor = 1. 
     
    457494 
    458495; we apply reverse 
    459   if keyword_set(key_yreverse) then res = reverse(temporary(res),  2) 
    460   if keyword_set(key_zreverse) AND (size(res))[0] EQ 3 AND jpt EQ 1 then res = reverse(temporary(res), 3) 
    461   if keyword_set(key_zreverse) AND (size(res))[0] EQ 4 THEN res = reverse(temporary(res), 3) 
    462  
     496  if keyword_set(key_yreverse) AND ny NE 1 THEN $ 
     497     res = reverse(reform(res, nx, ny, nz, jpt, /overwrite),  2) 
     498  if keyword_set(key_zreverse) AND nz NE 1 $ 
     499     AND varcontient.ndims - ((where(varcontient.dim EQ contient.recdim))[0] NE -1) EQ 3 THEN $ 
     500        res = reverse(reform(res, nx, ny, nz, jpt, /overwrite),  3) 
    463501; We apply the value valmask on land points. 
    464502  if NOT keyword_set(cont_nofill) then begin 
     
    501539  if add_offset NE 0 then res = temporary(res)+add_offset 
    502540  if missing[0] NE -1 then res[temporary(missing)] = !values.f_nan 
    503   if earth[0] NE -1 then res[temporary(earth)] = 1e20 
     541  if earth[0] NE -1 then res[temporary(earth)] = 1.e20 
     542;--------------------------------------------------------------------- 
     543; if it is roms outputs, we need to get additionals infos... 
     544  IF NOT keyword_set(callitself) THEN BEGIN 
     545    IF strmid(dimnames[0], 0, 3) EQ 'xi_' AND strmid(dimnames[1], 0, 4) EQ 'eta_' THEN BEGIN 
     546      ncdf_attget, cdfid, 'theta_s', theta_s, /global 
     547      ncdf_attget, cdfid, 'theta_b', theta_b, /global 
     548      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) 
     557      romszinfos = {h:temporary(hroms), zeta:temporary(zeta), theta_s:theta_s, theta_b:theta_b, hc:hc} 
     558    ENDIF ELSE romszinfos = {h:-1, zeta:-1, theta_s:-1, theta_b:-1, hc:-1} 
     559  ENDIF 
    504560;--------------------------------------------------------------------- 
    505561  ncdf_close, cdfid 
    506 ;--------------------------------------------------------------------- 
    507   if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4rdncdf.dat' 
    508   if keyword_set(nostruct) then return, res $ 
    509   ELSE BEGIN  
    510     IF keyword_set(key_forgetold) THEN BEGIN 
    511       return, {arr:res, grid:vargrid, unit:varunit, experiment:varexp, name:varname}  
    512     ENDIF ELSE BEGIN  
    513       return, {tab:res, grille:vargrid, unite:varunit, experience:varexp, nom:varname} 
    514     ENDELSE  
    515   ENDELSE  
     562 
     563  IF keyword_set(savedbox) THEN restoreboxparam, 'boxparam4rdncdf.dat' 
     564 
     565  IF keyword_set(nostruct) THEN return, res 
     566  IF keyword_set(key_forgetold) THEN BEGIN 
     567    return, {arr:temporary(res), grid:vargrid, unit:varunit, experiment:varexp, name:varname}  
     568  ENDIF ELSE BEGIN  
     569    return, {tab:temporary(res), grille:vargrid, unite:varunit, experience:varexp, nom:varname} 
     570  ENDELSE 
     571 
    516572END 
    517573 
  • trunk/SRC/ToBeReviewed/PLOTS/DESSINE/plt1d.pro

    r163 r172  
    180180    z1d = checkfield(tab, 'plt1d', TYPE = type, BOXZOOM = boxzoom $ 
    181181                     , direc = direc, _extra = ex) 
    182     grille, mask, glam, gphi, gdep, nx, ny, nz 
     182    grille, mask, glam, gphi, gdep, nx, ny, nz, type = type 
    183183  ENDELSE 
    184184  if z1d[0] EQ -1 then BEGIN  
  • trunk/SRC/ToBeReviewed/PLOTS/DESSINE/pltt.pro

    r163 r172  
    267267        return 
    268268      endif 
    269       grille, mask, glam, gphi, gdep, nx, ny,nz 
     269      grille, mask, glam, gphi, gdep, nx, ny, nz, type = type 
    270270   ENDELSE 
    271271;--------------------------------------------------------------- 
     
    412412            end 
    413413            type eq 'zt' : begin 
    414                yy =  gdep 
     414               IF size(gdep, /n_dimensions) EQ 2 THEN $ 
     415                  yy = transpose(gdep) ELSE yy = gdep 
    415416               xx = temps-tempsmin 
    416417               z2d = transpose(z2d) 
     
    463464      z2d = remplit(z2d,nite=2+keyword_set(nan), mask = mask, /basique, _extra=ex) 
    464465      if NOT keyword_set(strictfill) then z2d = min > z2d <  max 
    465       if keyword_set(nan) then $ 
    466        triangulation = triangule(mask,/basic,coinmonte=coinmontemask $ 
    467                                  ,coindescend=coindescendmask) $ 
    468        ELSE triangulation = -1  
     466      if keyword_set(nan) then BEGIN 
     467        triangulation = triangule(mask, /basic, coinmonte = coinmontemask $ 
     468                                  , coindescend = coindescendmask) 
     469        usetri = 1 
     470      ENDIF ELSE triangulation = -1  
     471       
     472      IF size(gdep, /n_dimensions) EQ 2 THEN BEGIN 
     473        usetri = 2 
     474        IF triangulation[0] EQ -1 THEN $ 
     475           triangulation = triangule(mask, /basic, coinmonte = coinmontemask $ 
     476                                     , coindescend = coindescendmask) 
     477      ENDIF   
    469478;---------------------------------------------------------------------- 
    470       pltbase,z2d, xx, yy, mask,xx, yy, level_z2d,colnumb, contour = contour,/noerase $ 
     479      pltbase, z2d, xx, yy, mask, xx, yy, level_z2d, colnumb, contour = contour, /noerase $ 
    471480       , c_linestyle=linestyle,c_labels=1-(indgen(n_elements(level_z2d)) MOD 2) $ 
    472481       , trichamp = triangulation, trimsk = triangulation, overplot = overplot $ 
    473        , c_thick=thick, performance = key_performance, usetri = keyword_set(nan) $ 
     482       , c_thick=thick, performance = key_performance, usetri = usetri $ 
    474483       , coinmontemask=coinmontemask, coindescendmask=coindescendmask, _extra = ex 
    475484;------------------------------------------------------------ 
  • trunk/SRC/ToBeReviewed/PLOTS/DESSINE/pltz.pro

    r171 r172  
    244244      return 
    245245    ENDIF 
    246     IF realsection EQ 1 THEN grille, mask, glam, gphi, gdep, nx, ny, nz, ifpltz = type, WDEPTH = wdepth $ 
     246    IF realsection EQ 1 THEN grille, mask, glam, gphi, gdep, nx, ny, nz, type = type, WDEPTH = wdepth $ 
    247247    ELSE grille, mask, glam, gphi, gdep, nx, ny, nz, WDEPTH = wdepth 
    248248  ENDELSE 
    249 ; stop 
     249  IF size(gdep, /n_dimensions) EQ 2 THEN usetri = 2 
    250250;--------------------------------------------------------------- 
    251251  profmax = !y.range[0] 
     
    357357; dessin en lui meme 
    358358;------------------------------------------------------------ 
     359  IF n_elements(romszinfos) EQ 1 THEN BEGIN 
     360; add one line at bottom to have nicer plot (colors go until the ocean bottom) 
     361    IF n_elements(romszinfos.h) NE 1 THEN BEGIN 
     362      CASE type OF 
     363        'xz':romsh = moyenne(romszinfos.h, 'y') 
     364        'yz':romsh = moyenne(romszinfos.h, 'x') 
     365      ENDCASE 
     366      IF nzt EQ jpk THEN BEGIN 
     367        z2d = [[z2d], [z2d[*, jpk-1]]] 
     368        zzaxis = [[zzaxis], [romsh]] 
     369      ENDIF 
     370    ENDIF 
     371  ENDIF 
    359372  pltbase, z2d, xxaxis, zzaxis, mask, xmask, zmask $ 
    360373    , level_z2d, colnumb, overplot = overplot $ 
  • trunk/SRC/ToBeReviewed/PLOTS/DIVERS/axis4pltz.pro

    r163 r172  
    9090    ENDELSE 
    9191    if keyword_set(sin) then xxaxis = sin(!pi/180.*xxaxis) 
    92     if (size(z))[0] EQ 1 THEN zzaxis = z ELSE zzaxis = z 
    9392  ENDIF ELSE BEGIN 
    9493    xxaxis = glam[*, 0] 
    95     if (size(z))[0] EQ 1 then zzaxis = z ELSE zzaxis = z 
    9694  ENDELSE  
     95  zzaxis = z 
    9796;---------------------------------------------------------- 
    9897; We project the z axis in [0,1] 
     
    102101  if zoom LT profmax then begin 
    103102    mp = projsegment([profmin, zoom], [0, zratio], /mp) 
    104     zzaxis[where(zzaxis LE zoom)] = mp[0]*zzaxis[where(zzaxis LE zoom)]+mp[1] 
     103    small = where(zzaxis LE zoom) 
     104    IF small[0] NE -1 THEN zzaxis[small] = mp[0]*zzaxis[small]+mp[1] 
    105105    mp = projsegment([zoom, profmax], [zratio, 1], /mp) 
    106     zzaxis[where(zzaxis GE zoom)] = mp[0]*zzaxis[where(zzaxis GE zoom)]+mp[1] 
     106    big = where(zzaxis GE zoom) 
     107    IF big[0] NE -1 THEN zzaxis[big] = mp[0]*zzaxis[big]+mp[1] 
    107108  ENDIF ELSE BEGIN 
    108109    mp = projsegment([profmin, profmax], [0, 1], /mp) 
  • trunk/SRC/ToBeReviewed/WIDGET/AUTOUR_de_XXX/buildcmd.pro

    r157 r172  
    184184      if yindex NE 0 then extra = create_struct(extra, 'yindex', yindex) 
    185185      exextra = cw_specifie_get_value(base) 
     186      tgnm = strlowcase(tag_names(exextra)) 
     187      indtmp = where(tgnm EQ 'box' OR tgnm EQ 'boxzoom', cnt) 
     188      IF cnt EQ 1 THEN BEGIN  
     189        boxextra = exextra.(indtmp[0]) 
     190        exextra = extractstru(exextra, ['box', 'boxzoom']) 
     191      ENDIF  
    186192      extra =  mixstru(exextra, extra) 
    187193      sextra = struct2string(extra) 
     
    342348; determination of the boxzoom's name. 
    343349  if NOT keyword_set(boxzoom) then widget_control, domainid, get_value = boxzoom 
     350  CASE n_elements(boxextra) OF 
     351    0: 
     352    1:boxzoom[5] = boxextra 
     353    2:boxzoom[4:5] = boxextra 
     354    4:boxzoom[0:3] = boxextra 
     355    5:boxzoom = [boxextra[0:3], 0, boxextra[4]] 
     356    6:boxzoom = boxextra 
     357  ENDCASE 
    344358; Writting of this one as a string 
    345359  box = '['+strtrim(boxzoom[0], 1) 
     
    358372      if chkstru(exextra, 'profmax') then  pmax = exextra.profmax $ 
    359373      ELSE pmax = 200 
    360       box = box+',0,'+strtrim(pmax, 1) 
     374      box = box+',0,'+strtrim(boxzoom[5] > pmax, 1) 
    361375    ENDELSE 
    362376  endif 
  • trunk/SRC/ToBeReviewed/WIDGET/AUTOUR_de_XXX/buildreadcmd.pro

    r157 r172  
    8787  if yindex NE 0 then extra = create_struct(extra, 'yindex', yindex) 
    8888  exextra = cw_specifie_get_value(base) 
    89   exextra = extractstru(exextra, ['min', 'max', 'inter', 'lct']) 
     89  tgnm = strlowcase(tag_names(exextra)) 
     90  indtmp = where(tgnm EQ 'box' OR tgnm EQ 'boxzoom', cnt) 
     91  IF cnt EQ 1 THEN boxextra = exextra.(indtmp[0]) 
     92  exextra = extractstru(exextra, ['min', 'max', 'inter', 'lct', 'box', 'boxzoom']) 
    9093  if size(exextra, /type) EQ 8 then extra = mixstru(exextra, extra) 
    9194  sextra = struct2string(extra) 
     
    116119;--------------- 
    117120  if NOT keyword_set(boxzoom) then widget_control, domainid, get_value = boxzoom 
     121  CASE n_elements(boxextra) OF 
     122    0: 
     123    1:boxzoom[5] = boxextra 
     124    2:boxzoom[4:5] = boxextra 
     125    4:boxzoom[0:3] = boxextra 
     126    5:boxzoom = [boxextra[0:3], 0, boxextra[4]] 
     127    6:boxzoom = boxextra 
     128  ENDCASE 
    118129; put boxzoom into a string 
    119130  box = '['+strtrim(boxzoom[0], 1) 
     
    121132     box = box+', '+strtrim(boxzoom[i], 1) 
    122133  if strpos(type, 'z') NE -1 then BEGIN 
    123       @common 
    124       min = min([gdept, gdepw], max = max) 
     134      @cm_4mesh 
     135      min = min([gdept, gdepw, boxzoom[4:5]], max = max) 
    125136      box = box+','+strtrim(floor(min), 1)+','+strtrim(ceil(max), 1) 
    126137    endif 
  • trunk/SRC/ToBeReviewed/WIDGET/AUTOUR_de_XXX/scanfile.pro

    r167 r172  
    8989;------------------------------------------------------------ 
    9090  infile = ncdf_inquire(cdfid)  ; 
    91 ; find vargrid ... 
    92   IF keyword_set(grid) THEN vargrid = strupcase(grid) ELSE BEGIN 
    93     vargrid = 'T'               ; default definition 
    94     IF finite(glamu[0]) EQ 1 THEN BEGIN 
     91;------------------------------------------------------------ 
     92; name of all dimensions 
     93;------------------------------------------------------------ 
     94  namedim = strarr(infile.ndims) 
     95  for dimiq = 0, infile.ndims-1 do begin 
     96    ncdf_diminq, cdfid, dimiq, tmpname, value  
     97    namedim[dimiq] = strlowcase(tmpname) 
     98  ENDFOR 
     99; roms file? 
     100  dimidx = where(namedim EQ 'xi_rho' OR namedim EQ 'xi_u' OR namedim EQ 'xi_v' OR namedim EQ 'xi_psi') 
     101  IF dimidx[0] EQ -1 THEN BEGIN 
     102; we are looking for a x dimension with a name matching one of the following regular expression: 
     103    testname = ['longitude', 'lon', 'x', 'longitude*', 'lon*', 'x*', '*longitude*', '*lon*', '*x*'] 
     104    cnt = -1 
     105    ii = 0 
     106    WHILE cnt NE 1 AND ii LT n_elements(testname) DO BEGIN 
     107      dimidx = where(strmatch(namedim, testname[ii]) EQ 1, cnt) 
     108      ii = ii+1 
     109    ENDWHILE 
     110    CASE cnt OF 
     111      0:begin 
     112        dummy = report(['none of the dimensions name matches one of the following regular expression:' $ 
     113                        , '''longitude'', ''lon'', ''x'', ''longitude*'', ''lon*'', ''x*'', ''*longitude*'', ''*lon*'', ''*x*''' $ 
     114                        , ' => we cannot find the x dimension']) 
     115        stop 
     116      END 
     117      1:dimidx = dimidx[0] 
     118      ELSE:begin 
     119        dummy = report(['several (and not one unique) dimensions name matches the following regular expression:' $ 
     120                        , '''longitude'', ''lon'', ''x'', ''longitude*'', ''lon*'', ''x*'', ''*longitude*'', ''*lon*'', ''*x*''' $ 
     121                        , ' => we cannot find the x dimension']) 
     122        stop 
     123      ENDELSE 
     124    ENDCASE 
     125  ENDIF 
     126; roms file? 
     127  dimidy = where(namedim EQ 'eta_rho' OR namedim EQ 'eta_u' OR namedim EQ 'eta_v' OR namedim EQ 'eta_psi') 
     128  IF dimidy[0] EQ -1 THEN BEGIN 
     129; we are looking for a y dimension with a name matching one of the following regular expression: 
     130    testname = ['latitude', 'lat', 'y', 'latitude*', 'lat*', 'y*', 'eta_*', '*latitude*', '*lat*', '*y*'] 
     131    cnt = -1 
     132    ii = 0 
     133    WHILE cnt NE 1 AND ii LT n_elements(testname) DO BEGIN 
     134      dimidy = where(strmatch(namedim, testname[ii]) EQ 1, cnt) 
     135      ii = ii+1 
     136    ENDWHILE 
     137    CASE cnt OF 
     138      0:begin 
     139        dummy = report(['none of the dimensions name matches one of the following regular expression:' $ 
     140                        , '''latitude'', ''lat'', ''y'', ''latitude*'', ''lat*'', ''y*'', ''eta_*'', ''*latitude*'', ''*lat*'', ''*y*''' $ 
     141                        , ' => we cannot find the y dimension']) 
     142        stop 
     143      END 
     144      1:dimidy = dimidy[0] 
     145      ELSE:begin 
     146        dummy = report(['several (and not one unique) dimensions name matches the following regular expression:' $ 
     147                        , '''latitude'', ''lat'', ''y'', ''latitude*'', ''lat*'', ''y*'', ''eta_*'', ''*latitude*'', ''*lat*'', ''*y*''' $ 
     148                        , ' => we cannot find the x dimension']) 
     149        stop 
     150      ENDELSE 
     151    ENDCASE 
     152  ENDIF 
     153;------------------------------------------------------------ 
     154; name of all variables 
     155;------------------------------------------------------------ 
     156; we keep only the variables containing at least x, y and time dimension (if existing...) 
     157  namevar = strarr(infile.nvars) 
     158  for varid = 0, infile.nvars-1 do begin 
     159    invar = ncdf_varinq(cdfid, varid) ; what contains the variable? 
     160    if (inter(invar.dim, dimidx))[0] NE -1 AND $ 
     161       (inter(invar.dim, dimidy))[0] NE -1 AND $ 
     162       ((where(invar.dim EQ infile.recdim))[0] NE -1 OR infile.recdim EQ -1) $ 
     163    THEN namevar[varid] = invar.name  
     164  ENDFOR 
     165  namevar = namevar[where(namevar NE '')] 
     166;------------------------------------------------------------ 
     167; find vargrid for each selected variable... 
     168;------------------------------------------------------------ 
     169  listgrid = strarr(n_elements(namevar)) 
     170; default definitions 
     171  IF keyword_set(grid) THEN vargrid = strupcase(grid) ELSE vargrid = 'T' 
     172; look for values of vargrid for each variable 
     173  IF finite(glamu[0]) EQ 1 AND NOT keyword_set(grid) THEN BEGIN 
     174; for each variable, look if we in one of the case corresponding to ROMS conventions? 
     175    FOR i = 0, n_elements(namevar)-1 do begin 
     176      invar = ncdf_varinq(cdfid, namevar[i]) 
     177      tmpnm = namedim[invar.dim] 
     178; are we in one of the case corresponding to ROMS conventions? 
     179      CASE 1 OF 
     180        tmpnm[2 <(invar.ndims-1)] EQ 's_w':vargrid = 'W' 
     181        tmpnm[0] EQ 'xi_rho' AND tmpnm[1] EQ 'eta_rho':listgrid[i] = 'T' 
     182        tmpnm[0] EQ 'xi_u'   AND tmpnm[1] EQ 'eta_u'  :listgrid[i] = 'U' 
     183        tmpnm[0] EQ 'xi_v'   AND tmpnm[1] EQ 'eta_v'  :listgrid[i] = 'V' 
     184        tmpnm[0] EQ 'xi_psi' AND tmpnm[1] EQ 'eta_psi':listgrid[i] = 'F' 
     185        tmpnm[0] EQ 'xi_rho' AND tmpnm[1] EQ 'eta_v'  :listgrid[i] = 'V' 
     186        tmpnm[0] EQ 'xi_u'   AND tmpnm[1] EQ 'eta_rho':listgrid[i] = 'U' 
     187        tmpnm[0] EQ 'xi_u'   AND tmpnm[1] EQ 'eta_v'  :listgrid[i] = 'F' 
     188        ELSE:  
     189      ENDCASE  
     190    ENDFOR 
     191    empty = where(listgrid EQ '') 
     192    IF empty[0] NE -1 THEN BEGIN    
     193; could we define the grid type from the file name?? 
    95194      pattern = ['GRID.', 'GRID_', 'GRID', 'UPID_', '30ID_'] 
    96195      gdtype = ['T', 'U', 'V', 'W', 'F'] 
     
    104203        ENDFOR 
    105204      ENDFOR 
    106     ENDIF 
    107   ENDELSE 
    108 ;------------------------------------------------------------ 
    109 ; name of all dimensions 
    110 ;------------------------------------------------------------ 
    111   namedim = strarr(infile.ndims) 
    112   for dimiq = 0, infile.ndims-1 do begin 
    113     ncdf_diminq, cdfid, dimiq, tmpname, value  
    114     namedim[dimiq] = strlowcase(tmpname) 
    115   ENDFOR 
    116 ; we are looking for a x dimension with a name matching one of the following regular expression: 
    117   testname = ['longitude', 'lon', 'x', 'longitude*', 'lon*', 'x*', '*longitude*', '*lon*', '*x*'] 
    118   cnt = -1 
    119   ii = 0 
    120   WHILE cnt NE 1 AND ii LT n_elements(testname) DO BEGIN 
    121     dimidx = where(strmatch(namedim, testname[ii]) EQ 1, cnt) 
    122     ii = ii+1 
    123   ENDWHILE 
    124   CASE cnt OF 
    125     0:begin 
    126       dummy = report(['none of the dimensions name matches one of the following regular expression:' $ 
    127                       , '''longitude'', ''lon'', ''x'', ''longitude*'', ''lon*'', ''x*'', ''*longitude*'', ''*lon*'', ''*x*''' $ 
    128                       , ' => we cannot find the x dimension']) 
    129       stop 
    130     END 
    131     1:dimidx = dimidx[0] 
    132     ELSE:begin 
    133       dummy = report(['several (and not one unique) dimensions name matches the following regular expression:' $ 
    134                       , '''longitude'', ''lon'', ''x'', ''longitude*'', ''lon*'', ''x*'', ''*longitude*'', ''*lon*'', ''*x*''' $ 
    135                       , ' => we cannot find the x dimension']) 
    136       stop 
    137     END 
    138   ENDCASE 
    139 ; we are looking for a y dimension with a name matching one of the following regular expression: 
    140   testname = ['latitude', 'lat', 'y', 'latitude*', 'lat*', 'y*', 'eta_*', '*latitude*', '*lat*', '*y*'] 
    141   cnt = -1 
    142   ii = 0 
    143   WHILE cnt NE 1 AND ii LT n_elements(testname) DO BEGIN 
    144     dimidy = where(strmatch(namedim, testname[ii]) EQ 1, cnt) 
    145     ii = ii+1 
    146   ENDWHILE 
    147   CASE cnt OF 
    148     0:begin 
    149       dummy = report(['none of the dimensions name matches one of the following regular expression:' $ 
    150                       , '''latitude'', ''lat'', ''y'', ''latitude*'', ''lat*'', ''y*'', ''eta_*'', ''*latitude*'', ''*lat*'', ''*y*''' $ 
    151                       , ' => we cannot find the y dimension']) 
    152       stop 
    153     END 
    154     1:dimidy = dimidy[0] 
    155     ELSE:begin 
    156       dummy = report(['several (and not one unique) dimensions name matches the following regular expression:' $ 
    157                       , '''latitude'', ''lat'', ''y'', ''latitude*'', ''lat*'', ''y*'', ''eta_*'', ''*latitude*'', ''*lat*'', ''*y*''' $ 
    158                       , ' => we cannot find the x dimension']) 
    159       stop 
    160     END 
    161   ENDCASE 
    162 ;------------------------------------------------------------ 
    163 ; name of all variables 
    164 ;------------------------------------------------------------ 
    165 ; we keep only the variables containing at least x, y and time dimension (if existing...) 
    166   namevar = strarr(infile.nvars) 
    167   for varid = 0, infile.nvars-1 do begin 
    168     invar = ncdf_varinq(cdfid, varid) ; what contains the variable? 
    169     if (where(invar.dim EQ dimidx))[0] NE -1 AND $ 
    170        (where(invar.dim EQ dimidy))[0] NE -1 AND $ 
    171        ((where(invar.dim EQ infile.recdim))[0] NE -1 OR infile.recdim EQ -1) $ 
    172     THEN namevar[varid] = invar.name  
    173   ENDFOR 
    174   namevar = namevar[where(namevar NE '')] 
    175   listgrid = replicate(vargrid, n_elements(namevar)) 
     205      listgrid[empty] = vargrid 
     206    ENDIF  
     207  ENDIF ELSE listgrid[*] = vargrid 
    176208;------------------------------------------------------------ 
    177209; time axis 
     
    229261          mots = str_sep(value, ' ') 
    230262          unite = mots[0] 
    231           debut = str_sep(mots[2], '-') 
     263          err = 0 
     264          IF unite NE 'seconds' AND unite NE 'hours' AND unite NE 'days' $ 
     265             AND unite NE 'months' AND unite NE 'years' THEN BEGIN 
     266            dummy = report('time units does not start with seconds/hours/days/months/years') 
     267            err = 1 
     268          ENDIF 
     269          err = err + 1 - stregex(value, '[^ ]* since ([0-9]){4}-([0-9]){2}-([0-9]){2}.*', /boolean) 
     270          IF err GT 0 THEN BEGIN  
     271            dummy = report('attribut units of time has not the good format: [^ ]* since ([0-9]){4}-([0-9]){2}-([0-9]){2}.*') 
     272            fakecal = 1 
     273            time = date0fk + lindgen(jpt) 
     274          ENDIF ELSE BEGIN  
     275            debut = str_sep(mots[2], '-') 
    232276; 
    233277; now we try to find the attribut called calendar... 
     
    235279; If no, we suppose that the calendar is gregorian calendar 
    236280; 
    237           if (where(attnames EQ 'calendar'))[0] NE -1 then BEGIN 
    238             ncdf_attget, cdfid, varid, 'calendar', value 
    239             value = string(value) 
    240             CASE value OF 
    241               'noleap':key_caltype = 'noleap' 
    242               '360d':key_caltype = '360d' 
    243               'greg':IF n_elements(key_caltype) EQ 0 THEN key_caltype = 'greg' 
    244               ELSE:BEGIN 
     281            if (where(attnames EQ 'calendar'))[0] NE -1 then BEGIN 
     282              ncdf_attget, cdfid, varid, 'calendar', value 
     283              value = string(value) 
     284              CASE value OF 
     285                'noleap':key_caltype = 'noleap' 
     286                '360d':key_caltype = '360d' 
     287                'greg':IF n_elements(key_caltype) EQ 0 THEN key_caltype = 'greg' 
     288                ELSE:BEGIN 
    245289;            notused = report('Unknown calendar: '+value+', we use greg calendar.')  
    246                 key_caltype = 'greg' 
     290                  key_caltype = 'greg' 
     291                END 
     292              ENDCASE 
     293            ENDIF ELSE BEGIN 
     294;        notused = report('Unknown calendar, we use '+key_caltype+' calendar.')  
     295              IF n_elements(key_caltype) EQ 0 THEN key_caltype = 'greg' 
     296            ENDELSE 
     297; 
     298; BEWARE we have to get back the calendar attribute and ajust time by consequence... 
     299; 
     300; 
     301; We pass time in IDL julian days 
     302; 
     303            unite = strlowcase(unite) 
     304            IF strpos(unite, 's', strlen(unite)-1) NE -1 THEN unite = strmid(unite, 0, strlen(unite)-1) 
     305            IF strpos(unite, 'julian_') NE -1 THEN unite = strmid(unite, 7) 
     306            case unite of 
     307              'second':time = julday(debut[1], debut[2], debut[0])+time/86400.d 
     308              'hour':time = julday(debut[1], debut[2], debut[0])+time/24.d 
     309              'day':time = julday(debut[1], debut[2], debut[0])+time 
     310              'month':BEGIN  
     311                if total(fix(time) NE time) NE 0 then $ ; we switch to days with 30d/m 
     312                   time = julday(debut[1], debut[2], debut[0])+round(time*30) $ 
     313                ELSE for t = 0, n_elements(time)-1 DO $ 
     314                   time[t] = julday(debut[1]+time[t], debut[2], debut[0]) 
     315              END 
     316              'year':BEGIN 
     317                if total(fix(time) NE time) NE 0 then $ ; we switch to days with 365d/y 
     318                   time = julday(debut[1], debut[2], debut[0])+round(time*365) $ 
     319                ELSE for t = 0, n_elements(time)-1 do $ 
     320                   time[t] = julday(debut[1], debut[2], debut[0]+time[t]) 
    247321              END 
    248322            ENDCASE 
    249           ENDIF ELSE BEGIN 
    250 ;        notused = report('Unknown calendar, we use '+key_caltype+' calendar.')  
    251             IF n_elements(key_caltype) EQ 0 THEN key_caltype = 'greg' 
     323; 
     324; high frequency calendar: more than one element per day 
     325            IF max(histogram([long(time-time[0])])) GT 1 THEN fakecal = 1 ELSE fakecal = 0 
     326            date0fk = date2jul(19000101) 
     327            IF keyword_set(fakecal) THEN time = date0fk+lindgen(jpt) $ 
     328            ELSE time = long(time) 
     329; 
    252330          ENDELSE 
    253 ; 
    254 ; BEWARE we have to get back the calendar attribute and ajust time by consequence... 
    255 ; 
    256 ; 
    257 ; We pass time in IDL julian days 
    258 ; 
    259           unite = strlowcase(unite) 
    260           IF strpos(unite, 's', strlen(unite)-1) NE -1 THEN unite = strmid(unite, 0, strlen(unite)-1) 
    261           IF strpos(unite, 'julian_') NE -1 THEN unite = strmid(unite, 7) 
    262           case unite of 
    263             'second':time = julday(debut[1], debut[2], debut[0])+time/86400.d 
    264             'hour':time = julday(debut[1], debut[2], debut[0])+time/24.d 
    265             'day':time = julday(debut[1], debut[2], debut[0])+time 
    266             'month':BEGIN  
    267               if total(fix(time) NE time) NE 0 then $ ; we switch to days with 30d/m 
    268                  time = julday(debut[1], debut[2], debut[0])+round(time*30) $ 
    269               ELSE for t = 0, n_elements(time)-1 DO $ 
    270                  time[t] = julday(debut[1]+time[t], debut[2], debut[0]) 
    271             END 
    272             'year':BEGIN 
    273               if total(fix(time) NE time) NE 0 then $ ; we switch to days with 365d/y 
    274                  time = julday(debut[1], debut[2], debut[0])+round(time*365) $ 
    275               ELSE for t = 0, n_elements(time)-1 do $ 
    276                  time[t] = julday(debut[1], debut[2], debut[0]+time[t]) 
    277             END 
    278           ENDCASE 
    279 ; 
    280 ; high frequency calendar: more than one element per day 
    281           IF max(histogram([long(time-time[0])])) GT 1 THEN fakecal = 1 ELSE fakecal = 0 
    282           date0fk = date2jul(19000101) 
    283           IF keyword_set(fakecal) THEN time = date0fk+lindgen(jpt) $ 
    284           ELSE time = long(time) 
    285 ; 
    286331        ENDELSE 
    287332      END 
  • trunk/SRC/ToBeReviewed/WIDGET/COMPOUND_WIDGET/cw_domain.pro

    r167 r172  
    245245      gdep1 = floor(gdep) 
    246246      gdep2 = ceil(gdep) 
    247       same = where(gdep2-gdep1 EQ 0) 
    248       if same[0] NE -1 then gdep2[same] = gdep2[same] + 1 
     247;;       same = where(gdep2-gdep1 EQ 0) 
     248;;       if same[0] NE -1 then gdep2[same] = gdep2[same] + 1 
    249249      widget_control, dthlv1id, set_value = {value:strtrim(gdep1, 1)} 
    250250      widget_control, dthlv2id, set_value = {value:strtrim(gdep2, 1)} 
     
    321321  compile_opt idl2, strictarrsubs 
    322322; 
    323    box = lonarr(6) 
     323   box = fltarr(6) 
    324324   possiblecase = ['lon1', 'lon2', 'lat1', 'lat2', 'depth1', 'depth2'] 
    325325   for i = 0, 5 do begin 
     
    327327       , get_value = value 
    328328      box[i] = value.value 
    329    endfor 
     329    ENDFOR 
    330330   return, box 
    331331end 
     
    636636  gdep1 = floor(gdep) 
    637637  gdep2 = ceil(gdep) 
    638   same = where(gdep2-gdep1 EQ 0) 
    639   if same[0] NE -1 then gdep2[same] = gdep2[same] +1 
     638;;   same = where(gdep2-gdep1 EQ 0) 
     639;;   if same[0] NE -1 then gdep2[same] = gdep2[same] +1 
    640640  sgdep1 = strtrim(gdep1, 1) 
    641641  sgdep2 = strtrim(gdep2, 1) 
Note: See TracChangeset for help on using the changeset viewer.