Index: trunk/ToBeReviewed/HOPE/completetype.pro
===================================================================
--- trunk/ToBeReviewed/HOPE/completetype.pro	(revision 53)
+++ trunk/ToBeReviewed/HOPE/completetype.pro	(revision 53)
@@ -0,0 +1,23 @@
+
+function completetype, typein
+   type=typein
+   case type of
+      'x':type=type+'yzt'
+      'y':type=type+'xzt'
+      'z':type=type+'zyt'
+      't':type=type+'xyz'
+      'xy':type=type+'zt'
+      'xz':type=type+'yt'
+      'yz':type=type+'xt'
+      'xt':type=type+'yz'
+      'yt':type=type+'xz'
+      'zt':type=type+'xy'
+      'xyz':type=type+'t'
+      'xyt':type=type+'z'
+      'yzt':type=type+'x'
+      'xyzt':
+   endcase
+   return, type
+
+end
+;
Index: trunk/ToBeReviewed/HOPE/computehopegrid.pro
===================================================================
--- trunk/ToBeReviewed/HOPE/computehopegrid.pro	(revision 53)
+++ trunk/ToBeReviewed/HOPE/computehopegrid.pro	(revision 53)
@@ -0,0 +1,231 @@
+;------------------------------------------------------------
+;------------------------------------------------------------
+;------------------------------------------------------------
+;+
+; NAME:computehopegrid
+;
+; PURPOSE:
+;
+; CATEGORY:grille
+;
+; CALLING SEQUENCE:computehopegrid
+; 
+; INPUTS:
+;
+; KEYWORD PARAMETERS:
+;
+; OUTPUTS:
+;
+; COMMON BLOCKS:common.pro
+;
+; SIDE EFFECTS:
+;
+; RESTRICTIONS:
+;
+; EXAMPLE:
+;
+; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr)
+;                      2001-06
+;-
+;------------------------------------------------------------
+;------------------------------------------------------------
+;------------------------------------------------------------
+PRO computehopegrid, xaxis, yaxis, zaxis, linetype, FORTHEMASK = forthemask, WPOINT = wpoint, FIRSTS = firsts, LASTS = lasts, PTTYPE = pttype
+;---------------------------------------------------------
+@cm_4mesh
+@cm_4data
+  IF NOT keyword_set(key_forgetold) THEN BEGIN
+@updatenew
+  ENDIF
+;---------------------------------------------------------
+;------------------------------------------------------------
+   if not (keyword_set(scalar)*keyword_set(vector)) then scalar=1
+;------------------------------------------------------------
+   jpiglo = n_elements(xaxis)
+   jpjglo = n_elements(yaxis)
+   jpkglo = n_elements(zaxis)
+;
+   jpi = jpiglo
+   jpj = jpjglo
+   jpk = jpkglo
+;
+   if NOT keyword_set(firsts) then firsts = [0, 0, 0]
+   if NOT keyword_set(lasts) then lasts = [jpi-1, jpj-1, jpk-1]
+;
+; depermination of the grid type and of the point type
+;
+   if keyword_set(pttype) then vargrid = pttype
+   if linetype EQ 'odd-even' then key_gridtype = 'e' ELSE key_gridtype = 'c'
+;
+; computation of the horizontal grid
+;
+   if key_gridtype EQ 'e' then begin
+      if vargrid EQ 'T' then begin
+         glamt=xaxis
+         glamt = glamt#replicate(1, jpj)
+         xstep=(glamt[1,0]-glamt[0,0])/2.
+         glamt[*,2*lindgen((jpj)/2)]=glamt[*,2*lindgen(jpj/2)]-xstep
+         glamu=glamt+xstep
+      ENDIF ELSE BEGIN
+         glamu=xaxis
+         glamu = glamu#replicate(1, jpj)
+         xstep=(glamu[1,0]-glamu[0,0])/2.
+         glamu[*,2*lindgen((jpj)/2)]=glamu[*,2*lindgen(jpj/2)]-xstep
+         glamt=glamu-xstep
+      ENDELSE
+;zoom
+      glamt = glamt[firsts[0]:lasts[0], firsts[1]:lasts[1]]
+      glamu = glamu[firsts[0]:lasts[0], firsts[1]:lasts[1]]
+      jpiglo = lasts[0]-firsts[0]+1
+      jpi = jpiglo
+      jpjglo = lasts[1]-firsts[1]+1
+      jpj = jpjglo
+      glamv = glamu
+      glamf = glamu
+      gphit = yaxis[firsts[1]:lasts[1]]
+      gphit = replicate(1, jpi)#gphit
+      gphif = gphit
+      gphiu = gphit
+      gphiv = gphif
+   ENDIF ELSE BEGIN
+      if vargrid eq 'T' then begin
+         glamt=xaxis
+         glamt = glamt#replicate(1, jpj)
+         glamu=glamt+(glamt[1,0]-glamt[0,0])/2.
+      ENDIF ELSE BEGIN
+         glamu=xaxis
+         glamu = glamu#replicate(1, jpj)
+         xstep=(glamu[1,0]-glamu[0,0])/2.
+         glamt=glamu-(glamu[1,0]-glamu[0,0])/2.
+      ENDELSE
+;zoom
+      glamt = glamt[firsts[0]:lasts[0], firsts[1]:lasts[1]]
+      glamu = glamu[firsts[0]:lasts[0], firsts[1]:lasts[1]]
+      jpiglo = lasts[0]-firsts[0]+1
+      jpi = jpiglo
+      jpjglo = lasts[1]-firsts[1]+1
+      jpj = jpjglo
+      glamv = glamt
+      glamf = glamu
+      gphit = yaxis[firsts[1]:lasts[1]]
+      gphit = replicate(1, jpi)#gphit
+      gphiu = gphit
+      if jpj GT 1 then begin
+         gphiv = gphit+(gphit[0, 1]-gphit[0, 0])/2.
+         gphif = gphit+(gphit[0, 1]-gphit[0, 0])/2.
+      ENDIF ELSE BEGIN 
+         gphiv = gphit
+         gphif = gphit
+      ENDELSE
+   ENDELSE
+;
+; computation of the vertical grid
+;
+   if keyword_set(wpoint) then begin
+      gdepw = zaxis
+      if jpk ne 1 then begin
+         gdept=(shift(gdepw, -1)+gdepw)/2.
+         gdept[jpk-1]=gdepw[jpk-1]+.5*(gdepw[jpk-1]-gdepw[jpk-2])
+      endif else gdept=zaxis
+   endif else begin
+      gdept = zaxis
+      if jpk ne 1 then begin
+         gdepw=(shift(gdept, 1)+gdept)/2.
+         gdepw[0]=0
+      endif else gdepw = zaxis
+   endelse
+;
+; computation of the vertical scale factors
+;
+   if jpk ne 1 then begin
+      e3t = abs(shift(gdepw,-1)-gdepw)
+      e3t[jpk-1] = abs(gdept[jpk-1]-gdepw[jpk-1])
+      e3w = abs(gdept-shift(gdept,1))
+      e3w[0] = abs(gdept[0]-gdepw[0])
+   endif else begin
+      e3t=1
+      e3w=1
+   endelse
+; zoom
+   gdept = gdept[firsts[2]:lasts[2]]
+   gdepw = gdepw[firsts[2]:lasts[2]]
+   e3t = e3t[firsts[2]:lasts[2]]
+   e3w = e3w[firsts[2]:lasts[2]]
+   jpkglo = lasts[2]-firsts[2]+1
+   jpk = jpkglo
+;
+; computation of the horizontal scale factors
+;
+   e1t = replicate(1b,jpi,jpj)
+   e2t = replicate(1b,jpi,jpj)
+   e1u = e1t
+   e2u = e2t
+   e1v = e1t
+   e2v = e2t
+   e1f = e1t
+   e2f = e2t
+;
+; mask 
+;
+   tmask = replicate(1b, jpi, jpj, jpk)
+   if keyword_set(forthemask) then BEGIN
+      land=where(forthemask ge valmask/10)
+      if land[0] ne -1 then tmask[land] = 0b
+   endif
+   umaskred = replicate(1, jpj, jpk)
+   vmaskred = replicate(1, jpi, jpk)
+   fmaskredy = replicate(1, jpj, jpk)
+   fmaskredx = replicate(1, jpi, jpk)
+   @updateold
+   domdef
+   if keyword_set(firsts) AND keyword_set(lasts) then BEGIN
+      if vargrid EQ 'T' then BEGIN
+         if jpj GT 1 then begin
+            lon1 = min(glamt[0, [0, 1]])
+            lon2 = max(glamt[jpi-1, [0, 1]])
+         endif ELSE BEGIN
+            lon1 = min(glamt[0, 0])
+            lon2 = max(glamt[jpi-1, [0]])
+         ENDELSE
+      ENDIF ELSE BEGIN
+         if jpj GT 1 then begin
+            lon1 = min(glamu[0, [0, 1]])
+            lon2 = max(glamu[jpi-1, [0, 1]])
+         endif ELSE BEGIN
+            lon1 = min(glamu[0, 0])
+            lon2 = max(glamu[jpi-1, 0])
+         ENDELSE
+      ENDELSE
+      lat1 = min([gphit[0, 0], gphit[0, jpj-1]])
+      lat2 = max([gphit[0, 0], gphit[0, jpj-1]])
+      domdef, lon1, lon2, lat1, lat2, gdepw[0], gdept[jpk-1], gridtype = vargrid
+   ENDIF
+;
+   ixminmesh  =0l
+   ixmaxmesh  =long(jpi-1)
+   iyminmesh  =0l
+   iymaxmesh  =long(jpj-1)
+   izminmesh  =0l
+   izmaxmesh  =long(jpk-1)
+;----------------------------------------------------------
+; for the triangulation
+;----------------------------------------------------------
+   key_periodic = glamt[0] EQ ((glamt[jpi-1]+glamt[+1]-glamt[0]) MOD 360)
+   if jpi gt 4 AND jpj GT 4 then begin
+      triangles_list = triangule(shifted = glamt[0, 0] LT glamt[0, 1])
+      twin_corners_up=-1
+      twin_corners_dn=-1
+   ENDIF ELSE BEGIN
+      triangles_list=-1
+      twin_corners_up=-1
+      twin_corners_dn=-1
+   ENDELSE
+;------------------------------------------------------------
+  IF NOT keyword_set(key_forgetold) THEN BEGIN
+   @updateold
+  ENDIF 
+;------------------------------------------------------------
+   return
+end
+
+
Index: trunk/ToBeReviewed/HOPE/createhopestruct.pro
===================================================================
--- trunk/ToBeReviewed/HOPE/createhopestruct.pro	(revision 53)
+++ trunk/ToBeReviewed/HOPE/createhopestruct.pro	(revision 53)
@@ -0,0 +1,124 @@
+FUNCTION createhopestruct, event
+   widget_control, event.top, get_uvalue=top_uvalue
+; find the selected variable
+   selected = *top_uvalue[1, findline(top_uvalue, 'selected')]
+; get the variable id
+   varid=(*top_uvalue[1, findline(top_uvalue, 'datavarid')])[selected]
+; get the section type
+   type = (*top_uvalue[1, findline(top_uvalue, 'sectype')])[selected]
+; get its dimension
+   dimsvar=(*top_uvalue[1, findline(top_uvalue, 'dimvar')])[*,selected]
+   tosort=sortdim(completetype(type))
+   dimsvar=dimsvar[tosort]
+; get the specified spatial domain and build reading parameters
+   linetype =(*top_uvalue[1, findline(top_uvalue, 'linetype')])[selected]
+   case linetype of
+      'odd':domainid = widget_info(event.top,find_by_uname = 'basedomainodd')
+      'even':domainid = widget_info(event.top,find_by_uname = 'basedomaineven')
+      'odd-even':domainid = widget_info(event.top,find_by_uname = 'basedomainodd-even')
+   endcase
+   allaxes=*top_uvalue[1, findline(top_uvalue, 'dimlist')]
+   xaxis=allaxes.(dimsvar[0])
+   xlimits = *top_uvalue[1, findline(top_uvalue, 'xlimits')]
+   if NOT keyword_set(xlimits) then begin
+      xid=widget_info(domainid,find_by_uname = 'xinterval')
+      widget_control, xid, get_value=xint
+   endif ELSE xint = xaxis[where(xaxis GE xlimits[0] AND xaxis LE xlimits[1])]
+   yaxis=allaxes.(dimsvar[1])
+   yaxis = reverse(yaxis)       ; latitudes from the south to the north
+   ylimits = *top_uvalue[1, findline(top_uvalue, 'ylimits')]
+   if NOT keyword_set(ylimits) then begin
+      yid=widget_info(domainid,find_by_uname = 'yinterval')
+      widget_control, yid, get_value=yint
+   endif ELSE yint = yaxis[where(yaxis GE ylimits[0] AND yaxis LE ylimits[1])]
+   zaxis=allaxes.(dimsvar[2])
+   zlimits = *top_uvalue[1, findline(top_uvalue, 'zlimits')]
+   if NOT keyword_set(zlimits) then begin
+      zid=widget_info(domainid,find_by_uname = 'zinterval')
+      widget_control, zid, get_value=zint
+   endif ELSE zint = zaxis[where(zaxis GE zlimits[0] AND zaxis LE zlimits[1])]
+; time axis and time interval
+   time=allaxes.(dimsvar[3])
+   yyyymmdd = vairdate(time)
+   tlimits = *top_uvalue[1, findline(top_uvalue, 'tlimits')]
+   if NOT keyword_set(tlimits) then BEGIN
+      date1id = widget_info(event.top, find_by_uname = 'date1')
+      widget_control, date1id, get_value = date1
+      date2id = widget_info(event.top, find_by_uname = 'date2')
+      widget_control, date2id, get_value = date2
+      tlimits = [date1, date2]
+   ENDIF
+   tint = time[where(yyyymmdd GE tlimits[0] AND yyyymmdd LE tlimits[1])]
+; 
+; limits of the domain
+;
+   nxt = n_elements(xint)
+   nyt = n_elements(yint)
+   nzt = n_elements(zint)
+   jpt = n_elements(tint) 
+;
+   firstx = (where(xaxis GE xint[0]))[0]
+   firsty = (where(yaxis GE yint[0]))[0]
+   lasty = firsty+nyt-1
+   firstz = (where(zaxis GE zint[0]))[0]
+   firstt = (where(time GE tint[0]))[0]
+;
+; read the array
+;
+   cdfid=ncdf_open(*top_uvalue[1, findline(top_uvalue, 'filename')])
+   offset=[firstx,n_elements(yaxis)-lasty-1,firstz,firstt]
+   count=[nxt,nyt,nzt,jpt]
+   tosortinv=sortdim(completetype(type),/inv)
+; sort the offset and count for the case of the array is not written
+; as a xyzt array but for example as a yzxt array....
+   offset=offset[tosortinv]
+   count=count[tosortinv]
+; call to ncdf_varget
+   ncdf_varget, cdfid, varid, array, offset=offset, count=count ;
+; force to keep the dimension equal to 1
+   if count[3] eq 1 then array=reform(array,count[0],count[1],count[2],count[3],/over)
+   if not (array_equal(tosort, lindgen(4))) then array=transpose(temporary(array),tosort)
+   count=[nxt,nyt,nzt,jpt]
+   if jpt eq 1 then array=reform(array,count[0],count[1],count[2],count[3],/over)
+   array=reverse(array, 2, /over)
+; if there is no longitude zoom, shift the array to obtain longitude
+; between 20 and 380
+   if nxt EQ 128 OR nxt EQ 256 then begin
+      key_shift = -(where(xaxis GE 20))[0]
+      xaxis = shift(temporary(xaxis), key_shift)
+      xaxis[where(xaxis LT 20)] = xaxis[where(xaxis LT 20)]+360
+      array = shift(temporary(array), key_shift, 0, 0, 0)
+   ENDIF ELSE key_shift = 0
+; get some informations about the array
+   insidevar=ncdf_varinq(cdfid,varid)
+   if insidevar.natts NE 0 then begin
+      attnames = strarr(insidevar.natts)
+      for attiq=0,insidevar.natts-1 do attnames[attiq]=strlowcase(ncdf_attname(cdfid,varid,attiq))
+; get the name
+      if (where(attnames EQ 'long_name'))[0] EQ -1 then value = '' $
+      ELSE ncdf_attget,cdfid,varid,'long_name',value
+      varname = strtrim(string(value), 2)
+; get the units
+      if (where(attnames EQ 'units'))[0] EQ -1 then value = '' $
+      ELSE ncdf_attget,cdfid,varid,'units',value
+      varunit = strtrim(string(value), 2)
+; get the 'missing_value'
+      if (where(attnames EQ 'missing_value'))[0] EQ -1 then valmask = 1e20 $
+      ELSE ncdf_attget,cdfid,varid,'missing_value', valmask
+   ENDIF ELSE BEGIN 
+      varunit = ''
+      valmask = 1e20
+      varname = ''
+   ENDELSE
+   varexp = ''
+;
+; build arguments to use computehopegrid and put it together in a structure
+   firsts = [firstx,firsty,firstz]
+   lasts = [firstx+nxt-1,firsty+nyt-1,firstz+nzt-1]
+   vargrid = (*top_uvalue[1, findline(top_uvalue, 'pointtype')])[selected]
+   hopegrid = {xaxis:xaxis, yaxis:yaxis, zaxis:zaxis, firsts:firsts, lasts:lasts, type:type, linetype:linetype, pttype:vargrid}
+   hopestru = {array:array, unit:varunit, name:varname, date:time[firstt:firstt+jpt-1], grid:vargrid, hopegrid:hopegrid}
+; we close the netcdf file before living!
+   ncdf_close,  cdfid
+   return, hopestru
+end
Index: trunk/ToBeReviewed/HOPE/cw_selectinterval.pro
===================================================================
--- trunk/ToBeReviewed/HOPE/cw_selectinterval.pro	(revision 53)
+++ trunk/ToBeReviewed/HOPE/cw_selectinterval.pro	(revision 53)
@@ -0,0 +1,97 @@
+
+PRO testwid_event, event
+   widget_control, event.id, get_uvalue=uval
+   if n_elements(uval) EQ 0 then return
+   case uval of
+      'done':widget_control, event.top, /destroy
+      'get':BEGIN
+         id = widget_info(event.top,find_by_uname = 'discret')
+         widget_control, id, get_value = value1
+         help, value1
+         print, 'value1', value1
+         id = widget_info(event.top,find_by_uname = 'continus')
+         widget_control, id, get_value = value2
+         help, value2
+         print, 'value2', value2
+      END
+      ELSE:
+   endcase
+   return
+end
+PRO testwid, _extra = ex
+   base=widget_base(/COLUMN)
+   nothing = widget_label(base, value = 'beginning of the test')
+;
+   nothing = cw_selectinterval(base, 10+indgen(5), _extra = ex, uname = 'discret', uvalue = 'discret')
+   print, nothing
+   nothing = cw_selectinterval(base, indgen(20), _extra = ex, uname = 'continus', uvalue = 'continus')
+   print, nothing
+;
+   nothing = widget_button(base, value = 'get', uvalue = 'get')
+   nothing = widget_button(base, value = 'done', uvalue = 'done')
+   widget_control, base, /REALIZE
+   xmanager,'testwid', base, /no_block
+   return
+end
+;--------------------------------------------------------------------------
+;--------------------------------------------------------------------------
+;--------------------------------------------------------------------------
+function cw_selectinterval_get_value, id
+   bgroupid=widget_info(id, find_by_uname = 'bgroup')
+; the widget is a set of button
+   if bgroupid ne 0 then begin
+      widget_control, bgroupid, get_value = selected
+      widget_control, bgroupid, get_uvalue = vecteur
+      vecteur = vecteur.vecteur
+   endif else begin
+; the widget is 2 sliders
+      Minid = Widget_Info(Id, Find_by_uname = 'min')
+      widget_control, minid, get_value = minval
+      minval = minval.value
+      maxid = widget_info(id, find_by_uname = 'max')
+      widget_control, maxid, get_value = maxval
+      maxval = maxval.value
+      widget_control, minid, get_uvalue = vecteur
+      vecteur = vecteur.vecteur
+      selected = where(vecteur ge minval and vecteur le maxval)
+   ENDELSE
+  if selected[0] eq -1 then return, -1 else return, vecteur[selected]
+END
+;--------------------------------------------------------------------------
+function cw_selectinterval_event, event
+   widget_control, event.id, get_uvalue=uval
+   case uval.name of
+      'min':begin               ; change the value if the minimum for the slider called max
+         maxid=widget_info(event.handler, find_by_uname = 'max')
+         widget_control, maxid, set_value={SLIDER_MIN:event.value+1}
+      end
+      'max':begin               ; change the value if the maximum for the slider called min
+         minid=widget_info(event.handler, find_by_uname = 'min')
+         widget_control, minid, set_value={SLIDER_MAX:event.value-1}
+      end
+      'bgroup':
+   endcase
+   return, {ID:event.handler, TOP:event.top, HANDLER:0L}
+END
+
+;--------------------------------------------------------------------------
+function cw_selectinterval, parent, vecteur, _extra = ex
+
+   base = widget_base(parent $
+                      , EVENT_FUNC = 'cw_selectinterval_event' $
+                      , FUNC_GET_VALUE='cw_selectinterval_get_value' $
+                      , PRO_SET_VALUE='cw_selectinterval_set_value' $
+                      , /ROW, _extra = ex)
+   if n_elements(vecteur) le 10 then begin
+      nothing = CW_BGROUP(base, strtrim(vecteur,1),/nonexclusive,/row, uvalue = {name:'bgroup', vecteur:vecteur}, uname='bgroup')
+      buttvalue=bytarr(n_elements(nothing))
+      buttvalue[0]=1
+      widget_control, nothing, set_value=buttvalue
+   endif else begin
+      min=min(floor(vecteur))
+      max=max(ceil(vecteur))
+      nothing=cw_slider_pm(base, value = min, min=min, max=max-1, uvalue = {name:'min', vecteur:vecteur}, uname='min')
+      nothing=cw_slider_pm(base, value = max, min=min+1, max=max, uvalue = {name:'max'}, uname='max')
+   endelse
+   return, base
+end
Index: trunk/ToBeReviewed/HOPE/domainpart.pro
===================================================================
--- trunk/ToBeReviewed/HOPE/domainpart.pro	(revision 53)
+++ trunk/ToBeReviewed/HOPE/domainpart.pro	(revision 53)
@@ -0,0 +1,54 @@
+pro domainpart, top_uvalue, basedomain, selected, DESTROY = destroy
+
+   if keyword_set(destroy) then BEGIN
+;       id = widget_info(basedomain,find_by_uname = 'title')
+;       IF id NE 0 THEN widget_control, id, /destroy
+      id = widget_info(basedomain,find_by_uname = 'oddsecchoice')
+      IF id NE 0 THEN widget_control, id, /destroy
+      id = widget_info(basedomain,find_by_uname = 'evensecchoice')
+      IF id NE 0 THEN widget_control, id, /destroy
+      id = widget_info(basedomain,find_by_uname = 'odd-evensecchoice')
+      IF id NE 0 THEN widget_control, id, /destroy
+      id = widget_info(basedomain,find_by_uname = 'basex')
+      IF id NE 0 THEN widget_control, id, /destroy
+      id = widget_info(basedomain,find_by_uname = 'basey')
+      IF id NE 0 THEN widget_control, id, /destroy
+      id = widget_info(basedomain,find_by_uname = 'basez')
+      IF id NE 0 THEN widget_control, id, /destroy
+      return
+   endif
+;
+; we get the size of the dimenstion id of this section
+;
+   dimvar = *top_uvalue[1, findline(top_uvalue, 'dimvar')]
+   selecteddim = dimvar[*, selected]
+   typedim = *top_uvalue[1, findline(top_uvalue, 'typedim')]
+   sorteddim = selecteddim[sortdim(typedim[selecteddim])]
+   dimlist = *top_uvalue[1, findline(top_uvalue, 'dimlist')]
+;
+;  longitude part
+;
+   basex=widget_info(basedomain,find_by_uname = 'basex')
+   IF basex NE 0 THEN widget_control, basex, /destroy
+   basex=widget_base(basedomain,/row, uname='basex')
+   nothing=widget_text(basex,value='longitude', xsize = 10)
+   nothing=cw_selectinterval(basex,dimlist.(sorteddim[0]),uname='xinterval',uvalue={name:'xinterval'})
+;
+;  latitude part
+;
+   basey=widget_info(basedomain,find_by_uname = 'basey')
+   IF basey NE 0 THEN widget_control, basey, /destroy
+   basey=widget_base(basedomain,/row, uname='basey')
+   nothing=widget_text(basey,value='latitude', xsize = 10)
+   nothing=cw_selectinterval(basey,reverse(dimlist.(sorteddim[1])), uname='yinterval',uvalue={name:'yinterval'})
+;
+;  depth part
+;
+   basez=widget_info(basedomain,find_by_uname = 'basez')
+   IF basez NE 0 THEN widget_control, basez, /destroy
+   basez=widget_base(basedomain,/row, uname='basez')
+   nothing=widget_text(basez,value='depth', xsize = 10)
+   nothing=cw_selectinterval(basez,dimlist.(sorteddim[2]),uname='zinterval',uvalue={name:'zinterval'})
+;
+end
+;
Index: trunk/ToBeReviewed/HOPE/findlineandpointtype.pro
===================================================================
--- trunk/ToBeReviewed/HOPE/findlineandpointtype.pro	(revision 53)
+++ trunk/ToBeReviewed/HOPE/findlineandpointtype.pro	(revision 53)
@@ -0,0 +1,269 @@
+FUNCTION findlineandpointtype, sectype, xaxis, yaxis, iodir
+; the file 'HOPE_lonlat.nc' is used in this function, This file must
+; be localized in iodir
+; netcdf HOPE_lonlat {
+; dimensions:
+;         latTlow = 242 ;
+;         lonTlowodd = 128 ;
+;         latThigh = 390 ;
+;         lonThighodd = 256 ;
+; variables:
+;         float latTlow(latTlow) ;
+;                 latTlow:units = "degrees_north" ;
+;         float lonTlowodd(lonTlowodd) ;
+;                 lonTlowodd:units = "degrees_east" ;
+;                 lonTlowodd:point_spacing = "even" ;
+;                 lonTlowodd:modulo = " " ;
+;         float latThigh(latThigh) ;
+;                 latThigh:units = "degrees_north" ;
+;         float lonThighodd(lonThighodd) ;
+;                 lonThighodd:units = "degrees_east" ;
+;                 lonThighodd:point_spacing = "even" ;
+;                 lonThighodd:modulo = " " ;
+; }
+   jpi = n_elements(xaxis)
+   jpj = n_elements(yaxis)
+;
+; depermination of the grid type and of the point type
+;
+; low resolution grid: jpi=128, jpj=121 ( x 2), jpk=20
+; 
+;                0.       1.4         2.8       4.2        5.6
+;    odd                    T          u          T          u  93.3
+;    even        T          u          T          u             92.2
+;    odd                    T          u          T          u  91.1
+;    even        T          u          T          u             90.0
+;
+;
+; high resolution grid: jpi=256, jpj=195 ( x 2), jpk=29
+; 
+;                0.       0.7         1.4        2.1        2.8       
+;    odd                    T          u          T          u  91.6
+;    even        T          u          T          u             91.0
+;    odd                    T          u          T          u  90.5
+;    even        T          u          T          u             90.0
+;
+;
+   x0 = floor(xaxis[0]*10)/10.
+   y0 = floor(yaxis[0]*10)/10.
+   case sectype of
+      'xy':BEGIN
+         if (jpi NE 128 and jpi NE 256) $
+          OR (jpj NE 121 AND jpj NE 121*2 AND jpj NE 195 AND jpj NE 195*2) then begin
+            print,  'CASE NOT coded...'
+            stop
+         ENDIF
+         case 1 of
+            jpj EQ 195: BEGIN
+               case X0 OF
+                  0:BEGIN
+                     line = 'even'
+                     vargrid = 'T'
+                  END
+                  0.7:BEGIN
+                     case y0 OF
+                        91.6:BEGIN
+                           line = 'odd'
+                           vargrid = 'T'
+                        END
+                        91.0:BEGIN
+                           line = 'even'
+                           vargrid = 'U'
+                        END
+                        ELSE:BEGIN
+                           print,  'CASE NOT coded...'
+                           stop
+                        END
+                     endcase
+                  END
+                  1.4:BEGIN
+                     line = 'odd'
+                     vargrid = 'U'
+                  END
+               endcase
+            END
+            jpj EQ 121:BEGIN
+               case x0 OF
+                  0:BEGIN
+                     line = 'even'
+                     vargrid = 'T'
+                  END
+                  1.4:BEGIN
+                     case y0 OF
+                        93.3:BEGIN
+                           line = 'odd'
+                           vargrid = 'T'
+                        END
+                        92.2:BEGIN
+                           line = 'even'
+                           vargrid = 'U'
+                        END
+                        ELSE:BEGIN
+                           print,  'CASE NOT coded...'
+                           stop
+                        END
+                     endcase
+                  END
+                  2.8:BEGIN
+                     line = 'odd'
+                     vargrid = 'U'
+                  END
+               endcase
+            END
+            jpj EQ 195*2:BEGIN
+               line = 'odd-even'
+               case x0 OF
+                  0.7:vargrid = 'T'
+                  1.4:vargrid = 'U'
+                  ELSE:BEGIN
+                     print,  'CASE NOT coded...'
+                     stop
+                  END
+               endcase
+            END
+            jpj EQ 121*2:BEGIN
+               line = 'odd-even'
+               case x0 OF
+                  1.4:vargrid = 'T'
+                  2.8:vargrid = 'U'
+                  ELSE:BEGIN
+                     print,  'CASE NOT coded...'
+                     stop
+                  END
+               endcase
+            END
+            ELSE:BEGIN
+               print,  'CASE NOT coded...'
+               stop
+            END
+         endcase
+      END
+      'xz':BEGIN
+         if (jpi NE 128 and jpi NE 256) then begin
+            print,  'CASE NOT coded...'
+            stop
+         ENDIF
+         case X0 OF
+            0:BEGIN
+               line = 'even'
+               vargrid = 'T'
+            END
+            0.7:BEGIN
+               id = ncdf_open(iodir+'HOPE_lonlat.nc')
+               ncdf_varget, id, 'latThigh', lat
+               test = (where(lat EQ yaxis[0]))[0]
+               if test EQ -1 then begin
+                  print,  'CASE NOT coded...'
+                  stop
+               endif
+               IF (test MOD 2) EQ 1 THEN BEGIN
+                  line = 'even'
+                  vargrid = 'U'
+               ENDIF ELSE BEGIN
+                  line = 'odd'
+                  vargrid = 'T'
+               ENDELSE
+               ncdf_close, id
+            END
+            1.4:BEGIN
+               if jpi EQ 128 then begin
+                  id = ncdf_open(iodir+'HOPE_lonlat.nc')
+                  ncdf_varget, id, 'latTlow', lat
+                  test = (where(lat EQ yaxis[0]))[0]
+                  if test EQ -1 then begin
+                     print,  'CASE NOT coded...'
+                     stop
+                  endif
+                  IF (test MOD 2) EQ 1 THEN BEGIN
+                     line = 'even'
+                     vargrid = 'U'
+                  ENDIF ELSE BEGIN
+                     line = 'odd'
+                     vargrid = 'T'
+                  ENDELSE
+                  ncdf_close, id
+               ENDIF ELSE BEGIN
+                  line = 'odd'
+                  vargrid = 'U'
+               ENDELSE
+            END
+            2.8:BEGIN
+               line = 'odd'
+               vargrid = 'U'
+            END
+         endcase
+      END
+      'yz':BEGIN
+         if (jpj NE 121 AND jpj NE 195) then begin
+            print,  'CASE NOT coded...'
+            stop
+         ENDIF
+         id = ncdf_open(iodir+'HOPE_lonlat.nc')
+         case y0 of
+            93.3:BEGIN
+               line = 'odd'
+               ncdf_varget, id, 'lonTlowodd', lonTodd
+               xstep = (lonTodd[1]-lonTodd[0])/2.
+               case 1 OF
+                  (where(lonTodd EQ xaxis[0]))[0] NE -1:vargrid = 'T'
+                  (where(lonTodd+xstep EQ xaxis[0]))[0] NE -1:vargrid = 'U'
+                  ELSE:BEGIN
+                     print,  'CASE NOT coded...'
+                     stop
+                  END
+               endcase
+            END
+            92.2:BEGIN
+               line = 'even'
+               ncdf_varget, id, 'lonTlowodd', lonTodd
+               xstep = (lonTodd[1]-lonTodd[0])/2.
+               case 1 OF
+                  (where(lonTodd EQ xaxis[0]))[0] NE -1:vargrid = 'U'
+                  (where(lonTodd-xstep EQ xaxis[0]))[0] NE -1:vargrid = 'T'
+                  ELSE:BEGIN
+                     print,  'CASE NOT coded...'
+                     stop
+                  END
+               endcase
+            END
+            91.6:BEGIN
+               line = 'odd'
+               ncdf_varget, id, 'lonThighodd', lonTodd
+               xstep = (lonTodd[1]-lonTodd[0])/2.
+               case 1 OF
+                  (where(lonTodd EQ xaxis[0]))[0] NE -1:vargrid = 'T'
+                  (where(lonTodd+xstep EQ xaxis[0]))[0] NE -1:vargrid = 'U'
+                  ELSE:BEGIN
+                     print,  'CASE NOT coded...'
+                     stop
+                  END
+               endcase
+            END
+            91.0:BEGIN
+               line = 'even'
+               ncdf_varget, id, 'lonThighodd', lonTodd
+               xstep = (lonTodd[1]-lonTodd[0])/2.
+               case 1 OF
+                  (where(lonTodd EQ xaxis[0]))[0] NE -1:vargrid = 'U'
+                  (where(lonTodd-xstep EQ xaxis[0]))[0] NE -1:vargrid = 'T'
+                  ELSE:BEGIN
+                     print,  'CASE NOT coded...'
+                     stop
+                  END
+               endcase
+            END
+            ELSE:BEGIN
+               print,  'CASE NOT coded...'
+               stop
+            END
+         endcase
+         ncdf_close, id
+      END
+      else:BEGIN
+         print, 'case not coded'
+         stop
+      END
+   endcase
+
+   return, {linetype:line, pointtype:vargrid}
+end
Index: trunk/ToBeReviewed/HOPE/read_hope.pro
===================================================================
--- trunk/ToBeReviewed/HOPE/read_hope.pro	(revision 53)
+++ trunk/ToBeReviewed/HOPE/read_hope.pro	(revision 53)
@@ -0,0 +1,576 @@
+;------------------------------------------------------------
+;------------------------------------------------------------
+;------------------------------------------------------------
+;+
+; NAME: read_hope
+;
+; PURPOSE: read the Hope grid file converted in NetCdf by xconv
+;
+; CATEGORY: reading
+;
+; CALLING SEQUENCE: a=read_hope([typein, varnamein])
+; 
+; INPUTS:
+;        typein: a string specifing from which type of section the 4D
+;        array based: 'xy, 'xz', 'yz'
+;
+;        varnamein: a string the name of the cariable to be read (in
+;        lower or upper case)
+;
+; KEYWORD PARAMETERS:
+;
+;         FILENAME = the name of the file to be read
+;
+;         XLIMITS = a two elements vertor [lonmin, lonmax]]
+;                   the bondary of the longitudes (from 0 to 360)
+;
+;         YLIMITS = a two elements vertor [latmin, latmax]]
+;                   the bondary of the latitudes (from -90 to 90)
+;
+;         ZLIMITS = a two elements vertor [depthmin, depthmax]]
+;                   the bondary of the depth
+;
+;         TLIMITS = a two elements vertor [date1, date2]]
+;                   the bondary of the calendar with date1 and date2
+;                   folowing the syntaxe yyyymmdd
+;
+;         /ODDPT: activate to read only the sections located on ODD
+;         points 
+;
+;         /EVENPT: activate to read only the sections located on even
+;         points 
+;
+;         /ODDEVENPT: activate to read only the sections located on
+;         both even and odd points (horizontal sections)
+;
+; OUTPUTS:
+;
+;        -1 if typein and varnamein are undefine (this is the widget
+;        version)
+;
+;        a structure which but be read by litchamp.pro and is
+;        necessary to complute the grid associated to the data (see
+;        the example).
+;
+; COMMON BLOCKS: common.pro (usefull only for the definition of iodir)
+;
+; SIDE EFFECTS:
+;     'x', 'y', 'z', 't', 'xt', 'yt' and 'zt' section not coded, xconv
+;     must be able to works with this kind of fonction.
+;     The grib file has no zoom possibilities on horizontal
+;     dimensions.
+;
+; RESTRICTIONS:
+;
+;     When typein and varnamein are defined, the methode to find the
+;     godd variable is:
+;     1) find the variables which are available on this type of
+;     sections woth this name
+;     2) if ODDPT, EVENPT or ODDEVENPT are specified, consider only
+;     these types of sections
+;     3) for an XY section the chosen variable is the one which has
+;     the most level in the vertical domain specified by ZLIMITS.
+;        for an XZ section the chosen variable is the one which has
+;     the most points in the latitude domain specified by YLIMITS.
+;        for an YZ section the chosen variable is the one which has
+;     the most points in the longitude domain specified by XLIMITS.
+;
+;
+; EXAMPLE:
+;
+;     IDL> a=read_hope('xy','ocpt',filename='CLIM_CNT_1993-1998.nc')
+;     IDL> help, a,/struct
+;     ** Structure <82ec344>, 6 tags, length=1860176, refs=1:
+;        ARRAY           FLOAT     Array[128, 242, 15]
+;        UNIT            STRING    'deg C'
+;        NAME            STRING    'Ocean potential temperature'
+;        DATE            FLOAT     Array[1]
+;        GRID            STRING    'T'
+;        HOPEGRID        STRUCT    -> <Anonymous> Array[1]
+;     IDL> help, a.hopegrid,/struct
+;     ** Structure <82eb9cc>, 8 tags, length=1588, refs=2:
+;        XAXIS           FLOAT     Array[128]
+;        YAXIS           FLOAT     Array[242]
+;        ZAXIS           FLOAT     Array[15]
+;        FIRSTS          LONG      Array[3]
+;        LASTS           LONG      Array[3]
+;        TYPE            STRING    'xy'
+;        LINETYPE        STRING    'odd-even'
+;        PTTYPE          STRING    'T'
+;     IDL> help, litchamp(a)
+;     <Expression>    FLOAT     = Array[128, 242, 15]
+;
+; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr)
+;                      June 2001
+;-
+;------------------------------------------------------------
+;------------------------------------------------------------
+;------------------------------------------------------------
+
+
+;
+pro read_hope_event, event
+   widget_control, event.id, get_uvalue=uval
+   widget_control, event.top, get_uvalue=top_uvalue
+   case uval.name OF
+;---------------------------------
+      'cancel':begin
+; close the file
+         cdfid=*top_uvalue[1, findline(top_uvalue, 'cdfid')]
+         ncdf_close, cdfid
+; clear the pointer
+         for i=0,n_elements(top_uvalue)-1 do ptr_free, top_uvalue[i]
+; kill the widget
+         widget_control,event.top,/destroy
+      end
+;---------------------------------
+      'type choice':begin
+; find the new type of selected section
+         typeindex=widget_info(event.id,/droplist_select)
+         selectedtype=(*top_uvalue[1, findline(top_uvalue, 'type choice')])[typeindex]
+; find the available variables for this type of section
+         sectype = *top_uvalue[1, findline(top_uvalue, 'sectype')]
+         goodvar = where(sectype EQ selectedtype)
+         namevar = *top_uvalue[1, findline(top_uvalue, 'namevar')]
+         goodnamevar = namevar[goodvar]
+; find the selected var name
+         varchoiceid = widget_info(event.top,find_by_uname = 'var choice')
+         varindex = widget_info(varchoiceid,/droplist_select)
+         varchoice = *top_uvalue[1, findline(top_uvalue, 'var choice')]
+         selectedvarname=varchoice[varindex]
+; do we change the variable?
+         if (where(goodnamevar EQ selectedvarname))[0] EQ -1 then begin
+            selectedvarname = goodnamevar[0]
+            varindex = (where(varchoice EQ selectedvarname))[0]
+            widget_control, varchoiceid, set_droplist_select = varindex
+         ENDIF
+; displays the different domains
+         selected = goodvar[where(goodnamevar EQ selectedvarname)]
+         rh_alldomains, event.top, selected
+      end
+;---------------------------------
+      'var choice':BEGIN
+; find the new variable
+         varindex=widget_info(event.id,/droplist_select)
+         selectedvar=(*top_uvalue[1, findline(top_uvalue, 'var choice')])[varindex]
+; find the available variables for this type of section
+         namevar = *top_uvalue[1, findline(top_uvalue, 'namevar')]
+         goodvar = where(namevar EQ selectedvar)
+         sectype = *top_uvalue[1, findline(top_uvalue, 'sectype')]
+         goodtype = sectype[goodvar]
+; find the selected type of section
+         typechoiceid = widget_info(event.top,find_by_uname = 'type choice')
+         typeindex = widget_info(typechoiceid,/droplist_select)
+         typechoice = *top_uvalue[1, findline(top_uvalue, 'type choice')]
+         selectedtype=typechoice[typeindex]
+; do we change the type of section ?
+         if (where(goodtype EQ selectedtype))[0] EQ -1 then begin
+            selectedtype = goodtype[0]
+            typeindex = (where(typechoice EQ selectedtype))[0]
+            widget_control, typechoiceid, set_droplist_select = typeindex
+         ENDIF
+; displays the different domains
+         selected = goodvar[where(goodtype EQ selectedtype)]
+         rh_alldomains, event.top, selected
+      END
+;---------------------------------
+      'plot':BEGIN
+; plot the array
+         res = createhopestruct(event)
+; type of section
+         selected = *top_uvalue[1, findline(top_uvalue, 'selected')]
+         type = (*top_uvalue[1, findline(top_uvalue, 'sectype')])[selected]
+; get the informations of cw_specifie
+         specifieid=widget_info(event.top,find_by_uname = 'specifie')
+         widget_control, specifieid, get_value = specifie
+         specifie = struct2string(specifie,/direct2string)
+         case type of
+            'x':command = 'plt1d,res,''x'','+specifie
+            'y':command = 'plt1d,res,''y'','+specifie
+            'z':command = 'plt1d,res,''z'','+specifie
+            't':command = 'pltt,res,''t'' ,'+specifie
+            'xy':command = 'plt, res,'+specifie
+            'xz':command = 'pltz, res,''xz'','+specifie
+            'yz':command = 'pltz, res,''yz'','+specifie
+            'xt':command = 'pltt,res,''xt'','+specifie
+            'yt':command = 'pltt,res,''yt'','+specifie
+            'zt':command = 'pltt,res,''zt'','+specifie
+            'xyz':
+            'xyt':
+            'yzt':
+            'xyzt':
+         ENDCASE
+         test = execute(command)
+         if test EQ 0 then stop
+      end
+;---------------------------------
+      'linechoice':BEGIN
+         if event.select EQ 1 then begin
+            sensitive = bytarr(3)
+            sensitive[where(['odd', 'even', 'odd-even'] eq event.value)] = 1
+            basedomainodd=widget_info(event.top,find_by_uname = 'basedomainodd')
+            widget_control, basedomainodd, sensitive = sensitive[0]
+            basedomaineven=widget_info(event.top,find_by_uname = 'basedomaineven')
+            widget_control, basedomaineven, sensitive = sensitive[1]
+            basedomainoddeven=widget_info(event.top,find_by_uname = 'basedomainodd-even')
+            widget_control, basedomainoddeven, sensitive = sensitive[2]
+            case (where(sensitive EQ 1))[0] of
+               0:BEGIN
+                  widget_control, basedomainodd, get_uvalue = oddsecchoice
+                  oddsecchoiceid=widget_info(event.top,find_by_uname = 'oddsecchoice')
+                  if oddsecchoiceid NE 0 then $
+                   index = widget_info(oddsecchoiceid, /droplist_select) $
+                  ELSE index = 0
+                  *top_uvalue[1, findline(top_uvalue, 'selected')] = oddsecchoice[index]
+               END
+               1:BEGIN
+                  widget_control, basedomaineven, get_uvalue = evensecchoice
+                  evensecchoiceid=widget_info(event.top,find_by_uname = 'evensecchoice')
+                  if evensecchoiceid NE 0 then $
+                   index = widget_info(evensecchoiceid, /droplist_select) $
+                  ELSE index = 0
+                  *top_uvalue[1, findline(top_uvalue, 'selected')] = evensecchoice[index]
+               END
+               2:BEGIN
+                  widget_control, basedomainodd, get_uvalue = oddevensecchoice
+                  oddevensecchoiceid=widget_info(event.top,find_by_uname = 'odd-evensecchoice')
+                  if oddevensecchoiceid NE 0 then $
+                   index = widget_info(oddevensecchoiceid, /droplist_select) $
+                  ELSE index = 0
+                  *top_uvalue[1, findline(top_uvalue, 'selected')] = oddevensecchoice[index]
+               END
+            endcase
+         endif
+      END
+;---------------------------------
+      'oddsecchoice':BEGIN
+         widget_control, event.top, update=0
+         basedomainodd=widget_info(event.top,find_by_uname = 'basedomainodd')
+         widget_control, basedomainodd, get_uvalue = oddsecchoice
+         domainpart, top_uvalue, basedomainodd, oddsecchoice[event.index]
+         *top_uvalue[1, findline(top_uvalue, 'selected')] = oddsecchoice[event.index]
+         widget_control, event.top, update=1
+      END
+;---------------------------------
+      'evensecchoice':BEGIN
+         widget_control, event.top, update=0
+         basedomaineven=widget_info(event.top,find_by_uname = 'basedomaineven')
+         widget_control, basedomaineven, get_uvalue = evensecchoice
+         domainpart, top_uvalue, basedomaineven, evensecchoice[event.index]
+         *top_uvalue[1, findline(top_uvalue, 'selected')] = evensecchoice[event.index]
+         widget_control, event.top, update=1
+      END
+;---------------------------------
+      'odd-evensecchoice':BEGIN
+         widget_control, event.top, update=0
+         basedomainoddeven=widget_info(event.top,find_by_uname = 'basedomainodd-even')
+         widget_control, basedomainoddeven, get_uvalue = oddevensecchoice
+         domainpart, top_uvalue, basedomainoddeven, oddevensecchoice[event.index]
+         *top_uvalue[1, findline(top_uvalue, 'selected')] = oddevensecchoice[event.index]
+         widget_control, event.top, update=1
+      END
+;---------------------------------
+      'date1':BEGIN
+         date2id = widget_info(event.top, find_by_uname = 'date2')
+         widget_control, date2id, get_value = date2
+         if event.value GT date2 then widget_control, date2id, set_value = event.value
+      END
+;---------------------------------
+      'date2':BEGIN
+         date1id = widget_info(event.top, find_by_uname = 'date1')
+         widget_control, date1id, get_value = date1
+         if event.value LT date1 then widget_control, date1id, set_value = event.value
+      END
+;---------------------------------
+      else:
+   endcase
+   return
+end
+;
+;
+;
+;
+;
+;
+;
+;
+;
+FUNCTION read_hope, typein, varnamein, FILENAME = filename, XLIMITS = xlimits, YLIMITS = ylimits,  ZLIMITS = zlimits, TLIMITS = tlimits, ODDPT = oddpt, ODDEVENPT = oddevenpt, EVENPT = evenpt, _extra = ex
+@common                         ; usefull only for the definition of iodir 
+  if n_elements(filename) EQ 0 then filename = isafile(iodirectory = iodir, _extra = ex)
+  IF size(filename, /type) NE 7 THEN return, -1
+  filename = isafile(filename = filename, iodirectory = iodir, _extra = ex)
+;
+  cdfid = ncdf_open(filename)       ; id of the netcdf file 
+  wathinside = ncdf_inquire(cdfid)  ; structure with global informations
+;------------------------------- 
+;  dimensions
+;------------------------------- 
+  namedim = strarr(wathinside.ndims)  ; name of the dimensions
+  typedim = strarr(wathinside.ndims)  ; type of the dimensions (x,y,z,t)
+  sizedim = lonarr(wathinside.ndims)  ; size of each dimension
+; loop on the dimensions to get the names and sizes
+  for dimiq = 0, wathinside.ndims-1 do begin
+    ncdf_diminq, cdfid, dimiq, name, value
+    namedim[dimiq] = name
+    case 1 of 
+      STRCMP(name, 'lon', 3, /FOLD_CASE):typedim[dimiq] = 'x'
+      STRCMP(name, 'lat', 3, /FOLD_CASE):typedim[dimiq] = 'y'
+      STRCMP(name, 'z', 1, /FOLD_CASE):typedim[dimiq] = 'z'
+      STRCMP(name, 't', 1, /FOLD_CASE):typedim[dimiq] = 't'
+      ELSE:BEGIN
+        ncdf_close, cdfid
+        return, report('Unknown name of dimension')
+      END
+    endcase
+    sizedim[dimiq] = value
+  endfor
+; dimlist: structure which contains the name and the value of each
+; dimension
+; we suppose that there is always a variable which has the 
+; same name that the dimension and which gives the values of
+; this dimension
+  ncdf_varget, cdfid, namedim[0], value
+  dimlist = create_struct(namedim[0], value)
+  for dimiq = 1, wathinside.ndims-1 do begin
+    ncdf_varget, cdfid, namedim[dimiq], value ;get the value
+    dimlist = create_struct(dimlist, namedim[dimiq], value)
+  endfor
+;------------------------------- 
+;  variables
+;------------------------------- 
+  namevar = strarr(wathinside.nvars)   ; names of the variables
+  ndimsvar = lonarr(wathinside.nvars)  ; number of dim for each variable
+  dimvar = replicate(-1, wathinside.ndims, wathinside.nvars) ; dims of each variables
+; loop over the variable ids to fill namevar, ndimsvar and dimvar
+  for varid = 0, wathinside.nvars-1 do begin
+    res = ncdf_varinq(cdfid, varid)
+    namevar[varid] = res.name
+    namevar[varid] = strjoin(strsplit(namevar[varid], '_[0-99]', /EXTRACT, /REGEX))
+    ndimsvar[varid] = res.ndims
+    dimvar[0:res.ndims-1, varid] = res.dim
+  ENDFOR
+; we cut dimvar to select only the interessant part
+  dimvar = dimvar[0:max(ndimsvar)-1, *]
+; selection of the data variables which are diffrent from the
+; dimension variables
+; we suppose that that data variables are 4D array (with sometime
+; dimensions equal to 1). they must be different from dimension
+; variables which have only 1 dimension
+  datavarid = where(ndimsvar eq 4)
+  numberofvar = n_elements(datavarid)
+  namevar = namevar[datavarid]
+  ndimsvar = ndimsvar[datavarid]
+  dimvar = dimvar[*, datavarid]
+;
+  sectype = strarr(numberofvar) ; the type of section for each variable :'xy', 'xz', 'yz'...
+  linetype = strarr(numberofvar) ; the line of the points : odd, even or odd-even
+  pointtype = strarr(numberofvar) ; the type of variable : scalar ('T') or vector ('U')
+  for i = 0, numberofvar-1 do begin
+    dimofthevar = dimvar[*, i]
+    sectype[i] = typedim[dimofthevar[0]]+typedim[dimofthevar[1]]
+    xaxisid = dimofthevar[where(typedim[dimofthevar] EQ 'x')]
+    yaxisid = dimofthevar[where(typedim[dimofthevar] EQ 'y')]
+    lineandpt = findlineandpointtype(sectype[i], dimlist.(xaxisid[0]), dimlist.(yaxisid[0]), iodir)
+    linetype[i] = lineandpt.linetype
+    pointtype[i] = lineandpt.pointtype
+  endfor
+;
+;---------------------------------------------------  
+;---------------------------------------------------  
+;---------------------------------------------------  
+;  definition of the widget
+;---------------------------------------------------  
+;---------------------------------------------------  
+;---------------------------------------------------  
+  base = widget_base(/column)
+;---------------------------------------------------  
+; first base: 
+;    droplist to select the type of section
+;    droplist to select the variable
+;    button to select type of line : odd, even or odd-even
+;---------------------------------------------------  
+  base1 = widget_base(base, /row, /frame)
+  typechoice = sectype[uniq(sectype, sort(sectype))]
+  if n_elements(typechoice) GT 1 then typechoice = typechoice[sortdim(typechoice)]
+  base11 = widget_droplist(base1, title = 'Type of section', value = typechoice, uvalue = {name:'type choice'}, uname = 'type choice')
+  if n_elements(typein) NE 0 then BEGIN
+    selectedtype = strmid(typein, 0, 2)
+    widget_control, base11, set_droplist_select $
+                    = 0L > (where(typechoice EQ selectedtype))[0]
+  ENDIF ELSE selectedtype = typechoice[0]
+; 
+  varchoice = namevar[uniq(namevar, sort(namevar))]
+  base12 = widget_droplist(base1, title = 'Available data', value = varchoice, uvalue = {name:'var choice'}, uname = 'var choice')
+  if n_elements(varnamein) NE 0 THEN BEGIN
+    selectedname = varnamein
+    widget_control, base12, set_droplist_select $
+                    = 0L > (where(strlowcase(varchoice) EQ strlowcase(varnamein)))[0]
+  ENDIF ELSE selectedname = varchoice[0]
+;
+  base13 = widget_base(base1, /row, uname = 'linechoicebase')
+;---------------------------------------------------  
+; base 2: base to select the domain of the odd points
+;---------------------------------------------------
+  base2 = widget_base(base, /column, uname = 'basedomainodd', /frame)
+;---------------------------------------------------  
+; base 3: base to select the domain of the even points
+;---------------------------------------------------
+  base3 = widget_base(base, /column, uname = 'basedomaineven', /frame)
+;---------------------------------------------------  
+; base 4: base to select the domain of the odd-even points
+;---------------------------------------------------
+  base4 = widget_base(base, /column, uname = 'basedomainodd-even', /frame)
+;---------------------------------------------------  
+; base 5: calendar
+;---------------------------------------------------
+  base5 = widget_base(base, /row, uname = 'baset', /frame)
+  timename = strlowcase((tag_names(dimlist))[wathinside.recdim])
+; read the time axis in julina days
+  time = ncdf_timeget(cdfid, timename)
+; update the dimlist structure
+  dimlist.(wathinside.recdim) = time
+  base51 = cw_calendar(base5, time, uname = 'date1', uvalue = {name:'date1'})
+  base52 = cw_calendar(base5, time, uname = 'date2', uvalue = {name:'date2'})
+;---------------------------------------------------  
+;  base 6: base to select the min, max, ... and others keywords
+;---------------------------------------------------
+  base6 = cw_specifie(base, /column, uname = 'specifie', uvalue = {name:'specifie'})
+;---------------------------------------------------  
+;  base 7: last base with the action buttons
+;---------------------------------------------------
+  base7 = widget_base(base, /row, uname = 'finalaction')
+  base71 = widget_button(base7, value = 'Plot', uvalue = {name:'plot'})
+  base72 = widget_button(base7, value = 'Cancel', uvalue = {name:'cancel'})
+;---------------------------------------------------  
+; determination of the selected variable ......
+;---------------------------------------------------  
+  goodname = 0 > where(strlowcase(namevar) EQ strlowcase(selectedname))
+  goodtype = 0 > where(sectype EQ selectedtype)
+  selected = inter(goodname, goodtype)
+  if selected[0] EQ -1 then BEGIN
+    widget_control, base, /destroy
+    ncdf_close, cdfid
+    return, report('impossible combinaison : type of section '+selectedtype+', variable name '+selectedname)
+  ENDIF
+  if n_elements(typein) NE 0 then BEGIN
+    if NOT keyword_set(xlimits) then xlimits = [-1e9, 1e9]
+    if NOT keyword_set(ylimits) then ylimits = [-1e9, 1e9]
+    if NOT keyword_set(zlimits) then zlimits = [-1e9, 1e9]
+    if NOT keyword_set(tlimits) then tlimits = [-1e9, 1e9]
+  ENDIF
+  if n_elements(typein) NE 0 AND n_elements(selected) NE 1 then BEGIN
+    if keyword_set(oddpt) then selected = inter(selected, where(linetype EQ 'odd'))
+    if keyword_set(evenpt) then selected = inter(selected, where(linetype EQ 'even'))
+    if keyword_set(oddevenpt) then selected = inter(selected, where(linetype EQ 'odd-even'))
+    if selected[0] EQ -1 then BEGIN
+      widget_control, base, /destroy
+      ncdf_close, cdfid
+      return, report('impossible combinaison : type of section '+selectedtype+', variable name '+selectedname+' and line type ')
+    endif
+    if n_elements(selected) NE 1 then begin
+      case selectedtype of
+        'xy':BEGIN
+; choice on the vertical axis
+; choice based on the variable which has the most available levels
+; between the zlimits.
+          if NOT keyword_set(zlimits) then begin
+            print, 'case not coded...'
+            stop
+          ENDIF
+          number = lonarr(n_elements(selected))
+          for i = 0, n_elements(selected)-1 do begin
+            zdim = dimvar[2, selected[i]]
+            zaxis = dimlist.(zdim)
+            nothing = where(zaxis GE zlimits[0] AND zaxis LE zlimits[1], count)
+            number[i] = count
+          ENDFOR
+          selected = selected[where(number EQ max(number))]
+          if n_elements(selected) NE 1 then begin
+            print, 'case not coded...'
+            stop
+          endif
+        END
+        'xz':BEGIN
+; choice on the latitude axis
+          if NOT keyword_set(ylimits) then begin
+            print, 'case not coded...'
+            stop
+          ENDIF
+          number = lonarr(n_elements(selected))
+          for i = 0, n_elements(selected)-1 do begin
+            ydim = dimvar[2, selected[i]]
+            yaxis = dimlist.(ydim)
+            nothing = where(yaxis GE ylimits[0] AND yaxis LE ylimits[1], count)
+            number[i] = count
+          ENDFOR
+          selected = selected[where(number EQ max(number))]
+          if n_elements(selected) NE 1 then begin
+            print, 'case not coded...'
+            stop
+          endif
+        END
+        'yz':BEGIN
+; choice on the longitude axis
+          if NOT keyword_set(xlimits) then begin
+            print, 'case not coded...'
+            stop
+          ENDIF
+          number = lonarr(n_elements(selected))
+          for i = 0, n_elements(selected)-1 do begin
+            xdim = dimvar[2, selected[i]]
+            xaxis = dimlist.(xdim)
+            nothing = where(xaxis GE xlimits[0] AND xaxis LE xlimits[1], count)
+            number[i] = count
+          ENDFOR
+          selected = selected[where(number EQ max(number))]
+          if n_elements(selected) NE 1 then begin
+            print, 'case not coded...'
+            stop
+          endif
+        END
+      endcase
+    endif
+  ENDIF
+;---------------------------------------------------  
+; definition of the uvalue of the base which allows to share the
+; variables between programs. 
+;---------------------------------------------------  
+  top_uvalue = ptrarr(2, 18, /allocate_heap)
+  *top_uvalue[0, 0] = 'type choice' & *top_uvalue[1, 0] = temporary(typechoice)
+  *top_uvalue[0, 1] = 'var choice' & *top_uvalue[1, 1] = temporary(varchoice)
+  *top_uvalue[0, 2] = 'namevar' & *top_uvalue[1, 2] = temporary(namevar)
+  *top_uvalue[0, 3] = 'dimvar' & *top_uvalue[1, 3] = temporary(dimvar)
+  *top_uvalue[0, 4] = 'sectype' & *top_uvalue[1, 4] = temporary(sectype)
+  *top_uvalue[0, 5] = 'linetype' & *top_uvalue[1, 5] = temporary(linetype)
+  *top_uvalue[0, 6] = 'pointtype' & *top_uvalue[1, 6] = temporary(pointtype)
+  *top_uvalue[0, 7] = 'dimlist' & *top_uvalue[1, 7] = temporary(dimlist)
+  *top_uvalue[0, 8] = 'typedim' & *top_uvalue[1, 8] = temporary(typedim)
+  *top_uvalue[0, 9] = 'sizedim' & *top_uvalue[1, 9] = temporary(sizedim)
+  *top_uvalue[0, 10] = 'cdfid' & *top_uvalue[1, 10] = cdfid
+  *top_uvalue[0, 11] = 'datavarid' & *top_uvalue[1, 11] = datavarid
+  *top_uvalue[0, 12] = 'selected' & *top_uvalue[1, 12] = selected
+  *top_uvalue[0, 13] = 'filename' & *top_uvalue[1, 13] = filename
+  *top_uvalue[0, 14] = 'xlimits' & *top_uvalue[1, 14] = testvar(var = xlimits)
+  *top_uvalue[0, 15] = 'ylimits' & *top_uvalue[1, 15] = testvar(var = ylimits)
+  *top_uvalue[0, 16] = 'zlimits' & *top_uvalue[1, 16] = testvar(var = zlimits)
+  *top_uvalue[0, 17] = 'tlimits' & *top_uvalue[1, 17] = testvar(var = tlimits)
+
+
+  widget_control, base, set_uvalue = top_uvalue
+  rh_alldomains, base, selected
+
+  if n_params() EQ 0 then BEGIN
+; we use the widget
+    widget_control, base, /REALIZE
+    xmanager, 'read_hope', base, /no_block
+    return,  -1
+  ENDIF
+; get the output
+  output = createhopestruct({top:base})
+; clear the pointer
+  for i = 0, n_elements(top_uvalue)-1 do ptr_free, top_uvalue[i]
+; close the file
+  ncdf_close, cdfid
+  return, output
+end
Index: trunk/ToBeReviewed/HOPE/rh_alldomains.pro
===================================================================
--- trunk/ToBeReviewed/HOPE/rh_alldomains.pro	(revision 53)
+++ trunk/ToBeReviewed/HOPE/rh_alldomains.pro	(revision 53)
@@ -0,0 +1,128 @@
+PRO rh_alldomains, topid, selected
+
+   widget_control, topid, get_uvalue=top_uvalue
+   widget_control, topid, update=0
+;
+   selectedline=(*top_uvalue[1, findline(top_uvalue, 'linetype')])[selected]
+;
+; we get the size of the dimenstion id of this section
+;
+   dimvar = *top_uvalue[1, findline(top_uvalue, 'dimvar')]
+   typedim = *top_uvalue[1, findline(top_uvalue, 'typedim')]
+   dimlist = *top_uvalue[1, findline(top_uvalue, 'dimlist')]
+   sizedim = *top_uvalue[1, findline(top_uvalue, 'sizedim')]
+;
+; buttons to select type of line : odd, even or odd-even
+;
+   linechoicebase=widget_info(topid,find_by_uname = 'linechoicebase')
+   id = widget_info(linechoicebase,find_by_uname = 'linechoice')
+   IF id NE 0 THEN widget_control, id, /destroy
+   choice = ''
+   if (where(selectedline EQ 'odd'))[0] NE -1 then choice = [choice, 'odd']
+   if (where(selectedline EQ 'even'))[0] NE -1 then choice = [choice, 'even']
+   if (where(selectedline EQ 'odd-even'))[0] NE -1 then choice = [choice, 'odd-even']
+   choice = choice[1:n_elements(choice)-1]
+   nothing = cw_bgroup(linechoicebase,choice, /row,/exclusive, /return_name, uname = 'linechoice', uvalue = {name:'linechoice'})
+   widget_control, nothing, set_value = 0
+   sensitive = bytarr(3)
+   sensitive[where(['odd', 'even', 'odd-even'] eq choice[0])] = 1
+;
+;  odd points domain
+;
+   basedomainodd=widget_info(topid,find_by_uname = 'basedomainodd')
+   id = widget_info(basedomainodd,find_by_uname = 'title')
+   IF id NE 0 THEN widget_control, id, /destroy
+   oddsecchoice = where(selectedline EQ 'odd')
+   if oddsecchoice[0] NE -1 then BEGIN
+      oddsecchoice = selected[oddsecchoice]
+      nothing=widget_label(basedomainodd, value = 'Domain of the odd points', uname = 'title')
+      IF n_elements(oddsecchoice) GT 1 THEN BEGIN
+         selecteddim = dimvar[*, oddsecchoice]
+         sorteddim = selecteddim
+         FOR i = 0, n_elements(oddsecchoice)-1 DO $
+          sorteddim[*, i] = selecteddim[sortdim(typedim[selecteddim[*, i]]), i]
+         zdim = sorteddim[2, *]
+         sizedims = sizedim[zdim]
+         sortedzdim = sort(sizedims)
+         sizedims = sizedims[sortedzdim]
+         oddsecchoice = oddsecchoice[sortedzdim]
+         nothing=widget_droplist(basedomainodd,title = 'number of levels', value = strtrim(sizedims, 2), uvalue = {name:'oddsecchoice'}, uname='oddsecchoice')
+      ENDIF 
+      domainpart, top_uvalue, basedomainodd, oddsecchoice[0]
+      widget_control, basedomainodd, set_uvalue = oddsecchoice
+   ENDIF ELSE BEGIN 
+      nothing=widget_label(basedomainodd, value = ' ', uname = 'title')
+      domainpart, top_uvalue, basedomainodd, /destroy
+      widget_control, basedomainodd, set_uvalue = -1
+   ENDELSE
+   widget_control, basedomainodd, sensitive = sensitive[0]
+;
+;  even points domain
+;
+   basedomaineven=widget_info(topid,find_by_uname = 'basedomaineven')
+   id = widget_info(basedomaineven,find_by_uname = 'title')
+   IF id NE 0 THEN widget_control, id, /destroy
+   evensecchoice = where(selectedline EQ 'even')
+   if evensecchoice[0] NE -1 then BEGIN
+      evensecchoice = selected[evensecchoice]
+      nothing=widget_label(basedomaineven, value = 'Domain of the even points', uname = 'title')
+      IF n_elements(evensecchoice) GT 1 THEN BEGIN
+         selecteddim = dimvar[*, evensecchoice]
+         sorteddim = selecteddim
+         FOR i = 0, n_elements(evensecchoice)-1 DO $
+          sorteddim[*, i] = selecteddim[sortdim(typedim[selecteddim[*, i]]), i]
+         zdim = sorteddim[2, *]
+         sizedims = sizedim[zdim]
+         sortedzdim = sort(sizedims)
+         sizedims = sizedims[sortedzdim]
+         evensecchoice = evensecchoice[sortedzdim]
+         nothing=widget_droplist(basedomaineven,title = 'number of levels', value = strtrim(sizedims, 2), uvalue = {name:'evensecchoice'}, uname='evensecchoice')
+      ENDIF 
+      domainpart, top_uvalue, basedomaineven, evensecchoice[0]
+      widget_control, basedomaineven, set_uvalue = evensecchoice
+   ENDIF ELSE BEGIN
+      domainpart, top_uvalue, basedomaineven, /destroy
+      nothing=widget_label(basedomaineven, value = ' ', uname = 'title')
+      widget_control, basedomaineven, set_uvalue = -1
+   ENDELSE
+   widget_control, basedomaineven, sensitive = sensitive[1]
+;
+;  odd-even points domain
+;
+   basedomainoddeven=widget_info(topid,find_by_uname = 'basedomainodd-even')
+   id = widget_info(basedomainoddeven,find_by_uname = 'title')
+   IF id NE 0 THEN widget_control, id, /destroy
+   oddevensecchoice = where(selectedline EQ 'odd-even')
+   if oddevensecchoice[0] NE -1 then BEGIN
+      oddevensecchoice = selected[oddevensecchoice]
+      nothing=widget_label(basedomainoddeven, value = 'Domain of the odd-even points', uname = 'title')
+      IF n_elements(oddevensecchoice) GT 1 THEN BEGIN
+         selecteddim = dimvar[*, oddevensecchoice]
+         sorteddim = selecteddim
+         FOR i = 0, n_elements(oddevensecchoice)-1 DO $
+          sorteddim[*, i] = selecteddim[sortdim(typedim[selecteddim[*, i]]), i]
+         zdim = sorteddim[2, *]
+         sizedims = sizedim[zdim]
+         sortedzdim = sort(sizedims)
+         sizedims = sizedims[sortedzdim]
+         oddevensecchoice = oddevensecchoice[sortedzdim]
+         nothing=widget_droplist(basedomainoddeven,title = 'number of levels', value = strtrim(sizedims, 2), uvalue = {name:'odd-evensecchoice'}, uname='odd-evensecchoice')
+      ENDIF 
+      domainpart, top_uvalue, basedomainoddeven, oddevensecchoice[0]
+      widget_control, basedomainoddeven, set_uvalue = oddevensecchoice
+   ENDIF ELSE BEGIN
+      domainpart, top_uvalue, basedomainoddeven, /destroy
+      nothing=widget_label(basedomainoddeven, value = ' ', uname = 'title')
+      widget_control, basedomainoddeven, set_uvalue = -1
+   ENDELSE
+   widget_control, basedomainoddeven, sensitive = sensitive[2]
+;
+   case (where(sensitive EQ 1))[0] of
+      0:*top_uvalue[1, findline(top_uvalue, 'selected')] = oddsecchoice[0]
+      1:*top_uvalue[1, findline(top_uvalue, 'selected')] = evensecchoice[0]
+      2:*top_uvalue[1, findline(top_uvalue, 'selected')] = oddevensecchoice[0]
+   endcase
+;
+   widget_control, topid, update=1
+   return
+end
Index: trunk/ToBeReviewed/HOPE/sortdim.pro
===================================================================
--- trunk/ToBeReviewed/HOPE/sortdim.pro	(revision 53)
+++ trunk/ToBeReviewed/HOPE/sortdim.pro	(revision 53)
@@ -0,0 +1,32 @@
+
+
+function sortdim, dims, inverse=inverse
+;
+;   IDL> a=['x','y','t','z'] 
+;   IDL> b=a[sortdim(a)] 
+;   IDL> print, a 
+;   x y t z
+;   IDL> print, b 
+;   x y z t
+;   IDL> print, b[sortdim(a,/inv)] 
+;   x y t z
+;   IDL> a='xytz'
+;   IDL> print, sortdim(a)
+;              0           1           3           2
+;
+;
+;
+   tosort = dims
+   if n_elements(tosort) eq 1 then $
+    tosort = string(reform(byte(tosort),1,(strlen(tosort))[0]))
+   tosort = strrepl(tosort,strwhere(tosort,'x'),'a')
+   tosort = strrepl(tosort,strwhere(tosort,'y'),'b')
+   tosort = strrepl(tosort,strwhere(tosort,'z'),'c')
+   tosort = strrepl(tosort,strwhere(tosort,'t'),'d')
+   tosort = uniq(tosort,sort(tosort))
+   if keyword_set(inverse) then tosort=sort(tosort)
+   return, tosort
+
+end
+;
+
Index: trunk/ToBeReviewed/HOPE/xrh.pro
===================================================================
--- trunk/ToBeReviewed/HOPE/xrh.pro	(revision 53)
+++ trunk/ToBeReviewed/HOPE/xrh.pro	(revision 53)
@@ -0,0 +1,5 @@
+; procedure to call read_hope in the widget mode
+PRO xrh, _extra = ex
+   a = read_hope(_extra = ex)
+   return
+end
