Index: trunk/SRC/ToBeReviewed/LECTURE/read_ncdf.pro
===================================================================
--- trunk/SRC/ToBeReviewed/LECTURE/read_ncdf.pro	(revision 172)
+++ trunk/SRC/ToBeReviewed/LECTURE/read_ncdf.pro	(revision 174)
@@ -27,14 +27,17 @@
 ; See BEGINNING.
 ; 
-; @param COMPATIBILITY {in}{required}
-; Useless
+; @param COMPATIBILITY {in}{optional}
+; Useless, defined for compatibility
 ;  
 ; @keyword BOXZOOM 
 ; Contain the boxzoom on which we have to do the reading 
 ; 
-; @keyword FILENAME {type=string}
+; @keyword CALLITSELF {default=0}{type=scalar: 0 or 1}
+; For ROMS outputs. Use by read_ncdf itself to access auxilliary data (h and zeta).
+; 
+; @keyword FILENAME {required}{type=string}
 ; It contains he file's name.
 ; 
-; @keyword INIT
+; @keyword INIT {default=0}{type=scalar: 0 or 1}
 ; To call automatically initncdf, filename and thus
 ; redefine all the grid parameters
@@ -46,14 +49,13 @@
 ; is not found.
 ; 
-; @keyword TIMESTEP
-; We activate to specify that BEGINNING and ENDING refer to indexes
-; of the time axis and not to dates
-;
-; @keyword TOUT
+; @keyword TIMESTEP {default=0}{type=scalar: 0 or 1}
+; Specify that BEGINNING and ENDING refer to indexes of the time axis and not to dates
+;
+; @keyword TOUT {default=0}{type=scalar: 0 or 1}
 ; We activate it if we want to read the file on the whole domain without 
 ; considerate the sub-domain defined by the boxzoom or 
 ; lon1,lon2,lat1,lat2,vert1,vert2.
 ; 
-; @keyword NOSTRUCT
+; @keyword NOSTRUCT {default=0}{type=scalar: 0 or 1}
 ; We activate it if we do not want that read_ncdf send back a structure 
 ; but only the array referring to the field.
@@ -64,4 +66,13 @@
 ; is no unlimited dimension or if the time axis selected by default
 ; (the first 1D array with unlimited dimension) is not the good one.
+;
+; @keyword HFILENAME {default=FILENAME}{type=string}
+; For ROMS outputs. The filename of the file where h vriable should be read
+;
+; @keyword ZETAFILENAME {default=FILENAME}{type=string}
+; For ROMS outputs. The filename of the file where zeta vriable should be read
+;
+; @keyword ZETAZERO {default=0}{type=scalar: 0 or 1}
+; For ROMS outputs. To define zeta to 0. instead of reading it
 ;
 ; @keyword _EXTRA
@@ -91,5 +102,7 @@
                     , PARENTIN = parentin, TIMESTEP = timestep, TIMEVAR = timevar $
                     , TOUT = tout, NOSTRUCT = nostruct, CONT_NOFILL = CONT_NOFILL, INIT = init $
-                    , GRID = grid, FBASE2TBASE = fbase2tbase, _EXTRA = ex, CALLITSELF = callitself
+                    , GRID = grid, FBASE2TBASE = fbase2tbase, CALLITSELF = callitself $
+                    , HFILENAME = hfilename, ZETAFILENAME = zetafilename, ZETAZERO = zetazero $
+                    , _EXTRA = ex
 ;---------------------------------------------------------
 ;
@@ -547,12 +560,33 @@
       ncdf_attget, cdfid, 'theta_b', theta_b, /global
       ncdf_attget, cdfid, 'hc', hc, /global
-; +++ binder l'exsitance de h et zeta...
-; +++ mettre zeta a 0 par defaut
-      hroms = read_ncdf('h', 0, 0, FILENAME = filename $
-                        , /TIMESTEP, /NOSTRUCT, CONT_NOFILL = CONT_NOFILL $
-                        , GRID = vargrid, /CALLITSELF, _EXTRA = ex)
-      zeta = read_ncdf('zeta', firsttps, lasttps, FILENAME = filename $
-                       , /TIMESTEP, /NOSTRUCT, CONT_NOFILL = CONT_NOFILL $
-                       , GRID = vargrid, /CALLITSELF, _EXTRA = ex)
+; look for all variables names
+      allvarnames = strarr(varcontient.nvars)
+      FOR i = 0, varcontient.nvars-1 DO BEGIN
+        tmp = ncdf_varinq( cdfid, i)
+        allvarnames[i] = tmp.name
+      ENDFOR
+      CASE 1 OF
+        keyword_set(hfilename):  $
+           hroms = read_ncdf('h', 0, 0, FILENAME = hfile $
+                             , /TIMESTEP, /NOSTRUCT, CONT_NOFILL = CONT_NOFILL $
+                             , GRID = vargrid, /CALLITSELF, _EXTRA = ex)
+        (where(allvarnames EQ 'h'))[0] NE -1: $
+           hroms = read_ncdf('h', 0, 0, FILENAME = filename $
+                             , /TIMESTEP, /NOSTRUCT, CONT_NOFILL = CONT_NOFILL $
+                             , GRID = vargrid, /CALLITSELF, _EXTRA = ex)
+        ELSE:return, report('The variable h was not found in the file, please use the keyword HFILENAME to specify the name of a file containing h')
+      ENDCASE
+      CASE 1 OF
+        keyword_set(zetazero):zeta = fltarr(nx, ny, jpt)
+        keyword_set(zetafilename):  $
+           zeta = read_ncdf('zeta', firsttps, lasttps, FILENAME = zetafilename $
+                            , /TIMESTEP, /NOSTRUCT, CONT_NOFILL = CONT_NOFILL $
+                            , GRID = vargrid, /CALLITSELF, _EXTRA = ex)
+        (where(allvarnames EQ 'h'))[0] NE -1: $
+           zeta = read_ncdf('zeta', firsttps, lasttps, FILENAME = filename $
+                            , /TIMESTEP, /NOSTRUCT, CONT_NOFILL = CONT_NOFILL $
+                            , GRID = vargrid, /CALLITSELF, _EXTRA = ex)
+        ELSE:return, report('The variable zeta was not found in the file, please use the keyword ZETAFILENAME to specify the name of a file containing zeta or use  keyword ZETAZERO to define zeta to 0.')
+      ENDCASE
       romszinfos = {h:temporary(hroms), zeta:temporary(zeta), theta_s:theta_s, theta_b:theta_b, hc:hc}
     ENDIF ELSE romszinfos = {h:-1, zeta:-1, theta_s:-1, theta_b:-1, hc:-1}
