Changeset 3797 for palm/trunk


Ignore:
Timestamp:
Mar 15, 2019 11:15:38 AM (3 years ago)
Author:
forkel
Message:

Modifications for OpenMP version by Klaus Ketelsen

Location:
palm/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/chem_gasphase_mod.f90

    r3789 r3797  
    9898                                                                 
    9999  LOGICAL                     :: data_loaded = .FALSE.             
     100  REAL(dp), POINTER, DIMENSION(:), CONTIGUOUS    :: var             
    100101! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    101102!
     
    113114!
    114115! File                 : chem_gasphase_mod_Parameters.f90
    115 ! Time                 : Fri Mar  8 19:01:03 2019
    116 ! Working directory    : /home/forkel-r/palmstuff/work/trunk20190308/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
     116! Time                 : Fri Mar 15 12:08:06 2019
     117! Working directory    : /home/forkel-r/palmstuff/work/trunk20190315/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
    117118! Equation file        : chem_gasphase_mod.kpp
    118119! Output root filename : chem_gasphase_mod
     
    190191!
    191192! File                 : chem_gasphase_mod_Global.f90
    192 ! Time                 : Fri Mar  8 19:01:03 2019
    193 ! Working directory    : /home/forkel-r/palmstuff/work/trunk20190308/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
     193! Time                 : Fri Mar 15 12:08:06 2019
     194! Working directory    : /home/forkel-r/palmstuff/work/trunk20190315/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
    194195! Equation file        : chem_gasphase_mod.kpp
    195196! Output root filename : chem_gasphase_mod
     
    205206
    206207! C - Concentration of all species
    207   REAL(kind=dp):: c(nspec)
     208  REAL(kind=dp), TARGET    :: c(nspec)
    208209! VAR - Concentrations of variable species (global)
    209   REAL(kind=dp):: var(nvar)
     210! REAL(kind=dp):: var(nvar)  var is now POINTER
    210211! FIX - Concentrations of fixed species (global)
    211212  REAL(kind=dp):: fix(nfix)
    212213! VAR,FIX are chunks of array C
    213       EQUIVALENCE( c(1), var(1))
    214214! RCONST - Rate constants (global)
    215215  REAL(kind=dp):: rconst(nreact)
     
    256256!
    257257! File                 : chem_gasphase_mod_JacobianSP.f90
    258 ! Time                 : Fri Mar  8 19:01:03 2019
    259 ! Working directory    : /home/forkel-r/palmstuff/work/trunk20190308/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
     258! Time                 : Fri Mar 15 12:08:06 2019
     259! Working directory    : /home/forkel-r/palmstuff/work/trunk20190315/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
    260260! Equation file        : chem_gasphase_mod.kpp
    261261! Output root filename : chem_gasphase_mod
     
    300300!
    301301! File                 : chem_gasphase_mod_Monitor.f90
    302 ! Time                 : Fri Mar  8 19:01:03 2019
    303 ! Working directory    : /home/forkel-r/palmstuff/work/trunk20190308/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
     302! Time                 : Fri Mar 15 12:08:06 2019
     303! Working directory    : /home/forkel-r/palmstuff/work/trunk20190315/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
    304304! Equation file        : chem_gasphase_mod.kpp
    305305! Output root filename : chem_gasphase_mod
     
    362362!
    363363! File                 : chem_gasphase_mod_Initialize.f90
    364 ! Time                 : Fri Mar  8 19:01:03 2019
    365 ! Working directory    : /home/forkel-r/palmstuff/work/trunk20190308/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
     364! Time                 : Fri Mar 15 12:08:06 2019
     365! Working directory    : /home/forkel-r/palmstuff/work/trunk20190315/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
    366366! Equation file        : chem_gasphase_mod.kpp
    367367! Output root filename : chem_gasphase_mod
     
    388388!
    389389! File                 : chem_gasphase_mod_Integrator.f90
    390 ! Time                 : Fri Mar  8 19:01:03 2019
    391 ! Working directory    : /home/forkel-r/palmstuff/work/trunk20190308/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
     390! Time                 : Fri Mar 15 12:08:06 2019
     391! Working directory    : /home/forkel-r/palmstuff/work/trunk20190315/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
    392392! Equation file        : chem_gasphase_mod.kpp
    393393! Output root filename : chem_gasphase_mod
     
    446446!
    447447! File                 : chem_gasphase_mod_LinearAlgebra.f90
    448 ! Time                 : Fri Mar  8 19:01:03 2019
    449 ! Working directory    : /home/forkel-r/palmstuff/work/trunk20190308/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
     448! Time                 : Fri Mar 15 12:08:06 2019
     449! Working directory    : /home/forkel-r/palmstuff/work/trunk20190315/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
    450450! Equation file        : chem_gasphase_mod.kpp
    451451! Output root filename : chem_gasphase_mod
     
    473473!
    474474! File                 : chem_gasphase_mod_Jacobian.f90
    475 ! Time                 : Fri Mar  8 19:01:03 2019
    476 ! Working directory    : /home/forkel-r/palmstuff/work/trunk20190308/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
     475! Time                 : Fri Mar 15 12:08:06 2019
     476! Working directory    : /home/forkel-r/palmstuff/work/trunk20190315/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
    477477! Equation file        : chem_gasphase_mod.kpp
    478478! Output root filename : chem_gasphase_mod
     
    500500!
    501501! File                 : chem_gasphase_mod_Function.f90
    502 ! Time                 : Fri Mar  8 19:01:03 2019
    503 ! Working directory    : /home/forkel-r/palmstuff/work/trunk20190308/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
     502! Time                 : Fri Mar 15 12:08:06 2019
     503! Working directory    : /home/forkel-r/palmstuff/work/trunk20190315/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
    504504! Equation file        : chem_gasphase_mod.kpp
    505505! Output root filename : chem_gasphase_mod
     
    529529!
    530530! File                 : chem_gasphase_mod_Rates.f90
    531 ! Time                 : Fri Mar  8 19:01:03 2019
    532 ! Working directory    : /home/forkel-r/palmstuff/work/trunk20190308/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
     531! Time                 : Fri Mar 15 12:08:06 2019
     532! Working directory    : /home/forkel-r/palmstuff/work/trunk20190315/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
    533533! Equation file        : chem_gasphase_mod.kpp
    534534! Output root filename : chem_gasphase_mod
     
    555555!
    556556! File                 : chem_gasphase_mod_Util.f90
    557 ! Time                 : Fri Mar  8 19:01:03 2019
    558 ! Working directory    : /home/forkel-r/palmstuff/work/trunk20190308/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
     557! Time                 : Fri Mar 15 12:08:06 2019
     558! Working directory    : /home/forkel-r/palmstuff/work/trunk20190315/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
    559559! Equation file        : chem_gasphase_mod.kpp
    560560! Output root filename : chem_gasphase_mod
     
    670670  END INTERFACE        chem_gasphase_integrate
    671671 
     672 
     673  ! openmp directives generated by kp4
     674 
     675  !$OMP THREADPRIVATE (vl, vl_glo, is, ie, data_loaded)
     676  !$OMP THREADPRIVATE (c, var, fix, rconst, time, temp, stepmin, cfactor)
     677  !$OMP THREADPRIVATE (qvap, fakt, cs_mech, a, icntrl, rcntrl)
    672678 
    673679 CONTAINS
     
    23082314  IF (PRESENT (rcntrl_i)) rcntrl  = rcntrl_i                     
    23092315                                                                   
     2316  var => c(1:nvar)                                                 
     2317                                                                   
    23102318  vl_glo = size(tempi, 1)                                           
    23112319                                                                   
  • palm/trunk/SOURCE/prognostic_equations.f90

    r3771 r3797  
    2525! -----------------
    2626! $Id$
     27! Call chem_integegrate in OpenMP loop   (ketelsen)
     28!
     29!
     30! 3771 2019-02-28 12:19:33Z raasch
    2731! preprocessor directivs fro rrtmg added
    2832!
     
    527531             CALL photolysis_control
    528532          ENDIF
    529           DO  i = nxl, nxr
    530              DO  j = nys, nyn
    531 
    532                 IF ( intermediate_timestep_count == 1 .OR.                        &
    533                      call_chem_at_all_substeps )  THEN
    534 
    535                    CALL cpu_log( log_point_s(19), 'chem.reactions', 'start' ) 
     533
     534          IF ( intermediate_timestep_count == 1 .OR.                        &
     535             call_chem_at_all_substeps )  THEN
     536
     537             CALL cpu_log( log_point_s(19), 'chem.reactions', 'start' )
     538             !$OMP PARALLEL PRIVATE (i,j)
     539             !$OMP DO schedule(static,1)
     540             DO  i = nxl, nxr
     541                DO  j = nys, nyn
    536542                   CALL chem_integrate (i,j)
    537                    CALL cpu_log( log_point_s(19), 'chem.reactions', 'stop' )
    538 
    539                    IF ( do_depo )  THEN
    540                       CALL cpu_log( log_point_s(24), 'chem.deposition', 'start' )
     543                ENDDO
     544             ENDDO
     545             !$OMP END PARALLEL
     546             CALL cpu_log( log_point_s(19), 'chem.reactions', 'stop' )
     547
     548             IF ( do_depo )  THEN
     549                CALL cpu_log( log_point_s(24), 'chem.deposition', 'start' )
     550                DO  i = nxl, nxr
     551                   DO  j = nys, nyn
    541552                      CALL chem_depo(i,j)
    542                       CALL cpu_log( log_point_s(24), 'chem.deposition', 'stop' )
    543                    ENDIF
    544                 ENDIF
    545              ENDDO
    546           ENDDO
     553                   ENDDO
     554                ENDDO
     555                CALL cpu_log( log_point_s(24), 'chem.deposition', 'stop' )
     556             ENDIF
     557          ENDIF
    547558       ENDIF
    548559!
  • palm/trunk/UTIL/chemistry/gasphase_preproc/kpp4palm/src/create_kpp_module.C

    r3789 r3797  
    1717//-----------------
    1818//$Id: create_kpp_module.C 3453 2018-10-30 13:21:51Z forkel $
     19// OpenMP version    (15.03.2019, ketelsen)
     20//
    1921// Added vector switch Kacc,Krej,IERRV, Commented add_line for istatf,    (05.03.2019, forkel)
    2022//      added ,pe after ierr_u,         
     
    233235
    234236   mz_kpp.add_line(" ");
     237
     238// Declare variables THREADPRIVATE for OpenMP version
     239
     240   mz_kpp.add_line("  ! OpenMP directives generated by kp4 ");
     241   mz_kpp.add_line(" ");
     242   mz_kpp.add_line("  !$OMP THREADPRIVATE (vl,vl_glo,is,ie,data_loaded)");
     243   mz_kpp.add_line("  !$OMP THREADPRIVATE (c,var,fix,rconst,time,temp,stepmin,cfactor)");
     244   mz_kpp.add_line("  !$OMP THREADPRIVATE (qvap,fakt,cs_mech,a,icntrl,rcntrl)");
     245   mz_kpp.add_line(" ");
     246   if(kpp_switches.is_vector()) {
     247      mz_kpp.add_line("  ! Vector mode Only ");
     248          mz_kpp.add_line(" ");
     249          mz_kpp.add_line("  !$OMP THREADPRIVATE (kacc,krej,ierrv)");
     250          mz_kpp.add_line("  !$OMP THREADPRIVATE (kpoints,kpoints_SAVE,index_org,done_check,index_step,cell_done)");
     251          mz_kpp.add_line("  !$OMP THREADPRIVATE (f_done,kacc_done,krej_done,ierr_done,compress_done)");
     252          mz_kpp.add_line(" ");
     253   }
    235254
    236255
     
    444463   }
    445464   mz_kpp.add_line("  logical                     :: data_loaded = .false.             ");
     465   if(kpp_switches.is_vector()) {
     466          mz_kpp.add_line("  REAL(dp),POINTER,DIMENSION(:,:),CONTIGUOUS    :: var           ");
     467   } else {
     468      mz_kpp.add_line("  REAL(dp),POINTER,DIMENSION(:),CONTIGUOUS    :: var             ");
     469   }
    446470   in.close();
    447471
     
    547571   kppi.add_line("  if (present (rcntrl_i) )  rcntrl  = rcntrl_i                      ");
    548572   kppi.add_line("                                                                    ");
     573   if(kpp_switches.is_vector()) {
     574      kppi.add_line("  var => c(:,1:nvar)                                                  ");
     575   } else {
     576      kppi.add_line("  var => c(1:nvar)                                                  ");
     577   }
     578   kppi.add_line("                                                                    ");
    549579   kppi.add_line("  vl_glo = size(tempi,1)                                            ");
    550580   kppi.add_line("                                                                    ");
  • palm/trunk/UTIL/chemistry/gasphase_preproc/kpp4palm/src/fortran_file.C

    r3789 r3797  
    1818//-----------------
    1919//$Id:
     20// OpenMP version    (15.03.2019, ketelsen)
    2021//
    21 // removal of unnecessary variables (Ntotal, TSTART)                        (08.03.2019 forkel)
     22// removal of unnecessary variables (Ntotal, TSTART)   (08.03.2019 forkel)
    2223//
    2324// Added vector switch and creation of dimension statement (rev. 3260, 18.09.2018, ketelsen)
     
    333334      lo_line.insert(0,"!DELETE ");
    334335    }
     336//  Delete KPP-generated EQUIVALENCE line (var is POINTER now)
     337    if(ip->get_token(0) == "EQUIVALENCE"  && ip->get_token_size() >= 1) {
     338      lo_line.insert(0,"!DELETE ");
     339    }
    335340
    336341//  Remove  REAL(kind=dp):: sun
     
    429434    }
    430435
    431 
    432 
    433436//  Make ind_ variables public
     437
    434438    if(ip->get_token(3).substr(0,4) == "ind_") {
    435439      global_substitute (lo_line,"PARAMETER","PARAMETER, PUBLIC");
     
    670674    ip->global_substitute(", - ",", -");
    671675
     676//  Replace Roundoff = WLAMCH('E') since WLAMCH does not work everywhere
     677       ip->global_substitute("Roundoff = WLAMCH('E')","roundoff = epsilon(one)");
     678
    672679// Now do some cosmetics to adapt the KPP generated output a bit o the looks of PALM,
    673680// i.e. add some blanks, convert all to lowercase except Fortran language elements, etc.
    674 //  Replace Roundoff = WLAMCH('E') by Roundoff = epsilon(one)
    675        ip->global_substitute("Roundoff = WLAMCH('E')","roundoff = epsilon(one)");
    676681       lo_line = ip->get_line();
    677682       if(lo_line.find("'",0) == string::npos)  {     // No substitution in line with strings
     
    706711         global_substitute(lo_line,"E+ ","E+");
    707712         global_substitute(lo_line,"E- ","E-");
     713//   Set all characters to lowercase
    708714         ip->global_subtolower(lo_line);
     715//   Restore OMP directives: The next 2 lines are not only cosmetics!
     716         global_substitute(lo_line,"!$omp","!$OMP");
     717         global_substitute(lo_line,"threadprivate","THREADPRIVATE");
     718
    709719         global_substitute(lo_line,"allocated","ALLOCATED");
    710720         global_substitute(lo_line,"allocatable","ALLOCATABLE");
     
    714724         global_substitute(lo_line,"character","CHARACTER");
    715725         global_substitute(lo_line,"contains","CONTAINS");
     726         global_substitute(lo_line,"contiguous","CONTIGUOUS");
    716727         global_substitute(lo_line,"deallocate","DEALLOCATE");
    717728         global_substitute(lo_line,"allocate","ALLOCATE");
     
    728739         global_substitute(lo_line,"tEND","tend");
    729740         global_substitute(lo_line,"#ENDIF","#endif");
    730          global_substitute(lo_line,"equivalence","EQUIVALENCE");
    731741         global_substitute(lo_line,"function","FUNCTION");
    732742         global_substitute(lo_line,"if(","IF (");
     
    743753         global_substitute(lo_line,"optional","OPTIONAL");
    744754         global_substitute(lo_line,"parameter","PARAMETER");
     755         global_substitute(lo_line,"pointer","POINTER");
    745756         global_substitute(lo_line,"present","PRESENT");
    746757         global_substitute(lo_line,"private","PRIVATE");
     
    752763         global_substitute(lo_line,"save","SAVE");
    753764         global_substitute(lo_line,"subroutine","SUBROUTINE");
     765         global_substitute(lo_line,"target","TARGET");
    754766         global_substitute(lo_line,"then","THEN");
    755767         global_substitute(lo_line,"where","WHERE");
     
    761773         global_substitute(lo_line,"(inout)","(INOUT)");
    762774         global_substitute(lo_line,"\t","      ");
     775
     776         // Skalar Version
     777         global_substitute(lo_line,"  REAL(kind=dp):: var(nvar)","! REAL(kind=dp):: var(nvar)  var is now POINTER");
     778         global_substitute(lo_line,"REAL(kind=dp):: c(nspec)","REAL(kind=dp), TARGET    :: c(nspec)");
     779         // Vektor Version
     780         global_substitute(lo_line,"  REAL(kind=dp):: var (vl_dim, nvar)","! REAL(kind=dp):: var (vl_dim, nvar)  var is now POINTER");
     781         global_substitute(lo_line,"REAL(kind=dp):: c (vl_dim, nspec)","REAL(kind=dp), TARGET    :: c (vl_dim, nspec)");
     782
    763783//       cout << "HIER1 " << lo_line <<endl;
    764784       }
Note: See TracChangeset for help on using the changeset viewer.