Index: /trunk/SRC/Grid/micromeshmask.pro
===================================================================
--- /trunk/SRC/Grid/micromeshmask.pro	(revision 301)
+++ /trunk/SRC/Grid/micromeshmask.pro	(revision 302)
@@ -102,6 +102,6 @@
   ENDELSE
 ; get the variables list related to the partial steps
-  varlist_ps = ncdf_listvars(cdfid)
-  varlist_ps = strtrim(strlowcase(varlist_ps), 2)
+  zgr_varlist = ncdf_listvars(cdfid)
+  zgr_varlist = strtrim(strlowcase(zgr_varlist), 2)
 ;------------------------------------------------------
 ;------------------------------------------------------
@@ -135,23 +135,25 @@
     varid[16+z] = ncdf_vardef(cdfidout, zgrlist[z], [dimidz], /float)
 ; variables related to the partial steps
-  IF (where(varlist_ps EQ 'hdept'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'hdept'))[0] NE -1 THEN $
     varid = [varid, ncdf_vardef(cdfidout, 'hdept', [dimidx, dimidy], /float)]
-  IF (where(varlist_ps EQ 'hdepw'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'hdepw'))[0] NE -1 THEN $
     varid = [varid, ncdf_vardef(cdfidout, 'hdepw', [dimidx, dimidy], /float)]
 ; old variable name. keep for compatibility with old run. Change e3tp to e3t_ps
-  IF (where(varlist_ps EQ 'e3tp'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'e3tp'))[0] NE -1 THEN $
     varid = [varid, ncdf_vardef(cdfidout, 'e3t_ps', [dimidx, dimidy], /float)]
 ; old variable name. keep for compatibility with old run. Change e3wp to e3w_ps
-  IF (where(varlist_ps EQ 'e3wp'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'e3wp'))[0] NE -1 THEN $
     varid = [varid, ncdf_vardef(cdfidout, 'e3w_ps', [dimidx, dimidy], /float)]
 ;
-  IF (where(varlist_ps EQ 'e3t_ps'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'e3t_ps'))[0] NE -1 THEN $
     varid = [varid, ncdf_vardef(cdfidout, 'e3t_ps', [dimidx, dimidy], /float)]
-  IF (where(varlist_ps EQ 'e3w_ps'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'e3w_ps'))[0] NE -1 THEN $
     varid = [varid, ncdf_vardef(cdfidout, 'e3w_ps', [dimidx, dimidy], /float)]
-;   IF (where(varlist_ps EQ 'e3u_ps'))[0] NE -1 THEN $
+;   IF (where(zgr_varlist EQ 'e3u_ps'))[0] NE -1 THEN $
 ;     varid = [varid, ncdf_vardef(cdfidout, 'e3u_ps', [dimidx, dimidy], /float)]
-;   IF (where(varlist_ps EQ 'e3v_ps'))[0] NE -1 THEN $
+;   IF (where(zgr_varlist EQ 'e3v_ps'))[0] NE -1 THEN $
 ;     varid = [varid, ncdf_vardef(cdfidout, 'e3v_ps', [dimidx, dimidy], /float)]
+  IF (where(zgr_varlist EQ 'mbathy'))[0] NE -1 THEN $
+    varid = [varid, ncdf_vardef(cdfidout, 'mbathy', [dimidx, dimidy], /short)]
 ; mask variable
   msklist = ['tmask', 'umask', 'vmask', 'fmask']
@@ -185,23 +187,27 @@
   ENDIF
 ;
+  inzgrlist =  zgrlist
+  IF (where(varlist EQ 'gdept_0'))[0] NE -1 THEN inzgrlist =  inzgrlist+'_0'
   FOR z = 0, n_elements(zgrlist)-1 DO $
-    ncdf_transfer, cdfid, cdfidout, zgrlist[z]
+    ncdf_transfer, cdfid, cdfidout, inzgrlist[z], zgrlist[z]
 ; partial step variables
-  IF (where(varlist_ps EQ 'hdept'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'hdept'))[0] NE -1 THEN $
     ncdf_transfer, cdfid, cdfidout, 'hdept'
-  IF (where(varlist_ps EQ 'hdepw'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'hdepw'))[0] NE -1 THEN $
     ncdf_transfer, cdfid, cdfidout, 'hdepw'
-  IF (where(varlist_ps EQ 'e3tp'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'e3tp'))[0] NE -1 THEN $
     ncdf_transfer, cdfid, cdfidout, 'e3tp', 'e3t_ps'
-  IF (where(varlist_ps EQ 'e3wp'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'e3wp'))[0] NE -1 THEN $
     ncdf_transfer, cdfid, cdfidout, 'e3wp', 'e3w_ps'
