Skip to content

Commit

Permalink
Note that ICNTRL/RCNTRL get handled differently in F90 and in C/Matlab
Browse files Browse the repository at this point in the history
Also updated ".. code-block ::F90" to ".. code-block:: fortran",
which is the proper value to render code with Fortran90 highlighting.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
  • Loading branch information
yantosca committed Jul 12, 2022
1 parent 6fcffe6 commit e2b2f22
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 27 deletions.
32 changes: 17 additions & 15 deletions docs/source/using_kpp/04_input_for_kpp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -454,14 +454,14 @@ example (described in :ref:`running-kpp-with-an-example-mechanism`),
:code:`C` has dimension :code:`NSPEC=7`. Using :command:`#DECLARE
SYMBOL` will generate the following code in :ref:`Global`:

.. code-block:: F90
.. code-block:: fortran
! C - Concentration of all species
REAL(kind=dp), TARGET :: C(NSPEC)
Whereas :command:`#DECLARE VALUE` will generate this code instead:

.. code-block:: F90
.. code-block:: fortran
! C - Concentration of all species
REAL(kind=dp), TARGET :: C(7)
Expand Down Expand Up @@ -528,7 +528,7 @@ any reaction. With :command:`#DUMMYINDEX OFF` (the default), those are
undefined variables. For example, if you frequently switch between
mechanisms with and without sulfuric acid, you can use this code:

.. code-block:: F90
.. code-block:: fortran
IF (ind_H2SO4=0) THEN
PRINT *, 'no H2SO4 in current mechanism'
Expand Down Expand Up @@ -852,7 +852,7 @@ F90_GLOBAL
This inline type can be used to declare global variables, e.g. for a
special rate coefficient:

.. code-block:: F90
.. code-block:: fortran
#INLINE F90_GLOBAL
REAL(dp) :: k_DMS_OH
Expand All @@ -866,7 +866,7 @@ If a large number of state variables needs to be held in inline code, or
require intermediate computation that may be repeated for many rate
coefficients, a derived type object should be used for efficiency, e.g.:

.. code-block:: F90
.. code-block:: fortran
#INLINE F90_GLOBAL
TYPE, PUBLIC :: ObjGlobal_t
Expand All @@ -880,7 +880,7 @@ This global variable :code:`ObjGlobal` can then be used globally in KPP.
Another way to avoid cluttering up the KPP input file is to
:code:`#include` a header file with global variables:

.. code-block:: F90
.. code-block:: fortran
#INLINE F90_GLOBAL
! Inline common variables into KPP_ROOT_Global.f90
Expand All @@ -898,7 +898,7 @@ F90_INIT
This inline type can be used to define initial values before the start of the
integration, e.g.:

.. code-block:: F90
.. code-block:: fortran
#INLINE F90_INIT
TSTART = (12.*3600.)
Expand All @@ -915,7 +915,7 @@ F90_RATES
This inline type can be used to add new subroutines to calculate rate
coefficients, e.g.:

.. code-block:: F90
.. code-block:: fortran
#INLINE F90_RATES
REAL FUNCTION k_SIV_H2O2(k_298,tdep,cHp,temp)
Expand All @@ -936,15 +936,15 @@ This inline type can be used to define time-dependent values of rate
coefficients. You may inline :code:`USE` statements that reference
modules where rate coefficients are computed, e.g.:

.. code-block:: F90
.. code-block:: fortran
#INLINE F90_RCONST
USE MyRateFunctionModule
#ENDINLINE
or define variables directly, e.g.:

.. code-block:: F90
.. code-block:: fortran
#INLINE F90_RCONST
k_DMS_OH = 1.E-9*EXP(5820./temp)*C(ind_O2)/ &
Expand Down Expand Up @@ -986,21 +986,21 @@ select the correct declaration type. For example if one needs to
declare an array BIG of size 1000, a declaration like the following
must be used:

.. code-block:: F90
.. code-block:: fortran
KPP_REAL :: BIG(1000)
When used with the command :command:`#DOUBLE ON`, the above line will be
automatically translated into:

.. code-block:: F90
.. code-block:: fortran
REAL(kind=dp) :: BIG(1000)
and when used with the command :command:`#DOUBLE OFF`, the same line will
become:

.. code-block:: F90
.. code-block:: fortran
REAL(kind=sp) :: BIG(1000)
Expand All @@ -1010,13 +1010,13 @@ in the resulting Fortran90 output file.
description file. In our example where we are processing
:file:`small_strato.kpp`, a line in an auxiliary Fortran90 file like

