Index: palm/trunk/UTIL/chemistry/gasphase_preproc/kpp4palm/src/create_kpp_module.C
===================================================================
--- palm/trunk/UTIL/chemistry/gasphase_preproc/kpp4palm/src/create_kpp_module.C	(revision 3789)
+++ palm/trunk/UTIL/chemistry/gasphase_preproc/kpp4palm/src/create_kpp_module.C	(revision 3797)
@@ -17,4 +17,6 @@
 //-----------------
 //$Id: create_kpp_module.C 3453 2018-10-30 13:21:51Z forkel $
+// OpenMP version    (15.03.2019, ketelsen)
+//
 // Added vector switch Kacc,Krej,IERRV, Commented add_line for istatf,    (05.03.2019, forkel)
 //      added ,pe after ierr_u,         
@@ -233,4 +235,21 @@
 
    mz_kpp.add_line(" ");
+
+// Declare variables THREADPRIVATE for OpenMP version
+
+   mz_kpp.add_line("  ! OpenMP directives generated by kp4 ");
+   mz_kpp.add_line(" ");
+   mz_kpp.add_line("  !$OMP THREADPRIVATE (vl,vl_glo,is,ie,data_loaded)");
+   mz_kpp.add_line("  !$OMP THREADPRIVATE (c,var,fix,rconst,time,temp,stepmin,cfactor)");
+   mz_kpp.add_line("  !$OMP THREADPRIVATE (qvap,fakt,cs_mech,a,icntrl,rcntrl)");
+   mz_kpp.add_line(" ");
+   if(kpp_switches.is_vector()) {
+      mz_kpp.add_line("  ! Vector mode Only ");
+	  mz_kpp.add_line(" ");
+	  mz_kpp.add_line("  !$OMP THREADPRIVATE (kacc,krej,ierrv)");
+	  mz_kpp.add_line("  !$OMP THREADPRIVATE (kpoints,kpoints_SAVE,index_org,done_check,index_step,cell_done)");
+	  mz_kpp.add_line("  !$OMP THREADPRIVATE (f_done,kacc_done,krej_done,ierr_done,compress_done)");
+	  mz_kpp.add_line(" ");
+   }
 
 
@@ -444,4 +463,9 @@
    }
    mz_kpp.add_line("  logical                     :: data_loaded = .false.             "); 
+   if(kpp_switches.is_vector()) {
+	  mz_kpp.add_line("  REAL(dp),POINTER,DIMENSION(:,:),CONTIGUOUS    :: var           ");
+   } else {
+      mz_kpp.add_line("  REAL(dp),POINTER,DIMENSION(:),CONTIGUOUS    :: var             ");
+   }
    in.close();
 
@@ -547,4 +571,10 @@
    kppi.add_line("  if (present (rcntrl_i) )  rcntrl  = rcntrl_i                      ");
    kppi.add_line("                                                                    ");
+   if(kpp_switches.is_vector()) {
+      kppi.add_line("  var => c(:,1:nvar)                                                  ");
+   } else {
+      kppi.add_line("  var => c(1:nvar)                                                  ");
+   }
+   kppi.add_line("                                                                    ");
    kppi.add_line("  vl_glo = size(tempi,1)                                            ");
    kppi.add_line("                                                                    ");
Index: palm/trunk/UTIL/chemistry/gasphase_preproc/kpp4palm/src/fortran_file.C
===================================================================
--- palm/trunk/UTIL/chemistry/gasphase_preproc/kpp4palm/src/fortran_file.C	(revision 3789)
+++ palm/trunk/UTIL/chemistry/gasphase_preproc/kpp4palm/src/fortran_file.C	(revision 3797)
@@ -18,6 +18,7 @@
 //-----------------
 //$Id: 
+// OpenMP version    (15.03.2019, ketelsen)
 //
-// removal of unnecessary variables (Ntotal, TSTART)                        (08.03.2019 forkel)
+// removal of unnecessary variables (Ntotal, TSTART)   (08.03.2019 forkel)
 // 
 // Added vector switch and creation of dimension statement (rev. 3260, 18.09.2018, ketelsen)
@@ -333,4 +334,8 @@
       lo_line.insert(0,"!DELETE ");
     }
