Index: source/python/classes/EcFlexpart.py
===================================================================
--- source/python/classes/EcFlexpart.py	(revision 70fee58eedd41328d9f5cdc56db77e03ec78bf71)
+++ source/python/classes/EcFlexpart.py	(revision 0934db124759dfed734b5a6149909d5e526c9bb7)
@@ -82,8 +82,12 @@
 import numpy as np
 
-from eccodes import (codes_index_select, codes_new_from_index, codes_get,
-                     codes_get_values, codes_set_values, codes_set,
-                     codes_write, codes_release, codes_new_from_index,
-                     codes_index_release, codes_index_get)
+from gribapi import (grib_set, grib_index_select, grib_new_from_index, grib_get,
+                     grib_write, grib_get_values, grib_set_values, grib_release,
+                     grib_index_release, grib_index_get)
+
+# from eccodes import (codes_index_select, codes_new_from_index, codes_get,
+                     # codes_get_values, codes_set_values, codes_set,
+                     # codes_write, codes_release, codes_new_from_index,
+                     # codes_index_release, codes_index_get)
 
 # software specific classes and modules from flex_extract
@@ -433,5 +437,5 @@
             #index_vals.append(grib_index_get(iid, key))
             #print(index_vals[-1])
-            key_vals = codes_index_get(iid, key)
+            key_vals = grib_index_get(iid, key)
             print(key_vals)
             # have to sort the steps for disaggregation,
@@ -791,8 +795,8 @@
 
             for i in range(len(index_keys)):
-                codes_index_select(iid, index_keys[i], prod[i])
+                grib_index_select(iid, index_keys[i], prod[i])
 
             # get first id from current product
-            gid = codes_new_from_index(iid)
+            gid = grib_new_from_index(iid)
 
             # if there is no data for this specific time combination / product
@@ -802,7 +806,7 @@
 
             # create correct timestamp from the three time informations
-            cdate = str(codes_get(gid, 'date'))
-            ctime = '{:0>2}'.format(codes_get(gid, 'time')/100)
-            cstep = '{:0>3}'.format(codes_get(gid, 'step'))
+            cdate = str(grib_get(gid, 'date'))
+            ctime = '{:0>2}'.format(grib_get(gid, 'time')/100)
+            cstep = '{:0>3}'.format(grib_get(gid, 'step'))
             t_date = datetime.strptime(cdate + ctime, '%Y%m%d%H')
             t_dt = t_date + timedelta(hours=int(cstep))
@@ -836,11 +840,11 @@
                 if not gid:
                     break
-                cparamId = str(codes_get(gid, 'paramId'))
-                step = codes_get(gid, 'step')
-                time = codes_get(gid, 'time')
-                ni = codes_get(gid, 'Ni')
-                nj = codes_get(gid, 'Nj')
+                cparamId = str(grib_get(gid, 'paramId'))
+                step = grib_get(gid, 'step')
+                time = grib_get(gid, 'time')
+                ni = grib_get(gid, 'Ni')
+                nj = grib_get(gid, 'Nj')
                 if cparamId in valsdict.keys():
-                    values = codes_get_values(gid)
+                    values = grib_get_values(gid)
                     vdp = valsdict[cparamId]
                     svdp = svalsdict[cparamId]
@@ -881,15 +885,15 @@
                                 values = svdp[0]
 
-                        codes_set_values(gid, values)
+                        grib_set_values(gid, values)
 
                         if c.maxstep > 12:
-                            codes_set(gid, 'step', max(0, step-2*int(c.dtime)))
+                            grib_set(gid, 'step', max(0, step-2*int(c.dtime)))
                         else:
-                            codes_set(gid, 'step', 0)
-                            codes_set(gid, 'time', t_m2dt.hour*100)
-                            codes_set(gid, 'date', int(t_m2dt.strftime('%Y%m%d')))
+                            grib_set(gid, 'step', 0)
+                            grib_set(gid, 'time', t_m2dt.hour*100)
+                            grib_set(gid, 'date', int(t_m2dt.strftime('%Y%m%d')))
 
                         with open(fnout, 'w') as f_handle:
-                            codes_write(gid, f_handle)
+                            grib_write(gid, f_handle)
 
                         if c.basetime:
@@ -911,14 +915,14 @@
 
                             values = svdp[3]
-                            codes_set_values(gid, values)
-                            codes_set(gid, 'step', 0)
+                            grib_set_values(gid, values)
+                            grib_set(gid, 'step', 0)
                             truedatetime = t_m2dt + timedelta(hours=
                                                               2*int(c.dtime))
