Index: /trunk/tools/nc_var_tools.py
===================================================================
--- /trunk/tools/nc_var_tools.py	(revision 1810)
+++ /trunk/tools/nc_var_tools.py	(revision 1811)
@@ -16,4 +16,5 @@
 import generic_tools as gen
 import subprocess as sub
+import module_ForDef as fdef
 
 ####### Contents:
@@ -174,4 +175,11 @@
 infmsg = 'INFORMATION -- information -- INFORMATION -- information'
 
+# Which resolution has been defined for Fortran reals?
+if type(fdef.module_definitions.onerk) == type(np.float64):
+    isFR64 = True
+else:
+    isFR64 = False
+print 'Lluis oneRK:', type(fdef.module_definitions.onerk), 'isFR64:', isFR64
+
 ## Constants
 # Radius of the Earth (m)
@@ -18051,4 +18059,5 @@
 def pinterp(values, ncfile, variables):
     """ Function to vertically interpolate using subroutines from the p_interp.F90 NCAR program
+      Using fortran codes: module_generic.F90
       values= [interplevs],[linloginterp],[extrap]
         [interplevs]: ':' separated list of pressure values to interpolate [Pa] (decreassing in Pa)
@@ -18060,10 +18069,8 @@
       variables = ',' separated list of names of variables to interpolate ('all', fo all 4D-atmospheric variables)
         'WRFght': for WRF geopotential height
-        'WRFhus': for WRF specific humidity
         'WRFrh': for WRF relative humidity
         'WRFt': for WRF temperature
         'WRFu': for WRF x-wind de-staggered
         'WRFv': for WRF y-wind de-staggered
-        'WRFw': for WRF z-wind de-staggered
     """
     import module_ForInt as fin
@@ -18181,5 +18188,8 @@
 
         pres0 = ovar1[:] + ovar2[:]
-        pres = pres0.astype('float64')
+        if isFR64:
+            pres = pres0.astype('float64')
+        else:
+            pres = pres0.astype('float')
 
         dimx = pres.shape[3]
@@ -18193,5 +18203,8 @@
     elif modname == 'LMDZ':
         ovar1 = onc.variables['pres']
-        pres = ovar1[:].astype('float64')
+        if isFR64:
+            pres = ovar1[:].astype('float64')
+        else:
+            pres = ovar1[:].astype('float')
         dimx = pres.shape[3]
         dimy = pres.shape[2]
@@ -18203,5 +18216,8 @@
     elif modname == 'cfLMDZ':
         ovar1 = onc.variables['p']
-        pres = ovar1[:].astype('float64')
+        if isFR64:
+            pres = ovar1[:].astype('float64')
+        else:
+            pres = ovar1[:].astype('float')
         dimx = pres.shape[3]
         dimy = pres.shape[2]
@@ -18213,5 +18229,8 @@
     else:
         ovar1 = onc.variables['p']
-        pres = ovar1[:].astype('float64')
+        if isFR64:
+            pres = ovar1[:].astype('float64')
+        else:
+            pres = ovar1[:].astype('float')
         dimx = pres.shape[3]
         dimy = pres.shape[2]
@@ -18227,11 +18246,20 @@
     if modname == 'WRF':
         ovar1 = onc.variables['PSFC']
-        psfc = ovar1[:].astype('float64')
+        if isFR64:
+            psfc = ovar1[:].astype('float64')
+        else:
+            psfc = ovar1[:].astype('float')
     elif modname == 'LMDZ' or modname == 'cfLMDZ':
         ovar1 = onc.variables['psol']
-        psfc = ovar1[:].astype('float64')
+        if isFR64:
+            psfc = ovar1[:].astype('float64')
+        else:
+            psfc = ovar1[:].astype('float')
     else:
         ovar1 = onc.variables['ps']
-        psfc = ovar1[:].astype('float64')
+        if isFR64:
+            psfc = ovar1[:].astype('float64')
+        else:
+            psfc = ovar1[:].astype('float')
 
     # geopotential height
@@ -18243,34 +18271,61 @@
         unstg[1] = unstg[1] - 1
         geop = np.zeros(tuple(unstg), dtype=np.float)
-        geop = 0.5*(geop0[:,1:dimz+1,:,:] + geop0[:,0:dimz,:,:]).astype('float64')
+        if isFR64:
+            geop = 0.5*(geop0[:,1:dimz+1,:,:] + geop0[:,0:dimz,:,:]).astype('float64')
+        else:
+            geop = 0.5*(geop0[:,1:dimz+1,:,:] + geop0[:,0:dimz,:,:]).astype('float')
     elif modname == 'LMDZ' or modname == 'cfLMDZ':
         ovar1 = onc.variables['geop']
