Index: source/python/_config.py
===================================================================
--- source/python/_config.py	(revision 0aaeb04b941d4c298b7dbc0b1c0f5407e88aad4a)
+++ source/python/_config.py	(revision c5074d295840f29091c45f8333ce650ad2a25ccd)
@@ -38,8 +38,9 @@
 TEMPFILE_INSTALL_COMPILEJOB = 'compilejob.template'
 FILE_INSTALL_COMPILEJOB = 'compilejob.ksh'
-TEMPFILE_INSTALL_JOB = 'job.temp.o'
+TEMPFILE_INSTALL_JOB = 'job.template'
 TEMPFILE_JOB = 'job.temp'
 FILE_JOB_OD = 'job.ksh'
 FILE_JOB_OP = 'jopoper.ksh'
+TEMPFILE_NAMELIST = 'convert.nl'
 FILE_NAMELIST = 'fort.4'
 FILE_GRIB_INDEX = 'date_time_stepRange.idx'
Index: source/python/classes/EcFlexpart.py
===================================================================
--- source/python/classes/EcFlexpart.py	(revision 0e576fcaf0dab8e7e586efa1a4b9b194ee90f8bb)
+++ source/python/classes/EcFlexpart.py	(revision c5074d295840f29091c45f8333ce650ad2a25ccd)
@@ -658,5 +658,5 @@
 
 
-    def write_namelist(self, c, filename):
+    def write_namelist(self, c):
         '''
         @Description:
@@ -683,4 +683,11 @@
         '''
 
+        from genshi.template.text import NewTextTemplate
+        from genshi.template import  TemplateLoader
+
+        loader = TemplateLoader(_config.PATH_TEMPLATES, auto_reload=False)
+        compile_template = loader.load(_config.TEMPFILE_NAMELIST,
+                                       cls=NewTextTemplate)
+
         self.inputdir = c.inputdir
         area = np.asarray(self.area.split('/')).astype(float)
@@ -692,25 +699,28 @@
         maxb = int((area[0] - area[2]) / grid[0]) + 1
 
-        with open(self.inputdir + '/' + filename, 'w') as f:
-            f.write('&NAMGEN\n')
-            f.write(',\n  '.join(['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)]))
-
-            f.write('\n/\n')
+        stream = compile_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'))
 
         return
Index: source/python/install.py
===================================================================
--- source/python/install.py	(revision 0aaeb04b941d4c298b7dbc0b1c0f5407e88aad4a)
+++ source/python/install.py	(revision c5074d295840f29091c45f8333ce650ad2a25ccd)
@@ -396,6 +396,6 @@
 
     stream = compile_template.generate(
+        usergroup = ecgid,
         username = ecuid,
-        usergroup = ecgid,
         version_number = _config._VERSION_STR,
         fp_root_scripts = fp_root,
@@ -410,34 +410,4 @@
         f.write(stream.render('text'))
 
-
-    # template = os.path.join(_config.PATH_REL_TEMPLATES,
-                            # _config.TEMPFILE_INSTALL_COMPILEJOB)
-    # with open(template) as f:
-        # fdata = f.read().split('\n')
-
-
-    # with open(compilejob, 'w') as fo:
-        # for data in fdata:
-            # if 'MAKEFILE=' in data:
-                # data = 'export MAKEFILE=' + makefile
-            # elif 'FLEXPART_ROOT_SCRIPTS=' in data:
-                # if fp_root != '../':
-                    # data = 'export FLEXPART_ROOT_SCRIPTS=' + fp_root
-                # else:
-                    # data = 'export FLEXPART_ROOT_SCRIPTS=$HOME'
-            # elif target.lower() != 'local':
-                # if '--workdir' in data:
-                    # data = '#SBATCH --workdir=/scratch/ms/' + \
-                            # ecgid + '/' + ecuid
-                # elif '##PBS -o' in data:
-                    # data = '##PBS -o /scratch/ms/' + ecgid + '/' + ecuid + \
-                           # 'flex_ecmwf.$Jobname.$Job_ID.out'
-                # elif 'FLEXPART_ROOT_SCRIPTS=' in data:
-                    # if fp_root != '../':
-                        # data = 'export FLEXPART_ROOT_SCRIPTS=' + fp_root
-                    # else:
-                        # data = 'export FLEXPART_ROOT_SCRIPTS=$HOME'
-            # fo.write(data + '\n')
-
     return
 
@@ -470,25 +440,28 @@
         <nothing>
     '''
-    fp_root_path_to_python = os.path.join(fp_root, _config.FLEXEXTRACT_DIRNAME,
-                         _config.PATH_REL_PYTHON)
-
-    template = os.path.join(_config.PATH_REL_TEMPLATES,
-                            _config.TEMPFILE_INSTALL_JOB)
-    with open(template) as f:
-        fdata = f.read().split('\n')
-
-    jobfile_temp = os.path.join(_config.PATH_REL_TEMPLATES,
-                                _config.TEMPFILE_JOB)
-    with open(jobfile_temp, 'w') as fo:
-        for data in fdata:
-            if '--workdir' in data:
-                data = '#SBATCH --workdir=/scratch/ms/' + ecgid + '/' + ecuid
-            elif '##PBS -o' in data:
-                data = '##PBS -o /scratch/ms/' + ecgid + '/' + \
-                        ecuid + 'flex_ecmwf.$Jobname.$Job_ID.out'
-            elif  'export PATH=${PATH}:' in data:
-                data += fp_root_path_to_python
-
-            fo.write(data + '\n')
+    from genshi.template.text import NewTextTemplate
+    from genshi.template import  TemplateLoader
+
+    loader = TemplateLoader(_config.PATH_TEMPLATES, auto_reload=False)
+    compile_template = loader.load(_config.TEMPFILE_INSTALL_JOB,
+                                   cls=NewTextTemplate)
+
+    fp_root_path_to_python = os.path.join(fp_root,
+                                          _config.FLEXEXTRACT_DIRNAME,
+                                          _config.PATH_REL_PYTHON)
+
+    stream = compile_template.generate(
+        usergroup = ecgid,
+        username = ecuid,
+        version_number = _config._VERSION_STR,
+        fp_root_path = fp_root_path_to_python,
+    )
+
+    tempjobfile = os.path.join(_config.PATH_TEMPLATES,
+                               _config.TEMPFILE_JOB)
+
+    with open(tempjobfile, 'w') as f:
+        f.write(stream.render('text'))
+
     return
 
Index: source/python/mods/prepare_flexpart.py
===================================================================
--- source/python/mods/prepare_flexpart.py	(revision 5bad6ecd8c2b5597cc84f56143c36adc3ad18530)
+++ source/python/mods/prepare_flexpart.py	(revision c5074d295840f29091c45f8333ce650ad2a25ccd)
@@ -160,5 +160,5 @@
     # deaccumulate the flux data
     flexpart = EcFlexpart(c, fluxes=True)
-    flexpart.write_namelist(c, _config.FILE_NAMELIST)
+    flexpart.write_namelist(c)
     flexpart.deacc_fluxes(inputfiles, c)
 
