Index: source/python/classes/ControlFile.py
===================================================================
--- source/python/classes/ControlFile.py	(revision 97f4f4c5a73cb9dc0b6c44b3e3a1134051a3b74e)
+++ source/python/classes/ControlFile.py	(revision 3f36e423871039ab295f5ea95c56af49ef5067ce)
@@ -61,5 +61,5 @@
 import _config
 from mods.tools import my_error, silent_remove
-from mods.checks import check_grid_area
+from mods.checks import check_grid, check_area, check_levels
 
 # ------------------------------------------------------------------------------
@@ -345,25 +345,27 @@
                 sys.exit(1)
 
-        # assure consistency of levelist and level
-        if not self.levelist and not self.level:
-            print('Warning: neither levelist nor level \
-                               specified in CONTROL file')
-            sys.exit(1)
-        elif not self.levelist and self.level:
-            self.levelist = '1/to/' + self.level
-        elif (self.levelist and not self.level) or \
-             (self.levelist[-1] != self.level[-1]):
-            self.level = self.levelist.split('/')[-1]
-        else:
-            pass
-
-        # check if max level is a valid level
-        if int(self.level) not in _config.MAX_LEVEL_LIST:
-            print('ERROR: ')
-            print('LEVEL must be the maximum level of a specified '
-                  'level list from ECMWF, e.g.')
-            print(_config.MAX_LEVEL_LIST)
-            print('Check parameter "LEVEL" or the max level of "LEVELIST"!')
-            sys.exit(1)
+        self.levelist, self.level = check_levels(self.levelist, self.level)
+
+        # # assure consistency of levelist and level
+        # if not self.levelist and not self.level:
+            # print('Warning: neither levelist nor level \
+                               # specified in CONTROL file')
+            # sys.exit(1)
+        # elif not self.levelist and self.level:
+            # self.levelist = '1/to/' + self.level
+        # elif (self.levelist and not self.level) or \
+             # (self.levelist[-1] != self.level[-1]):
+            # self.level = self.levelist.split('/')[-1]
+        # else:
+            # pass
+
+        # # check if max level is a valid level
+        # if int(self.level) not in _config.MAX_LEVEL_LIST:
+            # print('ERROR: ')
+            # print('LEVEL must be the maximum level of a specified '
+                  # 'level list from ECMWF, e.g.')
+            # print(_config.MAX_LEVEL_LIST)
+            # print('Check parameter "LEVEL" or the max level of "LEVELIST"!')
+            # sys.exit(1)
 
         # prepare step list if "/" signs are found
@@ -477,36 +479,9 @@
 
 
-        self.grid, self.area = check_grid_area(self.grid, self.area,
-                                               self.upper, self.lower,
-                                               self.left, self.right)
-
-
-
-        # convert grid and area components to correct format and input
-        #if 'N' in self.grid:  # Gaussian output grid
-        #    self.area = 'G'
-        # else:
-            # if '/' in self.grid:
-                # gridx, gridy = self.grid.split('/')
-                # if gridx == gridy:
-                    # self.grid = gridx
-
-
-            # # check on grid format
-            # if float(self.grid) / 100. >= 0.5:
-                # # grid is defined in 1/1000 degrees; old format
-                # self.grid = '{}/{}'.format(float(self.grid) / 1000.,
-                                           # float(self.grid) / 1000.)
-                # self.area = '{}/{}/{}/{}'.format(float(self.upper) / 1000.,
-                                                 # float(self.left) / 1000.,
-                                                 # float(self.lower) / 1000.,
-                                                 # float(self.right) / 1000.)
-            # elif float(self.grid) / 100. < 0.5:
-                # # grid is defined in normal degree; new format
-                # self.grid = '{}/{}'.format(float(self.grid), float(self.grid))
-                # self.area = '{}/{}/{}/{}'.format(float(self.upper),
-                                                 # float(self.left),
-                                                 # float(self.lower),
-                                                 # float(self.right))
+        self.grid = check_grid(self.grid)
+
+        self.area = check_area(self.grid, self.area, self.upper, self.lower,
+                               self.left, self.right)
+
 
         return
@@ -555,22 +530,2 @@
         return sorted(l)
 
