Index: trunk/tools/iniaqua.py
===================================================================
--- trunk/tools/iniaqua.py	(revision 223)
+++ trunk/tools/iniaqua.py	(revision 224)
@@ -19,5 +19,5 @@
 filekinds = ['CF', 'LMDZ', 'WRF']
 
-## g.e. # iniaqua.py -d 32,32,39 -p hybdrid -o WRF -t 19791201000000 -z tropo -q 2
+## e.g. # iniaqua.py -d 32,32,39 -p hybdrid -o WRF -t 19791201000000 -z tropo -q 2
 def fxy(dx, dy): 
     """! 
@@ -2555,4 +2555,5 @@
       extrattrns= list for the specific values for the variables' extra attributes
     """
+    fname = 'generic_NetCDFile'
 
 # Creation of dimensions
@@ -2570,49 +2571,56 @@
     for varn in kvarns.keys():
         varvals = kvarns[varn]
-        dimsvar = []
-        for dimn in varvals[1]:
-            dimsvar.append(kdimns[dimn])
-
-        if varvals[5] is not None:
-            nerwvar = ncobj.createVariable(varvals[0], 'f4', tuple(dimsvar),         \
-              fill_value=np.float(varvals[5]))
-        else:
-            newvar = ncobj.createVariable(varvals[0], 'f4', tuple(dimsvar))
+        if varvals[0] is not None:
+            dimsvar = []
+            for dimn in varvals[1]:
+                if dimn == 'DateStrLen':
+                    dimsvar.append(dimn)
+                else:
+                    dimsvar.append(kdimns[dimn])
+
+            if varvals[5] is not None:
+                nerwvar = ncobj.createVariable(varvals[0], 'f4', tuple(dimsvar),     \
+                  fill_value=np.float(varvals[5]))
+            else:
+                newvar = ncobj.createVariable(varvals[0], 'f4', tuple(dimsvar))
 
 # Attributes
-        for iattr in range(len(stdattrns)):
-            attrn = stdattrns[iattr]
-            if kattrns[attrn] is not None:
-                newvar.setncattr(kattrns[attrn], varvals[2+iattr])
+            attrns = stdattrns.keys()
+            for iattr in range(len(attrns)):
+                attrn = attrns[iattr]
+                if stdattrns[attrn] is not None and varvals[4+iattr] is not None:
+                    newvar.setncattr(stdattrns[attrn], varvals[4+iattr])
 
 # Extra attributes
-        for iattr in range(len(extrattrns)):
-            attrn = extrrattrns[iattr]
-            if kfile == 'LMDZ':
-                if attrn == 'coordinates':
-                    attrv = ''
-                    for din in varvals[1]:
-                        attrv = attrv + kdimns[din] + ' '
-            elif kfile == 'WRF':
-                if attrn == 'FieldType':
-                    attrv = '104'
-                elif attrn == 'MemoryOrder':
-                    attrv = ''
-                    Ndims = len(varvals[1])
-                    for idim in range(Ndims,0,-1):
-                        if varvals[1][idim] != 'T':
-                            attrv = attrv + varvals[1][idim].uppercase
-                elif attrn == 'stagger':
-                    staggeredvars = {}
-                    staggeredvars['U'] = 'X'
-                    staggeredvars['V'] = 'Y'
-                    staggeredvars['PH'] = 'Z'
-
-                    if ncvar.searchInlist(staggeredvars.keys(),varvals[0]):
-                        attrv = staggeredvars[vavals[0]]
-
-            newvar.setncattr(extrattrns[iattr], attrv)
-
-        newvar.sync()
+            for iattr in range(len(extrattrns)):
+                attrn = extrattrns[iattr]
+                if kfile == 'LMDZ':
+                    if attrn == 'coordinates':
+                        attrv = ''
+                        for din in varvals[1]:
+                            attrv = attrv + kdimns[din] + ' '
+                elif kfile == 'WRF':
+                    if attrn == 'FieldType':
+                        attrv = '104'
+                    elif attrn == 'MemoryOrder':
+                        attrv = ''
+                        Ndims = len(varvals[1])
+                        for idim in range(Ndims-1,0,-1):
+                            if varvals[1][idim] != 't':
+                                attrv = attrv + varvals[1][idim].upper()
+                    elif attrn == 'stagger':
+                        staggeredvars = {}
+                        staggeredvars['U'] = 'X'
+                        staggeredvars['V'] = 'Y'
+                        staggeredvars['PH'] = 'Z'
+    
+                        if ncvar.searchInlist(staggeredvars.keys(),varvals[0]):
+                            attrv = staggeredvars[varvals[0]]
+                        else:
+                            attrv = ''
+    
+                newvar.setncattr(extrattrns[iattr], attrv)
+    
+            ncobj.sync()
 
     return
