Index: trunk/SRC/Grid/ncdf_meshread.pro
===================================================================
--- trunk/SRC/Grid/ncdf_meshread.pro	(revision 358)
+++ trunk/SRC/Grid/ncdf_meshread.pro	(revision 359)
@@ -403,75 +403,83 @@
   ENDELSE
 ; boundary conditions used to compute umask.
-  varinq = ncdf_varinq(cdfid, 'umask')
-  name = varinq.name
-  nx = 1L
-  firstx = jpi-1
-  lastx = jpi-1
-  IF micromask NE -1 THEN BEGIN
-@read_ncdf_varget
-    umaskred = reform(binary(res), 8*ny, jpk, /over)
-    umaskred = umaskred[yyy1 MOD 8: 8*ny - 8 + yyy2 MOD 8, *]
-    IF key_stridetrue[1] NE 1 THEN umaskred = temporary(umaskred[yind, *])
-  ENDIF ELSE BEGIN
-@read_ncdf_varget
-    umaskred = reform(byte(res), /over)
-  ENDELSE
+  IF ncdf_varid(cdfid, 'umask') NE -1 THEN BEGIN 
+     varinq = ncdf_varinq(cdfid, 'umask')
+     name = varinq.name
+     nx = 1L
+     firstx = jpi-1
+     lastx = jpi-1
+     IF micromask NE -1 THEN BEGIN
+@read_ncdf_varget
+        umaskred = reform(binary(res), 8*ny, jpk, /over)
+        umaskred = umaskred[yyy1 MOD 8: 8*ny - 8 + yyy2 MOD 8, *]
+        IF key_stridetrue[1] NE 1 THEN umaskred = temporary(umaskred[yind, *])
+     ENDIF ELSE BEGIN
+@read_ncdf_varget
+        umaskred = reform(byte(res), /over)
+     ENDELSE
+  ENDIF ELSE umaskred = bytarr(jpj, jpk)
 ; boundary conditions used to compute fmask (1).
-  varinq = ncdf_varinq(cdfid, 'fmask')
-  name = varinq.name
-  IF micromask NE -1 THEN BEGIN
-@read_ncdf_varget
-    fmaskredy = reform(binary(res), 8*ny, jpk, /over)
-    fmaskredy = fmaskredy[yyy1 MOD 8: 8*ny - 8 + yyy2 MOD 8, *]
-    IF key_stridetrue[1] NE 1 THEN fmaskredy = temporary(fmaskredy[yind, *])
-  ENDIF ELSE BEGIN
-@read_ncdf_varget
-    fmaskredy = reform(byte(res), /over)
-    fmaskredy = temporary(fmaskredy) MOD 2
-  ENDELSE
+  IF ncdf_varid(cdfid, 'fmask') NE -1 THEN BEGIN 
+     varinq = ncdf_varinq(cdfid, 'fmask')
+     name = varinq.name
+     IF micromask NE -1 THEN BEGIN
+@read_ncdf_varget
+        fmaskredy = reform(binary(res), 8*ny, jpk, /over)
+        fmaskredy = fmaskredy[yyy1 MOD 8: 8*ny - 8 + yyy2 MOD 8, *]
+        IF key_stridetrue[1] NE 1 THEN fmaskredy = temporary(fmaskredy[yind, *])
+     ENDIF ELSE BEGIN
+@read_ncdf_varget
+        fmaskredy = reform(byte(res), /over)
+        fmaskredy = temporary(fmaskredy) MOD 2
+     ENDELSE
+  ENDIF ELSE fmaskredy = bytarr(jpj, jpk)
 ; boundary conditions used to compute vmask
