source: palm/trunk/UTIL/chemistry/gasphase_preproc/mechanisms/def_phstat/chem_gasphase_mod.f90 @ 3789

Last change on this file since 3789 was 3789, checked in by forkel, 5 years ago

Removed unused variables from chem_gasphase_mod.f90

File size: 79.8 KB
RevLine 
[2931]1MODULE chem_gasphase_mod
[3228]2 
[3280]3!   Mechanism: phstat
4!
[2931]5!------------------------------------------------------------------------------!
6!
7! ******Module chem_gasphase_mod is automatically generated by kpp4palm ******
8!
9!   *********Please do NOT change this Code,it will be ovewritten *********
10!
11!------------------------------------------------------------------------------!
12! This file was created by KPP (http://people.cs.vt.edu/asandu/Software/Kpp/)
[3228]13! and kpp4palm (created by Klaus Ketelsen). kpp4palm is an adapted version
14! of KP4 (Jöckel,P.,Kerkweg,A.,Pozzer,A.,Sander,R.,Tost,H.,Riede,
15! H.,Baumgaertner,A.,Gromov,S.,and Kern,B.,2010: Development cycle 2 of
16! the Modular Earth Submodel System (MESSy2),Geosci. Model Dev.,3,717-752,
17! https://doi.org/10.5194/gmd-3-717-2010). KP4 is part of the Modular Earth
18! Submodel System (MESSy),which is is available under the  GNU General Public
19! License (GPL).
[2931]20!
21! KPP is free software; you can redistribute it and/or modify it under the terms
22! of the General Public Licence as published by the Free Software Foundation;
23! either version 2 of the License,or (at your option) any later version.
24! KPP is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
25! without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
26! PURPOSE. See the GNU General Public Licence for more details.
27!
28!------------------------------------------------------------------------------!
29! This file is part of the PALM model system.
30!
31! PALM is free software: you can redistribute it and/or modify it under the
32! terms of the GNU General Public License as published by the Free Software
33! Foundation,either version 3 of the License,or (at your option) any later
34! version.
35!
36! PALM is distributed in the hope that it will be useful,but WITHOUT ANY
37! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
38! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
39!
40! You should have received a copy of the GNU General Public License along with
41! PALM. If not,see <http://www.gnu.org/licenses/>.
42!
[3681]43! Copyright 1997-2019 Leibniz Universitaet Hannover
[2931]44!--------------------------------------------------------------------------------!
45!
46!
[3585]47! MODULE HEADER TEMPLATE
[2931]48!
[3585]49!  Initial version (Nov. 2016,ketelsen),for later modifications of module_header
50!  see comments in kpp4palm/src/create_kpp_module.C
[2931]51
52! Set kpp Double Precision to PALM Default Precision
53
54  USE kinds,           ONLY: dp=>wp
55
[3228]56  USE pegrid,          ONLY: myid, threads_per_task
[2931]57
58  IMPLICIT        NONE
59  PRIVATE
[3228]60  !SAVE  ! note: occurs again in automatically generated code ...
[2931]61
62!  PUBLIC :: IERR_NAMES
63 
64! PUBLIC :: SPC_NAMES,EQN_NAMES,EQN_TAGS,REQ_HET,REQ_AEROSOL,REQ_PHOTRAT &
65!         ,REQ_MCFCT,IP_MAX,jname
66
[3780]67  PUBLIC :: cs_mech
[3228]68  PUBLIC :: eqn_names, phot_names, spc_names
[2931]69  PUBLIC :: nmaxfixsteps
[3228]70  PUBLIC :: atol, rtol
71  PUBLIC :: nspec, nreact
[2931]72  PUBLIC :: temp
[3228]73  PUBLIC :: qvap
74  PUBLIC :: fakt
[2931]75  PUBLIC :: phot 
76  PUBLIC :: rconst
77  PUBLIC :: nvar
78  PUBLIC :: nphot
[3263]79  PUBLIC :: vl_dim                     ! PUBLIC to ebable other MODULEs to distiguish between scalar and vec
[2931]80 
[3228]81  PUBLIC :: initialize, integrate, update_rconst
[2931]82  PUBLIC :: chem_gasphase_integrate
83  PUBLIC :: initialize_kpp_ctrl
[3780]84  PUBLIC :: get_mechanismname
[2931]85
86! END OF MODULE HEADER TEMPLATE
87                                                                 
88! Variables used for vector mode                                 
89                                                                 
[3249]90  LOGICAL, PARAMETER          :: l_vector = .FALSE.           
91  INTEGER, PARAMETER          :: i_lu_di = 2
92  INTEGER, PARAMETER          :: vl_dim = 1
[2931]93  INTEGER                     :: vl                             
94                                                                 
95  INTEGER                     :: vl_glo                         
[3228]96  INTEGER                     :: is, ie                           
[2931]97                                                                 
[3228]98                                                                 
99  LOGICAL                     :: data_loaded = .FALSE.             
[2931]100! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101!
102! Parameter Module File
103!
104! Generated by KPP-2.2.3 symbolic chemistry Kinetics PreProcessor
105!       (http://www.cs.vt.edu/~asandu/Software/KPP)
106! KPP is distributed under GPL,the general public licence
107!       (http://www.gnu.org/copyleft/gpl.html)
108! (C) 1995-1997,V. Damian & A. Sandu,CGRER,Univ. Iowa
109! (C) 1997-2005,A. Sandu,Michigan Tech,Virginia Tech
110!     With important contributions from:
111!        M. Damian,Villanova University,USA
112!        R. Sander,Max-Planck Institute for Chemistry,Mainz,Germany
113!
114! File                 : chem_gasphase_mod_Parameters.f90
[3789]115! Time                 : Fri Mar  8 19:01:00 2019
116! Working directory    : /home/forkel-r/palmstuff/work/trunk20190308/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
[2931]117! Equation file        : chem_gasphase_mod.kpp
118! Output root filename : chem_gasphase_mod
119!
120! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
121
122
123
124
125
126
127! NSPEC - Number of chemical species
[3228]128  INTEGER, PARAMETER :: nspec = 3 
[2931]129! NVAR - Number of Variable species
[3228]130  INTEGER, PARAMETER :: nvar = 3 
[2931]131! NVARACT - Number of Active species
[3228]132  INTEGER, PARAMETER :: nvaract = 3 
[2931]133! NFIX - Number of Fixed species
[3228]134  INTEGER, PARAMETER :: nfix = 1 
[2931]135! NREACT - Number of reactions
[3228]136  INTEGER, PARAMETER :: nreact = 2 
[2931]137! NVARST - Starting of variables in conc. vect.
[3228]138  INTEGER, PARAMETER :: nvarst = 1 
[2931]139! NFIXST - Starting of fixed in conc. vect.
[3228]140  INTEGER, PARAMETER :: nfixst = 4 
[2931]141! NONZERO - Number of nonzero entries in Jacobian
[3228]142  INTEGER, PARAMETER :: nonzero = 9 
[2931]143! LU_NONZERO - Number of nonzero entries in LU factoriz. of Jacobian
[3228]144  INTEGER, PARAMETER :: lu_nonzero = 9 
[2931]145! CNVAR - (NVAR+1) Number of elements in compressed row format
[3228]146  INTEGER, PARAMETER :: cnvar = 4 
[2931]147! CNEQN - (NREACT+1) Number stoicm elements in compressed col format
[3228]148  INTEGER, PARAMETER :: cneqn = 3 
[2931]149! NHESS - Length of Sparse Hessian
[3228]150  INTEGER, PARAMETER :: nhess = 3 
[2931]151! NMASS - Number of atoms to check mass balance
[3228]152  INTEGER, PARAMETER :: nmass = 1 
[2931]153
154! Index declaration for variable species in C and VAR
155!   VAR(ind_spc) = C(ind_spc)
156
[3228]157  INTEGER, PARAMETER, PUBLIC :: ind_o3 = 1 
158  INTEGER, PARAMETER, PUBLIC :: ind_no = 2 
159  INTEGER, PARAMETER, PUBLIC :: ind_no2 = 3 
[2931]160
161! Index declaration for fixed species in C
162!   C(ind_spc)
163
164
165! Index declaration for fixed species in FIX
166!    FIX(indf_spc) = C(ind_spc) = C(NVAR+indf_spc)
167
168
169! NJVRP - Length of sparse Jacobian JVRP
[3228]170  INTEGER, PARAMETER :: njvrp = 3 
[2931]171
172! NSTOICM - Length of Sparse Stoichiometric Matrix
[3228]173  INTEGER, PARAMETER :: nstoicm = 6 
[2931]174
175
176! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
177!
178! Global Data Module File
179!
180! Generated by KPP-2.2.3 symbolic chemistry Kinetics PreProcessor
181!       (http://www.cs.vt.edu/~asandu/Software/KPP)
182! KPP is distributed under GPL,the general public licence
183!       (http://www.gnu.org/copyleft/gpl.html)
184! (C) 1995-1997,V. Damian & A. Sandu,CGRER,Univ. Iowa
185! (C) 1997-2005,A. Sandu,Michigan Tech,Virginia Tech
186!     With important contributions from:
187!        M. Damian,Villanova University,USA
188!        R. Sander,Max-Planck Institute for Chemistry,Mainz,Germany
189!
190! File                 : chem_gasphase_mod_Global.f90
[3789]191! Time                 : Fri Mar  8 19:01:00 2019
192! Working directory    : /home/forkel-r/palmstuff/work/trunk20190308/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
[2931]193! Equation file        : chem_gasphase_mod.kpp
194! Output root filename : chem_gasphase_mod
195!
196! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
197
198
199
200
201
202
203! Declaration of global variables
204
205! C - Concentration of all species
206  REAL(kind=dp):: c(nspec)
207! VAR - Concentrations of variable species (global)
208  REAL(kind=dp):: var(nvar)
209! FIX - Concentrations of fixed species (global)
210  REAL(kind=dp):: fix(nfix)
211! VAR,FIX are chunks of array C
[3228]212      EQUIVALENCE( c(1), var(1))
[2931]213! RCONST - Rate constants (global)
214  REAL(kind=dp):: rconst(nreact)
215! TIME - Current integration time
216  REAL(kind=dp):: time
217! TEMP - Temperature
[3263]218  REAL(kind=dp):: temp
[2931]219! ATOL - Absolute tolerance
220  REAL(kind=dp):: atol(nvar)
221! RTOL - Relative tolerance
222  REAL(kind=dp):: rtol(nvar)
223! STEPMIN - Lower bound for integration step
224  REAL(kind=dp):: stepmin
225! CFACTOR - Conversion factor for concentration units
226  REAL(kind=dp):: cfactor
227
228! INLINED global variable declarations
229
[3228]230! QVAP - Water vapor
[3263]231  REAL(kind=dp):: qvap
[3228]232! FAKT - Conversion factor
[3263]233  REAL(kind=dp):: fakt
[3228]234
[3780]235! CS_MECH for check of mechanism name with namelist
236  CHARACTER(len=30):: cs_mech
[2931]237
238! INLINED global variable declarations
239
240
241
242! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
243!
244! Sparse Jacobian Data Structures File
245!
246! Generated by KPP-2.2.3 symbolic chemistry Kinetics PreProcessor
247!       (http://www.cs.vt.edu/~asandu/Software/KPP)
248! KPP is distributed under GPL,the general public licence
249!       (http://www.gnu.org/copyleft/gpl.html)
250! (C) 1995-1997,V. Damian & A. Sandu,CGRER,Univ. Iowa
251! (C) 1997-2005,A. Sandu,Michigan Tech,Virginia Tech
252!     With important contributions from:
253!        M. Damian,Villanova University,USA
254!        R. Sander,Max-Planck Institute for Chemistry,Mainz,Germany
255!
256! File                 : chem_gasphase_mod_JacobianSP.f90
[3789]257! Time                 : Fri Mar  8 19:01:00 2019
258! Working directory    : /home/forkel-r/palmstuff/work/trunk20190308/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
[2931]259! Equation file        : chem_gasphase_mod.kpp
260! Output root filename : chem_gasphase_mod
261!
262! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
263
264
265
266
267
268
269! Sparse Jacobian Data
270
271
[3228]272  INTEGER, PARAMETER, DIMENSION(9):: lu_irow =  (/ &
[2931]273       1, 1, 1, 2, 2, 2, 3, 3, 3 /) 
274
[3228]275  INTEGER, PARAMETER, DIMENSION(9):: lu_icol =  (/ &
[2931]276       1, 2, 3, 1, 2, 3, 1, 2, 3 /) 
277
[3228]278  INTEGER, PARAMETER, DIMENSION(4):: lu_crow =  (/ &
279       1, 4, 7, 10 /) 
[2931]280
[3228]281  INTEGER, PARAMETER, DIMENSION(4):: lu_diag =  (/ &
282       1, 5, 9, 10 /) 
[2931]283
284
285
286! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
287!
288! Utility Data Module File
289!
290! Generated by KPP-2.2.3 symbolic chemistry Kinetics PreProcessor
291!       (http://www.cs.vt.edu/~asandu/Software/KPP)
292! KPP is distributed under GPL,the general public licence
293!       (http://www.gnu.org/copyleft/gpl.html)
294! (C) 1995-1997,V. Damian & A. Sandu,CGRER,Univ. Iowa
295! (C) 1997-2005,A. Sandu,Michigan Tech,Virginia Tech
296!     With important contributions from:
297!        M. Damian,Villanova University,USA
298!        R. Sander,Max-Planck Institute for Chemistry,Mainz,Germany
299!
300! File                 : chem_gasphase_mod_Monitor.f90
[3789]301! Time                 : Fri Mar  8 19:01:00 2019
302! Working directory    : /home/forkel-r/palmstuff/work/trunk20190308/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
[2931]303! Equation file        : chem_gasphase_mod.kpp
304! Output root filename : chem_gasphase_mod
305!
306! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
307
308
309
310
311
[3228]312  CHARACTER(len=15), PARAMETER, DIMENSION(3):: spc_names =  (/ &
[2931]313     'O3             ','NO             ','NO2            ' /)
314
[3228]315  CHARACTER(len=100), PARAMETER, DIMENSION(2):: eqn_names =  (/ &
[2931]316     '    NO2 --> O3 + NO                                                                                 ',&
317     'O3 + NO --> NO2                                                                                     ' /)
318
319! INLINED global variables
320
321  !   inline f90_data: declaration of global variables for photolysis
322  !   REAL(kind=dp):: phot(nphot)must eventually be moved to global later for
[3228]323  INTEGER, PARAMETER :: nphot = 1
[2931]324  !   phot photolysis frequencies
325  REAL(kind=dp):: phot(nphot)
326
[3228]327  INTEGER, PARAMETER, PUBLIC :: j_no2 = 1
[2931]328
[3228]329  CHARACTER(len=15), PARAMETER, DIMENSION(nphot):: phot_names =   (/ &
[2931]330     'J_NO2          '/)
331
332! End INLINED global variables
333
334
335! Automatic generated PUBLIC Statements for ip_ and ihs_ variables
336 
337! Automatic generated PUBLIC Statements for ip_ and ihs_ variables
338 
339! Automatic generated PUBLIC Statements for ip_ and ihs_ variables
340 
341! Automatic generated PUBLIC Statements for ip_ and ihs_ variables
342 
343 
344!  variable definations from  individual module headers
345 
346! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
347!
348! Initialization File
349!
350! Generated by KPP-2.2.3 symbolic chemistry Kinetics PreProcessor
351!       (http://www.cs.vt.edu/~asandu/Software/KPP)
352! KPP is distributed under GPL,the general public licence
353!       (http://www.gnu.org/copyleft/gpl.html)
354! (C) 1995-1997,V. Damian & A. Sandu,CGRER,Univ. Iowa
355! (C) 1997-2005,A. Sandu,Michigan Tech,Virginia Tech
356!     With important contributions from:
357!        M. Damian,Villanova University,USA
358!        R. Sander,Max-Planck Institute for Chemistry,Mainz,Germany
359!
360! File                 : chem_gasphase_mod_Initialize.f90
[3789]361! Time                 : Fri Mar  8 19:01:00 2019
362! Working directory    : /home/forkel-r/palmstuff/work/trunk20190308/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
[2931]363! Equation file        : chem_gasphase_mod.kpp
364! Output root filename : chem_gasphase_mod
365!
366! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
367
368
369
370
371
372! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
373!
374! Numerical Integrator (Time-Stepping) File
375!
376! Generated by KPP-2.2.3 symbolic chemistry Kinetics PreProcessor
377!       (http://www.cs.vt.edu/~asandu/Software/KPP)
378! KPP is distributed under GPL,the general public licence
379!       (http://www.gnu.org/copyleft/gpl.html)
380! (C) 1995-1997,V. Damian & A. Sandu,CGRER,Univ. Iowa
381! (C) 1997-2005,A. Sandu,Michigan Tech,Virginia Tech
382!     With important contributions from:
383!        M. Damian,Villanova University,USA
384!        R. Sander,Max-Planck Institute for Chemistry,Mainz,Germany
385!
386! File                 : chem_gasphase_mod_Integrator.f90
[3789]387! Time                 : Fri Mar  8 19:01:00 2019
388! Working directory    : /home/forkel-r/palmstuff/work/trunk20190308/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
[2931]389! Equation file        : chem_gasphase_mod.kpp
390! Output root filename : chem_gasphase_mod
391!
392! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
393
394
395
396! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
397!
398! INTEGRATE - Integrator routine
399!   Arguments :
400!      TIN       - Start Time for Integration
401!      TOUT      - End Time for Integration
402!
403! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
404
405!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
406!  Rosenbrock - Implementation of several Rosenbrock methods:             !
407!               *Ros2                                                    !
408!               *Ros3                                                    !
409!               *Ros4                                                    !
410!               *Rodas3                                                  !
411!               *Rodas4                                                  !
412!  By default the code employs the KPP sparse linear algebra routines     !
413!  Compile with -DFULL_ALGEBRA to use full linear algebra (LAPACK)        !
414!                                                                         !
415!    (C)  Adrian Sandu,August 2004                                       !
416!    Virginia Polytechnic Institute and State University                  !
417!    Contact: sandu@cs.vt.edu                                             !
418!    Revised by Philipp Miehe and Adrian Sandu,May 2006                  !                               !
419!    This implementation is part of KPP - the Kinetic PreProcessor        !
420!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
421
422
423  SAVE
424 
425!~~~>  statistics on the work performed by the rosenbrock method
[3228]426  INTEGER, PARAMETER :: nfun=1, njac=2, nstp=3, nacc=4, &
427                        nrej=5, ndec=6, nsol=7, nsng=8, &
428                        ntexit=1, nhexit=2, nhnew = 3
[2931]429
430! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
431!
432! Linear Algebra Data and Routines File
433!
434! Generated by KPP-2.2.3 symbolic chemistry Kinetics PreProcessor
435!       (http://www.cs.vt.edu/~asandu/Software/KPP)
436! KPP is distributed under GPL,the general public licence
437!       (http://www.gnu.org/copyleft/gpl.html)
438! (C) 1995-1997,V. Damian & A. Sandu,CGRER,Univ. Iowa
439! (C) 1997-2005,A. Sandu,Michigan Tech,Virginia Tech
440!     With important contributions from:
441!        M. Damian,Villanova University,USA
442!        R. Sander,Max-Planck Institute for Chemistry,Mainz,Germany
443!
444! File                 : chem_gasphase_mod_LinearAlgebra.f90
[3789]445! Time                 : Fri Mar  8 19:01:00 2019
446! Working directory    : /home/forkel-r/palmstuff/work/trunk20190308/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
[2931]447! Equation file        : chem_gasphase_mod.kpp
448! Output root filename : chem_gasphase_mod
449!
450! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
451
452
453
454
455
456
457! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
458!
459! The ODE Jacobian of Chemical Model File
460!
461! Generated by KPP-2.2.3 symbolic chemistry Kinetics PreProcessor
462!       (http://www.cs.vt.edu/~asandu/Software/KPP)
463! KPP is distributed under GPL,the general public licence
464!       (http://www.gnu.org/copyleft/gpl.html)
465! (C) 1995-1997,V. Damian & A. Sandu,CGRER,Univ. Iowa
466! (C) 1997-2005,A. Sandu,Michigan Tech,Virginia Tech
467!     With important contributions from:
468!        M. Damian,Villanova University,USA
469!        R. Sander,Max-Planck Institute for Chemistry,Mainz,Germany
470!
471! File                 : chem_gasphase_mod_Jacobian.f90
[3789]472! Time                 : Fri Mar  8 19:01:00 2019
473! Working directory    : /home/forkel-r/palmstuff/work/trunk20190308/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
[2931]474! Equation file        : chem_gasphase_mod.kpp
475! Output root filename : chem_gasphase_mod
476!
477! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
478
479
480
481
482
483
484! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
485!
486! The ODE Function of Chemical Model File
487!
488! Generated by KPP-2.2.3 symbolic chemistry Kinetics PreProcessor
489!       (http://www.cs.vt.edu/~asandu/Software/KPP)
490! KPP is distributed under GPL,the general public licence
491!       (http://www.gnu.org/copyleft/gpl.html)
492! (C) 1995-1997,V. Damian & A. Sandu,CGRER,Univ. Iowa
493! (C) 1997-2005,A. Sandu,Michigan Tech,Virginia Tech
494!     With important contributions from:
495!        M. Damian,Villanova University,USA
496!        R. Sander,Max-Planck Institute for Chemistry,Mainz,Germany
497!
498! File                 : chem_gasphase_mod_Function.f90
[3789]499! Time                 : Fri Mar  8 19:01:00 2019
500! Working directory    : /home/forkel-r/palmstuff/work/trunk20190308/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
[2931]501! Equation file        : chem_gasphase_mod.kpp
502! Output root filename : chem_gasphase_mod
503!
504! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
505
506
507
508
509
510! A - Rate for each equation
511  REAL(kind=dp):: a(nreact)
512
513! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
514!
515! The Reaction Rates File
516!
517! Generated by KPP-2.2.3 symbolic chemistry Kinetics PreProcessor
518!       (http://www.cs.vt.edu/~asandu/Software/KPP)
519! KPP is distributed under GPL,the general public licence
520!       (http://www.gnu.org/copyleft/gpl.html)
521! (C) 1995-1997,V. Damian & A. Sandu,CGRER,Univ. Iowa
522! (C) 1997-2005,A. Sandu,Michigan Tech,Virginia Tech
523!     With important contributions from:
524!        M. Damian,Villanova University,USA
525!        R. Sander,Max-Planck Institute for Chemistry,Mainz,Germany
526!
527! File                 : chem_gasphase_mod_Rates.f90
[3789]528! Time                 : Fri Mar  8 19:01:00 2019
529! Working directory    : /home/forkel-r/palmstuff/work/trunk20190308/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
[2931]530! Equation file        : chem_gasphase_mod.kpp
531! Output root filename : chem_gasphase_mod
532!
533! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
534
535
536
537
538
539! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
540!
541! Auxiliary Routines File
542!
543! Generated by KPP-2.2.3 symbolic chemistry Kinetics PreProcessor
544!       (http://www.cs.vt.edu/~asandu/Software/KPP)
545! KPP is distributed under GPL,the general public licence
546!       (http://www.gnu.org/copyleft/gpl.html)
547! (C) 1995-1997,V. Damian & A. Sandu,CGRER,Univ. Iowa
548! (C) 1997-2005,A. Sandu,Michigan Tech,Virginia Tech
549!     With important contributions from:
550!        M. Damian,Villanova University,USA
551!        R. Sander,Max-Planck Institute for Chemistry,Mainz,Germany
552!
553! File                 : chem_gasphase_mod_Util.f90
[3789]554! Time                 : Fri Mar  8 19:01:00 2019
555! Working directory    : /home/forkel-r/palmstuff/work/trunk20190308/UTIL/chemistry/gasphase_preproc/tmp_kpp4palm
[2931]556! Equation file        : chem_gasphase_mod.kpp
557! Output root filename : chem_gasphase_mod
558!
559! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
560
561
562
563
564
565
566  ! header MODULE initialize_kpp_ctrl_template
567
568  ! notes:
[3228]569  ! - l_vector is automatically defined by kp4
570  ! - vl_dim is automatically defined by kp4
571  ! - i_lu_di is automatically defined by kp4
572  ! - wanted is automatically defined by xmecca
573  ! - icntrl rcntrl are automatically defined by kpp
574  ! - "USE messy_main_tools" is in MODULE_header of messy_mecca_kpp.f90
575  ! - SAVE will be automatically added by kp4
[2931]576
577  !SAVE
578
579  ! for fixed time step control
580  ! ... max. number of fixed time steps (sum must be 1)
[3228]581  INTEGER, PARAMETER         :: nmaxfixsteps = 50
[2931]582  ! ... switch for fixed time stepping
[3228]583  LOGICAL, PUBLIC            :: l_fixed_step = .FALSE.
584  INTEGER, PUBLIC            :: nfsteps = 1
[2931]585  ! ... number of kpp control PARAMETERs
[3228]586  INTEGER, PARAMETER, PUBLIC :: nkppctrl = 20
[2931]587  !
[3228]588  INTEGER, DIMENSION(nkppctrl), PUBLIC     :: icntrl = 0
589  REAL(dp), DIMENSION(nkppctrl), PUBLIC     :: rcntrl = 0.0_dp
590  REAL(dp), DIMENSION(nmaxfixsteps), PUBLIC :: t_steps = 0.0_dp
[2931]591
592  ! END header MODULE initialize_kpp_ctrl_template
593
594 
595! Interface Block
596 
597  INTERFACE            initialize
598    MODULE PROCEDURE   initialize
599  END INTERFACE        initialize
600 
601  INTERFACE            integrate
602    MODULE PROCEDURE   integrate
603  END INTERFACE        integrate
604 
605  INTERFACE            fun
606    MODULE PROCEDURE   fun
607  END INTERFACE        fun
608 
609  INTERFACE            kppsolve
610    MODULE PROCEDURE   kppsolve
611  END INTERFACE        kppsolve
612 
613  INTERFACE            jac_sp
614    MODULE PROCEDURE   jac_sp
615  END INTERFACE        jac_sp
616 
617  INTERFACE            k_arr
618    MODULE PROCEDURE   k_arr
619  END INTERFACE        k_arr
620 
621  INTERFACE            update_rconst
622    MODULE PROCEDURE   update_rconst
623  END INTERFACE        update_rconst
624 
625  INTERFACE            arr2
626    MODULE PROCEDURE   arr2
627  END INTERFACE        arr2
628 
629  INTERFACE            initialize_kpp_ctrl
630    MODULE PROCEDURE   initialize_kpp_ctrl
631  END INTERFACE        initialize_kpp_ctrl
632 
633  INTERFACE            error_output
634    MODULE PROCEDURE   error_output
635  END INTERFACE        error_output
636 
637  INTERFACE            wscal
638    MODULE PROCEDURE   wscal
639  END INTERFACE        wscal
640 
[3228]641!INTERFACE not working  INTERFACE            waxpy
642!INTERFACE not working    MODULE PROCEDURE   waxpy
643!INTERFACE not working  END INTERFACE        waxpy
[2931]644 
645  INTERFACE            rosenbrock
646    MODULE PROCEDURE   rosenbrock
647  END INTERFACE        rosenbrock
648 
649  INTERFACE            funtemplate
650    MODULE PROCEDURE   funtemplate
651  END INTERFACE        funtemplate
652 
653  INTERFACE            jactemplate
654    MODULE PROCEDURE   jactemplate
655  END INTERFACE        jactemplate
656 
[3228]657  INTERFACE            kppdecomp
658    MODULE PROCEDURE   kppdecomp
659  END INTERFACE        kppdecomp
660 
[3780]661  INTERFACE            get_mechanismname
662    MODULE PROCEDURE   get_mechanismname
663  END INTERFACE        get_mechanismname
664 
[2931]665  INTERFACE            chem_gasphase_integrate
666    MODULE PROCEDURE   chem_gasphase_integrate
667  END INTERFACE        chem_gasphase_integrate
668 
669 
670 CONTAINS
671 
672SUBROUTINE initialize()
673
674
[3789]675 INTEGER         :: k
[2931]676
677  INTEGER :: i
678  REAL(kind=dp):: x
[3249]679  k = is
[2931]680  cfactor = 1.000000e+00_dp
681
[3228]682  x = (0.) * cfactor
[3249]683  DO i = 1 , nvar
[2931]684  ENDDO
685
[3228]686  x = (0.) * cfactor
[3249]687  DO i = 1 , nfix
[2931]688    fix(i) = x
689  ENDDO
690
691! constant rate coefficients
692! END constant rate coefficients
693
694! INLINED initializations
695
696! End INLINED initializations
697
698     
699END SUBROUTINE initialize
700 
[3228]701SUBROUTINE integrate( tin, tout, &
702  icntrl_u, rcntrl_u, istatus_u, rstatus_u, ierr_u)
[2931]703
704
[3228]705   REAL(kind=dp), INTENT(IN):: tin  ! start time
706   REAL(kind=dp), INTENT(IN):: tout ! END time
[2931]707   ! OPTIONAL input PARAMETERs and statistics
[3228]708   INTEGER,      INTENT(IN), OPTIONAL :: icntrl_u(20)
709   REAL(kind=dp), INTENT(IN), OPTIONAL :: rcntrl_u(20)
710   INTEGER,      INTENT(OUT), OPTIONAL :: istatus_u(20)
711   REAL(kind=dp), INTENT(OUT), OPTIONAL :: rstatus_u(20)
712   INTEGER,      INTENT(OUT), OPTIONAL :: ierr_u
[2931]713
[3228]714   REAL(kind=dp):: rcntrl(20), rstatus(20)
715   INTEGER       :: icntrl(20), istatus(20), ierr
[2931]716
717
718   icntrl(:) = 0
719   rcntrl(:) = 0.0_dp
720   istatus(:) = 0
721   rstatus(:) = 0.0_dp
722
723    !~~~> fine-tune the integrator:
[3249]724   icntrl(1) = 0      ! 0 - non- autonomous, 1 - autonomous
725   icntrl(2) = 0      ! 0 - vector tolerances, 1 - scalars
[2931]726
[3228]727   ! IF OPTIONAL PARAMETERs are given, and IF they are >0,
[2931]728   ! THEN they overwrite default settings.
[3228]729   IF (PRESENT(icntrl_u))THEN
730     WHERE(icntrl_u(:)> 0)icntrl(:) = icntrl_u(:)
[2931]731   ENDIF
[3228]732   IF (PRESENT(rcntrl_u))THEN
733     WHERE(rcntrl_u(:)> 0)rcntrl(:) = rcntrl_u(:)
[2931]734   ENDIF
735
736
[3228]737   CALL rosenbrock(nvar, var, tin, tout,  &
738         atol, rtol,               &
739         rcntrl, icntrl, rstatus, istatus, ierr)
[2931]740
741   !~~~> debug option: show no of steps
742   ! ntotal = ntotal + istatus(nstp)
743   ! PRINT*,'NSTEPS=',ISTATUS(Nstp),' (',Ntotal,')','  O3=',VAR(ind_O3)
744
745   stepmin = rstatus(nhexit)
746   ! IF OPTIONAL PARAMETERs are given for output they
747   ! are updated with the RETURN information
[3228]748   IF (PRESENT(istatus_u))istatus_u(:) = istatus(:)
749   IF (PRESENT(rstatus_u))rstatus_u(:) = rstatus(:)
750   IF (PRESENT(ierr_u))  ierr_u       = ierr
[2931]751
752END SUBROUTINE integrate
753 
[3228]754SUBROUTINE fun(v, f, rct, vdot)
[2931]755
756! V - Concentrations of variable species (local)
757  REAL(kind=dp):: v(nvar)
758! F - Concentrations of fixed species (local)
759  REAL(kind=dp):: f(nfix)
760! RCT - Rate constants (local)
761  REAL(kind=dp):: rct(nreact)
762! Vdot - Time derivative of variable species concentrations
763  REAL(kind=dp):: vdot(nvar)
764
765
766! Computation of equation rates
[3228]767  a(1) = rct(1) * v(3)
768  a(2) = rct(2) * v(1) * v(2)
[2931]769
770! Aggregate function
[3228]771  vdot(1) = a(1) - a(2)
772  vdot(2) = a(1) - a(2)
773  vdot(3) = - a(1) + a(2)
[2931]774     
775END SUBROUTINE fun
776 
[3228]777SUBROUTINE kppsolve(jvs, x)
[2931]778
779! JVS - sparse Jacobian of variables
780  REAL(kind=dp):: jvs(lu_nonzero)
781! X - Vector for variables
782  REAL(kind=dp):: x(nvar)
783
[3228]784  x(2) = x(2) - jvs(4) * x(1)
785  x(3) = x(3) - jvs(7) * x(1) - jvs(8) * x(2)
786  x(3) = x(3) / jvs(9)
787  x(2) = (x(2) - jvs(6) * x(3)) /(jvs(5))
788  x(1) = (x(1) - jvs(2) * x(2) - jvs(3) * x(3)) /(jvs(1))
[2931]789     
790END SUBROUTINE kppsolve
791 
[3228]792SUBROUTINE jac_sp(v, f, rct, jvs)
[2931]793
794! V - Concentrations of variable species (local)
795  REAL(kind=dp):: v(nvar)
796! F - Concentrations of fixed species (local)
797  REAL(kind=dp):: f(nfix)
798! RCT - Rate constants (local)
799  REAL(kind=dp):: rct(nreact)
800! JVS - sparse Jacobian of variables
801  REAL(kind=dp):: jvs(lu_nonzero)
802
803
804! Local variables
805! B - Temporary array
806  REAL(kind=dp):: b(3)
807
808! B(1) = dA(1)/dV(3)
809  b(1) = rct(1)
810! B(2) = dA(2)/dV(1)
[3228]811  b(2) = rct(2) * v(2)
[2931]812! B(3) = dA(2)/dV(2)
[3228]813  b(3) = rct(2) * v(1)
[2931]814
815! Construct the Jacobian terms from B's
816! JVS(1) = Jac_FULL(1,1)
817  jvs(1) = - b(2)
818! JVS(2) = Jac_FULL(1,2)
819  jvs(2) = - b(3)
820! JVS(3) = Jac_FULL(1,3)
821  jvs(3) = b(1)
822! JVS(4) = Jac_FULL(2,1)
823  jvs(4) = - b(2)
824! JVS(5) = Jac_FULL(2,2)
825  jvs(5) = - b(3)
826! JVS(6) = Jac_FULL(2,3)
827  jvs(6) = b(1)
828! JVS(7) = Jac_FULL(3,1)
829  jvs(7) = b(2)
830! JVS(8) = Jac_FULL(3,2)
831  jvs(8) = b(3)
832! JVS(9) = Jac_FULL(3,3)
833  jvs(9) = - b(1)
834     
835END SUBROUTINE jac_sp
836 
[3228]837  elemental REAL(kind=dp)FUNCTION k_arr (k_298, tdep, temp)
[2931]838    ! arrhenius FUNCTION
839
[3228]840    REAL,    INTENT(IN):: k_298 ! k at t = 298.15k
841    REAL,    INTENT(IN):: tdep  ! temperature dependence
842    REAL(kind=dp), INTENT(IN):: temp  ! temperature
[2931]843
844    intrinsic exp
845
[3228]846    k_arr = k_298 * exp(tdep* (1._dp/temp- 3.3540e-3_dp))! 1/298.15=3.3540e-3
[2931]847
848  END FUNCTION k_arr
849 
850SUBROUTINE update_rconst()
[3249]851 INTEGER         :: k
[2931]852
853  k = is
854
855! Begin INLINED RCONST
856
857
858! End INLINED RCONST
859
860  rconst(1) = (phot(j_no2))
[3263]861  rconst(2) = (arr2(1.8e-12_dp , 1370.0_dp , temp))
[2931]862     
863END SUBROUTINE update_rconst
864 
[3228]865!  END FUNCTION ARR2
866REAL(kind=dp)FUNCTION arr2( a0, b0, temp)
[2931]867    REAL(kind=dp):: temp
[3228]868    REAL(kind=dp):: a0, b0
869    arr2 = a0 * exp( - b0 / temp)
[2931]870END FUNCTION arr2
871 
[3249]872SUBROUTINE initialize_kpp_ctrl(status)
[2931]873
874
875  ! i/o
[3228]876  INTEGER,         INTENT(OUT):: status
[2931]877
878  ! local
879  REAL(dp):: tsum
880  INTEGER  :: i
881
882  ! check fixed time steps
883  tsum = 0.0_dp
[3228]884  DO i=1, nmaxfixsteps
[2931]885     IF (t_steps(i)< tiny(0.0_dp))exit
886     tsum = tsum + t_steps(i)
887  ENDDO
888
889  nfsteps = i- 1
890
891  l_fixed_step = (nfsteps > 0).and.((tsum - 1.0)< tiny(0.0_dp))
892
893  IF (l_vector)THEN
894     WRITE(*,*) ' MODE             : VECTOR (LENGTH=',VL_DIM,')'
895  ELSE
896     WRITE(*,*) ' MODE             : SCALAR'
897  ENDIF
898  !
899  WRITE(*,*) ' DE-INDEXING MODE :',I_LU_DI
900  !
901  WRITE(*,*) ' ICNTRL           : ',icntrl
902  WRITE(*,*) ' RCNTRL           : ',rcntrl
903  !
[3228]904  ! note: this is ONLY meaningful for vectorized (kp4)rosenbrock- methods
[2931]905  IF (l_vector)THEN
906     IF (l_fixed_step)THEN
907        WRITE(*,*) ' TIME STEPS       : FIXED (',t_steps(1:nfsteps),')'
908     ELSE
909        WRITE(*,*) ' TIME STEPS       : AUTOMATIC'
910     ENDIF
911  ELSE
912     WRITE(*,*) ' TIME STEPS       : AUTOMATIC '//&
913          &'(t_steps (CTRL_KPP) ignored in SCALAR MODE)'
914  ENDIF
915  ! mz_pj_20070531-
916
917  status = 0
918
919
920END SUBROUTINE initialize_kpp_ctrl
921 
[3228]922SUBROUTINE error_output(c, ierr, pe)
[2931]923
924
[3228]925  INTEGER, INTENT(IN):: ierr
926  INTEGER, INTENT(IN):: pe
927  REAL(dp), DIMENSION(:), INTENT(IN):: c
[2931]928
[3789]929  write(6,*) 'ERROR in chem_gasphase_mod ',ierr,C(1),PE
[2931]930
931
932END SUBROUTINE error_output
933 
[3228]934      SUBROUTINE wscal(n, alpha, x, incx)
[2931]935!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
936!     constant times a vector: x(1:N) <- Alpha*x(1:N)
937!     only for incX=incY=1
938!     after BLAS
939!     replace this by the function from the optimized BLAS implementation:
940!         CALL SSCAL(N,Alpha,X,1) or  CALL DSCAL(N,Alpha,X,1)
941!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
942
[3228]943      INTEGER  :: i, incx, m, mp1, n
944      REAL(kind=dp) :: x(n), alpha
945      REAL(kind=dp), PARAMETER  :: zero=0.0_dp, one=1.0_dp
[2931]946
947      IF (alpha .eq. one)RETURN
948      IF (n .le. 0)RETURN
949
[3228]950      m = mod(n, 5)
951      IF ( m .ne. 0)THEN
[2931]952        IF (alpha .eq. (- one))THEN
[3228]953          DO i = 1, m
[2931]954            x(i) = - x(i)
955          ENDDO
956        ELSEIF (alpha .eq. zero)THEN
[3228]957          DO i = 1, m
[2931]958            x(i) = zero
959          ENDDO
960        ELSE
[3228]961          DO i = 1, m
962            x(i) = alpha* x(i)
[2931]963          ENDDO
964        ENDIF
[3228]965        IF ( n .lt. 5)RETURN
[2931]966      ENDIF
967      mp1 = m + 1
968      IF (alpha .eq. (- one))THEN
[3228]969        DO i = mp1, n, 5
970          x(i)   = - x(i)
[2931]971          x(i + 1) = - x(i + 1)
972          x(i + 2) = - x(i + 2)
973          x(i + 3) = - x(i + 3)
974          x(i + 4) = - x(i + 4)
975        ENDDO
976      ELSEIF (alpha .eq. zero)THEN
[3228]977        DO i = mp1, n, 5
978          x(i)   = zero
[2931]979          x(i + 1) = zero
980          x(i + 2) = zero
981          x(i + 3) = zero
982          x(i + 4) = zero
983        ENDDO
984      ELSE
[3228]985        DO i = mp1, n, 5
986          x(i)   = alpha* x(i)
987          x(i + 1) = alpha* x(i + 1)
988          x(i + 2) = alpha* x(i + 2)
989          x(i + 3) = alpha* x(i + 3)
990          x(i + 4) = alpha* x(i + 4)
[2931]991        ENDDO
992      ENDIF
993
994      END SUBROUTINE wscal
995 
[3228]996      SUBROUTINE waxpy(n, alpha, x, incx, y, incy)
[2931]997!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
998!     constant times a vector plus a vector: y <- y + Alpha*x
999!     only for incX=incY=1
1000!     after BLAS
1001!     replace this by the function from the optimized BLAS implementation:
1002!         CALL SAXPY(N,Alpha,X,1,Y,1) or  CALL DAXPY(N,Alpha,X,1,Y,1)
1003!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1004
[3228]1005      INTEGER  :: i, incx, incy, m, mp1, n
1006      REAL(kind=dp):: x(n), y(n), alpha
1007      REAL(kind=dp), PARAMETER :: zero = 0.0_dp
[2931]1008
1009      IF (alpha .eq. zero)RETURN
1010      IF (n .le. 0)RETURN
1011
[3228]1012      m = mod(n, 4)
1013      IF ( m .ne. 0)THEN
1014        DO i = 1, m
1015          y(i) = y(i) + alpha* x(i)
[2931]1016        ENDDO
[3228]1017        IF ( n .lt. 4)RETURN
[2931]1018      ENDIF
1019      mp1 = m + 1
[3228]1020      DO i = mp1, n, 4
1021        y(i) = y(i) + alpha* x(i)
1022        y(i + 1) = y(i + 1) + alpha* x(i + 1)
1023        y(i + 2) = y(i + 2) + alpha* x(i + 2)
1024        y(i + 3) = y(i + 3) + alpha* x(i + 3)
[2931]1025      ENDDO
1026     
1027      END SUBROUTINE waxpy
1028 
[3228]1029SUBROUTINE rosenbrock(n, y, tstart, tend, &
1030           abstol, reltol,             &
1031           rcntrl, icntrl, rstatus, istatus, ierr)
[2931]1032!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1033!
1034!    Solves the system y'=F(t,y) using a Rosenbrock method defined by:
1035!
1036!     G = 1/(H*gamma(1)) - Jac(t0,Y0)
1037!     T_i = t0 + Alpha(i)*H
1038!     Y_i = Y0 + \sum_{j=1}^{i-1} A(i,j)*K_j
1039!     G *K_i = Fun( T_i,Y_i)+ \sum_{j=1}^S C(i,j)/H *K_j +
1040!         gamma(i)*dF/dT(t0,Y0)
1041!     Y1 = Y0 + \sum_{j=1}^S M(j)*K_j
1042!
1043!    For details on Rosenbrock methods and their implementation consult:
1044!      E. Hairer and G. Wanner
1045!      "Solving ODEs II. Stiff and differential-algebraic problems".
1046!      Springer series in computational mathematics,Springer-Verlag,1996.
1047!    The codes contained in the book inspired this implementation.
1048!
1049!    (C)  Adrian Sandu,August 2004
1050!    Virginia Polytechnic Institute and State University
1051!    Contact: sandu@cs.vt.edu
1052!    Revised by Philipp Miehe and Adrian Sandu,May 2006                 
1053!    This implementation is part of KPP - the Kinetic PreProcessor
1054!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1055!
1056!~~~>   input arguments:
1057!
[3228]1058!-     y(n)  = vector of initial conditions (at t=tstart)
1059!-    [tstart, tend]  = time range of integration
[2931]1060!     (if Tstart>Tend the integration is performed backwards in time)
[3228]1061!-    reltol, abstol = user precribed accuracy
1062!- SUBROUTINE  fun( t, y, ydot) = ode FUNCTION,
[2931]1063!                       returns Ydot = Y' = F(T,Y)
[3228]1064!- SUBROUTINE  jac( t, y, jcb) = jacobian of the ode FUNCTION,
[2931]1065!                       returns Jcb = dFun/dY
[3228]1066!-    icntrl(1:20)  = INTEGER inputs PARAMETERs
1067!-    rcntrl(1:20)  = REAL inputs PARAMETERs
[2931]1068!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1069!
1070!~~~>     output arguments:
1071!
[3228]1072!-    y(n)  - > vector of final states (at t- >tend)
1073!-    istatus(1:20) - > INTEGER output PARAMETERs
1074!-    rstatus(1:20) - > REAL output PARAMETERs
1075!-    ierr            - > job status upon RETURN
[2931]1076!                        success (positive value) or
1077!                        failure (negative value)
1078!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1079!
1080!~~~>     input PARAMETERs:
1081!
1082!    Note: For input parameters equal to zero the default values of the
1083!       corresponding variables are used.
1084!
1085!    ICNTRL(1) = 1: F = F(y)   Independent of T (AUTONOMOUS)
1086!              = 0: F = F(t,y) Depends on T (NON-AUTONOMOUS)
1087!
1088!    ICNTRL(2) = 0: AbsTol,RelTol are N-dimensional vectors
1089!              = 1: AbsTol,RelTol are scalars
1090!
1091!    ICNTRL(3)  -> selection of a particular Rosenbrock method
1092!        = 0 :    Rodas3 (default)
1093!        = 1 :    Ros2
1094!        = 2 :    Ros3
1095!        = 3 :    Ros4
1096!        = 4 :    Rodas3
1097!        = 5 :    Rodas4
1098!
1099!    ICNTRL(4)  -> maximum number of integration steps
1100!        For ICNTRL(4) =0) the default value of 100000 is used
1101!
1102!    RCNTRL(1)  -> Hmin,lower bound for the integration step size
1103!          It is strongly recommended to keep Hmin = ZERO
1104!    RCNTRL(2)  -> Hmax,upper bound for the integration step size
1105!    RCNTRL(3)  -> Hstart,starting value for the integration step size
1106!
1107!    RCNTRL(4)  -> FacMin,lower bound on step decrease factor (default=0.2)
1108!    RCNTRL(5)  -> FacMax,upper bound on step increase factor (default=6)
1109!    RCNTRL(6)  -> FacRej,step decrease factor after multiple rejections
1110!                          (default=0.1)
1111!    RCNTRL(7)  -> FacSafe,by which the new step is slightly smaller
1112!         than the predicted value  (default=0.9)
1113!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1114!
1115!
1116!    OUTPUT ARGUMENTS:
1117!    -----------------
1118!
1119!    T           -> T value for which the solution has been computed
1120!                     (after successful return T=Tend).
1121!
1122!    Y(N)        -> Numerical solution at T
1123!
1124!    IDID        -> Reports on successfulness upon return:
1125!                    = 1 for success
1126!                    < 0 for error (value equals error code)
1127!
1128!    ISTATUS(1)  -> No. of function calls
1129!    ISTATUS(2)  -> No. of jacobian calls
1130!    ISTATUS(3)  -> No. of steps
1131!    ISTATUS(4)  -> No. of accepted steps
1132!    ISTATUS(5)  -> No. of rejected steps (except at very beginning)
1133!    ISTATUS(6)  -> No. of LU decompositions
1134!    ISTATUS(7)  -> No. of forward/backward substitutions
1135!    ISTATUS(8)  -> No. of singular matrix decompositions
1136!
1137!    RSTATUS(1)  -> Texit,the time corresponding to the
1138!                     computed Y upon return
1139!    RSTATUS(2)  -> Hexit,last accepted step before exit
1140!    RSTATUS(3)  -> Hnew,last predicted step (not yet taken)
1141!                   For multiple restarts,use Hnew as Hstart
1142!                     in the subsequent run
1143!
1144!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1145
1146
1147!~~~>  arguments
[3228]1148   INTEGER,      INTENT(IN)  :: n
1149   REAL(kind=dp), INTENT(INOUT):: y(n)
1150   REAL(kind=dp), INTENT(IN)  :: tstart, tend
1151   REAL(kind=dp), INTENT(IN)  :: abstol(n), reltol(n)
1152   INTEGER,      INTENT(IN)  :: icntrl(20)
1153   REAL(kind=dp), INTENT(IN)  :: rcntrl(20)
1154   INTEGER,      INTENT(INOUT):: istatus(20)
1155   REAL(kind=dp), INTENT(INOUT):: rstatus(20)
1156   INTEGER, INTENT(OUT) :: ierr
1157!~~~>  PARAMETERs of the rosenbrock method, up to 6 stages
1158   INTEGER ::  ros_s, rosmethod
1159   INTEGER, PARAMETER :: rs2=1, rs3=2, rs4=3, rd3=4, rd4=5, rg3=6
1160   REAL(kind=dp):: ros_a(15), ros_c(15), ros_m(6), ros_e(6), &
1161                    ros_alpha(6), ros_gamma(6), ros_elo
[2931]1162   LOGICAL :: ros_newf(6)
1163   CHARACTER(len=12):: ros_name
1164!~~~>  local variables
[3228]1165   REAL(kind=dp):: roundoff, facmin, facmax, facrej, facsafe
1166   REAL(kind=dp):: hmin, hmax, hstart
[2931]1167   REAL(kind=dp):: texit
[3228]1168   INTEGER       :: i, uplimtol, max_no_steps
1169   LOGICAL       :: autonomous, vectortol
[2931]1170!~~~>   PARAMETERs
[3228]1171   REAL(kind=dp), PARAMETER :: zero = 0.0_dp, one  = 1.0_dp
1172   REAL(kind=dp), PARAMETER :: deltamin = 1.0e-5_dp
[2931]1173
1174!~~~>  initialize statistics
1175   istatus(1:8) = 0
1176   rstatus(1:3) = zero
1177
1178!~~~>  autonomous or time dependent ode. default is time dependent.
1179   autonomous = .not.(icntrl(1) == 0)
1180
1181!~~~>  for scalar tolerances (icntrl(2).ne.0) the code uses abstol(1)and reltol(1)
1182!   For Vector tolerances (ICNTRL(2) == 0) the code uses AbsTol(1:N) and RelTol(1:N)
1183   IF (icntrl(2) == 0)THEN
[3228]1184      vectortol = .TRUE.
[2931]1185      uplimtol  = n
1186   ELSE
[3228]1187      vectortol = .FALSE.
[2931]1188      uplimtol  = 1
1189   ENDIF
1190
1191!~~~>   initialize the particular rosenbrock method selected
1192   select CASE (icntrl(3))
1193     CASE (1)
1194       CALL ros2
1195     CASE (2)
1196       CALL ros3
1197     CASE (3)
1198       CALL ros4
[3228]1199     CASE (0, 4)
[2931]1200       CALL rodas3
1201     CASE (5)
1202       CALL rodas4
1203     CASE (6)
1204       CALL rang3
1205     CASE default
1206       PRINT *,'Unknown Rosenbrock method: ICNTRL(3) =',ICNTRL(3) 
[3228]1207       CALL ros_errormsg(- 2, tstart, zero, ierr)
[2931]1208       RETURN
1209   END select
1210
1211!~~~>   the maximum number of steps admitted
1212   IF (icntrl(4) == 0)THEN
1213      max_no_steps = 200000
1214   ELSEIF (icntrl(4)> 0)THEN
1215      max_no_steps=icntrl(4)
1216   ELSE
1217      PRINT *,'User-selected max no. of steps: ICNTRL(4) =',ICNTRL(4)
[3228]1218      CALL ros_errormsg(- 1, tstart, zero, ierr)
[2931]1219      RETURN
1220   ENDIF
1221
1222!~~~>  unit roundoff (1+ roundoff>1)
[3228]1223   roundoff = epsilon(one)
[2931]1224
1225!~~~>  lower bound on the step size: (positive value)
1226   IF (rcntrl(1) == zero)THEN
1227      hmin = zero
1228   ELSEIF (rcntrl(1)> zero)THEN
1229      hmin = rcntrl(1)
1230   ELSE
1231      PRINT *,'User-selected Hmin: RCNTRL(1) =',RCNTRL(1)
[3228]1232      CALL ros_errormsg(- 3, tstart, zero, ierr)
[2931]1233      RETURN
1234   ENDIF
1235!~~~>  upper bound on the step size: (positive value)
1236   IF (rcntrl(2) == zero)THEN
1237      hmax = abs(tend-tstart)
1238   ELSEIF (rcntrl(2)> zero)THEN
[3228]1239      hmax = min(abs(rcntrl(2)), abs(tend-tstart))
[2931]1240   ELSE
1241      PRINT *,'User-selected Hmax: RCNTRL(2) =',RCNTRL(2)
[3228]1242      CALL ros_errormsg(- 3, tstart, zero, ierr)
[2931]1243      RETURN
1244   ENDIF
1245!~~~>  starting step size: (positive value)
1246   IF (rcntrl(3) == zero)THEN
[3228]1247      hstart = max(hmin, deltamin)
[2931]1248   ELSEIF (rcntrl(3)> zero)THEN
[3228]1249      hstart = min(abs(rcntrl(3)), abs(tend-tstart))
[2931]1250   ELSE
1251      PRINT *,'User-selected Hstart: RCNTRL(3) =',RCNTRL(3)
[3228]1252      CALL ros_errormsg(- 3, tstart, zero, ierr)
[2931]1253      RETURN
1254   ENDIF
1255!~~~>  step size can be changed s.t.  facmin < hnew/hold < facmax
1256   IF (rcntrl(4) == zero)THEN
1257      facmin = 0.2_dp
1258   ELSEIF (rcntrl(4)> zero)THEN
1259      facmin = rcntrl(4)
1260   ELSE
1261      PRINT *,'User-selected FacMin: RCNTRL(4) =',RCNTRL(4)
[3228]1262      CALL ros_errormsg(- 4, tstart, zero, ierr)
[2931]1263      RETURN
1264   ENDIF
1265   IF (rcntrl(5) == zero)THEN
1266      facmax = 6.0_dp
1267   ELSEIF (rcntrl(5)> zero)THEN
1268      facmax = rcntrl(5)
1269   ELSE
1270      PRINT *,'User-selected FacMax: RCNTRL(5) =',RCNTRL(5)
[3228]1271      CALL ros_errormsg(- 4, tstart, zero, ierr)
[2931]1272      RETURN
1273   ENDIF
1274!~~~>   facrej: factor to decrease step after 2 succesive rejections
1275   IF (rcntrl(6) == zero)THEN
1276      facrej = 0.1_dp
1277   ELSEIF (rcntrl(6)> zero)THEN
1278      facrej = rcntrl(6)
1279   ELSE
1280      PRINT *,'User-selected FacRej: RCNTRL(6) =',RCNTRL(6)
[3228]1281      CALL ros_errormsg(- 4, tstart, zero, ierr)
[2931]1282      RETURN
1283   ENDIF
1284!~~~>   facsafe: safety factor in the computation of new step size
1285   IF (rcntrl(7) == zero)THEN
1286      facsafe = 0.9_dp
1287   ELSEIF (rcntrl(7)> zero)THEN
1288      facsafe = rcntrl(7)
1289   ELSE
1290      PRINT *,'User-selected FacSafe: RCNTRL(7) =',RCNTRL(7)
[3228]1291      CALL ros_errormsg(- 4, tstart, zero, ierr)
[2931]1292      RETURN
1293   ENDIF
1294!~~~>  check IF tolerances are reasonable
[3228]1295    DO i=1, uplimtol
1296      IF ((abstol(i)<= zero).or. (reltol(i)<= 10.0_dp* roundoff)&
[2931]1297         .or. (reltol(i)>= 1.0_dp))THEN
1298        PRINT *,' AbsTol(',i,') = ',AbsTol(i)
1299        PRINT *,' RelTol(',i,') = ',RelTol(i)
[3228]1300        CALL ros_errormsg(- 5, tstart, zero, ierr)
[2931]1301        RETURN
1302      ENDIF
1303    ENDDO
1304
1305
1306!~~~>  CALL rosenbrock method
[3228]1307   CALL ros_integrator(y, tstart, tend, texit,  &
1308        abstol, reltol,                         &
[2931]1309!  Integration parameters
[3228]1310        autonomous, vectortol, max_no_steps,    &
1311        roundoff, hmin, hmax, hstart,           &
1312        facmin, facmax, facrej, facsafe,        &
[2931]1313!  Error indicator
1314        ierr)
1315
1316!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1317CONTAINS !  SUBROUTINEs internal to rosenbrock
1318!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1319   
1320!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
[3228]1321 SUBROUTINE ros_errormsg(code, t, h, ierr)
[2931]1322!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
1323!    Handles all error messages
1324!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
1325 
[3228]1326   REAL(kind=dp), INTENT(IN):: t, h
1327   INTEGER, INTENT(IN) :: code
1328   INTEGER, INTENT(OUT):: ierr
[2931]1329   
1330   ierr = code
[3228]1331   print * , &
[2931]1332     'Forced exit from Rosenbrock due to the following error:' 
1333     
1334   select CASE (code)
[3228]1335    CASE (- 1) 
[2931]1336      PRINT *,'--> Improper value for maximal no of steps'
[3228]1337    CASE (- 2) 
[2931]1338      PRINT *,'--> Selected Rosenbrock method not implemented'
[3228]1339    CASE (- 3) 
[2931]1340      PRINT *,'--> Hmin/Hmax/Hstart must be positive'
[3228]1341    CASE (- 4) 
[2931]1342      PRINT *,'--> FacMin/FacMax/FacRej must be positive'
1343    CASE (- 5)
1344      PRINT *,'--> Improper tolerance values'
1345    CASE (- 6)
1346      PRINT *,'--> No of steps exceeds maximum bound'
1347    CASE (- 7)
1348      PRINT *,'--> Step size too small: T + 10*H = T',&
1349            ' or H < Roundoff'
[3228]1350    CASE (- 8) 
[2931]1351      PRINT *,'--> Matrix is repeatedly singular'
1352    CASE default
1353      PRINT *,'Unknown Error code: ',Code
1354   END select
1355   
[3228]1356   print * , "t=", t, "and h=", h
[2931]1357     
1358 END SUBROUTINE ros_errormsg
1359
1360!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[3228]1361 SUBROUTINE ros_integrator (y, tstart, tend, t, &
1362        abstol, reltol,                         &
[2931]1363!~~~> integration PARAMETERs
[3228]1364        autonomous, vectortol, max_no_steps,    &
1365        roundoff, hmin, hmax, hstart,           &
1366        facmin, facmax, facrej, facsafe,        &
[2931]1367!~~~> error indicator
1368        ierr)
1369!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1370!   Template for the implementation of a generic Rosenbrock method
1371!      defined by ros_S (no of stages)
1372!      and its coefficients ros_{A,C,M,E,Alpha,Gamma}
1373!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1374
1375
1376!~~~> input: the initial condition at tstart; output: the solution at t
[3228]1377   REAL(kind=dp), INTENT(INOUT):: y(n)
[2931]1378!~~~> input: integration interval
[3228]1379   REAL(kind=dp), INTENT(IN):: tstart, tend
1380!~~~> output: time at which the solution is RETURNed (t=tendIF success)
1381   REAL(kind=dp), INTENT(OUT)::  t
[2931]1382!~~~> input: tolerances
[3228]1383   REAL(kind=dp), INTENT(IN)::  abstol(n), reltol(n)
[2931]1384!~~~> input: integration PARAMETERs
[3228]1385   LOGICAL, INTENT(IN):: autonomous, vectortol
1386   REAL(kind=dp), INTENT(IN):: hstart, hmin, hmax
1387   INTEGER, INTENT(IN):: max_no_steps
1388   REAL(kind=dp), INTENT(IN):: roundoff, facmin, facmax, facrej, facsafe
[2931]1389!~~~> output: error indicator
[3228]1390   INTEGER, INTENT(OUT):: ierr
[2931]1391! ~~~~ Local variables
[3228]1392   REAL(kind=dp):: ynew(n), fcn0(n), fcn(n)
1393   REAL(kind=dp):: k(n* ros_s), dfdt(n)
[2931]1394#ifdef full_algebra   
[3228]1395   REAL(kind=dp):: jac0(n, n), ghimj(n, n)
[2931]1396#else
[3228]1397   REAL(kind=dp):: jac0(lu_nonzero), ghimj(lu_nonzero)
[2931]1398#endif
[3228]1399   REAL(kind=dp):: h, hnew, hc, hg, fac, tau
1400   REAL(kind=dp):: err, yerr(n)
1401   INTEGER :: pivot(n), direction, ioffset, j, istage
1402   LOGICAL :: rejectlasth, rejectmoreh, singular
[2931]1403!~~~>  local PARAMETERs
[3228]1404   REAL(kind=dp), PARAMETER :: zero = 0.0_dp, one  = 1.0_dp
1405   REAL(kind=dp), PARAMETER :: deltamin = 1.0e-5_dp
[2931]1406!~~~>  locally called FUNCTIONs
1407!    REAL(kind=dp) WLAMCH
1408!    EXTERNAL WLAMCH
1409!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1410
1411
1412!~~~>  initial preparations
1413   t = tstart
1414   rstatus(nhexit) = zero
[3228]1415   h = min( max(abs(hmin), abs(hstart)), abs(hmax))
1416   IF (abs(h)<= 10.0_dp* roundoff)h = deltamin
[2931]1417
[3228]1418   IF (tend  >=  tstart)THEN
[2931]1419     direction = + 1
1420   ELSE
1421     direction = - 1
1422   ENDIF
[3228]1423   h = direction* h
[2931]1424
[3228]1425   rejectlasth=.FALSE.
1426   rejectmoreh=.FALSE.
[2931]1427
1428!~~~> time loop begins below
1429
[3228]1430timeloop: DO WHILE((direction > 0).and.((t- tend) + roundoff <= zero)&
1431       .or. (direction < 0).and.((tend-t) + roundoff <= zero))
[2931]1432
[3228]1433   IF (istatus(nstp)> max_no_steps)THEN  ! too many steps
1434      CALL ros_errormsg(- 6, t, h, ierr)
[2931]1435      RETURN
1436   ENDIF
[3228]1437   IF (((t+ 0.1_dp* h) == t).or.(h <= roundoff))THEN  ! step size too small
1438      CALL ros_errormsg(- 7, t, h, ierr)
[2931]1439      RETURN
1440   ENDIF
1441
1442!~~~>  limit h IF necessary to avoid going beyond tend
[3228]1443   h = min(h, abs(tend-t))
[2931]1444
1445!~~~>   compute the FUNCTION at current time
[3228]1446   CALL funtemplate(t, y, fcn0)
1447   istatus(nfun) = istatus(nfun) + 1
[2931]1448
1449!~~~>  compute the FUNCTION derivative with respect to t
1450   IF (.not.autonomous)THEN
[3228]1451      CALL ros_funtimederivative(t, roundoff, y, &
1452                fcn0, dfdt)
[2931]1453   ENDIF
1454
1455!~~~>   compute the jacobian at current time
[3228]1456   CALL jactemplate(t, y, jac0)
1457   istatus(njac) = istatus(njac) + 1
[2931]1458
1459!~~~>  repeat step calculation until current step accepted
1460untilaccepted: do
1461
[3228]1462   CALL ros_preparematrix(h, direction, ros_gamma(1), &
1463          jac0, ghimj, pivot, singular)
[2931]1464   IF (singular)THEN ! more than 5 consecutive failed decompositions
[3228]1465       CALL ros_errormsg(- 8, t, h, ierr)
[2931]1466       RETURN
1467   ENDIF
1468
1469!~~~>   compute the stages
[3228]1470stage: DO istage = 1, ros_s
[2931]1471
1472      ! current istage offset. current istage vector is k(ioffset+ 1:ioffset+ n)
[3228]1473       ioffset = n* (istage-1)
[2931]1474
1475      ! for the 1st istage the FUNCTION has been computed previously
[3228]1476       IF (istage == 1)THEN
1477         !slim: CALL wcopy(n, fcn0, 1, fcn, 1)
[3249]1478       fcn(1:n) = fcn0(1:n)
[2931]1479      ! istage>1 and a new FUNCTION evaluation is needed at the current istage
1480       ELSEIF(ros_newf(istage))THEN
[3228]1481         !slim: CALL wcopy(n, y, 1, ynew, 1)
[3249]1482       ynew(1:n) = y(1:n)
[3228]1483         DO j = 1, istage-1
1484           CALL waxpy(n, ros_a((istage-1) * (istage-2) /2+ j), &
1485            k(n* (j- 1) + 1), 1, ynew, 1)
[2931]1486         ENDDO
[3228]1487         tau = t + ros_alpha(istage) * direction* h
1488         CALL funtemplate(tau, ynew, fcn)
1489         istatus(nfun) = istatus(nfun) + 1
[2931]1490       ENDIF ! IF istage == 1 ELSEIF ros_newf(istage)
[3228]1491       !slim: CALL wcopy(n, fcn, 1, k(ioffset+ 1), 1)
[2931]1492       k(ioffset+ 1:ioffset+ n) = fcn(1:n)
[3228]1493       DO j = 1, istage-1
1494         hc = ros_c((istage-1) * (istage-2) /2+ j) /(direction* h)
1495         CALL waxpy(n, hc, k(n* (j- 1) + 1), 1, k(ioffset+ 1), 1)
[2931]1496       ENDDO
1497       IF ((.not. autonomous).and.(ros_gamma(istage).ne.zero))THEN
[3228]1498         hg = direction* h* ros_gamma(istage)
1499         CALL waxpy(n, hg, dfdt, 1, k(ioffset+ 1), 1)
[2931]1500       ENDIF
[3228]1501       CALL ros_solve(ghimj, pivot, k(ioffset+ 1))
[2931]1502
1503   END DO stage
1504
1505
1506!~~~>  compute the new solution
[3228]1507   !slim: CALL wcopy(n, y, 1, ynew, 1)
[2931]1508   ynew(1:n) = y(1:n)
[3228]1509   DO j=1, ros_s
1510         CALL waxpy(n, ros_m(j), k(n* (j- 1) + 1), 1, ynew, 1)
[2931]1511   ENDDO
1512
1513!~~~>  compute the error estimation
[3228]1514   !slim: CALL wscal(n, zero, yerr, 1)
[2931]1515   yerr(1:n) = zero
[3228]1516   DO j=1, ros_s
1517        CALL waxpy(n, ros_e(j), k(n* (j- 1) + 1), 1, yerr, 1)
[2931]1518   ENDDO
[3228]1519   err = ros_errornorm(y, ynew, yerr, abstol, reltol, vectortol)
[2931]1520
1521!~~~> new step size is bounded by facmin <= hnew/h <= facmax
[3228]1522   fac  = min(facmax, max(facmin, facsafe/err** (one/ros_elo)))
1523   hnew = h* fac
[2931]1524
1525!~~~>  check the error magnitude and adjust step size
[3228]1526   istatus(nstp) = istatus(nstp) + 1
1527   IF ((err <= one).or.(h <= hmin))THEN  !~~~> accept step
1528      istatus(nacc) = istatus(nacc) + 1
1529      !slim: CALL wcopy(n, ynew, 1, y, 1)
[2931]1530      y(1:n) = ynew(1:n)
[3228]1531      t = t + direction* h
1532      hnew = max(hmin, min(hnew, hmax))
[2931]1533      IF (rejectlasth)THEN  ! no step size increase after a rejected step
[3228]1534         hnew = min(hnew, h)
[2931]1535      ENDIF
1536      rstatus(nhexit) = h
1537      rstatus(nhnew) = hnew
1538      rstatus(ntexit) = t
[3228]1539      rejectlasth = .FALSE.
1540      rejectmoreh = .FALSE.
[2931]1541      h = hnew
1542      exit untilaccepted ! exit the loop: WHILE step not accepted
1543   ELSE           !~~~> reject step
1544      IF (rejectmoreh)THEN
[3228]1545         hnew = h* facrej
[2931]1546      ENDIF
1547      rejectmoreh = rejectlasth
[3228]1548      rejectlasth = .TRUE.
[2931]1549      h = hnew
[3228]1550      IF (istatus(nacc)>= 1) istatus(nrej) = istatus(nrej) + 1
[2931]1551   ENDIF ! err <= 1
1552
1553   END DO untilaccepted
1554
1555   END DO timeloop
1556
1557!~~~> succesful exit
1558   ierr = 1  !~~~> the integration was successful
1559
1560  END SUBROUTINE ros_integrator
1561
1562
1563!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[3228]1564  REAL(kind=dp)FUNCTION ros_errornorm(y, ynew, yerr, &
1565                               abstol, reltol, vectortol)
[2931]1566!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1567!~~~> computes the "scaled norm" of the error vector yerr
1568!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1569
1570! Input arguments
[3228]1571   REAL(kind=dp), INTENT(IN):: y(n), ynew(n), &
1572          yerr(n), abstol(n), reltol(n)
1573   LOGICAL, INTENT(IN)::  vectortol
[2931]1574! Local variables
[3228]1575   REAL(kind=dp):: err, scale, ymax
[2931]1576   INTEGER  :: i
[3228]1577   REAL(kind=dp), PARAMETER :: zero = 0.0_dp
[2931]1578
1579   err = zero
[3228]1580   DO i=1, n
1581     ymax = max(abs(y(i)), abs(ynew(i)))
[2931]1582     IF (vectortol)THEN
[3228]1583       scale = abstol(i) + reltol(i) * ymax
[2931]1584     ELSE
[3228]1585       scale = abstol(1) + reltol(1) * ymax
[2931]1586     ENDIF
[3228]1587     err = err+ (yerr(i) /scale) ** 2
[2931]1588   ENDDO
1589   err  = sqrt(err/n)
1590
[3228]1591   ros_errornorm = max(err, 1.0d-10)
[2931]1592
1593  END FUNCTION ros_errornorm
1594
1595
1596!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[3228]1597  SUBROUTINE ros_funtimederivative(t, roundoff, y, &
1598                fcn0, dfdt)
[2931]1599!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1600!~~~> the time partial derivative of the FUNCTION by finite differences
1601!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1602
1603!~~~> input arguments
[3228]1604   REAL(kind=dp), INTENT(IN):: t, roundoff, y(n), fcn0(n)
[2931]1605!~~~> output arguments
[3228]1606   REAL(kind=dp), INTENT(OUT):: dfdt(n)
[2931]1607!~~~> local variables
1608   REAL(kind=dp):: delta
[3228]1609   REAL(kind=dp), PARAMETER :: one = 1.0_dp, deltamin = 1.0e-6_dp
[2931]1610
[3228]1611   delta = sqrt(roundoff) * max(deltamin, abs(t))
1612   CALL funtemplate(t+ delta, y, dfdt)
1613   istatus(nfun) = istatus(nfun) + 1
1614   CALL waxpy(n, (- one), fcn0, 1, dfdt, 1)
1615   CALL wscal(n, (one/delta), dfdt, 1)
[2931]1616
1617  END SUBROUTINE ros_funtimederivative
1618
1619
1620!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[3228]1621  SUBROUTINE ros_preparematrix(h, direction, gam, &
1622             jac0, ghimj, pivot, singular)
[2931]1623! --- --- --- --- --- --- --- --- --- --- --- --- ---
1624!  Prepares the LHS matrix for stage calculations
1625!  1.  Construct Ghimj = 1/(H*ham) - Jac0
1626!      "(Gamma H) Inverse Minus Jacobian"
1627!  2.  Repeat LU decomposition of Ghimj until successful.
1628!       -half the step size if LU decomposition fails and retry
1629!       -exit after 5 consecutive fails
1630! --- --- --- --- --- --- --- --- --- --- --- --- ---
1631
1632!~~~> input arguments
1633#ifdef full_algebra   
[3228]1634   REAL(kind=dp), INTENT(IN)::  jac0(n, n)
[2931]1635#else
[3228]1636   REAL(kind=dp), INTENT(IN)::  jac0(lu_nonzero)
[2931]1637#endif   
[3228]1638   REAL(kind=dp), INTENT(IN)::  gam
1639   INTEGER, INTENT(IN)::  direction
[2931]1640!~~~> output arguments
1641#ifdef full_algebra   
[3228]1642   REAL(kind=dp), INTENT(OUT):: ghimj(n, n)
[2931]1643#else
[3228]1644   REAL(kind=dp), INTENT(OUT):: ghimj(lu_nonzero)
[2931]1645#endif   
[3228]1646   LOGICAL, INTENT(OUT)::  singular
1647   INTEGER, INTENT(OUT)::  pivot(n)
[2931]1648!~~~> inout arguments
[3228]1649   REAL(kind=dp), INTENT(INOUT):: h   ! step size is decreased when lu fails
[2931]1650!~~~> local variables
[3228]1651   INTEGER  :: i, ising, nconsecutive
[2931]1652   REAL(kind=dp):: ghinv
[3228]1653   REAL(kind=dp), PARAMETER :: one  = 1.0_dp, half = 0.5_dp
[2931]1654
1655   nconsecutive = 0
[3228]1656   singular = .TRUE.
[2931]1657
1658   DO WHILE (singular)
1659
[3228]1660!~~~>    construct ghimj = 1/(h* gam) - jac0
[2931]1661#ifdef full_algebra   
[3228]1662     !slim: CALL wcopy(n* n, jac0, 1, ghimj, 1)
1663     !slim: CALL wscal(n* n, (- one), ghimj, 1)
[2931]1664     ghimj = - jac0
[3228]1665     ghinv = one/(direction* h* gam)
1666     DO i=1, n
1667       ghimj(i, i) = ghimj(i, i) + ghinv
[2931]1668     ENDDO
1669#else
[3228]1670     !slim: CALL wcopy(lu_nonzero, jac0, 1, ghimj, 1)
1671     !slim: CALL wscal(lu_nonzero, (- one), ghimj, 1)
[2931]1672     ghimj(1:lu_nonzero) = - jac0(1:lu_nonzero)
[3228]1673     ghinv = one/(direction* h* gam)
1674     DO i=1, n
1675       ghimj(lu_diag(i)) = ghimj(lu_diag(i)) + ghinv
[2931]1676     ENDDO
1677#endif   
1678!~~~>    compute lu decomposition
[3228]1679     CALL ros_decomp( ghimj, pivot, ising)
[2931]1680     IF (ising == 0)THEN
1681!~~~>    IF successful done
[3228]1682        singular = .FALSE.
[2931]1683     ELSE ! ising .ne. 0
1684!~~~>    IF unsuccessful half the step size; IF 5 consecutive fails THEN RETURN
[3228]1685        istatus(nsng) = istatus(nsng) + 1
[2931]1686        nconsecutive = nconsecutive+1
[3228]1687        singular = .TRUE.
[2931]1688        PRINT*,'Warning: LU Decomposition returned ISING = ',ISING
1689        IF (nconsecutive <= 5)THEN ! less than 5 consecutive failed decompositions
[3228]1690           h = h* half
[2931]1691        ELSE  ! more than 5 consecutive failed decompositions
1692           RETURN
1693        ENDIF  ! nconsecutive
1694      ENDIF    ! ising
1695
1696   END DO ! WHILE singular
1697
1698  END SUBROUTINE ros_preparematrix
1699
1700
1701!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[3228]1702  SUBROUTINE ros_decomp( a, pivot, ising)
[2931]1703!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1704!  Template for the LU decomposition
1705!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1706!~~~> inout variables
1707#ifdef full_algebra   
[3228]1708   REAL(kind=dp), INTENT(INOUT):: a(n, n)
[2931]1709#else   
[3228]1710   REAL(kind=dp), INTENT(INOUT):: a(lu_nonzero)
[2931]1711#endif
1712!~~~> output variables
[3228]1713   INTEGER, INTENT(OUT):: pivot(n), ising
[2931]1714
1715#ifdef full_algebra   
[3228]1716   CALL  dgetrf( n, n, a, n, pivot, ising)
[2931]1717#else   
[3228]1718   CALL kppdecomp(a, ising)
[2931]1719   pivot(1) = 1
1720#endif
[3228]1721   istatus(ndec) = istatus(ndec) + 1
[2931]1722
1723  END SUBROUTINE ros_decomp
1724
1725
1726!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[3228]1727  SUBROUTINE ros_solve( a, pivot, b)
[2931]1728!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1729!  Template for the forward/backward substitution (using pre-computed LU decomposition)
1730!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1731!~~~> input variables
1732#ifdef full_algebra   
[3228]1733   REAL(kind=dp), INTENT(IN):: a(n, n)
[2931]1734   INTEGER :: ising
1735#else   
[3228]1736   REAL(kind=dp), INTENT(IN):: a(lu_nonzero)
[2931]1737#endif
[3228]1738   INTEGER, INTENT(IN):: pivot(n)
[2931]1739!~~~> inout variables
[3228]1740   REAL(kind=dp), INTENT(INOUT):: b(n)
[2931]1741
1742#ifdef full_algebra   
1743   CALL  DGETRS( 'N',N ,1,A,N,Pivot,b,N,ISING)
[3228]1744   IF (info < 0)THEN
1745      print* , "error in dgetrs. ising=", ising
[2931]1746   ENDIF 
1747#else   
[3228]1748   CALL kppsolve( a, b)
[2931]1749#endif
1750
[3228]1751   istatus(nsol) = istatus(nsol) + 1
[2931]1752
1753  END SUBROUTINE ros_solve
1754
1755
1756
1757!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1758  SUBROUTINE ros2
1759!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1760! --- AN L-STABLE METHOD,2 stages,order 2
1761!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1762
1763   double precision g
1764
1765    g = 1.0_dp + 1.0_dp/sqrt(2.0_dp)
1766    rosmethod = rs2
1767!~~~> name of the method
1768    ros_Name = 'ROS-2'
1769!~~~> number of stages
1770    ros_s = 2
1771
1772!~~~> the coefficient matrices a and c are strictly lower triangular.
1773!   The lower triangular (subdiagonal) elements are stored in row-wise order:
1774!   A(2,1) = ros_A(1),A(3,1) =ros_A(2),A(3,2) =ros_A(3),etc.
1775!   The general mapping formula is:
1776!       A(i,j) = ros_A( (i-1)*(i-2)/2 + j)
1777!       C(i,j) = ros_C( (i-1)*(i-2)/2 + j)
1778
[3228]1779    ros_a(1) = (1.0_dp) /g
1780    ros_c(1) = (- 2.0_dp) /g
[2931]1781!~~~> does the stage i require a new FUNCTION evaluation (ros_newf(i) =true)
1782!   or does it re-use the function evaluation from stage i-1 (ros_NewF(i) =FALSE)
[3228]1783    ros_newf(1) = .TRUE.
1784    ros_newf(2) = .TRUE.
[2931]1785!~~~> m_i = coefficients for new step solution
[3228]1786    ros_m(1) = (3.0_dp) /(2.0_dp* g)
1787    ros_m(2) = (1.0_dp) /(2.0_dp* g)
[2931]1788! E_i = Coefficients for error estimator
[3228]1789    ros_e(1) = 1.0_dp/(2.0_dp* g)
1790    ros_e(2) = 1.0_dp/(2.0_dp* g)
1791!~~~> ros_elo = estimator of local order - the minimum between the
[2931]1792!    main and the embedded scheme orders plus one
1793    ros_elo = 2.0_dp
[3228]1794!~~~> y_stage_i ~ y( t + h* alpha_i)
[2931]1795    ros_alpha(1) = 0.0_dp
1796    ros_alpha(2) = 1.0_dp
[3228]1797!~~~> gamma_i = \sum_j  gamma_{i, j}
[2931]1798    ros_gamma(1) = g
[3228]1799    ros_gamma(2) = -g
[2931]1800
1801 END SUBROUTINE ros2
1802
1803
1804!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1805  SUBROUTINE ros3
1806!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1807! --- AN L-STABLE METHOD,3 stages,order 3,2 function evaluations
1808!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1809
1810   rosmethod = rs3
1811!~~~> name of the method
1812   ros_Name = 'ROS-3'
1813!~~~> number of stages
1814   ros_s = 3
1815
1816!~~~> the coefficient matrices a and c are strictly lower triangular.
1817!   The lower triangular (subdiagonal) elements are stored in row-wise order:
1818!   A(2,1) = ros_A(1),A(3,1) =ros_A(2),A(3,2) =ros_A(3),etc.
1819!   The general mapping formula is:
1820!       A(i,j) = ros_A( (i-1)*(i-2)/2 + j)
1821!       C(i,j) = ros_C( (i-1)*(i-2)/2 + j)
1822
1823   ros_a(1) = 1.0_dp
1824   ros_a(2) = 1.0_dp
1825   ros_a(3) = 0.0_dp
1826
1827   ros_c(1) = - 0.10156171083877702091975600115545e+01_dp
1828   ros_c(2) =  0.40759956452537699824805835358067e+01_dp
1829   ros_c(3) =  0.92076794298330791242156818474003e+01_dp
1830!~~~> does the stage i require a new FUNCTION evaluation (ros_newf(i) =true)
1831!   or does it re-use the function evaluation from stage i-1 (ros_NewF(i) =FALSE)
[3228]1832   ros_newf(1) = .TRUE.
1833   ros_newf(2) = .TRUE.
1834   ros_newf(3) = .FALSE.
[2931]1835!~~~> m_i = coefficients for new step solution
1836   ros_m(1) =  0.1e+01_dp
1837   ros_m(2) =  0.61697947043828245592553615689730e+01_dp
1838   ros_m(3) = - 0.42772256543218573326238373806514_dp
1839! E_i = Coefficients for error estimator
1840   ros_e(1) =  0.5_dp
1841   ros_e(2) = - 0.29079558716805469821718236208017e+01_dp
1842   ros_e(3) =  0.22354069897811569627360909276199_dp
[3228]1843!~~~> ros_elo = estimator of local order - the minimum between the
[2931]1844!    main and the embedded scheme orders plus 1
1845   ros_elo = 3.0_dp
[3228]1846!~~~> y_stage_i ~ y( t + h* alpha_i)
[2931]1847   ros_alpha(1) = 0.0_dp
1848   ros_alpha(2) = 0.43586652150845899941601945119356_dp
1849   ros_alpha(3) = 0.43586652150845899941601945119356_dp
[3228]1850!~~~> gamma_i = \sum_j  gamma_{i, j}
[2931]1851   ros_gamma(1) = 0.43586652150845899941601945119356_dp
1852   ros_gamma(2) = 0.24291996454816804366592249683314_dp
1853   ros_gamma(3) = 0.21851380027664058511513169485832e+01_dp
1854
1855  END SUBROUTINE ros3
1856
1857!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1858
1859
1860!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1861  SUBROUTINE ros4
1862!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1863!     L-STABLE ROSENBROCK METHOD OF ORDER 4,WITH 4 STAGES
1864!     L-STABLE EMBEDDED ROSENBROCK METHOD OF ORDER 3
1865!
1866!      E. HAIRER AND G. WANNER,SOLVING ORDINARY DIFFERENTIAL
1867!      EQUATIONS II. STIFF AND DIFFERENTIAL-ALGEBRAIC PROBLEMS.
1868!      SPRINGER SERIES IN COMPUTATIONAL MATHEMATICS,
1869!      SPRINGER-VERLAG (1990)
1870!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1871
1872
1873   rosmethod = rs4
1874!~~~> name of the method
1875   ros_Name = 'ROS-4'
1876!~~~> number of stages
1877   ros_s = 4
1878
1879!~~~> the coefficient matrices a and c are strictly lower triangular.
1880!   The lower triangular (subdiagonal) elements are stored in row-wise order:
1881!   A(2,1) = ros_A(1),A(3,1) =ros_A(2),A(3,2) =ros_A(3),etc.
1882!   The general mapping formula is:
1883!       A(i,j) = ros_A( (i-1)*(i-2)/2 + j)
1884!       C(i,j) = ros_C( (i-1)*(i-2)/2 + j)
1885
1886   ros_a(1) = 0.2000000000000000e+01_dp
1887   ros_a(2) = 0.1867943637803922e+01_dp
1888   ros_a(3) = 0.2344449711399156_dp
1889   ros_a(4) = ros_a(2)
1890   ros_a(5) = ros_a(3)
1891   ros_a(6) = 0.0_dp
1892
[3228]1893   ros_c(1) = -0.7137615036412310e+01_dp
[2931]1894   ros_c(2) = 0.2580708087951457e+01_dp
1895   ros_c(3) = 0.6515950076447975_dp
[3228]1896   ros_c(4) = -0.2137148994382534e+01_dp
1897   ros_c(5) = -0.3214669691237626_dp
1898   ros_c(6) = -0.6949742501781779_dp
[2931]1899!~~~> does the stage i require a new FUNCTION evaluation (ros_newf(i) =true)
1900!   or does it re-use the function evaluation from stage i-1 (ros_NewF(i) =FALSE)
[3228]1901   ros_newf(1) = .TRUE.
1902   ros_newf(2) = .TRUE.
1903   ros_newf(3) = .TRUE.
1904   ros_newf(4) = .FALSE.
[2931]1905!~~~> m_i = coefficients for new step solution
1906   ros_m(1) = 0.2255570073418735e+01_dp
1907   ros_m(2) = 0.2870493262186792_dp
1908   ros_m(3) = 0.4353179431840180_dp
1909   ros_m(4) = 0.1093502252409163e+01_dp
1910!~~~> e_i  = coefficients for error estimator
[3228]1911   ros_e(1) = -0.2815431932141155_dp
1912   ros_e(2) = -0.7276199124938920e-01_dp
1913   ros_e(3) = -0.1082196201495311_dp
1914   ros_e(4) = -0.1093502252409163e+01_dp
1915!~~~> ros_elo  = estimator of local order - the minimum between the
[2931]1916!    main and the embedded scheme orders plus 1
1917   ros_elo  = 4.0_dp
[3228]1918!~~~> y_stage_i ~ y( t + h* alpha_i)
[2931]1919   ros_alpha(1) = 0.0_dp
1920   ros_alpha(2) = 0.1145640000000000e+01_dp
1921   ros_alpha(3) = 0.6552168638155900_dp
1922   ros_alpha(4) = ros_alpha(3)
[3228]1923!~~~> gamma_i = \sum_j  gamma_{i, j}
[2931]1924   ros_gamma(1) = 0.5728200000000000_dp
[3228]1925   ros_gamma(2) = -0.1769193891319233e+01_dp
[2931]1926   ros_gamma(3) = 0.7592633437920482_dp
[3228]1927   ros_gamma(4) = -0.1049021087100450_dp
[2931]1928
1929  END SUBROUTINE ros4
1930
1931!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1932  SUBROUTINE rodas3
1933!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1934! --- A STIFFLY-STABLE METHOD,4 stages,order 3
1935!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1936
1937
1938   rosmethod = rd3
1939!~~~> name of the method
1940   ros_Name = 'RODAS-3'
1941!~~~> number of stages
1942   ros_s = 4
1943
1944!~~~> the coefficient matrices a and c are strictly lower triangular.
1945!   The lower triangular (subdiagonal) elements are stored in row-wise order:
1946!   A(2,1) = ros_A(1),A(3,1) =ros_A(2),A(3,2) =ros_A(3),etc.
1947!   The general mapping formula is:
1948!       A(i,j) = ros_A( (i-1)*(i-2)/2 + j)
1949!       C(i,j) = ros_C( (i-1)*(i-2)/2 + j)
1950
1951   ros_a(1) = 0.0_dp
1952   ros_a(2) = 2.0_dp
1953   ros_a(3) = 0.0_dp
1954   ros_a(4) = 2.0_dp
1955   ros_a(5) = 0.0_dp
1956   ros_a(6) = 1.0_dp
1957
1958   ros_c(1) = 4.0_dp
1959   ros_c(2) = 1.0_dp
[3228]1960   ros_c(3) = -1.0_dp
[2931]1961   ros_c(4) = 1.0_dp
[3228]1962   ros_c(5) = -1.0_dp
1963   ros_c(6) = -(8.0_dp/3.0_dp)
[2931]1964
1965!~~~> does the stage i require a new FUNCTION evaluation (ros_newf(i) =true)
1966!   or does it re-use the function evaluation from stage i-1 (ros_NewF(i) =FALSE)
[3228]1967   ros_newf(1) = .TRUE.
1968   ros_newf(2) = .FALSE.
1969   ros_newf(3) = .TRUE.
1970   ros_newf(4) = .TRUE.
[2931]1971!~~~> m_i = coefficients for new step solution
1972   ros_m(1) = 2.0_dp
1973   ros_m(2) = 0.0_dp
1974   ros_m(3) = 1.0_dp
1975   ros_m(4) = 1.0_dp
1976!~~~> e_i  = coefficients for error estimator
1977   ros_e(1) = 0.0_dp
1978   ros_e(2) = 0.0_dp
1979   ros_e(3) = 0.0_dp
1980   ros_e(4) = 1.0_dp
[3228]1981!~~~> ros_elo  = estimator of local order - the minimum between the
[2931]1982!    main and the embedded scheme orders plus 1
1983   ros_elo  = 3.0_dp
[3228]1984!~~~> y_stage_i ~ y( t + h* alpha_i)
[2931]1985   ros_alpha(1) = 0.0_dp
1986   ros_alpha(2) = 0.0_dp
1987   ros_alpha(3) = 1.0_dp
1988   ros_alpha(4) = 1.0_dp
[3228]1989!~~~> gamma_i = \sum_j  gamma_{i, j}
[2931]1990   ros_gamma(1) = 0.5_dp
1991   ros_gamma(2) = 1.5_dp
1992   ros_gamma(3) = 0.0_dp
1993   ros_gamma(4) = 0.0_dp
1994
1995  END SUBROUTINE rodas3
1996
1997!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1998  SUBROUTINE rodas4
1999!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2000!     STIFFLY-STABLE ROSENBROCK METHOD OF ORDER 4,WITH 6 STAGES
2001!
2002!      E. HAIRER AND G. WANNER,SOLVING ORDINARY DIFFERENTIAL
2003!      EQUATIONS II. STIFF AND DIFFERENTIAL-ALGEBRAIC PROBLEMS.
2004!      SPRINGER SERIES IN COMPUTATIONAL MATHEMATICS,
2005!      SPRINGER-VERLAG (1996)
2006!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2007
2008
2009    rosmethod = rd4
2010!~~~> name of the method
2011    ros_Name = 'RODAS-4'
2012!~~~> number of stages
2013    ros_s = 6
2014
[3228]2015!~~~> y_stage_i ~ y( t + h* alpha_i)
[2931]2016    ros_alpha(1) = 0.000_dp
2017    ros_alpha(2) = 0.386_dp
2018    ros_alpha(3) = 0.210_dp
2019    ros_alpha(4) = 0.630_dp
2020    ros_alpha(5) = 1.000_dp
2021    ros_alpha(6) = 1.000_dp
2022
[3228]2023!~~~> gamma_i = \sum_j  gamma_{i, j}
[2931]2024    ros_gamma(1) = 0.2500000000000000_dp
[3228]2025    ros_gamma(2) = -0.1043000000000000_dp
[2931]2026    ros_gamma(3) = 0.1035000000000000_dp
[3228]2027    ros_gamma(4) = -0.3620000000000023e-01_dp
[2931]2028    ros_gamma(5) = 0.0_dp
2029    ros_gamma(6) = 0.0_dp
2030
2031!~~~> the coefficient matrices a and c are strictly lower triangular.
2032!   The lower triangular (subdiagonal) elements are stored in row-wise order:
2033!   A(2,1) = ros_A(1),A(3,1) =ros_A(2),A(3,2) =ros_A(3),etc.
2034!   The general mapping formula is:  A(i,j) = ros_A( (i-1)*(i-2)/2 + j)
2035!                  C(i,j) = ros_C( (i-1)*(i-2)/2 + j)
2036
2037    ros_a(1) = 0.1544000000000000e+01_dp
2038    ros_a(2) = 0.9466785280815826_dp
2039    ros_a(3) = 0.2557011698983284_dp
2040    ros_a(4) = 0.3314825187068521e+01_dp
2041    ros_a(5) = 0.2896124015972201e+01_dp
2042    ros_a(6) = 0.9986419139977817_dp
2043    ros_a(7) = 0.1221224509226641e+01_dp
2044    ros_a(8) = 0.6019134481288629e+01_dp
2045    ros_a(9) = 0.1253708332932087e+02_dp
[3228]2046    ros_a(10) = -0.6878860361058950_dp
[2931]2047    ros_a(11) = ros_a(7)
2048    ros_a(12) = ros_a(8)
2049    ros_a(13) = ros_a(9)
2050    ros_a(14) = ros_a(10)
2051    ros_a(15) = 1.0_dp
2052
[3228]2053    ros_c(1) = -0.5668800000000000e+01_dp
2054    ros_c(2) = -0.2430093356833875e+01_dp
2055    ros_c(3) = -0.2063599157091915_dp
2056    ros_c(4) = -0.1073529058151375_dp
2057    ros_c(5) = -0.9594562251023355e+01_dp
2058    ros_c(6) = -0.2047028614809616e+02_dp
[2931]2059    ros_c(7) = 0.7496443313967647e+01_dp
[3228]2060    ros_c(8) = -0.1024680431464352e+02_dp
2061    ros_c(9) = -0.3399990352819905e+02_dp
[2931]2062    ros_c(10) = 0.1170890893206160e+02_dp
2063    ros_c(11) = 0.8083246795921522e+01_dp
[3228]2064    ros_c(12) = -0.7981132988064893e+01_dp
2065    ros_c(13) = -0.3152159432874371e+02_dp
[2931]2066    ros_c(14) = 0.1631930543123136e+02_dp
[3228]2067    ros_c(15) = -0.6058818238834054e+01_dp
[2931]2068
2069!~~~> m_i = coefficients for new step solution
2070    ros_m(1) = ros_a(7)
2071    ros_m(2) = ros_a(8)
2072    ros_m(3) = ros_a(9)
2073    ros_m(4) = ros_a(10)
2074    ros_m(5) = 1.0_dp
2075    ros_m(6) = 1.0_dp
2076
2077!~~~> e_i  = coefficients for error estimator
2078    ros_e(1) = 0.0_dp
2079    ros_e(2) = 0.0_dp
2080    ros_e(3) = 0.0_dp
2081    ros_e(4) = 0.0_dp
2082    ros_e(5) = 0.0_dp
2083    ros_e(6) = 1.0_dp
2084
2085!~~~> does the stage i require a new FUNCTION evaluation (ros_newf(i) =true)
2086!   or does it re-use the function evaluation from stage i-1 (ros_NewF(i) =FALSE)
[3228]2087    ros_newf(1) = .TRUE.
2088    ros_newf(2) = .TRUE.
2089    ros_newf(3) = .TRUE.
2090    ros_newf(4) = .TRUE.
2091    ros_newf(5) = .TRUE.
2092    ros_newf(6) = .TRUE.
[2931]2093
[3228]2094!~~~> ros_elo  = estimator of local order - the minimum between the
[2931]2095!        main and the embedded scheme orders plus 1
2096    ros_elo = 4.0_dp
2097
2098  END SUBROUTINE rodas4
2099!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2100  SUBROUTINE rang3
2101!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2102! STIFFLY-STABLE W METHOD OF ORDER 3,WITH 4 STAGES
2103!
2104! J. RANG and L. ANGERMANN
2105! NEW ROSENBROCK W-METHODS OF ORDER 3
2106! FOR PARTIAL DIFFERENTIAL ALGEBRAIC
2107!        EQUATIONS OF INDEX 1                                             
2108! BIT Numerical Mathematics (2005) 45: 761-787
2109!  DOI: 10.1007/s10543-005-0035-y
2110! Table 4.1-4.2
2111!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2112
2113
2114    rosmethod = rg3
2115!~~~> name of the method
2116    ros_Name = 'RANG-3'
2117!~~~> number of stages
2118    ros_s = 4
2119
2120    ros_a(1) = 5.09052051067020d+00;
2121    ros_a(2) = 5.09052051067020d+00;
2122    ros_a(3) = 0.0d0;
2123    ros_a(4) = 4.97628111010787d+00;
2124    ros_a(5) = 2.77268164715849d-02;
2125    ros_a(6) = 2.29428036027904d-01;
2126
2127    ros_c(1) = - 1.16790812312283d+01;
2128    ros_c(2) = - 1.64057326467367d+01;
2129    ros_c(3) = - 2.77268164715850d-01;
2130    ros_c(4) = - 8.38103960500476d+00;
2131    ros_c(5) = - 8.48328409199343d-01;
2132    ros_c(6) =  2.87009860433106d-01;
2133
2134    ros_m(1) =  5.22582761233094d+00;
2135    ros_m(2) = - 5.56971148154165d-01;
2136    ros_m(3) =  3.57979469353645d-01;
2137    ros_m(4) =  1.72337398521064d+00;
2138
2139    ros_e(1) = - 5.16845212784040d+00;
2140    ros_e(2) = - 1.26351942603842d+00;
2141    ros_e(3) = - 1.11022302462516d-16;
2142    ros_e(4) =  2.22044604925031d-16;
2143
2144    ros_alpha(1) = 0.0d00;
2145    ros_alpha(2) = 2.21878746765329d+00;
2146    ros_alpha(3) = 2.21878746765329d+00;
2147    ros_alpha(4) = 1.55392337535788d+00;
2148
2149    ros_gamma(1) =  4.35866521508459d-01;
2150    ros_gamma(2) = - 1.78292094614483d+00;
2151    ros_gamma(3) = - 2.46541900496934d+00;
2152    ros_gamma(4) = - 8.05529997906370d-01;
2153
2154
2155!~~~> does the stage i require a new FUNCTION evaluation (ros_newf(i) =true)
2156!   or does it re-use the function evaluation from stage i-1 (ros_NewF(i) =FALSE)
[3228]2157    ros_newf(1) = .TRUE.
2158    ros_newf(2) = .TRUE.
2159    ros_newf(3) = .TRUE.
2160    ros_newf(4) = .TRUE.
[2931]2161
[3228]2162!~~~> ros_elo  = estimator of local order - the minimum between the
[2931]2163!        main and the embedded scheme orders plus 1
2164    ros_elo = 3.0_dp
2165
2166  END SUBROUTINE rang3
2167!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2168
2169!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2170!   End of the set of internal Rosenbrock subroutines
2171!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2172END SUBROUTINE rosenbrock
2173 
[3228]2174SUBROUTINE funtemplate( t, y, ydot)
[2931]2175!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2176!  Template for the ODE function call.
2177!  Updates the rate coefficients (and possibly the fixed species) at each call
2178!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2179!~~~> input variables
[3228]2180   REAL(kind=dp):: t, y(nvar)
[2931]2181!~~~> output variables
2182   REAL(kind=dp):: ydot(nvar)
2183!~~~> local variables
2184   REAL(kind=dp):: told
2185
2186   told = time
2187   time = t
[3228]2188   CALL fun( y, fix, rconst, ydot)
[2931]2189   time = told
2190
2191END SUBROUTINE funtemplate
2192 
[3228]2193SUBROUTINE jactemplate( t, y, jcb)
[2931]2194!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2195!  Template for the ODE Jacobian call.
2196!  Updates the rate coefficients (and possibly the fixed species) at each call
2197!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2198!~~~> input variables
[3228]2199    REAL(kind=dp):: t, y(nvar)
[2931]2200!~~~> output variables
2201#ifdef full_algebra   
[3228]2202    REAL(kind=dp):: jv(lu_nonzero), jcb(nvar, nvar)
[2931]2203#else
2204    REAL(kind=dp):: jcb(lu_nonzero)
2205#endif   
2206!~~~> local variables
2207    REAL(kind=dp):: told
2208#ifdef full_algebra   
[3228]2209    INTEGER :: i, j
[2931]2210#endif   
2211
2212    told = time
2213    time = t
2214#ifdef full_algebra   
[3228]2215    CALL jac_sp(y, fix, rconst, jv)
2216    DO j=1, nvar
2217      DO i=1, nvar
2218         jcb(i, j) = 0.0_dp
[2931]2219      ENDDO
2220    ENDDO
[3228]2221    DO i=1, lu_nonzero
2222       jcb(lu_irow(i), lu_icol(i)) = jv(i)
[2931]2223    ENDDO
2224#else
[3228]2225    CALL jac_sp( y, fix, rconst, jcb)
[2931]2226#endif   
2227    time = told
2228
2229END SUBROUTINE jactemplate
2230 
[3228]2231  SUBROUTINE kppdecomp( jvs, ier)                                   
2232  ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2233  !        sparse lu factorization                                   
2234  ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2235  ! loop expansion generated by kp4                                   
2236                                                                     
2237    INTEGER  :: ier                                                   
[3789]2238    REAL(kind=dp):: jvs(lu_nonzero), a                         
[3228]2239                                                                     
2240    a = 0.                                                           
2241    ier = 0                                                           
2242                                                                     
2243!   i = 1
2244!   i = 2
2245    jvs(4) = (jvs(4)) / jvs(1) 
2246    jvs(5) = jvs(5) - jvs(2) * jvs(4)
2247    jvs(6) = jvs(6) - jvs(3) * jvs(4)
2248!   i = 3
2249    jvs(7) = (jvs(7)) / jvs(1) 
2250    a = 0.0; a = a  - jvs(2) * jvs(7)
2251    jvs(8) = (jvs(8) + a) / jvs(5) 
2252    jvs(9) = jvs(9) - jvs(3) * jvs(7) - jvs(6) * jvs(8)
2253    RETURN                                                           
2254                                                                     
2255  END SUBROUTINE kppdecomp                                           
2256 
[3780]2257SUBROUTINE get_mechanismname                                       
2258                                                                   
2259  IMPLICIT NONE                                                     
2260
2261! Set cs_mech for check with mechanism name from namelist
2262    cs_mech = 'phstat'
2263                                                                   
2264  RETURN                                                           
2265END SUBROUTINE get_mechanismname                                   
2266                                                                   
2267 
[3228]2268SUBROUTINE chem_gasphase_integrate (time_step_len, conc, tempi, qvapi, fakti, photo, ierrf, xnacc, xnrej, istatus, l_debug, pe, &
2269                     icntrl_i, rcntrl_i) 
[2931]2270                                                                   
2271  IMPLICIT NONE                                                     
2272                                                                   
[3228]2273  REAL(dp), INTENT(IN)                  :: time_step_len           
2274  REAL(dp), DIMENSION(:, :), INTENT(INOUT) :: conc                   
2275  REAL(dp), DIMENSION(:, :), INTENT(IN)   :: photo                   
2276  REAL(dp), DIMENSION(:), INTENT(IN)     :: tempi                   
2277  REAL(dp), DIMENSION(:), INTENT(IN)     :: qvapi                   
2278  REAL(dp), DIMENSION(:), INTENT(IN)     :: fakti                   
2279  INTEGER, INTENT(OUT), OPTIONAL        :: ierrf(:)               
2280  INTEGER, INTENT(OUT), OPTIONAL        :: xnacc(:)               
2281  INTEGER, INTENT(OUT), OPTIONAL        :: xnrej(:)               
2282  INTEGER, INTENT(INOUT), OPTIONAL      :: istatus(:)             
2283  INTEGER, INTENT(IN), OPTIONAL         :: pe                     
2284  LOGICAL, INTENT(IN), OPTIONAL         :: l_debug                 
2285  INTEGER, DIMENSION(nkppctrl), INTENT(IN), OPTIONAL  :: icntrl_i         
2286  REAL(dp), DIMENSION(nkppctrl), INTENT(IN), OPTIONAL  :: rcntrl_i         
[2931]2287                                                                   
2288  INTEGER                                 :: k   ! loop variable     
[3228]2289  REAL(dp)                               :: dt                     
2290  INTEGER, DIMENSION(20)                :: istatus_u               
2291  INTEGER                                :: ierr_u                 
2292  INTEGER                                :: vl_dim_lo               
[2931]2293                                                                   
2294                                                                   
[3228]2295  IF (PRESENT (istatus)) istatus = 0                             
2296  IF (PRESENT (icntrl_i)) icntrl  = icntrl_i                     
2297  IF (PRESENT (rcntrl_i)) rcntrl  = rcntrl_i                     
[2931]2298                                                                   
[3263]2299  vl_glo = size(tempi, 1)                                           
[3249]2300                                                                   
[3228]2301  vl_dim_lo = vl_dim                                               
2302  DO k=1, vl_glo, vl_dim_lo                                           
[2931]2303    is = k                                                         
[3228]2304    ie = min(k+ vl_dim_lo-1, vl_glo)                                 
2305    vl = ie-is+ 1                                                   
[2931]2306                                                                   
[3228]2307    c(:) = conc(is, :)                                           
[2931]2308                                                                   
[3228]2309    temp = tempi(is)                                             
[2931]2310                                                                   
[3228]2311    qvap = qvapi(is)                                             
[2931]2312                                                                   
[3228]2313    fakt = fakti(is)                                             
2314                                                                   
2315    CALL initialize                                                 
2316                                                                   
2317    phot(:) = photo(is, :)                                           
2318                                                                   
[2931]2319    CALL update_rconst                                             
2320                                                                   
2321    dt = time_step_len                                             
2322                                                                   
2323    ! integrate from t=0 to t=dt                                   
[3228]2324    CALL integrate(0._dp, dt, icntrl, rcntrl, istatus_u = istatus_u, ierr_u=ierr_u)
[2931]2325                                                                   
2326                                                                   
[3228]2327   IF (PRESENT(l_debug) .AND. PRESENT(pe)) THEN                       
[3789]2328      IF (l_debug) CALL error_output(conc(is, :), ierr_u, pe)           
[3228]2329   ENDIF                                                             
2330                                                                     
2331    conc(is, :) = c(:)                                               
[2931]2332                                                                   
[3228]2333    ! RETURN diagnostic information                                 
[2931]2334                                                                   
[3228]2335    IF (PRESENT(ierrf))   ierrf(is) = ierr_u                     
2336    IF (PRESENT(xnacc))   xnacc(is) = istatus_u(4)               
2337    IF (PRESENT(xnrej))   xnrej(is) = istatus_u(5)               
[2931]2338                                                                   
[3228]2339    IF (PRESENT (istatus)) THEN                                   
2340      istatus(1:8) = istatus(1:8) + istatus_u(1:8)               
[2931]2341    ENDIF                                                         
2342                                                                   
2343  END DO                                                           
2344 
2345                                                                   
2346! Deallocate input arrays                                           
2347                                                                   
2348                                                                   
[3228]2349  data_loaded = .FALSE.                                             
[2931]2350                                                                   
2351  RETURN                                                           
[3780]2352END SUBROUTINE chem_gasphase_integrate                             
[2931]2353
2354END MODULE chem_gasphase_mod
2355 
Note: See TracBrowser for help on using the repository browser.