@@ -2749,6 +2757,8 @@
 # Vertical profile
 tetajl =  np.zeros((dimz, dimy+1, dimx), dtype=np.float)
-theta = np.zeros((dimy+1, dimx+1), dtype=np.float)
-thetarappel = np.zeros((dimz, dimy+1, dimx+1), dtype=np.float)
+#theta = np.zeros((dimy+1, dimx+1), dtype=np.float)
+#thetarappel = np.zeros((dimz, dimy+1, dimx+1), dtype=np.float)
+theta = np.zeros((dimy, dimx), dtype=np.float)
+thetarappel = np.zeros((dimz, dimy, dimx), dtype=np.float)
 
 for l in range (dimz):
@@ -2824,5 +2834,4 @@
 
 # bulk initialization of tracers
-print 'Lluis nqtot:',nqtot
 q = np.zeros((dimz, dimy, dimx, nqtot), dtype=np.float)
 
@@ -2858,21 +2867,22 @@
 for varn in ncf.variables.keys():
     varobj = ncf.variables[varn]
-    if varn == 'lon': varobj[:] = lon
-    elif varn == 'lat': varobj[:] = lat
-    elif varn == 'lev': varobj[:] = presnivs
-    elif varn == 'time': varobj[:] = timev
-    elif varn == 'temp': varobj[0,:,:,:] = theta[:]
-    elif varn == 'tsfc': varobj[:] = theta[0,:,:]
-    elif varn == 'u10m': varobj[:] = ucov[0,:,:]
-    elif varn == 'v10m': varobj[:] = vcov[0,:,:]
-    elif varn == 'u': varobj[0,:,:,:] = ucov[:]
-    elif varn == 'v': varobj[0,:,:,:] = vcov[:]
-    elif varn == 'zsfc': varobj[0,:,:] = phisfc[:]
-    elif varn == 'geopot': varobj[0,:,:] = phisall[:]
-    elif varn == 'psfc': varobj[0,:,:] = press[:]
-    elif varn == 'pres': varobj[0,:,:,:] = pres[:]
-    elif varn == 'H2Ov': varobj[0,:,:,:] = q[:,:,:0]
-    elif varn == 'H2Ol': varobj[0,:,:,:] = q[:,:,:1]
-
+    if varn == filevarns['lon'][0]: varobj[:] = lon
+    elif varn == filevarns['lat'][0]: varobj[:] = lat
+    elif varn == filevarns['lev'][0]: varobj[:] = presnivs
+    elif varn == filevarns['time'][0]: varobj[:] = timev
+    elif varn == filevarns['temp'][0]: 
+        print 'Lluis shapes varobj:',varobj.shape,'theta:',theta.shape
+        varobj[0,:,:,:] = theta[:]
+    elif varn == filevarns['tsfc'][0]: varobj[:] = theta[0,:,:]
+    elif varn == filevarns['u10m'][0]: varobj[:] = ucov[0,:,:]
+    elif varn == filevarns['v10m'][0]: varobj[:] = vcov[0,:,:]
+    elif varn == filevarns['u'][0]: varobj[0,:,:,:] = ucov[:]
+    elif varn == filevarns['v'][0]: varobj[0,:,:,:] = vcov[:]
+    elif varn == filevarns['zsfc'][0]: varobj[0,:,:] = phisfc[:]
+    elif varn == filevarns['geopot'][0]: varobj[0,:,:] = phisall[:]
+    elif varn == filevarns['psfc'][0]: varobj[0,:,:] = press[:]
+    elif varn == filevarns['pres'][0]: varobj[0,:,:,:] = pres[:]
+    elif varn == filevarns['H2Ov'][0]: varobj[0,:,:,:] = q[:,:,:0]
+    elif varn == filevarns['H2Ol'][0]: varobj[0,:,:,:] = q[:,:,:1]
 
 ncf.sync()