.. code-block:: F90
.. code-block:: fortran
USE KPP_ROOT_Monitor
will be translated into

.. code-block:: F90
.. code-block:: fortran
USE small_strato_Monitor
Expand Down Expand Up @@ -1101,6 +1101,8 @@ List of symbols replaced by the substitution preprocessor
| | called | |
+--------------------------+-------------------------------+----------------------------+

.. _icntrl-rcntrl:

=================================================================
Controlling the Integrator with :code:`ICNTRL` and :code:`RCNTRL`
=================================================================
Expand Down
39 changes: 27 additions & 12 deletions docs/source/using_kpp/05_output_from_kpp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Fortran90 code uses parameterized real
types. :file:`ROOT_Precision.f90` (or :file:`.F90`) contains the
following real kind definitions:

.. code-block:: F90
.. code-block:: fortran
! KPP_SP - Single precision kind
INTEGER, PARAMETER :: &
Expand Down Expand Up @@ -211,13 +211,13 @@ KPP orders the variable species such that the sparsity pattern of the
Jacobian is maintained after an LU decomposition. For our example there
are five variable species (:code:`NVAR = 5`) ordered as

.. code-block:: F90
.. code-block:: fortran
ind_O1D=1, ind_O=2, ind_O3=3, ind_NO=4, ind_NO2=5
and two fixed species (:code:`NFIX = 2`)

.. code-block:: F90
.. code-block:: fortran
ind_M = 6, ind_O2 = 7.
Expand Down Expand Up @@ -279,7 +279,7 @@ of species is the sum of the :code:`NVAR` and :code:`NFIX`. The parts
can also be accessed separately through pointer variables :code:`VAR` and
:code:`FIX`, which point to the proper elements in :code:`C`.

.. code-block:: F90
.. code-block:: fortran
VAR(1:NVAR) => C(1:NVAR)
FIX(1:NFIX) => C(NVAR+1:NSPEC)
Expand Down Expand Up @@ -338,7 +338,7 @@ argument :code:`Aout`. Below is the Fortran90
code generated by KPP for the ODE function of our
:program:`small_strato` example.

.. code-block:: F90
.. code-block:: fortran
SUBROUTINE Fun (V, F, RCT, Vdot, Aout, Vdotout )
Expand Down Expand Up @@ -464,7 +464,7 @@ the Jacobian entry in row :code:`LU_IROW(K)` and column
:code:`LU_ICOL(K`). For the :program:`small_strato` example KPP
generates the following Jacobian sparse data structure:

.. code-block:: F90
.. code-block:: fortran
LU_ICOL = (/ 1,3,1,2,3,5,1,2,3,4, &
5,2,3,4,5,2,3,4,5 /)
Expand Down Expand Up @@ -738,7 +738,7 @@ compressed sparse format, as shown in :ref:`table-hess-fun`. The
parameter :code:`NJVRP` holds the number of nonzero elements. For our
:program:`small_strato` example:

.. code-block:: F90
.. code-block:: fortran
NJVRP = 13
CROW_JVRP = (/ 1,1,2,3,5,6,7,9,11,13,14 /)
Expand Down Expand Up @@ -898,13 +898,20 @@ compiler options.
The C code
==========

The driver file :file:`ROOT.c` contains the main (driver) and
.. important::

Some run-time options for C-language integrators (specified in
the :ref:`ICNTRL and RCNTRL arrays <icntrl-rcntrl>`) do not exactly
correspond to the Fortran90 run-time options. We will standardize
run-time integrator options across all target languages in a future
KPP release.

The driver file :file:`ROOT.c` contains the main (driver) program and
numerical integrator functions, as well as declarations and
initializations of global variables.

The generated C code includes
three header files which are :code:`#include`-d in other files as
appropriate.

The generated C code includes three header files which are
:code:`#include`-d in other files as appropriate.

#. The global parameters (cf. :ref:`table-par`) are :code:`#include`-d in
the header file :file:`ROOT_Parameters.h`
Expand Down Expand Up @@ -954,6 +961,14 @@ function, Jacobian, and Hessian to be called directly from Matlab
The Matlab code
===============

.. important::

Some run-time options for Matlab-language integrators (specified in
the :ref:`ICNTRL and RCNTRL arrays <icntrl-rcntrl>`) do not exactly
correspond to the Fortran90 run-time options. We will standardize
run-time integrator options across all target languages in a future
KPP release.

`Matlab <http://www.mathworks.com/products/matlab/>`_ provides a
high-level programming environment that allows algorithm development,
numerical computations, and data analysis and visualization. The
Expand Down

0 comments on commit e2b2f22

Please sign in to comment.