-  IF (where(varlist_ps EQ 'e3t_ps'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'e3t_ps'))[0] NE -1 THEN $
     ncdf_transfer, cdfid, cdfidout, 'e3t_ps'
-  IF (where(varlist_ps EQ 'e3w_ps'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'e3w_ps'))[0] NE -1 THEN $
     ncdf_transfer, cdfid, cdfidout, 'e3w_ps'
-;   IF (where(varlist_ps EQ 'e3u_ps'))[0] NE -1 THEN $
+;   IF (where(zgr_varlist EQ 'e3u_ps'))[0] NE -1 THEN $
 ;     ncdf_transfer, cdfid, cdfidout, 'e3u_ps'
-;   IF (where(varlist_ps EQ 'e3v_ps'))[0] NE -1 THEN $
+;   IF (where(zgr_varlist EQ 'e3v_ps'))[0] NE -1 THEN $
 ;     ncdf_transfer, cdfid, cdfidout, 'e3v_ps'
+  IF (where(zgr_varlist EQ 'mbathy'))[0] NE -1 THEN $
+    ncdf_transfer, cdfid, cdfidout, 'mbathy'
 ;
 ; mask
Index: /trunk/SRC/Grid/ncdf_meshread.pro
===================================================================
--- /trunk/SRC/Grid/ncdf_meshread.pro	(revision 301)
+++ /trunk/SRC/Grid/ncdf_meshread.pro	(revision 302)
@@ -12,5 +12,5 @@
 ; @param filename {in}{optional}{default='meshmask.nc'}{type=scalar string}
 ;    Name of the meshmask file to read. If this name does not contain any "/"
-;    and if iodirectory keyword is not specify, then the common variable
+;    and if iodirectory keyword is not specified, then the common variable
 ;    iodir will be used to define the mesh file path.
 ;
@@ -479,4 +479,6 @@
 ; 1d arrays
 ;-------------------------------------------------------
+  IF (where(allvarname EQ 'e3t_O'))[0] NE -1 THEN fnamevar = ['e3t_O', 'e3w_O', 'gdept_O', 'gdepw_O'] $
+  ELSE                                            fnamevar = ['e3t', 'e3w', 'gdept', 'gdepw'] 
   namevar = ['e3t', 'e3w', 'gdept', 'gdepw']
   for i = 0, n_elements(namevar)-1 do begin
@@ -484,15 +486,15 @@
     CASE n_elements(varinq.dim) OF
       4:BEGIN
-        command = 'ncdf_varget,cdfid,namevar[i],'+namevar[i] $
+        command = 'ncdf_varget,cdfid,fnamevar[i],'+namevar[i] $
                    +',offset = [0,0,izminmesh,0], count = [1,1,jpk,1]'
         if key_stride[2] NE 1 then command = command+', stride=[1,1,key_stride[2],1]'
       END
       2:BEGIN
-        command = 'ncdf_varget,cdfid,namevar[i],'+namevar[i] $
+        command = 'ncdf_varget,cdfid,fnamevar[i],'+namevar[i] $
                    +',offset = [izminmesh,0], count = [jpk,1]'
         if key_stride[2] NE 1 then command = command+', stride=key_stride[2]'
       END
       1:BEGIN
-        command = 'ncdf_varget,cdfid,namevar[i],'+namevar[i] $
+        command = 'ncdf_varget,cdfid,fnamevar[i],'+namevar[i] $
                    +',offset = [izminmesh], count = [jpk]'
         if key_stride[2] NE 1 then command = command+', stride=key_stride[2]'
Index: /trunk/SRC/Grid/smallmeshmask.pro
===================================================================
--- /trunk/SRC/Grid/smallmeshmask.pro	(revision 301)
+++ /trunk/SRC/Grid/smallmeshmask.pro	(revision 302)
@@ -107,6 +107,6 @@
   ENDELSE
 ; get the variables list related to the partial steps
-  varlist_ps = ncdf_listvars(cdfid)
-  varlist_ps = strtrim(strlowcase(varlist_ps), 2)
+  zgr_varlist = ncdf_listvars(cdfid)
+  zgr_varlist = strtrim(strlowcase(zgr_varlist), 2)
 ;------------------------------------------------------
 ;------------------------------------------------------
@@ -140,23 +140,25 @@
     varid[16+z] = ncdf_vardef(cdfidout, zgrlist[z], [dimidz], /float)
 ; variables related to the partial steps
-  IF (where(varlist_ps EQ 'hdept'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'hdept'))[0] NE -1 THEN $
     varid = [varid, ncdf_vardef(cdfidout, 'hdept', [dimidx, dimidy], /float)]
