Index: source/python/install.py
===================================================================
--- source/python/install.py	(revision 27fe96979b13f659a887ea2518f03cadd0f7ad9e)
+++ source/python/install.py	(revision 0aaeb04b941d4c298b7dbc0b1c0f5407e88aad4a)
@@ -320,4 +320,5 @@
         Creates a file named ECMWF_ENV which contains the
         necessary environmental variables at ECMWF servers.
+        It is based on the template ECMWF_ENV.template.
 
     @Input:
@@ -338,10 +339,19 @@
         <nothing>
     '''
-
-    with open(_config.PATH_REL_ECMWF_ENV, 'w') as fo:
-        fo.write('ECUID ' + ecuid + '\n')
-        fo.write('ECGID ' + ecgid + '\n')
-        fo.write('GATEWAY ' + gateway + '\n')
-        fo.write('DESTINATION ' + destination + '\n')
+    from genshi.template.text import NewTextTemplate
+    from genshi.template import  TemplateLoader
+
+    loader = TemplateLoader(_config.PATH_TEMPLATES, auto_reload=False)
+    ecmwfvars_template = loader.load(_config.TEMPFILE_USER_ENVVARS,
+                                     cls=NewTextTemplate)
+
+    stream = ecmwfvars_template.generate(user_name = ecuid,
+                                       user_group = ecgid,
+                                       gateway_name = gateway,
+                                       destination_name = destination
+                                       )
+
+    with open(_config.PATH_ECMWF_ENV, 'w') as f:
+        f.write(stream.render('text'))
 
     return
@@ -375,34 +385,58 @@
         <nothing>
     '''
-
-    template = os.path.join(_config.PATH_REL_TEMPLATES,
-                            _config.TEMPFILE_INSTALL_COMPILEJOB)
-    with open(template) as f:
-        fdata = f.read().split('\n')
-
-    compilejob = os.path.join(_config.PATH_REL_JOBSCRIPTS,
+    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_COMPILEJOB,
+                                   cls=NewTextTemplate)
+
+    if fp_root == '../':
+        fp_root = '$HOME'
+
+    stream = compile_template.generate(
+        username = ecuid,
+        usergroup = ecgid,
+        version_number = _config._VERSION_STR,
+        fp_root_scripts = fp_root,
+        makefile = makefile,
+        fortran_program = _config.FORTRAN_EXECUTABLE
+    )
+
+    compilejob = os.path.join(_config.PATH_JOBSCRIPTS,
                               _config.FILE_INSTALL_COMPILEJOB)
-    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')
+
+    with open(compilejob, 'w') as f:
+        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