-    def check_ppid(self, ppid):
-        '''Sets the current PPID.
-
-        Parameters
-        ----------
-        ppid : :obj:`int` or :obj:`None`
-            Contains the ppid number provided by the command line parameter
-            of is None otherwise.
-
-        Return
-        ------
-
-        '''
-
-        if not ppid:
-            self.ppid = str(os.getppid())
-        else:
-            self.ppid = ppid
-
-        return
Index: source/python/classes/EcFlexpart.py
===================================================================
--- source/python/classes/EcFlexpart.py	(revision 2d56c04d12d1df747e1122329edf58c18fc28eb5)
+++ source/python/classes/EcFlexpart.py	(revision 3f36e423871039ab295f5ea95c56af49ef5067ce)
@@ -147,10 +147,4 @@
         i = 0
         if fluxes and c.maxstep <= 24:
-            # no forecast beyond one day is needed!
-            # Thus, prepare flux data manually as usual
-            # with only forecast fields with start times at 00/12
-            # (but without 00/12 fields since these are
-            # the initialisation times of the flux fields
-            # and therefore are zero all the time)
             self.types[str(c.acctype)] = {'times': str(c.acctime),
                                           'steps': '{}/to/{}/by/{}'.format(
@@ -523,6 +517,4 @@
                 retr_param_dict['gaussian'] = self.gaussian
 
-                if pk == 'OG__SL':
-                    pass
                 if pk == 'OG_OROLSM__SL' and not oro:
                     oro = True
@@ -658,42 +650,62 @@
         from genshi.template.text import NewTextTemplate
         from genshi.template import  TemplateLoader
-
-        loader = TemplateLoader(_config.PATH_TEMPLATES, auto_reload=False)
-        namelist_template = loader.load(_config.TEMPFILE_NAMELIST,
-                                       cls=NewTextTemplate)
-
-        self.inputdir = c.inputdir
-        area = np.asarray(self.area.split('/')).astype(float)
-        grid = np.asarray(self.grid.split('/')).astype(float)
-
-        if area[1] > area[3]:
-            area[1] -= 360
-        maxl = int((area[3] - area[1]) / grid[1]) + 1
-        maxb = int((area[0] - area[2]) / grid[0]) + 1
-
-        stream = namelist_template.generate(
-            maxl = str(maxl),
-            maxb = str(maxb),
-            mlevel = str(self.level),
-            mlevelist = str(self.levelist),
-            mnauf = str(self.resol),
-            metapar = '77',
-            rlo0 = str(area[1]),
-            rlo1 = str(area[3]),
-            rla0 = str(area[2]),
-            rla1 = str(area[0]),
-            momega = str(c.omega),
-            momegadiff = str(c.omegadiff),
-            mgauss = str(c.gauss),
-            msmooth = str(c.smooth),
-            meta = str(c.eta),
-            metadiff = str(c.etadiff),
-            mdpdeta = str(c.dpdeta)
-        )
-
-        namelistfile = os.path.join(self.inputdir, _config.FILE_NAMELIST)
-
-        with open(namelistfile, 'w') as f:
-            f.write(stream.render('text'))
+        from genshi.template.eval import  UndefinedError
+
+        try:
+            loader = TemplateLoader(_config.PATH_TEMPLATES, auto_reload=False)
+            namelist_template = loader.load(_config.TEMPFILE_NAMELIST,
+                                            cls=NewTextTemplate)
+
+            self.inputdir = c.inputdir
+            area = np.asarray(self.area.split('/')).astype(float)
+            grid = np.asarray(self.grid.split('/')).astype(float)
+
+            if area[1] > area[3]:
+                area[1] -= 360
+            maxl = int((area[3] - area[1]) / grid[1]) + 1
+            maxb = int((area[0] - area[2]) / grid[0]) + 1
+
+            stream = namelist_template.generate(
+                maxl = str(maxl),
+                maxb = str(maxb),
+                mlevel = str(self.level),
+                mlevelist = str(self.levelist),
+                mnauf = str(self.resol),
+                metapar = '77',
+                rlo0 = str(area[1]),
+                rlo1 = str(area[3]),
+                rla0 = str(area[2]),
+                rla1 = str(area[0]),
+                momega = str(c.omega),
+                momegadiff = str(c.omegadiff),
+                mgauss = str(c.gauss),
+                msmooth = str(c.smooth),
+                meta = str(c.eta),
+                metadiff = str(c.etadiff),
+                mdpdeta = str(c.dpdeta)
+            )
+        except UndefinedError as e:
+            print('... ERROR ' + str(e))
+
+            sys.exit('\n... error occured while trying to generate namelist ' +
+                     _config.TEMPFILE_NAMELIST)
+        except OSError as e:
+            print('... ERROR CODE: ' + str(e.errno))
+            print('... ERROR MESSAGE:\n \t ' + str(e.strerror))
+
+            sys.exit('\n... error occured while trying to generate template ' +
+                     _config.TEMPFILE_NAMELIST)
+
+        try:
+            namelistfile = os.path.join(self.inputdir, _config.FILE_NAMELIST)
+
+            with open(namelistfile, 'w') as f:
+                f.write(stream.render('text'))
+        except OSError as e:
+            print('... ERROR CODE: ' + str(e.errno))
+            print('... ERROR MESSAGE:\n \t ' + str(e.strerror))
+
+            sys.exit('\n... error occured while trying to write ' +
+                     namelistfile)
 
         return
@@ -701,5 +713,7 @@
 
     def deacc_fluxes(self, inputfiles, c):
-        '''Goes through all flux fields in ordered time and de-accumulate
+        '''De-accumulate and disaggregate flux data.
+
+        Goes through all flux fields in ordered time and de-accumulate
         the fields. Afterwards the fields are disaggregated in time.
         Different versions of disaggregation is provided for rainfall
@@ -988,5 +1002,5 @@
             if not gid:
                 continue
-
+#============================================================================================
             # remove old fort.* files and open new ones
             # they are just valid for a single product
@@ -995,5 +1009,5 @@
                 silent_remove(fortfile)
                 fdict[k] = open(fortfile, 'w')
-
+#============================================================================================
             # create correct timestamp from the three time informations
             cdate = str(codes_get(gid, 'date'))
@@ -1019,5 +1033,5 @@
                                 'WRF' + cdate + '.' + ctime + '.000.grb2'), 'w')
                     olddate = cdate[:]