-  IF (where(varlist_ps EQ 'hdepw'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'hdepw'))[0] NE -1 THEN $
     varid = [varid, ncdf_vardef(cdfidout, 'hdepw', [dimidx, dimidy], /float)]
 ; old variable name. keep for compatibility with old run. Change e3tp to e3t_ps
-  IF (where(varlist_ps EQ 'e3tp'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'e3tp'))[0] NE -1 THEN $
     varid = [varid, ncdf_vardef(cdfidout, 'e3t_ps', [dimidx, dimidy], /float)]
 ; old variable name. keep for compatibility with old run. Change e3wp to e3w_ps
-  IF (where(varlist_ps EQ 'e3wp'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'e3wp'))[0] NE -1 THEN $
     varid = [varid, ncdf_vardef(cdfidout, 'e3w_ps', [dimidx, dimidy], /float)]
 ;
-  IF (where(varlist_ps EQ 'e3t_ps'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'e3t_ps'))[0] NE -1 THEN $
     varid = [varid, ncdf_vardef(cdfidout, 'e3t_ps', [dimidx, dimidy], /float)]
-  IF (where(varlist_ps EQ 'e3w_ps'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'e3w_ps'))[0] NE -1 THEN $
     varid = [varid, ncdf_vardef(cdfidout, 'e3w_ps', [dimidx, dimidy], /float)]
-;   IF (where(varlist_ps EQ 'e3u_ps'))[0] NE -1 THEN $
+;   IF (where(zgr_varlist EQ 'e3u_ps'))[0] NE -1 THEN $
 ;     varid = [varid, ncdf_vardef(cdfidout, 'e3u_ps', [dimidx, dimidy], /float)]
-;   IF (where(varlist_ps EQ 'e3v_ps'))[0] NE -1 THEN $
+;   IF (where(zgr_varlist EQ 'e3v_ps'))[0] NE -1 THEN $
 ;     varid = [varid, ncdf_vardef(cdfidout, 'e3v_ps', [dimidx, dimidy], /float)]
+  IF (where(zgr_varlist EQ 'mbathy'))[0] NE -1 THEN $
+    varid = [varid, ncdf_vardef(cdfidout, 'mbathy', [dimidx, dimidy], /short)]
 ; mask variable
   msklist = ['tmask', 'umask', 'vmask', 'fmask']
@@ -186,23 +188,27 @@
   ENDIF
 ;
+  inzgrlist =  zgrlist
+  IF (where(zgr_varlist EQ 'gdept_0'))[0] NE -1 THEN inzgrlist =  inzgrlist+'_0'
   FOR z = 0, n_elements(zgrlist)-1 DO $
-    ncdf_transfer, cdfid, cdfidout, zgrlist[z]
+    ncdf_transfer, cdfid, cdfidout, inzgrlist[z], zgrlist[z]
 ; partial step variables
-  IF (where(varlist_ps EQ 'hdept'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'hdept'))[0] NE -1 THEN $
     ncdf_transfer, cdfid, cdfidout, 'hdept'
-  IF (where(varlist_ps EQ 'hdepw'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'hdepw'))[0] NE -1 THEN $
     ncdf_transfer, cdfid, cdfidout, 'hdepw'
-  IF (where(varlist_ps EQ 'e3tp'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'e3tp'))[0] NE -1 THEN $
     ncdf_transfer, cdfid, cdfidout, 'e3tp', 'e3t_ps'
-  IF (where(varlist_ps EQ 'e3wp'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'e3wp'))[0] NE -1 THEN $
     ncdf_transfer, cdfid, cdfidout, 'e3wp', 'e3w_ps'
-  IF (where(varlist_ps EQ 'e3t_ps'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'e3t_ps'))[0] NE -1 THEN $
     ncdf_transfer, cdfid, cdfidout, 'e3t_ps'
-  IF (where(varlist_ps EQ 'e3w_ps'))[0] NE -1 THEN $
+  IF (where(zgr_varlist EQ 'e3w_ps'))[0] NE -1 THEN $
     ncdf_transfer, cdfid, cdfidout, 'e3w_ps'
-;   IF (where(varlist_ps EQ 'e3u_ps'))[0] NE -1 THEN $
+;   IF (where(zgr_varlist EQ 'e3u_ps'))[0] NE -1 THEN $
 ;     ncdf_transfer, cdfid, cdfidout, 'e3u_ps'
-;   IF (where(varlist_ps EQ 'e3v_ps'))[0] NE -1 THEN $
+;   IF (where(zgr_varlist EQ 'e3v_ps'))[0] NE -1 THEN $
 ;     ncdf_transfer, cdfid, cdfidout, 'e3v_ps'
+  IF (where(zgr_varlist EQ 'mbathy'))[0] NE -1 THEN $
+    ncdf_transfer, cdfid, cdfidout, 'mbathy'
 ;
 ; mask