+//  Delete KPP-generated EQUIVALENCE line (var is POINTER now)
+    if(ip->get_token(0) == "EQUIVALENCE"  && ip->get_token_size() >= 1) {
+      lo_line.insert(0,"!DELETE ");
+    }
 
 //  Remove  REAL(kind=dp):: sun
@@ -429,7 +434,6 @@
     }
 
-
-
 //  Make ind_ variables public
+
     if(ip->get_token(3).substr(0,4) == "ind_") {
       global_substitute (lo_line,"PARAMETER","PARAMETER, PUBLIC");
@@ -670,8 +674,9 @@
     ip->global_substitute(", - ",", -");
 
+//  Replace Roundoff = WLAMCH('E') since WLAMCH does not work everywhere
+       ip->global_substitute("Roundoff = WLAMCH('E')","roundoff = epsilon(one)");
+
 // Now do some cosmetics to adapt the KPP generated output a bit o the looks of PALM, 
 // i.e. add some blanks, convert all to lowercase except Fortran language elements, etc.
-//  Replace Roundoff = WLAMCH('E') by Roundoff = epsilon(one)
-       ip->global_substitute("Roundoff = WLAMCH('E')","roundoff = epsilon(one)");
        lo_line = ip->get_line();
        if(lo_line.find("'",0) == string::npos)  {     // No substitution in line with strings
@@ -706,5 +711,10 @@
          global_substitute(lo_line,"E+ ","E+");
          global_substitute(lo_line,"E- ","E-");
+//   Set all characters to lowercase
          ip->global_subtolower(lo_line);
+//   Restore OMP directives: The next 2 lines are not only cosmetics!
+         global_substitute(lo_line,"!$omp","!$OMP");
+         global_substitute(lo_line,"threadprivate","THREADPRIVATE");
+
          global_substitute(lo_line,"allocated","ALLOCATED");
          global_substitute(lo_line,"allocatable","ALLOCATABLE");
@@ -714,4 +724,5 @@
          global_substitute(lo_line,"character","CHARACTER");
          global_substitute(lo_line,"contains","CONTAINS");
+         global_substitute(lo_line,"contiguous","CONTIGUOUS");
          global_substitute(lo_line,"deallocate","DEALLOCATE");
          global_substitute(lo_line,"allocate","ALLOCATE");
@@ -728,5 +739,4 @@
          global_substitute(lo_line,"tEND","tend");
          global_substitute(lo_line,"#ENDIF","#endif");
-         global_substitute(lo_line,"equivalence","EQUIVALENCE");
          global_substitute(lo_line,"function","FUNCTION");
          global_substitute(lo_line,"if(","IF (");
@@ -743,4 +753,5 @@
          global_substitute(lo_line,"optional","OPTIONAL");
          global_substitute(lo_line,"parameter","PARAMETER");
+         global_substitute(lo_line,"pointer","POINTER");
          global_substitute(lo_line,"present","PRESENT");
          global_substitute(lo_line,"private","PRIVATE");
@@ -752,4 +763,5 @@
          global_substitute(lo_line,"save","SAVE");
          global_substitute(lo_line,"subroutine","SUBROUTINE");
+         global_substitute(lo_line,"target","TARGET");
          global_substitute(lo_line,"then","THEN");
          global_substitute(lo_line,"where","WHERE");
@@ -761,4 +773,12 @@
          global_substitute(lo_line,"(inout)","(INOUT)");
          global_substitute(lo_line,"\t","      ");
+
+         // Skalar Version
+         global_substitute(lo_line,"  REAL(kind=dp):: var(nvar)","! REAL(kind=dp):: var(nvar)  var is now POINTER");
+         global_substitute(lo_line,"REAL(kind=dp):: c(nspec)","REAL(kind=dp), TARGET    :: c(nspec)");
+         // Vektor Version
+         global_substitute(lo_line,"  REAL(kind=dp):: var (vl_dim, nvar)","! REAL(kind=dp):: var (vl_dim, nvar)  var is now POINTER");
+         global_substitute(lo_line,"REAL(kind=dp):: c (vl_dim, nspec)","REAL(kind=dp), TARGET    :: c (vl_dim, nspec)");
+
 //       cout << "HIER1 " << lo_line <<endl;
        }