-
+#============================================================================================
             # savedfields remembers which fields were already used.
             savedfields = []
@@ -1083,8 +1097,8 @@
                 codes_release(gid)
                 gid = codes_new_from_index(iid)
-
+#============================================================================================
             for f in fdict.values():
                 f.close()
-
+#============================================================================================
             # call for Fortran program to convert e.g. reduced_gg grids to
             # regular_ll and calculate detadot/dp
@@ -1097,5 +1111,5 @@
                 my_error(c.mailfail, 'fort.21 is empty while parameter eta \
                          is set to 1 in CONTROL file')
-
+#============================================================================================
             # write out all output to log file before starting fortran programm
             sys.stdout.flush()
@@ -1105,5 +1119,5 @@
                 c.exedir, _config.FORTRAN_EXECUTABLE)], shell=True)
             os.chdir(pwd)
-
+#============================================================================================
             # create name of final output file, e.g. EN13040500 (ENYYMMDDHH)
             if c.maxstep > 12:
@@ -1115,5 +1129,5 @@
             # collect for final processing
             self.outputfilelist.append(os.path.basename(fnout))
-
+#============================================================================================
             # create outputfile and copy all data from intermediate files
             # to the outputfile (final GRIB input files for FLEXPART)
@@ -1135,5 +1149,5 @@
                     shutil.copyfileobj(open(os.path.join(c.inputdir, 'fort.25'),
                                             'rb'), fout)
-
+#============================================================================================
         if c.wrf:
             fwrf.close()
@@ -1145,5 +1159,7 @@
 
     def process_output(self, c):
-        '''The grib files are postprocessed depending on the selection in
+        '''Postprocessing of FLEXPART input files.
+
+        The grib files are postprocessed depending on the selection in
         CONTROL file. The resulting files are moved to the output
         directory if its not equal to the input directory.
@@ -1180,5 +1196,5 @@
 
             if c.format.lower() == 'grib2':
-                p = subprocess.check_call(['codes_set', '-s', 'edition=2,',
+                p = subprocess.check_call(['grib_set', '-s', 'edition=2,',
                                            'productDefinitionTemplateNumber=8',
                                            ofile, ofile + '_2'])