-        geop = ovar1[:].astype('float64')
+        if isFR64:
+            geop = ovar1[:].astype('float64')
+        else:
+            geop = ovar1[:].astype('float')
     else:
         ovar1 = onc.variables['z']
-        geop = ovar1[:].astype('float64')
+        if isFR64:
+            geop = ovar1[:].astype('float64')
+        else:
+            geop = ovar1[:].astype('float')
 
     # terrain height
     if modname == 'WRF':
         ovar1 = onc.variables['HGT']
-        hgt = ovar1[0,:,:].astype('float64')
+        if isFR64:
+            hgt = ovar1[0,:,:].astype('float64')
+        else:
+            hgt = ovar1[0,:,:].astype('float')
     elif modname == 'LMDZ' or modname == 'cfLMDZ':
         grav = 9.81
         ovar1 = onc.variables['phis']
-        hgt = (ovar1[0,:,:]/grav).astype('float64')
+        if isFR64:
+            hgt = (ovar1[0,:,:]/grav).astype('float64')
+        else:
+            hgt = (ovar1[0,:,:]/grav).astype('float')
     else:
         ovar1 = onc.variables['orog']
-        hgt = ovar1[:].astype('float64')
+        if isFR64:
+            hgt = ovar1[:].astype('float64')
+        else:
+            hgt = ovar1[:].astype('float')
 
     # water vapour mixing ratio
     if modname == 'WRF':
         ovar1 = onc.variables['QVAPOR']
-        qv = ovar1[:].astype('float64')
+        if isFR64:
+            qv = ovar1[:].astype('float64')
+        else:
+            qv = ovar1[:].astype('float')
     elif modname == 'LMDZ' or modname == 'cfLMDZ':
         ovar1 = onc.variables['ovap']
-        qv = ovar1[:].astype('float64')
+        if isFR64:
+            qv = ovar1[:].astype('float64')
+        else:
+            qv = ovar1[:].astype('float')
     else:
         ovar1 = onc.variables['hus']
-        qv = ovar1[:].astype('float64')
+        if isFR64:
+            qv = ovar1[:].astype('float64')
+        else:
+            qv = ovar1[:].astype('float')
 
     # temperature
@@ -18282,13 +18337,25 @@
         ovar10 = onc.variables['T']
         var10 = ovar10[:]
-        ovar1 = (var10).astype('float64')
+        if isFR64:
+            ovar1 = (var10).astype('float64')
+        else:
+            ovar1 = (var10).astype('float')
         temp0 = (ovar1[:]+300.)*(pres[:]/p0)**RCP
-        temp = temp0.astype('float64')
+        if isFR64:
+            temp = temp0.astype('float64')
+        else:
+            temp = temp0.astype('float')
     elif modname == 'LMDZ' or modname == 'cfLMDZ':
         ovar1 = onc.variables['temp']
-        temp = ovar1[:].astype('float64')
+        if isFR64:
+            temp = ovar1[:].astype('float64')
+        else:
+            temp = ovar1[:].astype('float')
     else:
         ovar1 = onc.variables['ta']
-        temp = ovar1[:].astype('float64')
+        if isFR64:
+            temp = ovar1[:].astype('float64')
+        else:
+            temp = ovar1[:].astype('float')
 
     onewnc = NetCDFFile(ofile, 'w')
@@ -18351,13 +18418,4 @@
                 isgeop = True
                 varattrs = gen.variables_values('WRFght')
-                CFvn = varattrs[0]
-                newvarattr['standard_name'] = varattrs[1]
-                newvarattr['long_name'] = varattrs[4].replace('|',' ')
-                newvarattr['units'] = varattrs[5]
-            elif vn == 'WRFhus': 
-                # relative humidity
-                varin = qv/(1.+qv)
-                isgeop = False
-                varattrs = gen.variables_values('hus')
                 CFvn = varattrs[0]
                 newvarattr['standard_name'] = varattrs[1]
@@ -18409,17 +18467,4 @@
                 newvarattr['long_name'] = varattrs[4].replace('|',' ')
                 newvarattr['units'] = varattrs[5]
-            elif vn == 'WRFw':
-                ovarin = onc.variables['W']
-                print infmsg
-                print '  ' + fname + ': De-staggering z-wind variable !!'
-                print '    from:', ovarin.shape, 'to', (dimt, dimz, dimy, dimx)
-                varin = np.zeros((dimt, dimz, dimy, dimx), dtype=np.float64)
-                varin[:] = 0.5*(ovarin[:,0:dimz,:,:] + ovarin[:,1:dimz+1,:,:])
-                isgeop = False
-                varattrs = gen.variables_values('wa')
-                CFvn = varattrs[0]
-                newvarattr['standard_name'] = varattrs[1]
-                newvarattr['long_name'] = varattrs[4].replace('|',' ')
-                newvarattr['units'] = varattrs[5]
             elif vn == 'pres':
                 varin = pres