-  varinq = ncdf_varinq(cdfid, 'vmask')
-  name = varinq.name
-  nx = jpi
-  firstx = 0L
-  lastx = jpi-1L
-  ny = 1L
-  firsty = jpj-1
-  lasty = jpj-1
-  IF micromask NE -1 THEN BEGIN
-    yyy1 = firsty*key_stridetrue[1]+iyminmeshtrue
-    yyy2 = lasty*key_stridetrue[1]+iyminmeshtrue
-    iyminmesh = 0L
-    firsty = yyy1/8
-    lasty = yyy2/8
-    ny = lasty-firsty+1
-@read_ncdf_varget
-    IF jpk EQ 1 THEN res = reform(res, jpi, 1, jpk, /over)
-    vmaskred = transpose(temporary(res), [1, 0, 2])
-    vmaskred = reform(binary(vmaskred), 8*ny, nx, nz, /over)
-    vmaskred = transpose(temporary(vmaskred), [1, 0, 2])
-    vmaskred = reform(vmaskred[*, yyy1 MOD 8: 8*ny - 8 + yyy2 MOD 8, *])
-  ENDIF ELSE BEGIN
-@read_ncdf_varget
-    vmaskred = reform(byte(res), /over)
-  ENDELSE
+  IF ncdf_varid(cdfid, 'vmask') NE -1 THEN BEGIN 
+     varinq = ncdf_varinq(cdfid, 'vmask')
+     name = varinq.name
+     nx = jpi
+     firstx = 0L
+     lastx = jpi-1L
+     ny = 1L
+     firsty = jpj-1
+     lasty = jpj-1
+     IF micromask NE -1 THEN BEGIN
+        yyy1 = firsty*key_stridetrue[1]+iyminmeshtrue
+        yyy2 = lasty*key_stridetrue[1]+iyminmeshtrue
+        iyminmesh = 0L
+        firsty = yyy1/8
+        lasty = yyy2/8
+        ny = lasty-firsty+1
+@read_ncdf_varget
+        IF jpk EQ 1 THEN res = reform(res, jpi, 1, jpk, /over)
+        vmaskred = transpose(temporary(res), [1, 0, 2])
+        vmaskred = reform(binary(vmaskred), 8*ny, nx, nz, /over)
+        vmaskred = transpose(temporary(vmaskred), [1, 0, 2])
+        vmaskred = reform(vmaskred[*, yyy1 MOD 8: 8*ny - 8 + yyy2 MOD 8, *])
+     ENDIF ELSE BEGIN
+@read_ncdf_varget
+        vmaskred = reform(byte(res), /over)
+     ENDELSE
+  ENDIF ELSE vmaskred = bytarr(jpi, jpk)
 ; boundary conditions used to compute fmask (2).
-  varinq = ncdf_varinq(cdfid, 'fmask')
-  name = varinq.name
-  IF micromask NE -1 THEN BEGIN
-@read_ncdf_varget
-    IF jpk EQ 1 THEN res = reform(res, jpi, 1, jpk, /over)
-    fmaskredx = transpose(temporary(res), [1, 0, 2])
-    fmaskredx = reform(binary(fmaskredx), 8*ny, nx, nz, /over)
-    fmaskredx = transpose(temporary(fmaskredx), [1, 0, 2])
-    fmaskredx = reform(fmaskredx[*, yyy1 MOD 8: 8*ny - 8 + yyy2 MOD 8, *])
-;
-    iyminmesh = iyminmeshtrue
-    key_stride = key_stridetrue
-  ENDIF ELSE BEGIN
-@read_ncdf_varget
-    fmaskredx = reform(byte(res), /over)
-    fmaskredx = fmaskredx MOD 2
-  ENDELSE
+  IF ncdf_varid(cdfid, 'fmask') NE -1 THEN BEGIN 
+     varinq = ncdf_varinq(cdfid, 'fmask')
+     name = varinq.name
+     IF micromask NE -1 THEN BEGIN
+@read_ncdf_varget
+        IF jpk EQ 1 THEN res = reform(res, jpi, 1, jpk, /over)
+        fmaskredx = transpose(temporary(res), [1, 0, 2])
+        fmaskredx = reform(binary(fmaskredx), 8*ny, nx, nz, /over)
+        fmaskredx = transpose(temporary(fmaskredx), [1, 0, 2])
+        fmaskredx = reform(fmaskredx[*, yyy1 MOD 8: 8*ny - 8 + yyy2 MOD 8, *])
+;
+        iyminmesh = iyminmeshtrue
+        key_stride = key_stridetrue
+     ENDIF ELSE BEGIN
+@read_ncdf_varget
+        fmaskredx = reform(byte(res), /over)
+        fmaskredx = fmaskredx MOD 2
+     ENDELSE
+  ENDIF ELSE fmaskredx = bytarr(jpi, jpk)
 ;-------------------------------------------------------
 ; 1d arrays
