Index: /trunk/procs/com_eg.pro
===================================================================
--- /trunk/procs/com_eg.pro	(revision 8)
+++ /trunk/procs/com_eg.pro	(revision 9)
@@ -43,5 +43,5 @@
 ; attributs champs
 ;
-COMMON fld_att, fldatt, field, fld_prev, index_over, fldatt_bak, cmd_prev, key_shift_map, vecplot, time1_r, time2_r, cmdline2, cmdm, macro_base_fld, datyp, datyp2, fldrem_t1, fldrem_t2, fld_flag, vargrid1, vargrid2, mean_sc
+COMMON fld_att, fldatt, field, fld_prev, index_over, fldatt_bak, cmd_prev, key_shift_map, vecplot, time1_r, time2_r, cmdline2, cmdm, macro_base_fld, datyp, datyp2, fldrem_t1, fldrem_t2, fld_flag, vargrid1, vargrid2, mean_sc, var_read_grd_file
 ;
 ; stats
Index: /trunk/procs/def_grid.pro
===================================================================
--- /trunk/procs/def_grid.pro	(revision 8)
+++ /trunk/procs/def_grid.pro	(revision 9)
@@ -47,5 +47,9 @@
       print, ' Will read grid info '+cmd.grid+' from data file'
       key_shift_map = 0
-   ENDIF 
+      IF strpos(cmd.var, '@@') NE -1 THEN BEGIN 
+         @def_macro_base_fld
+         var_read_grd_file = macro_base_fld
+      ENDIF ELSE var_read_grd_file = cmd.var
+   ENDIF ELSE var_read_grd_file = cmd.var
 
    IF debug_w THEN print,    '  cmd.grid after test read_grid_from_file: ', cmd.grid
@@ -257,5 +261,13 @@
    ENDCASE  
 
-key_shift_map = key_shift
+   key_shift_map = key_shift
+
+   IF read_grid_from_file EQ 1 THEN BEGIN 
+      ; def base field if macro
+ ; needed ?     cmd.grid = strmid(cmd.grid, 0, strlen(cmd.grid)-1)
+      @def_file_suff_var
+      var_read_grd_file = macro_base_fld
+      file_suff_var = ''
+   ENDIF 
 
 final:
@@ -265,4 +277,5 @@
    IF debug_w THEN print,  '   cmd.grid in def_grid:          ', cmd.grid 
    IF debug_w THEN print,  '   file_suff_var in def_grid:     ', file_suff_var 
+   IF debug_w THEN print,  '   var_read_grd_file in def_grid: ', var_read_grd_file 
    IF debug_w THEN print,  '   meshlec_type in def_grid:      ', meshlec_type
    IF debug_w THEN print,  '  ...EXIT def_grid'
Index: /trunk/procs/meshes/mesh_from_file.pro
===================================================================
--- /trunk/procs/meshes/mesh_from_file.pro	(revision 8)
+++ /trunk/procs/meshes/mesh_from_file.pro	(revision 9)
@@ -6,4 +6,5 @@
 ; masks made in data_read
 ;
+   IF debug_w THEN print, '  ENTER mesh_from_file...'
 
    IF strpos(ncdf_db, ':') GE 1 THEN directory = (str_sep(ncdf_db, ':'))[1] $
@@ -12,5 +13,5 @@
    s_file = directory+file_name
 
-   print,' Model inits for ', model, ' from file', s_file
+   print,'   Model inits for ', model, ' from file: ', s_file
 
    sm_file = hom_idl+'grids/grids_'+model+'.nc' 
@@ -21,5 +22,5 @@
       initncdf, s_file, GLAMBOUNDARY = glamboundary_box
 
-      IF debug_w THEN print, ' Found mask from ',sm_file 
+      print, '    Found mask from ',sm_file 
 
       tmask = byte(read_ncdf('sftlf', 0, 0, /timestep, file = sm_file, /nostruct))
@@ -35,8 +36,25 @@
 
    ENDIF ELSE BEGIN 
-      initncdf, s_file, USEASMASK = var_name, GLAMBOUNDARY = glamboundary_box, ZAXISNAME = 'depth'
+      CASE var_name OF
+         '@@voenergy': var_local = 'so'
+         ELSE: var_local = var_read_grd_file
+      ENDCASE 
+
+      ; find valmask
+      cdfidl=ncdf_open(s_file) 
+      contient=ncdf_inquire(cdfidl)
+      varidl = ncdf_varid(cdfidl, var_local)
+      varcontient=ncdf_varinq(cdfidl, var_local)
+      valmask = 1.e20
+      FOR i = 0, varcontient.natts-1 DO BEGIN
+         att_txt = ncdf_attname(cdfidl, varidl, i)
+         IF att_txt EQ 'missing_value' OR att_txt EQ 'mask value' OR att_txt EQ '_FillValue' THEN ncdf_attget, cdfidl, varidl, att_txt, valmask
+         IF debug_w THEN print, 'valmask found = ',valmask 
+      ENDFOR 
+      ncdf_close, cdfidl
+      ; read grid
+      initncdf, s_file, USEASMASK = var_local, missing_value = valmask, GLAMBOUNDARY = glamboundary_box, ZAXISNAME = 'depth'
+
    ENDELSE 
-
-   IF debug_w THEN print, 'vargrid = ',vargrid 
 
    key_offset = [0, 0, 0]
@@ -45,4 +63,5 @@
 ;
    diaznl_idx = 1
+   IF debug_w THEN print, '  ...EXIT mesh_from_file'
 
   return