-                            codes_set(gid, 'time', truedatetime.hour * 100)
-                            codes_set(gid, 'date', truedatetime.year * 10000 +
+                            grib_set(gid, 'time', truedatetime.hour * 100)
+                            grib_set(gid, 'date', truedatetime.year * 10000 +
                                       truedatetime.month * 100 +
                                       truedatetime.day)
                             with open(hnout, 'w') as h_handle:
-                                codes_write(gid, h_handle)
+                                grib_write(gid, h_handle)
 
                             #values = (svdp[1]+svdp[2])/2.
@@ -928,19 +932,19 @@
                                 values = disaggregation.dapoly(list(reversed(svdp)))
 
-                            codes_set(gid, 'step', 0)
+                            grib_set(gid, 'step', 0)
                             truedatetime = t_m2dt + timedelta(hours=int(c.dtime))
-                            codes_set(gid, 'time', truedatetime.hour * 100)
-                            codes_set(gid, 'date', truedatetime.year * 10000 +
+                            grib_set(gid, 'time', truedatetime.hour * 100)
+                            grib_set(gid, 'date', truedatetime.year * 10000 +
                                      truedatetime.month * 100 +
                                      truedatetime.day)
-                            codes_set_values(gid, values)
+                            grib_set_values(gid, values)
                             with open(gnout, 'w') as g_handle:
-                                codes_write(gid, g_handle)
-
-                codes_release(gid)
-
-                gid = codes_new_from_index(iid)
-
-        codes_index_release(iid)
+                                grib_write(gid, g_handle)
+
+                grib_release(gid)
+
+                gid = grib_new_from_index(iid)
+
+        grib_index_release(iid)
 
         return
@@ -1016,8 +1020,8 @@
 
             for i in range(len(index_keys)):
-                codes_index_select(iid, index_keys[i], prod[i])
+                grib_index_select(iid, index_keys[i], prod[i])
 
             # get first id from current product
-            gid = codes_new_from_index(iid)
+            gid = grib_new_from_index(iid)
 
             # if there is no data for this specific time combination / product
@@ -1034,7 +1038,7 @@
 
             # create correct timestamp from the three time informations
-            cdate = str(codes_get(gid, 'date'))
-            ctime = '{:0>2}'.format(codes_get(gid, 'time')/100)
-            cstep = '{:0>3}'.format(codes_get(gid, 'step'))
+            cdate = str(grib_get(gid, 'date'))
+            ctime = '{:0>2}'.format(grib_get(gid, 'time')/100)
+            cstep = '{:0>3}'.format(grib_get(gid, 'step'))
             timestamp = datetime.strptime(cdate + ctime, '%Y%m%d%H')
             timestamp += timedelta(hours=int(cstep))
@@ -1064,32 +1068,32 @@
                 if not gid:
                     break
-                paramId = codes_get(gid, 'paramId')
-                gridtype = codes_get(gid, 'gridType')
-                levtype = codes_get(gid, 'typeOfLevel')
+                paramId = grib_get(gid, 'paramId')
+                gridtype = grib_get(gid, 'gridType')
+                levtype = grib_get(gid, 'typeOfLevel')
                 if paramId == 77: # ETADOT
-                    codes_write(gid, fdict['21'])
+                    grib_write(gid, fdict['21'])
                 elif paramId == 130: # T
-                    codes_write(gid, fdict['11'])
+                    grib_write(gid, fdict['11'])
                 elif paramId == 131 or paramId == 132: # U, V wind component
-                    codes_write(gid, fdict['10'])
+                    grib_write(gid, fdict['10'])
                 elif paramId == 133 and gridtype != 'reduced_gg': # Q
-                    codes_write(gid, fdict['17'])
+                    grib_write(gid, fdict['17'])
                 elif paramId == 133 and gridtype == 'reduced_gg': # Q, gaussian
-                    codes_write(gid, fdict['18'])
+                    grib_write(gid, fdict['18'])
                 elif paramId == 135: # W
-                    codes_write(gid, fdict['19'])
+                    grib_write(gid, fdict['19'])
                 elif paramId == 152: # LNSP
-                    codes_write(gid, fdict['12'])
+                    grib_write(gid, fdict['12'])
                 elif paramId == 155 and gridtype == 'sh': # D
-                    codes_write(gid, fdict['13'])
+                    grib_write(gid, fdict['13'])
                 elif paramId == 246 or paramId == 247: # CLWC, CIWC
                     # sum cloud liquid water and ice
-                    if not scwc:
-                        scwc = codes_get_values(gid)
+                    if scwc is None:
+                        scwc = grib_get_values(gid)
                     else:
-                        scwc += codes_get_values(gid)
-                        codes_set_values(gid, scwc)
-                        codes_set(gid, 'paramId', 201031)
-                        codes_write(gid, fdict['22'])
+                        scwc += grib_get_values(gid)
+                        grib_set_values(gid, scwc)
+                        grib_set(gid, 'paramId', 201031)
+                        grib_write(gid, fdict['22'])
                 elif c.wrf and paramId in [129, 138, 155] and \
                       levtype == 'hybrid': # Z, VO, D
@@ -1101,5 +1105,5 @@
                         # SD/MSL/TCC/10U/10V/2T/2D/Z/LSM/SDOR/CVL/CVH/SR
                         # and all ADDPAR parameter
-                        codes_write(gid, fdict['16'])
+                        grib_write(gid, fdict['16'])
                         savedfields.append(paramId)
                     else:
@@ -1111,13 +1115,13 @@
                         if levtype == 'hybrid' and \
                            paramId in [129, 130, 131, 132, 133, 138, 155]:
-                            codes_write(gid, fwrf)
+                            grib_write(gid, fwrf)
                         # sfc layer
                         elif paramId in wrfpars:
-                            codes_write(gid, fwrf)
+                            grib_write(gid, fwrf)
                 except AttributeError:
                     pass
 
-                codes_release(gid)
-                gid = codes_new_from_index(iid)
+                grib_release(gid)
+                gid = grib_new_from_index(iid)
 
             for f in fdict.values():
@@ -1173,5 +1177,5 @@
             fwrf.close()
 
-        codes_index_release(iid)
+        grib_index_release(iid)
 
         return
