Ignore:
Timestamp:
Oct 12, 2023, 10:30:22 AM (15 months ago)
Author:
slebonnois
Message:

BBT : Update for the titan microphysics and cloud model

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.TITAN/libf/muphytitan/mm_globals.f90

    r2242 r3083  
    1 ! Copyright 2013-2015,2017 Université de Reims Champagne-Ardenne
     1! Copyright 2013-2015,2017,2022 Université de Reims Champagne-Ardenne
    22! Contributor: J. Burgalat (GSMA, URCA)
    33! email of the author : jeremie.burgalat@univ-reims.fr
    4 ! 
     4!
    55! This software is a computer program whose purpose is to compute
    66! microphysics processes using a two-moments scheme.
    7 ! 
     7!
    88! This library is governed by the CeCILL-B license under French law and
    9 ! abiding by the rules of distribution of free software.  You can  use, 
     9! abiding by the rules of distribution of free software.  You can  use,
    1010! modify and/ or redistribute the software under the terms of the CeCILL-B
    1111! license as circulated by CEA, CNRS and INRIA at the following URL
    12 ! "http://www.cecill.info". 
    13 ! 
     12! "http://www.cecill.info".
     13!
    1414! As a counterpart to the access to the source code and  rights to copy,
    1515! modify and redistribute granted by the license, users are provided only
    1616! with a limited warranty  and the software's author,  the holder of the
    1717! economic rights,  and the successive licensors  have only  limited
    18 ! liability. 
    19 ! 
     18! liability.
     19!
    2020! In this respect, the user's attention is drawn to the risks associated
    2121! with loading,  using,  modifying and/or developing or reproducing the
     
    2525! professionals having in-depth computer knowledge. Users are therefore
    2626! encouraged to load and test the software's suitability as regards their
    27 ! requirements in conditions enabling the security of their systems and/or 
    28 ! data to be ensured and,  more generally, to use and operate it in the 
    29 ! same conditions as regards security. 
    30 ! 
     27! requirements in conditions enabling the security of their systems and/or
     28! data to be ensured and,  more generally, to use and operate it in the
     29! same conditions as regards security.
     30!
    3131! The fact that you are presently reading this means that you have had
    3232! knowledge of the CeCILL-B license and that you accept its terms.
     
    3535!! summary: Parameters and global variables module.
    3636!! author: J. Burgalat
    37 !! date: 2013-2015,2017
     37!! date: 2013-2015,2017,2022
    3838
    3939MODULE MM_GLOBALS
    4040  !! Parameters and global variables module.
    41   !! 
     41  !!
    4242  !! # Module overview
    4343  !!
    4444  !! The module defines all the parameters and global variables that are common
    4545  !! to all other modules of the library.
    46   !! 
     46  !!
    4747  !! It is separated in two parts :
    4848  !!
     
    5252  !!   method.
    5353  !! - The second part defines a set of vectors that defines the vertical structure of the atmosphere.
    54   !!   Each time a new atmospheric column has to be computed (either on a new timestep or on a new couple 
    55   !!   of longitude/latitude), these vectors should be intialized with new values by calling 
    56   !!   [[mm_globals(module):mm_column_init(function)]] method. 
    57   !!   This part is separated in two sets : 
    58   !!
    59   !!   - The atmospheric structure with temperature, pressure levels and altitude definitions. 
    60   !!   - The vertical profiles of tracers with the moments of the two aerosols modes (both \(M_{0}\) 
    61   !!     and \(M_{3}\) for a total of 4 vectors), the _clouds_ microphysics moments tracers (i.e. 
     54  !!   Each time a new atmospheric column has to be computed (either on a new timestep or on a new couple
     55  !!   of longitude/latitude), these vectors should be intialized with new values by calling
     56  !!   [[mm_globals(module):mm_column_init(function)]] method.
     57  !!   This part is separated in two sets :
     58  !!
     59  !!   - The atmospheric structure with temperature, pressure levels and altitude definitions.
     60  !!   - The vertical profiles of tracers with the moments of the two aerosols modes (both \(M_{0}\)
     61  !!     and \(M_{3}\) for a total of 4 vectors), the _clouds_ microphysics moments tracers (i.e.
    6262  !!     \(M_{0}\) and \(M_{3}\) for the ccn and \(M_{3}\) for the ice components).
    63   !!     Additionally, the module also stores intermediates variables of interest such as the 
    64   !!     characteristic radii of the aerosols modes, the mean drop radius and the drop density, 
     63  !!     Additionally, the module also stores intermediates variables of interest such as the
     64  !!     characteristic radii of the aerosols modes, the mean drop radius and the drop density,
    6565  !!     the molar fraction of each condensible species (related to ice components) and some
    6666  !!     scalar variables that holds arrays sizes.
    6767  !!
    6868  !! @note
    69   !! All the vectors that represent the vertical structure of the atmosphere (altitude, pressure and 
     69  !! All the vectors that represent the vertical structure of the atmosphere (altitude, pressure and
    7070  !! temperature...) are oriented from the __TOP__ of the atmosphere to the __GROUND__.
    7171  !!
    72   !! @note 
    73   !! The module also imports errors module from __FCCP__ library to get definitions of the error object
     72  !! @note
     73  !! The module also imports errors module from __SWIFT__ library to get definitions of the error object
    7474  !! everywhere in the library ([[mm_globals(module)]] is always imported, except in [[mm_mprec(module)]]).
    7575  !!
    76   !! # Global variables 
     76  !! # Global variables
    7777  !!
    7878  !! [[mm_globals(module)]] module contains the declaration of all global/common variable that are shared
     
    8282  !! the following sections list all the global variables by category.
    8383  !!
    84   !! ## Control flags 
    85   !! 
     84  !! ## Control flags
     85  !!
    8686  !! | Name               | Description
    8787  !! | :----------------- | :-----------------
     
    9393  !! | mm_w_clouds_sed    | Enable/Disable clouds microphysics sedimentation
    9494  !! | mm_w_clouds_nucond | Enable/Disable clouds microphysics nucleation/condensation
    95   !! | mm_wsed_m0         | Force all aerosols moments to fall at M0 settling velocity 
     95  !! | mm_wsed_m0         | Force all aerosols moments to fall at M0 settling velocity
    9696  !! | mm_wsed_m3         | Force all aerosols moments to fall at M3 settling velocity
    9797  !! | mm_no_fiadero_w    | Enable/Disable __Fiadero__ correction
     
    101101  !! | Name            | Description
    102102  !! | :-------------- | :-----------------
    103   !! | mm_fiadero_min  | Minimum ratio for __Fiadero__'s correction 
     103  !! | mm_fiadero_min  | Minimum ratio for __Fiadero__'s correction
    104104  !! | mm_fiadero_max  | Maximum ratio for __Fiadero__'s correction
    105   !! | mm_coag_choice  | Coagulation interaction activation flag. It should be a combination of [[mm_globals(module):mm_coag_no(variable)]], [[mm_globals(module):mm_coag_ss(variable)]], [[mm_globals(module):mm_coag_sf(variable)]] and [[mm_globals(module):mm_coag_ff(variable)]]. 
    106   !!
    107   !! ## Physical constants 
     105  !! | mm_coag_choice  | Coagulation interaction activation flag. It should be a combination of [[mm_globals(module):mm_coag_no(variable)]], [[mm_globals(module):mm_coag_ss(variable)]], [[mm_globals(module):mm_coag_sf(variable)]] and [[mm_globals(module):mm_coag_ff(variable)]].
     106  !!
     107  !! ## Physical constants
    108108  !!
    109109  !! | Name      | Description
     
    131131  !! | mm_w_prod   | Angular frequency of the time-dependent production rate.
    132132  !! | mm_ne       | Electric charging of aerosols (\(e^{-}.m^{-1}\)) (unused)
    133   !! | mm_rb2ra    | Bulk to apparent radius conversion pre-factor (\(m^X\)) 
     133  !! | mm_rb2ra    | Bulk to apparent radius conversion pre-factor (\(m^X\))
    134134  !! | mm_rpla     | Planet radius (m)
    135135  !! | mm_g0       | Planet acceleration due to gravity constant (ground) (\(m.s^{-2}\))
     
    152152  ! the following variables are read-only outside this module.
    153153  ! One must call the afferent subroutine to update them.
    154    
     154
    155155  ! initialization control flags (cannot be updated)
    156156  PROTECTED :: mm_ini,mm_ini_col,mm_ini_aer,mm_ini_cld
     
    165165  ! Moments parameters (derived, are updated with moments parameters)
    166166  PROTECTED :: mm_rcs, mm_rcf, mm_drad, mm_drho
    167 
    168   LOGICAL, SAVE :: mm_debug = .true.  !! Enable QnD debug mode (can be used for devel).
    169   LOGICAL, SAVE :: mm_log = .false.   !! Enable log mode (for configuration only).
     167  ! Thresholds parameters
     168  PROTECTED :: mm_m0as_min, mm_m3as_min, mm_rcs_min, mm_m0af_min, mm_m3af_min, mm_rcf_min, mm_m0n_min, mm_m3cld_min
     169
     170  LOGICAL, SAVE :: mm_debug = .false.  !! Enable QnD debug mode (can be used for devel).
     171  LOGICAL, SAVE :: mm_log   = .false.   !! Enable log mode (for configuration only).
    170172
    171173  LOGICAL, SAVE :: mm_w_haze_prod = .true. !! Enable/Disable haze production.
     
    182184  !> Enable/Disable __Fiadero__'s correction.
    183185  !!
    184   !! This flag enables/disables the __Fiadero__ correction alogrithm for fractal mode settling velocity 
    185   !! computation. 
     186  !! This flag enables/disables the __Fiadero__ correction alogrithm for fractal mode settling velocity
     187  !! computation.
    186188  !!
    187189  !! @bug
    188   !! Currently, the Fiadero correction creates instatibilities on the vertical structure. It seems to be 
     190  !! Currently, the Fiadero correction creates instatibilities on the vertical structure. It seems to be
    189191  !! related to the coupling between the two moments. In order to reduce the instabilities, settling
    190192  !! velocity of moments are forced to be the same, see [[mm_globals(module):mm_wsed_m0(variable)]] and
    191193  !! [[mm_globals(module):mm_wsed_m3(variable)]]).
    192   LOGICAL, SAVE          :: mm_no_fiadero_w = .false. 
     194  LOGICAL, SAVE          :: mm_no_fiadero_w = .false.
    193195
    194196  !> Minimum ratio for __Fiadero__ correction.
    195197  !!
    196   !! When [[mm_globals(module):mm_no_fiadero_w(variable)]] is disabled, this variable defines the minimum 
     198  !! When [[mm_globals(module):mm_no_fiadero_w(variable)]] is disabled, this variable defines the minimum
    197199  !! value of the moment's ratio between two adjacents vertical cells to be used within the correction.
    198200  REAL(kind=mm_wp), SAVE :: mm_fiadero_min  = 0.1_mm_wp
     
    200202  !> Maximum ratio for __Fiadero__ correction.
    201203  !!
    202   !! When [[mm_globals(module):mm_no_fiadero_w(variable)]] is disabled, this variable defines the maximum 
     204  !! When [[mm_globals(module):mm_no_fiadero_w(variable)]] is disabled, this variable defines the maximum
    203205  !! value of the moment's ratio between two adjacents vertical cells to be used within the correction.
    204206  REAL(kind=mm_wp), SAVE :: mm_fiadero_max  = 10._mm_wp
     
    213215  INTEGER, PARAMETER :: mm_coag_ff = 4 !! FF mode interaction for coagulation.
    214216  !> Default interactions to activate (all by default).
    215   INTEGER, SAVE      :: mm_coag_choice = mm_coag_ss+mm_coag_sf+mm_coag_ff 
     217  INTEGER, SAVE      :: mm_coag_choice = mm_coag_ss+mm_coag_sf+mm_coag_ff
    216218
    217219  !> Pi number.
    218220  REAL(kind=mm_wp), PARAMETER :: mm_pi = 4._mm_wp*atan(1._mm_wp)
    219221  !> Avogadro number.
    220   REAL(kind=mm_wp), PARAMETER :: mm_navo = 6.0221367e23_mm_wp 
     222  REAL(kind=mm_wp), PARAMETER :: mm_navo = 6.0221367e23_mm_wp
    221223  !> Boltzmann constant (\(J.K^{-1}\)).
    222224  REAL(kind=mm_wp), PARAMETER :: mm_kboltz = 1.3806488e-23_mm_wp
     
    261263
    262264  !> Bulk to apparent radius conversion pre-factor (\(m^{X}\)).
    263   !! 
    264   !! It is initialized using [[mm_globals(module):mm_rm(variable)]] in 
     265  !!
     266  !! It is initialized using [[mm_globals(module):mm_rm(variable)]] in
    265267  !! [[mm_globals(module):mm_global_init(interface)]] from the following equation:
    266268  !!
    267269  !! $$ r_{a} = r_{b}^{3/D_{f}}\times r_{m}^{\frac{D_{f}-3}{D_{f}}} $$
    268270  !!
    269   !! Where \(r_{a}\) is the apparent radius, \(r_{b}\) the bulk radius and 
     271  !! Where \(r_{a}\) is the apparent radius, \(r_{b}\) the bulk radius and
    270272  !! \(rb2ra = r_{m}^{\frac{D_{f}-3}{D_{f}}}\) is the returned pre-factor
    271   REAL(kind=mm_wp), SAVE :: mm_rb2ra = 1._mm_wp
     273  REAL(kind=mm_wp), SAVE :: mm_rb2ra = 1._mm_wp
     274
     275  ! Thresholds !
     276
     277  !> (min.) Total number of aerosols minimum threshold for the spherical mode.
     278  REAL(kind=mm_wp), SAVE :: mm_m0as_min = 1.e-10_mm_wp
     279
     280  !> (min.) Total volume of aerosols minimum threshold for the spherical mode.
     281  REAL(kind=mm_wp), SAVE :: mm_m3as_min = 1.e-40_mm_wp
     282
     283  !> Characteristic radius minimum threshold for the spherical mode.
     284  REAL(kind=mm_wp), SAVE :: mm_rcs_min = 1.e-9_mm_wp
     285
     286  !> (min.) Total number of aerosols minimum threshold for the fractal mode.
     287  REAL(kind=mm_wp), SAVE :: mm_m0af_min = 1.e-10_mm_wp
     288
     289  !> (min.) Total volume of aerosols minimum threshold for the fractal mode.
     290  REAL(kind=mm_wp), SAVE :: mm_m3af_min = 1.e-40_mm_wp
     291
     292  !> Characteristic radius minimum threshold for the fractal mode.
     293  REAL(kind=mm_wp), SAVE :: mm_rcf_min = 1.e-9_mm_wp
     294
     295  !> (min.) Total number of cloud drop minimum threshold.
     296  REAL(kind=mm_wp), SAVE :: mm_m0n_min = 1.e-10_mm_wp
     297
     298  !> (min.) Total volume of cloud drop minimum threshold.
     299  REAL(kind=mm_wp), SAVE :: mm_m3cld_min = 1.e-40_mm_wp
    272300
    273301  !> Characteristic radius threshold.
    274302  REAL(kind=mm_wp), SAVE :: mm_rc_min = 1.e-200_mm_wp
     303
     304  !> Minimum cloud drop radius
     305  REAL(kind=mm_wp), SAVE :: mm_drad_min = 1.e-9_mm_wp
     306
     307  !> Maximum cloud drop radius
     308  REAL(kind=mm_wp), SAVE :: mm_drad_max = 1.e-3_mm_wp
    275309
    276310  !> Name of condensible species.
     
    339373  REAL(kind=mm_wp), DIMENSION(:), ALLOCATABLE, SAVE :: mm_temp
    340374  !>  Air density vertical profile (\(kg.m^{-3}\)).
    341   REAL(kind=mm_wp), DIMENSION(:), ALLOCATABLE, SAVE :: mm_rhoair 
     375  REAL(kind=mm_wp), DIMENSION(:), ALLOCATABLE, SAVE :: mm_rhoair
    342376  !> Temperature vertical profil at interfaces (K).
    343377  REAL(kind=mm_wp), DIMENSION(:), ALLOCATABLE, SAVE :: mm_btemp
    344378
    345379  !> Atmospheric levels thickness (m).
    346   !! 
    347   !! Atmospheric thickness between two adjacent levels (\(m\)) from the 
     380  !!
     381  !! Atmospheric thickness between two adjacent levels (\(m\)) from the
    348382  !! __TOP__ to the __GROUND__.
    349383  !! @note __mm_dzlev__ is defined on the total number of layers and actually
     
    352386
    353387  !> Atmospheric layers "thickness" (m).
    354   !! 
     388  !!
    355389  !! Atmospheric thickness between the center of two adjacent layers (\(m\))
    356390  !! from the __TOP__ to the __GROUND__.
    357   !! @note 
    358   !! __mm_dzlay__ is defined on the total number of layers. The last 
     391  !! @note
     392  !! __mm_dzlay__ is defined on the total number of layers. The last
    359393  !! value of __mm_dzlay__ is set to twice the altitude of the ground layer.
    360   !! @note This value corresponds to the thickness between the center of the 
     394  !! @note This value corresponds to the thickness between the center of the
    361395  !! __GROUND__ layer and below the surface. It is arbitrary and not used.
    362396  REAL(kind=mm_wp), DIMENSION(:), ALLOCATABLE, SAVE :: mm_dzlay
     
    377411  !> Ice components 3rd order moments (\(m^{3}.m^{-3}\)).
    378412  !!
    379   !! It is a 2D array with the vertical layers in first dimension, and the number of ice 
     413  !! It is a 2D array with the vertical layers in first dimension, and the number of ice
    380414  !! components in the second.
    381   !! @note 
     415  !! @note
    382416  !! Both [[mm_globals(module):mm_m3ice(variable)]] and [[mm_globals(module):mm_gazs(variable)]]
    383417  !! share the same indexing (related to species order).
     
    387421  !!
    388422  !! It is a 2D array with the vertical layers in first dimension, and
    389   !! the number of condensible species in the second. 
    390   !! @note 
     423  !! the number of condensible species in the second.
     424  !! @note
    391425  !! Both [[mm_globals(module):mm_m3ice(variable)]] and [[mm_globals(module):mm_gazs(variable)]]
    392426  !! share the same indexing (related to species order).
     
    410444  !> Spherical mode \(M_{0}\) settling velocity (\(m.s^{-1}\)).
    411445  !!
    412   !! It is a vector with the vertical layers that contains the settling velocity for 
     446  !! It is a vector with the vertical layers that contains the settling velocity for
    413447  !! the \(0^{th}\) order moment of the spherical mode.
    414448  !! It is updated in [[mm_haze(module):mm_haze_sedimentation(subroutine)]].
    415   !! @note 
     449  !! @note
    416450  !! This variable is always negative.
    417451  REAL(kind=mm_wp), DIMENSION(:), ALLOCATABLE, SAVE :: mm_m0as_vsed
     
    419453  !> Spherical mode \(M_{3}\) settling velocity (\(m.s^{-1}\)).
    420454  !!
    421   !! It is a vector with the vertical layers that contains the settling velocity for the 
     455  !! It is a vector with the vertical layers that contains the settling velocity for the
    422456  !! \(3^{rd}\) order moment of the spherical mode.
    423457  !! It is updated in [[mm_haze(module):mm_haze_sedimentation(subroutine)]].
    424   !! @note 
     458  !! @note
    425459  !! This variable is always negative.
    426460  REAL(kind=mm_wp), DIMENSION(:), ALLOCATABLE, SAVE :: mm_m3as_vsed
     
    428462  !> Fractal mode \(M_{0}\) settling velocity (\(m.s^{-1}\)).
    429463  !!
    430   !! It is a vector with the vertical layers that contains the settling velocity for the 
     464  !! It is a vector with the vertical layers that contains the settling velocity for the
    431465  !! \(0^{th}\) order moment of the fractal mode.
    432466  !! It is updated in [[mm_haze(module):mm_haze_sedimentation(subroutine)]].
    433   !! @note 
     467  !! @note
    434468  !! This variable is always negative.
    435469  REAL(kind=mm_wp), DIMENSION(:), ALLOCATABLE, SAVE :: mm_m0af_vsed
     
    437471  !> Fractal mode \(M_{3}\) settling velocity (\(m.s^{-1}\)).
    438472  !!
    439   !! It is a vector with the vertical layers that contains the settling velocity for the 
     473  !! It is a vector with the vertical layers that contains the settling velocity for the
    440474  !! \(3^{rd}\) order moment of the fractal mode.
    441475  !! It is updated in [[mm_haze(module):mm_haze_sedimentation(subroutine)]].
    442   !! @note 
     476  !! @note
    443477  !! This variable is always negative.
    444478  REAL(kind=mm_wp), DIMENSION(:), ALLOCATABLE, SAVE :: mm_m3af_vsed
     
    448482  !! It is a vector with the vertical layers that contains the mass fluxes for spherical aerosols.
    449483  !! It is updated in [[mm_haze(module):mm_haze_sedimentation(subroutine)]].
    450   !! @note 
     484  !! @note
    451485  !! This variable is always negative.
    452486  REAL(kind=mm_wp), DIMENSION(:), ALLOCATABLE, SAVE :: mm_aer_s_flux
     
    456490  !! It is a vector with the vertical layers that contains the mass fluxes for fractal aerosols
    457491  !! It is updated in [[mm_haze(module):mm_haze_sedimentation(subroutine)]].
    458   !! @note 
     492  !! @note
    459493  !! This variable is always negative.
    460494  REAL(kind=mm_wp), DIMENSION(:), ALLOCATABLE, SAVE :: mm_aer_f_flux
     
    464498  REAL(kind=mm_wp), SAVE :: mm_ccn_prec = 0._mm_wp
    465499
    466   !> CCN mass fluxes (\(kg.m^{-2}.s^{-1}\)).
    467   !!
    468   !! It is a vector with the vertical layers that contains the 
    469   !! mass fluxes for CCN.
     500  !> CCN settling velocity (\(m.s^{-1}\)).
     501  !!
     502  !! It is a vector with the vertical layers that contains the
     503  !! settling velocity for CCN (and ices).
    470504  !! It is updated in [[mm_clouds(module):mm_cloud_microphysics(subroutine)]].
    471505  !! @note
    472   !! This variable is always negative.
     506  !! This variable is always positive.
     507  REAL(kind=mm_wp), DIMENSION(:), ALLOCATABLE, SAVE :: mm_ccn_w
     508 
     509  !> CCN mass fluxes (\(kg.m^{-2}.s^{-1}\)).
     510  !!
     511  !! It is a vector with the vertical layers that contains the
     512  !! mass fluxes for CCN.
     513  !! It is updated in [[mm_clouds(module):mm_cloud_microphysics(subroutine)]].
     514  !! @note
     515  !! This variable is always positive.
    473516  REAL(kind=mm_wp), DIMENSION(:), ALLOCATABLE, SAVE :: mm_ccn_flux
    474517
    475518  !> Ice components precipitations (m).
    476519  !!
    477   !! It is a vector of [[mm_globals(module):mm_nesp(variable)]] values which share the same indexing 
     520  !! It is a vector of [[mm_globals(module):mm_nesp(variable)]] values which share the same indexing
    478521  !! than [[mm_globals(module):mm_m3ice(variable)]] and [[mm_globals(module):mm_gazs(variable)]].
    479522  !! It is updated in [[mm_clouds(module):mm_cloud_microphysics(subroutine)]].
     
    484527  !> Ice components sedimentation fluxes (\(kg.m^{-2}.s-1\)).
    485528  !!
    486   !! It is a 2D-array with the vertical layers in first dimension and the number of ice components 
     529  !! It is a 2D-array with the vertical layers in first dimension and the number of ice components
    487530  !! in the second. It is updated in [[mm_clouds(module):mm_cloud_microphysics(subroutine)]].
    488531  !! @note
     
    492535  !> Condensible species saturation ratio (--).
    493536  !!
    494   !! It is a 2D-array with the vertical layers in first dimension and the number of condensible 
     537  !! It is a 2D-array with the vertical layers in first dimension and the number of condensible
    495538  !! species in the second.
    496539  !! It is updated in [[mm_clouds(module):mm_cloud_microphysics(subroutine)]].
     
    516559  INTERFACE mm_cloud_properties
    517560    MODULE PROCEDURE cldprop_sc,cldprop_ve
    518   END INTERFACE
     561  END INTERFACE mm_cloud_properties
    519562
    520563  !> Interface to global initialization.
     
    522565  !! The method performs the global initialization of the model.
    523566  !! @warning
    524   !! If OpenMP is activated, this subroutine must be called in an $OMP SINGLE statement as it 
     567  !! If OpenMP is activated, this subroutine must be called in an $OMP SINGLE statement as it
    525568  !! initializes global variable that are not thread private.
    526569  !!
    527   !! '''
    528   !! !$OMP SINGLE
    529   !! call mm_global_init(...)
    530   !! !$OMP END SINGLE
     570  !!   !$OMP SINGLE
     571  !!   call mm_global_init(...)
     572  !!   !$OMP END SINGLE
    531573  INTERFACE mm_global_init
    532574    MODULE PROCEDURE mm_global_init_0,mm_global_init_1
    533   END INTERFACE
     575  END INTERFACE mm_global_init
    534576
    535577  !> Check an option from the configuration system.
     
    538580  !! set a default value if the option is not found. This is an overloaded method
    539581  !! that can take in input either a floating point, integer, logical or string
    540   !! option value. 
     582  !! option value.
    541583  INTERFACE mm_check_opt
    542584    MODULE PROCEDURE check_r1,check_i1,check_l1,check_s1
    543   END INTERFACE
     585  END INTERFACE mm_check_opt
    544586
    545587  ! --- OPENMP ---------------
    546   ! All variable related to column computations should be private to each thread
     588  ! All variables related to column computations should be private to each thread
    547589  !
    548590  !$OMP THREADPRIVATE(mm_ini_col,mm_ini_aer,mm_ini_cld)
     
    551593  !$OMP THREADPRIVATE(mm_m0ccn,mm_m3ccn,mm_m3ice,mm_gazs)
    552594  !$OMP THREADPRIVATE(mm_rcs,mm_rcf,mm_drad,mm_drho)
    553   !$OMP THREADPRIVATE(mm_aer_s_flux,mm_aer_f_flux,mm_ccn_flux,mm_ice_prec,mm_ice_fluxes,mm_gazs_sat)
     595  !$OMP THREADPRIVATE(mm_aer_s_flux,mm_aer_f_flux,mm_ccn_w,mm_ccn_flux,mm_ice_prec,mm_ice_fluxes,mm_gazs_sat)
    554596  !$OMP THREADPRIVATE(mm_m0as_vsed,mm_m3as_vsed,mm_m0af_vsed,mm_m3af_vsed)
    555 
     597  !$OMP THREADPRIVATE(mm_m0as_min,mm_m3as_min,mm_rcs_min,mm_m0af_min,mm_m3af_min,mm_rcf_min,mm_m0n_min,mm_m3cld_min)
    556598  !$OMP THREADPRIVATE(mm_nla,mm_nle)
    557599
     
    559601
    560602
    561   CONTAINS
     603CONTAINS
    562604
    563605  FUNCTION mm_global_init_0(dt,df,rm,rho_aer,p_prod,tx_prod,rc_prod,rplanet,g0, &
    564                             air_rad,air_mmol,coag_interactions,clouds,spcfile,  &
    565                             w_haze_prod,w_haze_sed,w_haze_coag,w_cloud_nucond,  &
    566                             w_cloud_sed,force_wsed_to_m0,force_wsed_to_m3,      &
    567                             no_fiadero,fiadero_min,fiadero_max) RESULT(err)
     606    air_rad,air_mmol,coag_interactions,clouds,spcfile,  &
     607    w_haze_prod,w_haze_sed,w_haze_coag,w_cloud_nucond,  &
     608    w_cloud_sed,force_wsed_to_m0,force_wsed_to_m3,      &
     609    no_fiadero,fiadero_min,fiadero_max,                 &
     610    m0as_min,rcs_min,m0af_min,rcf_min,m0n_min,debug) RESULT(err)
    568611    !! Initialize global parameters of the model.
    569     !! 
     612    !!
    570613    !! The function initializes all the global parameters of the model from direct input.
    571     !! Boolean (and Fiadero) parameters are optional as they are rather testing parameters. Their
    572     !! default values are suitable for production runs. 
     614    !! Boolean, Fiadero and thresholds parameters are optional as they are rather testing parameters.
     615    !! Their default values are suitable for production runs.
    573616    !! @note
    574617    !! If the method fails to initialize parameters (i.e. returned error is not 0). Then the model
    575618    !! should probably be aborted as the global variables of the model will not be correctly setup.
    576619    !! @warning
    577     !! If OpenMP is activated, this subroutine must be called in an $OMP SINGLE statement as it
    578     !! initializes global variable that are not thread private.
    579     !!
    580     !! '''
    581     !! !$OMP SINGLE
    582     !! call mm_global_init_0(...)
    583     !! !$OMP END SINGLE
     620    !! If OpenMP is activated, this subroutine must be called in an $OMP SINGLE statement as it
     621    !! initializes (only) global variables that are not thread private.
     622    !!
     623    !!   !$OMP SINGLE
     624    !!   call mm_global_init_0(...)
     625    !!   !$OMP END SINGLE
    584626    REAL(kind=mm_wp), INTENT(in)           :: dt
    585       !! Microphysics timestep in seconds.
     627    !! Microphysics timestep in seconds.
    586628    REAL(kind=mm_wp), INTENT(in)           :: df
    587       !! Fractal dimension of fractal aerosol.
     629    !! Fractal dimension of fractal aerosol.
    588630    REAL(kind=mm_wp), INTENT(in)           :: rm
    589       !! Monomer radius in meter.
     631    !! Monomer radius in meter.
    590632    REAL(kind=mm_wp), INTENT(in)           :: rho_aer
    591       !! Aerosol density in \(kg.m^{-3}\).
     633    !! Aerosol density in \(kg.m^{-3}\).
    592634    REAL(kind=mm_wp), INTENT(in)           :: p_prod
    593       !!  Aerosol production pressure level in Pa.
     635    !!  Aerosol production pressure level in Pa.
    594636    REAL(kind=mm_wp), INTENT(in)           :: tx_prod
    595       !! Spherical aerosol mode production rate in \(kg.m^{-2}.s^{-1}\).
     637    !! Spherical aerosol mode production rate in \(kg.m^{-2}.s^{-1}\).
    596638    REAL(kind=mm_wp), INTENT(in)           :: rc_prod
    597       !! Spherical mode characteristic radius for production in meter.
     639    !! Spherical mode characteristic radius for production in meter.
    598640    REAL(kind=mm_wp), INTENT(in)           :: rplanet
    599       !! Planet radius in meter
     641    !! Planet radius in meter
    600642    REAL(kind=mm_wp), INTENT(in)           :: g0
    601       !! Planet gravity acceleration at ground level in \(m.s^{-2}\).
     643    !! Planet gravity acceleration at ground level in \(m.s^{-2}\).
    602644    REAL(kind=mm_wp), INTENT(in)           :: air_rad
    603       !! Air molecules mean radius in meter.
     645    !! Air molecules mean radius in meter.
    604646    REAL(kind=mm_wp), INTENT(in)           :: air_mmol
    605       !! Air molecules mean molar mass in \(kg.mol^{-1}\).
     647    !! Air molecules mean molar mass in \(kg.mol^{-1}\).
    606648    INTEGER, INTENT(in)                    :: coag_interactions
    607       !! Coagulation interactions process control flag.
     649    !! Coagulation interactions process control flag.
    608650    LOGICAL, INTENT(in)                    :: clouds
    609       !! Clouds microphysics control flag.
     651    !! Clouds microphysics control flag.
    610652    CHARACTER(len=*), INTENT(in)           :: spcfile
    611       !! Clouds microphysics condensible species properties file.
     653    !! Clouds microphysics condensible species properties file.
    612654    REAL(kind=mm_wp), INTENT(in), OPTIONAL :: fiadero_max
    613       !! Maximum moment ratio threshold for Fiadero correction (default: 10.) .
     655    !! Maximum moment ratio threshold for Fiadero correction (default: 10.) .
    614656    REAL(kind=mm_wp), INTENT(in), OPTIONAL :: fiadero_min
    615       !! Minimum moment ratio threshold for Fiadero correction (default: 0.1).
     657    !! Minimum moment ratio threshold for Fiadero correction (default: 0.1).
    616658    LOGICAL, INTENT(in), OPTIONAL          :: w_haze_prod
    617       !! Haze microphysics production process control flag (default: T).
     659    !! Haze microphysics production process control flag (default: T).
    618660    LOGICAL, INTENT(in), OPTIONAL          :: w_haze_sed
    619       !! Haze microphysics sedimentation process control flag (default: T).
     661    !! Haze microphysics sedimentation process control flag (default: T).
    620662    LOGICAL, INTENT(in), OPTIONAL          :: w_haze_coag
    621       !! Haze microphysics coagulation process control flag (default: T).
     663    !! Haze microphysics coagulation process control flag (default: T).
    622664    LOGICAL, INTENT(in), OPTIONAL          :: w_cloud_sed
    623       !! Cloud microphysics nucleation/conensation process control flag (default: __clouds__ value).
     665    !! Cloud microphysics nucleation/conensation process control flag (default: __clouds__ value).
    624666    LOGICAL, INTENT(in), OPTIONAL          :: w_cloud_nucond
    625       !! Cloud microphysics production process control flag (default: __clouds__ value).
     667    !! Cloud microphysics production process control flag (default: __clouds__ value).
    626668    LOGICAL, INTENT(in), OPTIONAL          :: no_fiadero
    627       !! Disable Fiadero correction for haze sedimentation process (default: F).
     669    !! Disable Fiadero correction for haze sedimentation process (default: F).
    628670    LOGICAL, INTENT(in), OPTIONAL          :: force_wsed_to_m0
    629       !! force __all__ aerosols moments to fall at M0 settling velocity (default: T).
    630     LOGICAL, INTENT(in), OPTIONAL          :: force_wsed_to_m3
    631       !! Force __all__ aerosols moments to fall at M3 settling velocity (default: F).
     671    !! force __all__ aerosols moments to fall at M0 settling velocity (default: T).
     672    LOGICAL, INTENT(in), OPTIONAL          :: force_wsed_to_m3
     673    !! Force __all__ aerosols moments to fall at M3 settling velocity (default: F).
     674    REAL(kind=mm_wp), INTENT(in), OPTIONAL :: m0as_min
     675    !! Minimum threshold for M0 of the spherical mode (default: 1e-10).
     676    REAL(kind=mm_wp), INTENT(in), OPTIONAL :: rcs_min
     677    !! Minimum threshold for the characteristic radius of the spherical mode in meter (default: 1e-9).
     678    REAL(kind=mm_wp), INTENT(in), OPTIONAL :: m0af_min
     679    !! Minimum threshold for M0 of the factal mode (default: 1e-10).
     680    REAL(kind=mm_wp), INTENT(in), OPTIONAL :: rcf_min
     681    !! Minimum threshold for the characteristic radius of the fractal mode in meter (default: _monomer radius_).
     682    REAL(kind=mm_wp), INTENT(in), OPTIONAL :: m0n_min
     683    !! Minimum threshold for M0 of cloud drop (default: 1e-10).
     684    LOGICAL, INTENT(in), OPTIONAL          :: debug
     685    !! Debug mode control flag (may print lot of stuff if enabled)
    632686    TYPE(error) :: err
    633       !! Error status of the function.
     687    !! Error status of the function.
    634688    INTEGER                                           :: i
    635689    TYPE(cfgparser)                                   :: cp
    636     CHARACTER(len=st_slen)                            :: spcpath
    637     CHARACTER(len=:), ALLOCATABLE                     :: defmsg
    638690    CHARACTER(len=st_slen), DIMENSION(:), ALLOCATABLE :: species
    639691    REAL(kind=mm_wp)                                  :: zfiamin,zfiamax
    640692    LOGICAL                                           :: zwhp,zwhs,zwhc,zwcs,zwcn,znofia, &
    641693                                                         zwstom0,zwstom3
    642 
    643694    zwhp = .true. ; zwhs = .true. ; zwhc = .true.
    644     zwcs = clouds ; zwcn = clouds 
     695    zwcs = clouds ; zwcn = clouds
    645696    znofia = .false. ; zfiamin = 0.1_mm_wp ; zfiamax = 10._mm_wp
    646697    zwstom0 = .true. ; zwstom3 = .false.
     
    652703
    653704    ! Store options values in global variables...
    654     mm_df          = df 
    655     mm_rm          = rm 
     705    mm_df          = df
     706    mm_rm          = rm
    656707    mm_rb2ra       = mm_rm**((mm_df-3._mm_wp)/mm_df) ! conversion factor for bulk -> fractal radius
    657     mm_rhoaer      = rho_aer 
     708    mm_rhoaer      = rho_aer
    658709    mm_p_prod      = p_prod
    659710    mm_tx_prod     = tx_prod
     
    662713    mm_g0          = g0
    663714    mm_dt          = dt
    664     mm_air_rad     = mm_air_rad
     715    mm_air_rad     = air_rad
    665716    mm_air_mmol    = air_mmol
    666717    mm_coag_choice = coag_interactions
     
    670721      RETURN
    671722    ENDIF
     723
     724    ! force fractal radius minimum threshold to monomer radius ^^
     725    mm_rcf_min = mm_rm
    672726
    673727    mm_w_clouds = clouds
     
    680734        RETURN
    681735      ENDIF
    682       ! Reads species properties configuration file 
     736      ! Reads species properties configuration file
    683737      err = cfg_read_config(cp,TRIM(spcfile)) ; IF (err /= 0) RETURN
    684       err = cfg_get_value(cp,"used_species",species) 
     738      err = cfg_get_value(cp,"used_species",species)
    685739      IF (err /= 0) THEN
    686740        err = error("mm_global_init: cannot retrieve 'used_species' values",-1)
     
    691745      ALLOCATE(mm_spcname(mm_nesp),mm_xESPS(mm_nesp))
    692746      DO i=1,mm_nesp
    693         mm_spcname(i) = to_lower(species(i))
     747        mm_spcname(i) = TRIM(species(i))
    694748        IF(.NOT.cfg_has_section(cp,TRIM(mm_spcname(i)))) THEN
    695749          err = error("mm_global_init: Cannot find "//TRIM(mm_spcname(i))//" properties",-1)
     
    708762
    709763    ! optional flags
     764    ! debug mode
     765    IF (PRESENT(debug)) THEN
     766      mm_debug = debug
     767    ELSE
     768      mm_debug = .false.
     769      call printw("mm_debug",to_string(mm_debug))
     770    ENDIF
    710771    ! haze control flags
    711     IF (PRESENT(w_haze_prod)) THEN 
     772    IF (PRESENT(w_haze_prod)) THEN
    712773      mm_w_haze_prod = w_haze_prod
    713     ELSE 
    714       mm_w_haze_prod = zwhp 
     774    ELSE
     775      mm_w_haze_prod = zwhp
    715776      call printw("mm_haze_production",to_string(mm_w_haze_prod))
    716777    ENDIF
    717     IF (PRESENT(w_haze_sed)) THEN 
     778    IF (PRESENT(w_haze_sed)) THEN
    718779      mm_w_haze_sed = w_haze_sed
    719     ELSE 
    720       mm_w_haze_sed = zwhs 
     780    ELSE
     781      mm_w_haze_sed = zwhs
    721782      call printw("mm_haze_sedimentation",to_string(mm_w_haze_sed))
    722783    ENDIF
    723     IF (PRESENT(w_haze_coag)) THEN 
     784    IF (PRESENT(w_haze_coag)) THEN
    724785      mm_w_haze_coag = w_haze_coag
    725     ELSE 
     786    ELSE
    726787      mm_w_haze_coag = zwhc
    727788      call printw("mm_haze_coagulation",to_string(mm_w_haze_coag))
    728789    ENDIF
    729     IF (PRESENT(force_wsed_to_m0)) THEN 
     790    IF (PRESENT(force_wsed_to_m0)) THEN
    730791      mm_wsed_m0 = force_wsed_to_m0
    731     ELSE 
     792    ELSE
    732793      mm_wsed_m0 = zwstom0
    733794      call printw("mm_wsed_m0",to_string(mm_wsed_m0))
    734795    ENDIF
    735     IF (PRESENT(force_wsed_to_m3)) THEN 
     796    IF (PRESENT(force_wsed_to_m3)) THEN
    736797      mm_wsed_m3 = force_wsed_to_m3
    737     ELSE 
     798    ELSE
    738799      mm_wsed_m3 = zwstom3
    739800      call printw("mm_wsed_m3",to_string(mm_wsed_m3))
    740801    ENDIF
    741     IF (PRESENT(no_fiadero)) THEN 
     802    IF (PRESENT(no_fiadero)) THEN
    742803      mm_no_fiadero_w = no_fiadero
    743     ELSE 
    744       mm_no_fiadero_w = znofia 
     804    ELSE
     805      mm_no_fiadero_w = znofia
    745806      call printw("mm_no_fiadero",to_string(mm_no_fiadero_w))
    746807    ENDIF
    747     IF (PRESENT(fiadero_min)) THEN 
     808    IF (PRESENT(fiadero_min)) THEN
    748809      mm_fiadero_min = fiadero_min
    749     ELSE 
     810    ELSE
    750811      mm_fiadero_min = zfiamin
    751812      call printw("mm_fiadero_min",to_string(mm_fiadero_min))
    752813    ENDIF
    753     IF (PRESENT(fiadero_max)) THEN 
     814    IF (PRESENT(fiadero_max)) THEN
    754815      mm_fiadero_max = fiadero_max
    755     ELSE 
     816    ELSE
    756817      mm_fiadero_max = zfiamax
    757818      call printw("mm_fiadero_max",to_string(mm_fiadero_max))
    758819    ENDIF
     820
     821    ! moments threshold flags
     822    IF (PRESENT(m0as_min)) THEN
     823      mm_m0as_min = MAX(0._mm_wp,m0as_min)
     824    ELSE
     825      call printw("mm_m0as_min",to_string(mm_m0as_min))
     826    ENDIF
     827    IF (PRESENT(rcs_min)) THEN
     828      mm_rcs_min = MAX(1.e-9_mm_wp,rcs_min)
     829    ELSE
     830      call printw("mm_rcs_min",to_string(mm_rcs_min))
     831    ENDIF
     832    IF (PRESENT(m0af_min)) THEN
     833      mm_m0af_min = MAX(0._mm_wp,m0af_min)
     834    ELSE
     835      call printw("mm_m0af_min",to_string(mm_m0af_min))
     836    ENDIF
     837    IF (PRESENT(rcf_min)) THEN
     838      mm_rcf_min = MAX(rcf_min,mm_rm)
     839    ELSE
     840      mm_rcf_min = mm_rm
     841      call printw("mm_rcf_min",to_string(mm_rcf_min))
     842    ENDIF
     843    IF (PRESENT(m0n_min)) THEN
     844      mm_m0n_min = MAX(0._mm_wp,m0n_min)
     845    ELSE
     846      call printw("mm_m0n_min",to_string(mm_m0n_min))
     847    ENDIF
     848
     849    ! compute m3 thresholds from user-defined thresholds.
     850    mm_m3as_min  =  mm_m0as_min*mm_alpha_s(3._mm_wp) * mm_rcs_min**3._mm_wp
     851    mm_m3af_min  =  mm_m0af_min*mm_alpha_f(3._mm_wp) * mm_rcf_min**3._mm_wp
     852    mm_m3cld_min =  mm_m0n_min * (4._mm_wp * mm_pi / 3._mm_wp) * mm_drad_min**3._mm_wp
     853
    759854    ! clouds control flags
    760855    IF (mm_w_clouds) THEN
    761       IF (PRESENT(w_cloud_sed)) THEN 
     856      IF (PRESENT(w_cloud_sed)) THEN
    762857        mm_w_cloud_sed = w_cloud_sed
    763       ELSE 
    764         mm_w_cloud_sed = zwcs 
    765         call printw("mm_cloud_sed",to_string(mm_w_cloud_sed)) 
     858      ELSE
     859        mm_w_cloud_sed = zwcs
     860        call printw("mm_cloud_sed",to_string(mm_w_cloud_sed))
    766861      ENDIF
    767       IF (PRESENT(w_cloud_nucond)) THEN 
     862      IF (PRESENT(w_cloud_nucond)) THEN
    768863        mm_w_cloud_nucond = w_cloud_nucond
    769       ELSE 
     864      ELSE
    770865        mm_w_cloud_nucond = zwcs
    771         call printw("mm_cloud_nucond",to_string(mm_w_cloud_nucond)) 
     866        call printw("mm_cloud_nucond",to_string(mm_w_cloud_nucond))
    772867      ENDIF
    773868    ENDIF
     
    781876    mm_ini = err == noerror
    782877
    783     CONTAINS
     878  CONTAINS
    784879
    785880    SUBROUTINE printw(string,value)
     
    788883      CHARACTER(len=*), INTENT(in) :: value  !! (string) Value of the option.
    789884      IF (mm_log) &
    790       WRITE(*,'(a,a,a)') "warning: Parameter "//string//"not given... Using default value: "//value
    791     END SUBROUTINE printw 
     885        WRITE(*,'(a,a,a)') "warning: Parameter "//string//"not given... Using default value: "//value
     886    END SUBROUTINE printw
    792887  END FUNCTION mm_global_init_0
    793888
     
    796891    !!
    797892    !! See [[mm_globals(module):mm_global_init_0(function)]].
    798     TYPE(cfgparser), INTENT(in) :: cfg  !! Configuration file path.
    799     TYPE(error) :: err                  !! Error status of the function.
     893    TYPE(cfgparser), INTENT(in) :: cfg
     894    !! Configuration file path.
     895    TYPE(error) :: err
     896    !! Error status of the function.
    800897    INTEGER                                           :: i
    801898    TYPE(cfgparser)                                   :: spccfg
    802899    CHARACTER(len=st_slen)                            :: spcpath
    803     CHARACTER(len=:), ALLOCATABLE                     :: defmsg
    804900    CHARACTER(len=st_slen), DIMENSION(:), ALLOCATABLE :: species
    805901    REAL(kind=mm_wp)                                  :: zfiamin,zfiamax
    806902    LOGICAL                                           :: zwhp,zwhs,zwhc,zwcs,zwcn,znofia, &
    807                                                          zwstom0,zwstom3
     903      zwstom0,zwstom3
    808904
    809905    err = noerror
     
    856952      ! Gets species property file path
    857953      err = cfg_get_value(cfg,'specie_cfg',spcpath) ; IF (err /= 0) RETURN
    858       ! Reads species properties configuration file 
     954      ! Reads species properties configuration file
    859955      err = cfg_read_config(spccfg,trim(spcpath)) ; IF (err /= 0) RETURN
    860       err = cfg_get_value(spccfg,"used_species",species) 
     956      err = cfg_get_value(spccfg,"used_species",species)
    861957      IF (err /= 0) THEN
    862958        err = error("mm_global_init: cannot retrieve 'used_species' values",-1)
     
    868964      !mm_spcname(1:mm_nesp) = species(:)
    869965      DO i=1,mm_nesp
    870         mm_spcname(i) = to_lower(species(i))
     966        mm_spcname(i) = TRIM(species(i))
    871967        IF (.NOT.cfg_has_section(spccfg,TRIM(mm_spcname(i)))) THEN
    872968          err = error("mm_global_init: Cannot find "//TRIM(mm_spcname(i))//" properties",-1)
     
    890986
    891987    ! MP2M Optional parameters
     988    err = mm_check_opt(cfg_get_value(cfg,"debug",mm_debug),mm_debug,.false.,wlog=mm_log)
    892989    err = mm_check_opt(cfg_get_value(cfg,"haze_production",mm_w_haze_prod),mm_w_haze_prod,zwhp,wlog=mm_log)
    893990    err = mm_check_opt(cfg_get_value(cfg,"haze_sedimentation",mm_w_haze_sed),mm_w_haze_sed,zwhs,wlog=mm_log)
     
    901998    err = mm_check_opt(cfg_get_value(cfg,"fiadero_max_ratio",mm_fiadero_max),mm_fiadero_max,zfiamax,wlog=mm_log)
    902999
     1000    err = mm_check_opt(cfg_get_value(cfg,"m0as_min",mm_m0as_min),mm_m0as_min,1e-10_mm_wp,wlog=mm_log)
     1001    err = mm_check_opt(cfg_get_value(cfg,"rcs_min",mm_rcs_min),mm_rcs_min,1e-9_mm_wp,wlog=mm_log)
     1002    err = mm_check_opt(cfg_get_value(cfg,"m0af_min",mm_m0af_min),mm_m0af_min,1e-10_mm_wp,wlog=mm_log)
     1003    err = mm_check_opt(cfg_get_value(cfg,"rcf_min",mm_rcf_min),mm_rcf_min,mm_rm,wlog=mm_log)
     1004    err = mm_check_opt(cfg_get_value(cfg,"m0n_min",mm_m0n_min),mm_m0n_min,1e-10_mm_wp,wlog=mm_log)
     1005
     1006
     1007    ! force fractal radius minimum threshold to monomer radius ^^
     1008    mm_rcf_min = MAX(mm_rm,mm_rcf_min)
     1009
     1010    ! compute m3 thresholds from user-defined thresholds.
     1011    mm_m3as_min  =  mm_m0as_min*mm_alpha_s(3._mm_wp) * mm_rcs_min**3._mm_wp
     1012    mm_m3af_min  =  mm_m0af_min*mm_alpha_f(3._mm_wp) * mm_rcf_min**3._mm_wp
     1013    mm_m3cld_min =  mm_m0n_min * (4._mm_wp * mm_pi / 3._mm_wp) * mm_drad_min**3._mm_wp
     1014
    9031015    err = noerror
    9041016    ! special check for settling velocity
     
    9111023  FUNCTION mm_column_init(plev,zlev,play,zlay,temp) RESULT(err)
    9121024    !! Initialize vertical atmospheric fields.
    913     !! 
     1025    !!
    9141026    !! This subroutine initializes vertical fields needed by the microphysics:
    9151027    !!
    916     !! 1. Save reversed input field into "local" array 
     1028    !! 1. Save reversed input field into "local" array
    9171029    !! 2. Compute thicknesses layers and levels
    9181030    !! 3. Interpolate temperature at levels
     
    9221034    !! @attention
    9231035    !! All the input vectors should be defined from __GROUND__ to __TOP__ of the atmosphere,
    924     !! otherwise nasty things will occur in computations. 
     1036    !! otherwise nasty things will occur in computations.
    9251037    REAL(kind=mm_wp), DIMENSION(:), INTENT(in) :: plev !! Pressure levels (Pa).
    9261038    REAL(kind=mm_wp), DIMENSION(:), INTENT(in) :: zlev !! Altitude levels (m).
     
    9301042    TYPE(error) :: err                                 !! Error status of the function.
    9311043    INTEGER :: i
    932     mm_ini_col = .false.                         
     1044    mm_ini_col = .false.
    9331045    err = noerror
    9341046    IF (.NOT.mm_ini) THEN
     
    9801092    ! Hydrostatic equilibrium
    9811093    mm_rhoair(1:mm_nla) = (mm_plev(2:mm_nle)-mm_plev(1:mm_nla)) / &
    982                           (mm_effg(mm_zlay)*mm_dzlev)
    983     mm_ini_col = .true.                         
     1094      (mm_effg(mm_zlay)*mm_dzlev)
     1095    mm_ini_col = .true.
    9841096    ! write out profiles (only if BOTH debug and log are enabled).
    9851097    IF (mm_log.AND.mm_debug) THEN
     
    10031115  FUNCTION mm_aerosols_init(m0aer_s,m3aer_s,m0aer_f,m3aer_f) RESULT(err)
    10041116    !! Initialize clouds tracers vertical grid.
    1005     !! 
    1006     !! The subroutine initializes aerosols microphysics tracers columns. It allocates variables if 
    1007     !! required and stores input vectors in reversed order. It also computes the characteristic radii 
    1008     !! of each mode. 
     1117    !!
     1118    !! The subroutine initializes aerosols microphysics tracers columns. It allocates variables if
     1119    !! required and stores input vectors in reversed order. It also computes the characteristic radii
     1120    !! of each mode.
    10091121    !! @note
    1010     !! All the input arguments should be defined from ground to top. 
     1122    !! All the input arguments should be defined from ground to top.
    10111123    !!
    10121124    !! @attention
    10131125    !! [[mm_globals(module):mm_global_init(interface)]] and [[mm_globals(module):mm_column_init(function)]]
    10141126    !! must have been called at least once before this method is called. Moreover, this method should be
    1015     !! after each call of [[mm_globals(module):mm_column_init(function)]] to reflect changes in the 
     1127    !! after each call of [[mm_globals(module):mm_column_init(function)]] to reflect changes in the
    10161128    !! vertical atmospheric structure.
    10171129    REAL(kind=mm_wp), DIMENSION(:), INTENT(in) :: m0aer_s !! \(0^{th}\) order moment of the spherical mode (\(m^{-2}\)).
     
    10631175    mm_m0aer_f = m0aer_f(mm_nla:1:-1)/mm_dzlev(:)
    10641176    mm_m3aer_f = m3aer_f(mm_nla:1:-1)/mm_dzlev(:)
     1177
     1178    ! Setup threshold:
     1179    call mm_set_moments_thresholds()
     1180
    10651181    ! aerosols characteristic radii
    1066     ! il faudrait peut etre revoir la gestion des zeros ici et la
    1067     ! remplacer par une valeur seuil des moments.
    1068     !
    1069     !-> JVO 19 : Done. Zero threshold set at espilon from dynamics on the
    1070     ! input moments in calmufi (safer than here). Might still be some unphysical
    1071     ! values after the dynamics near the threshold. Could be a could idea to add
    1072     ! a sanity check filtering too high values of radii.
    1073     !
    1074     ! TBD : Add a sanity check for high radii ????
    10751182    WHERE(mm_m3aer_s > 0._mm_wp .AND. mm_m0aer_s > 0._mm_wp)
    10761183      mm_rcs = mm_get_rcs(mm_m0aer_s,mm_m3aer_s)
     
    10881195  FUNCTION mm_clouds_init(m0ccn,m3ccn,m3ice,gazs) RESULT(err)
    10891196    !! Initialize clouds tracers vertical grid.
    1090     !! 
    1091     !! The subroutine initializes cloud microphysics tracers columns. It allocates variables if 
    1092     !! required and stores input vectors in reversed order. It also computes the mean drop radius 
     1197    !!
     1198    !! The subroutine initializes cloud microphysics tracers columns. It allocates variables if
     1199    !! required and stores input vectors in reversed order. It also computes the mean drop radius
    10931200    !! and density and allocates diagnostic vectors.
    10941201    !! @note
    1095     !! All the input arguments should be defined from ground to top. 
     1202    !! All the input arguments should be defined from ground to top.
    10961203    !!
    10971204    !! @attention
    10981205    !! [[mm_globals(module):mm_global_init(interface)]] and [[mm_globals(module):mm_column_init(function)]]
    10991206    !! must have been called at least once before this method is called. Moreover, this method should be
    1100     !! after each call of [[mm_globals(module):mm_column_init(function)]] to reflect changes in the 
     1207    !! after each call of [[mm_globals(module):mm_column_init(function)]] to reflect changes in the
    11011208    !! vertical atmospheric structure.
    11021209    REAL(kind=mm_wp), DIMENSION(:), INTENT(in)   :: m0ccn !! 0th order moment of the CCN distribution (\(m^{-2}\)).
     
    11211228    !  Actually, mm_nla should always initialized the first time mm_column_init is called, NOT HERE.
    11221229    IF (mm_nla < 0)  mm_nla  = SIZE(gazs,DIM=1)
    1123     ! Note: 
     1230    ! Note:
    11241231    !   here we could check that mm_nesp is the same size of gazs(DIM=2)
    11251232    !   Actually, mm_nesp should be always initialized in mm_global_init, NOT HERE.
     
    11341241    IF (.NOT.ALLOCATED(mm_drho))    ALLOCATE(mm_drho(mm_nla))
    11351242    ! Allocate memory for diagnostics
     1243    IF (.NOT.ALLOCATED(mm_ccn_w)) THEN
     1244      ALLOCATE(mm_ccn_w(mm_nla)) ; mm_ccn_w(:) = 0._mm_wp
     1245    ENDIF
    11361246    IF (.NOT.ALLOCATED(mm_ccn_flux)) THEN
    11371247      ALLOCATE(mm_ccn_flux(mm_nla)) ; mm_ccn_flux(:) = 0._mm_wp
     
    11541264      mm_gazs(:,i)  = gazs(mm_nla:1:-1,i)
    11551265    ENDDO
     1266
     1267    ! Setup threshold :
     1268    call mm_set_moments_cld_thresholds()
     1269
    11561270    ! drop mean radius
    11571271    call mm_cloud_properties(mm_m0ccn,mm_m3ccn,mm_m3ice,mm_drad,mm_drho)
     
    11621276    !! Dump model global parameters on stdout.
    11631277    WRITE(*,'(a)')         "========= YAMMS PARAMETERS ============"
     1278    WRITE(*,'(a,a)')       "mm_fp_precision        : ", mm_wp_s
     1279    WRITE(*,'(a,L2)')      "mm_debug               : ", mm_debug
    11641280    WRITE(*,'(a,L2)')      "mm_w_haze_prod         : ", mm_w_haze_prod
    11651281    WRITE(*,'(a,ES14.7)')  "   mm_p_prod           : ", mm_p_prod
     
    11681284    WRITE(*,'(a,L2)')      "mm_w_haze_coag         : ", mm_w_haze_coag
    11691285    WRITE(*,'(a,I2.2)')    "   mm_coag_interactions: ", mm_coag_choice
    1170     WRITE(*,'(a,L2)')      "mm_w_haze_sed          : ", mm_w_haze_sed 
     1286    WRITE(*,'(a,L2)')      "mm_w_haze_sed          : ", mm_w_haze_sed
    11711287    WRITE(*,'(a,L2)')      "   mm_wsed_m0          : ", mm_wsed_m0
    11721288    WRITE(*,'(a,L2)')      "   mm_wsed_m3          : ", mm_wsed_m3
     
    11781294    WRITE(*,'(a,L2)')      "   mm_w_cloud_nucond   : ", mm_w_cloud_nucond
    11791295    WRITE(*,'(a)')         "---------------------------------------"
     1296    WRITE(*,'(a)')         "Thresholds spherical mode"
     1297    WRITE(*,'(a,ES14.7)')  "  mm_m0as_min          : ", mm_m0as_min
     1298    WRITE(*,'(a,ES14.7)')  "  mm_rcs_min           : ", mm_rcs_min
     1299    WRITE(*,'(a)')         "Thresholds fractal mode"
     1300    WRITE(*,'(a,ES14.7)')  "  mm_m0af_min          : ", mm_m0af_min
     1301    WRITE(*,'(a,ES14.7)')  "  mm_rcf_min           : ", mm_rcf_min
     1302    WRITE(*,'(a)')         "Thresholds clouds drop"
     1303    WRITE(*,'(a,ES14.7)')  "  mm_m0n_min           : ", mm_m0n_min
     1304    WRITE(*,'(a,ES14.7)')  "  mm_drad_min          : ", mm_drad_min
     1305    WRITE(*,'(a,ES14.7)')  "  mm_drad_max          : ", mm_drad_max
     1306    WRITE(*,'(a)')         "---------------------------------------"
    11801307    WRITE(*,'(a,ES14.7)')  "mm_dt                  : ", mm_dt
    11811308    IF (mm_nla > -1) THEN
     
    11911318  END SUBROUTINE mm_dump_parameters
    11921319
     1320  SUBROUTINE mm_set_moments_thresholds()
     1321    !! Apply minimum threshold for the aerosols moments.
     1322    !!
     1323    !! The method resets moments (for both modes and orders, 0 and 3) values to zero if
     1324    !! their current value is below the minimum threholds.
     1325    !!
     1326    !! See also [[mm_globals(module):mm_m0as_min(variable)]], [[mm_globals(module):mm_rcs_min(variable)]],
     1327    !! [[mm_globals(module):mm_rcf_min(variable)]] and [[mm_globals(module):mm_m0as_min(variable)]].
     1328    INTEGER :: i
     1329    DO i=1,mm_nla
     1330      IF ((mm_m0aer_s(i) < mm_m0as_min) .OR. (mm_m3aer_s(i) < mm_m3as_min)) THEN
     1331        mm_m0aer_s(i) = 0._mm_wp ! mm_m0as_min
     1332        mm_m3aer_s(i) = 0._mm_wp ! mm_m0as_min * mm_rcs_min**3._mm_wp * mm_alpha_s(3._mm_wp)
     1333      ENDIF
     1334      IF ((mm_m0aer_f(i) < mm_m0af_min) .OR. (mm_m3aer_f(i) < mm_m3af_min)) THEN
     1335        mm_m0aer_f(i) = 0._mm_wp ! mm_m0af_min
     1336        mm_m3aer_f(i) = 0._mm_wp ! mm_m0af_min * mm_rcf_min**3._mm_wp * mm_alpha_f(3._mm_wp)
     1337      ENDIF
     1338    ENDDO
     1339  END SUBROUTINE mm_set_moments_thresholds
     1340
     1341  SUBROUTINE mm_set_moments_cld_thresholds()
     1342    !! Apply minimum threshold for the cloud drop moments.
     1343    !!
     1344    !! The method resets moments (for both modes and orders, 0 and 3) values to zero if
     1345    !! their current value is below the minimum threholds.
     1346    INTEGER :: i, j
     1347    REAL(kind=mm_wp) :: m3cld
     1348
     1349    DO i = 1, mm_nla
     1350      m3cld = mm_m3ccn(i)
     1351      DO j = 1, mm_nesp
     1352        m3cld = m3cld + mm_m3ice(i,j)
     1353      ENDDO
     1354
     1355      IF ((mm_m0ccn(i) < mm_m0n_min) .OR. (m3cld < mm_m3cld_min)) THEN
     1356        mm_m0ccn(i) = 0._mm_wp
     1357        mm_m3ccn(i) = 0._mm_wp
     1358        DO j = 1, mm_nesp
     1359          mm_m3ice(i,j) = 0._mm_wp
     1360        ENDDO
     1361      ENDIF
     1362    ENDDO
     1363  END SUBROUTINE mm_set_moments_cld_thresholds
     1364
     1365  ELEMENTAL SUBROUTINE mm_check_tendencies(v,dv)
     1366    !! Check that tendencies is not greater than value.
     1367    !!
     1368    !! the purpose of the subroutine is to update dvalue so that v+dv is not negative.
     1369    REAL(kind=mm_wp), INTENT(in)    :: v  !! Value to check.
     1370    REAL(kind=mm_wp), INTENT(inout) :: dv !! Value tendencies to check and update consequently.
     1371    REAL(kind=mm_wp), PARAMETER :: a = (epsilon(1._mm_wp)-1._mm_wp)
     1372    IF (v+dv < 0._mm_wp) THEN
     1373      dv = a*v
     1374    ENDIF
     1375  END SUBROUTINE mm_check_tendencies
     1376
    11931377  ELEMENTAL FUNCTION mm_get_rcs(m0,m3) RESULT(res)
    11941378    !! Get the characteristic radius for the spherical aerosols size distribution.
    1195     !! 
     1379    !!
    11961380    !! The method computes the characteristic radius of the size distribution law
    11971381    !! of the spherical aerosols mode according to its moments and its inter-moments
    11981382    !! relation.
    1199     REAL(kind=mm_wp), INTENT(in) :: m0 !! \(0^{th}\) order moment 
     1383    REAL(kind=mm_wp), INTENT(in) :: m0 !! \(0^{th}\) order moment
    12001384    REAL(kind=mm_wp), INTENT(in) :: m3 !! \(3^{rd}\) order moment
    12011385    REAL(kind=mm_wp) :: res            !! Radius
    1202     ! arbitrary: if there is no way to compute radius
    1203     IF (m3 <= 0._mm_wp .OR. m0 <= 0._mm_wp) res = 1._mm_wp
    12041386    res = (m3/m0/mm_alpha_s(3._mm_wp))**(1._mm_wp/3._mm_wp)
    12051387  END FUNCTION mm_get_rcs
     
    12071389  ELEMENTAL FUNCTION mm_get_rcf(m0,m3) RESULT(res)
    12081390    !! Get the characteristic radius for the fractal aerosols size distribution.
    1209     !! 
     1391    !!
    12101392    !! The method computes the characteristic radius of the size distribution law
    12111393    !! of the fractal aerosols mode according to its moments and its inter-moments
    12121394    !! relation.
    1213     REAL(kind=mm_wp), INTENT(in) :: m0 !! \(0^{th}\) order moment 
     1395    REAL(kind=mm_wp), INTENT(in) :: m0 !! \(0^{th}\) order moment
    12141396    REAL(kind=mm_wp), INTENT(in) :: m3 !! \(3^{rd}\) order moment
    12151397    REAL(kind=mm_wp) :: res            !! Radius
    1216     ! arbitrary: if there is no way to compute radius
    1217     IF (m3 <= 0._mm_wp .OR. m0 <= 0._mm_wp) res = 1._mm_wp
    12181398    res = (m3/m0/mm_alpha_f(3._mm_wp))**(1._mm_wp/3._mm_wp)
    12191399  END FUNCTION mm_get_rcf
    12201400
    1221   ELEMENTAL FUNCTION mm_effg(z) RESULT(effg) 
     1401  ELEMENTAL FUNCTION mm_effg(z) RESULT(effg)
    12221402    !! Compute effective gravitational acceleration.
    12231403    REAL(kind=mm_wp), INTENT(in) :: z !! Altitude in meters
     
    12261406    IF (mm_use_effg) effg = effg * (mm_rpla/(mm_rpla+z))**2
    12271407    RETURN
    1228   END FUNCTION mm_effg 
     1408  END FUNCTION mm_effg
    12291409
    12301410  !==================================
     
    12371417    !! The method computes the mean radius and mean density of cloud drops.
    12381418    !!
    1239     !! @bug 
    1240     !! A possible bug can happen because of threshold snippet. If __drad__ is greater than 
    1241     !! __drmax__ (== 100 microns) it is automatically set to __drmax__, but computation of
     1419    !! @bug
     1420    !! A possible bug can happen because of threshold snippet. If __drad__ is greater than
     1421    !! __drmax__ (== 1e3 microns) it is automatically set to __drmax__, but computation of
    12421422    !! __drho__ remains unmodified. So __drho__ is not correct in that case.
    12431423    !!
    1244     !! @todo 
    1245     !! Fix the bug of the subroutine, but it is rather minor, since theoretically we do not 
     1424    !! @todo
     1425    !! Fix the bug of the subroutine, but it is rather minor, since theoretically we do not
    12461426    !! need the density of the drop.
    12471427    !!
    1248     !! @todo 
    1249     !! Think about a better implementation of thresholds, and get sure of their consequences in 
    1250     !! the other parts of the model. 
    1251     REAL(kind=mm_wp), INTENT(in)               :: m0ccn !! \(0^{th}\) order moment of the ccn 
    1252     REAL(kind=mm_wp), INTENT(in)               :: m3ccn !! \(3^{rd}\) order moment of the ccn 
     1428    !! @todo
     1429    !! Think about a better implementation of thresholds, and get sure of their consequences in
     1430    !! the other parts of the model.
     1431    REAL(kind=mm_wp), INTENT(in)               :: m0ccn !! \(0^{th}\) order moment of the ccn
     1432    REAL(kind=mm_wp), INTENT(in)               :: m3ccn !! \(3^{rd}\) order moment of the ccn
    12531433    REAL(kind=mm_wp), INTENT(in), DIMENSION(:) :: m3ice !! \(3^{rd}\) order moments of each ice component
    1254     REAL(kind=mm_wp), INTENT(out)              :: drad  !! Output mean drop radius 
     1434    REAL(kind=mm_wp), INTENT(out)              :: drad  !! Output mean drop radius
    12551435    REAL(kind=mm_wp), INTENT(out), OPTIONAL    :: drho  !! Optional output mean drop density
    1256     REAL(kind=mm_wp)            :: vtot, wtot, ntot
    1257     REAL(kind=mm_wp), PARAMETER :: threshold = 1.e-25_mm_wp,         & 
    1258                                        drmin = 1.e-10_mm_wp,         &
    1259                                        drmax = 1.e-4_mm_wp,          &
    1260                                       athird = 1._mm_wp/3._mm_wp,    &
    1261                                        pifac = 4._mm_wp/3._mm_wp*mm_pi
     1436    REAL(kind=mm_wp)            :: Ntot, Vtot, Wtot
     1437    REAL(kind=mm_wp), PARAMETER :: athird = 1._mm_wp / 3._mm_wp
     1438    REAL(kind=mm_wp), PARAMETER :: pifac  = (4._mm_wp * mm_pi) / 3._mm_wp
     1439   
     1440    ! Set to zero :
    12621441    drad = 0._mm_wp
    1263     ntot = m0ccn
    1264     vtot = pifac*m3ccn+SUM(m3ice)
    1265     wtot = pifac*m3ccn*mm_rhoaer+SUM(m3ice*mm_xESPS(:)%rho)
    1266     IF (ntot <= threshold .OR. vtot <= 0._mm_wp) THEN
    1267       drad  = drmin
    1268       IF (PRESENT(drho)) drho  = mm_rhoaer
    1269     ELSE
    1270       drad = (vtot/ntot/pifac)**athird
    1271       drad = MAX(MIN(drad,drmax),drmin)
    1272       IF (PRESENT(drho)) drho = wtot/vtot
    1273     ENDIF
     1442    IF (PRESENT(drho)) drho  = 0._mm_wp
     1443   
     1444    ! Initialization :
     1445    Ntot = m0ccn
     1446    Vtot = pifac * m3ccn + SUM(m3ice)
     1447    Wtot = pifac * ((m3ccn*mm_rhoaer) + SUM(m3ice*mm_xESPS(:)%rho))
     1448
     1449    IF (Ntot <= mm_m0n_min .OR. Vtot <= mm_m3cld_min) THEN
     1450      drad = mm_drad_min
     1451      IF (PRESENT(drho)) drho = mm_rhoaer
     1452    ELSE
     1453      drad = (Vtot / (pifac*Ntot))**athird
     1454      drad = MAX(MIN(drad,mm_drad_max),mm_drad_min)
     1455      IF (PRESENT(drho)) drho = Wtot / Vtot
     1456    ENDIF
     1457
    12741458    RETURN
    12751459  END SUBROUTINE cldprop_sc
     
    12861470    REAL(kind=mm_wp), INTENT(out), DIMENSION(:)           :: drad  !! Output mean drop radius.
    12871471    REAL(kind=mm_wp), INTENT(out), DIMENSION(:), OPTIONAL :: drho  !! Optional output mean drop density.
    1288     INTEGER                                     :: i,ns
    1289     REAL(kind=mm_wp), DIMENSION(:), ALLOCATABLE :: vtot,wtot,ntot,rho
    1290     REAL(kind=mm_wp), PARAMETER                 :: threshold = 1.e-25_mm_wp,         & 
    1291                                                        drmin = 1.e-10_mm_wp,         &
    1292                                                        drmax = 1.e-4_mm_wp,          &
    1293                                                       athird = 1._mm_wp/3._mm_wp,    &
    1294                                                        pifac = 4._mm_wp/3._mm_wp*mm_pi
    1295                                                      
    1296     ns = SIZE(m0ccn) ; ALLOCATE(vtot(ns),wtot(ns),ntot(ns),rho(ns))
    1297     drad = 0._mm_wp
    1298     ntot = m0ccn
    1299     vtot = pifac*m3ccn+SUM(m3ice,DIM=2)
    1300     wtot = pifac*m3ccn*mm_rhoaer
    1301     DO i=1,SIZE(m3ice,DIM=2)
    1302       wtot = wtot+m3ice(:,i)*mm_xESPS(i)%rho
    1303     ENDDO
    1304     WHERE(ntot <= threshold .OR. vtot <= 0._mm_wp)
    1305       drad  = drmin
    1306       rho = mm_rhoaer
    1307     ELSEWHERE
    1308       drad = (vtot/ntot/pifac)**athird
    1309       drad = MAX(MIN(drad,drmax),drmin)
    1310       rho = wtot/vtot
    1311     END WHERE
    1312     IF (PRESENT(drho)) drho  = rho
     1472    INTEGER :: i
     1473    IF (PRESENT(drho)) THEN
     1474      DO i = 1, SIZE(m0ccn) ; call cldprop_sc(m0ccn(i),m3ccn(i),m3ice(i,:),drad(i),drho(i)) ; ENDDO
     1475    ELSE
     1476      DO i = 1, SIZE(m0ccn) ; call cldprop_sc(m0ccn(i),m3ccn(i),m3ice(i,:),drad(i)) ; ENDDO
     1477    ENDIF
    13131478    RETURN
    13141479  END SUBROUTINE cldprop_ve
    13151480
    1316   ! For configuration file (requires fccp library).
     1481  ! For configuration file (requires swift library).
    13171482
    13181483  FUNCTION read_esp(parser,sec,pp) RESULT (err)
     
    13221487    TYPE(mm_esp), INTENT(out)     :: pp     !! [[mm_globals(module):mm_esp(type)]] object that stores the parameters.
    13231488    TYPE(error)                   :: err    !! Error status of the function.
    1324     err = cfg_get_value(parser,TRIM(sec)//'name',pp%name)       ; IF (err /= 0) RETURN
    1325     err = cfg_get_value(parser,TRIM(sec)//'mas',pp%mas)         ; IF (err /= 0) RETURN
    1326     err = cfg_get_value(parser,TRIM(sec)//'vol',pp%vol)         ; IF (err /= 0) RETURN
    1327     err = cfg_get_value(parser,TRIM(sec)//'ray',pp%ray)         ; IF (err /= 0) RETURN
    1328     err = cfg_get_value(parser,TRIM(sec)//'mas',pp%mas)         ; IF (err /= 0) RETURN
    1329     err = cfg_get_value(parser,TRIM(sec)//'vol',pp%vol)         ; IF (err /= 0) RETURN
    1330     err = cfg_get_value(parser,TRIM(sec)//'ray',pp%ray)         ; IF (err /= 0) RETURN
    1331     err = cfg_get_value(parser,TRIM(sec)//'masmol',pp%masmol)   ; IF (err /= 0) RETURN
    1332     err = cfg_get_value(parser,TRIM(sec)//'rho',pp%rho)         ; IF (err /= 0) RETURN
    1333     err = cfg_get_value(parser,TRIM(sec)//'tc',pp%tc)           ; IF (err /= 0) RETURN
    1334     err = cfg_get_value(parser,TRIM(sec)//'pc',pp%pc)           ; IF (err /= 0) RETURN
    1335     err = cfg_get_value(parser,TRIM(sec)//'tb',pp%tb)           ; IF (err /= 0) RETURN
    1336     err = cfg_get_value(parser,TRIM(sec)//'w',pp%w)             ; IF (err /= 0) RETURN
    1337     err = cfg_get_value(parser,TRIM(sec)//'a_sat',pp%a_sat)     ; IF (err /= 0) RETURN
    1338     err = cfg_get_value(parser,TRIM(sec)//'b_sat',pp%b_sat)     ; IF (err /= 0) RETURN
    1339     err = cfg_get_value(parser,TRIM(sec)//'c_sat',pp%c_sat)     ; IF (err /= 0) RETURN
    1340     err = cfg_get_value(parser,TRIM(sec)//'d_sat',pp%d_sat)     ; IF (err /= 0) RETURN
    1341     err = cfg_get_value(parser,TRIM(sec)//'mteta',pp%mteta)     ; IF (err /= 0) RETURN
    1342     err = cfg_get_value(parser,TRIM(sec)//'tx_prod',pp%tx_prod) ; IF (err /= 0) RETURN
     1489    err = cfg_get_value(parser,TRIM(sec)//'/name',pp%name)       ; IF (err /= 0) RETURN
     1490    err = cfg_get_value(parser,TRIM(sec)//'/mas',pp%mas)         ; IF (err /= 0) RETURN
     1491    err = cfg_get_value(parser,TRIM(sec)//'/vol',pp%vol)         ; IF (err /= 0) RETURN
     1492    err = cfg_get_value(parser,TRIM(sec)//'/ray',pp%ray)         ; IF (err /= 0) RETURN
     1493    err = cfg_get_value(parser,TRIM(sec)//'/mas',pp%mas)         ; IF (err /= 0) RETURN
     1494    err = cfg_get_value(parser,TRIM(sec)//'/vol',pp%vol)         ; IF (err /= 0) RETURN
     1495    err = cfg_get_value(parser,TRIM(sec)//'/ray',pp%ray)         ; IF (err /= 0) RETURN
     1496    err = cfg_get_value(parser,TRIM(sec)//'/masmol',pp%masmol)   ; IF (err /= 0) RETURN
     1497    err = cfg_get_value(parser,TRIM(sec)//'/rho',pp%rho)         ; IF (err /= 0) RETURN
     1498    err = cfg_get_value(parser,TRIM(sec)//'/tc',pp%tc)           ; IF (err /= 0) RETURN
     1499    err = cfg_get_value(parser,TRIM(sec)//'/pc',pp%pc)           ; IF (err /= 0) RETURN
     1500    err = cfg_get_value(parser,TRIM(sec)//'/tb',pp%tb)           ; IF (err /= 0) RETURN
     1501    err = cfg_get_value(parser,TRIM(sec)//'/w',pp%w)             ; IF (err /= 0) RETURN
     1502    err = cfg_get_value(parser,TRIM(sec)//'/a_sat',pp%a_sat)     ; IF (err /= 0) RETURN
     1503    err = cfg_get_value(parser,TRIM(sec)//'/b_sat',pp%b_sat)     ; IF (err /= 0) RETURN
     1504    err = cfg_get_value(parser,TRIM(sec)//'/c_sat',pp%c_sat)     ; IF (err /= 0) RETURN
     1505    err = cfg_get_value(parser,TRIM(sec)//'/d_sat',pp%d_sat)     ; IF (err /= 0) RETURN
     1506    err = cfg_get_value(parser,TRIM(sec)//'/mteta',pp%mteta)     ; IF (err /= 0) RETURN
     1507    err = cfg_get_value(parser,TRIM(sec)//'/tx_prod',pp%tx_prod) ; IF (err /= 0) RETURN
    13431508    RETURN
    13441509  END FUNCTION read_esp
     
    13461511  ! =========================================================================
    13471512  ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1348   !                CONFIGURATION PARSER checking methods 
     1513  !                CONFIGURATION PARSER checking methods
    13491514  ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    13501515  ! =========================================================================
     
    13521517  FUNCTION check_r1(err,var,def,wlog) RESULT(ret)
    13531518    !! Check an option value (float).
    1354     !! 
    1355     !! The method checks an option value and optionally set a default value, __def__ to initialize 
     1519    !!
     1520    !! The method checks an option value and optionally set a default value, __def__ to initialize
    13561521    !! __var__ on error if given.
    13571522    TYPE(error), INTENT(in)                :: err  !! Error object from value getter.
     
    13601525    LOGICAL, INTENT(in), OPTIONAL          :: wlog !! .true. to print warning/error message.
    13611526    TYPE(error) :: ret                             !! Input error.
    1362     CHARACTER(len=*), PARAMETER :: defmsg = '... Using default value: ' 
     1527    CHARACTER(len=*), PARAMETER :: defmsg = '... Using default value: '
    13631528    LOGICAL                     :: zlog
    13641529    ret = err
     
    13761541  FUNCTION check_l1(err,var,def,wlog) RESULT(ret)
    13771542    !! Check an option value (logical).
    1378     !! 
    1379     !! The method checks an option value and optionally set a default value, __def__ to initialize 
     1543    !!
     1544    !! The method checks an option value and optionally set a default value, __def__ to initialize
    13801545    !! __var__ on error if given.
    13811546    TYPE(error), INTENT(in)       :: err  !! Error object from value getter.
     
    13841549    LOGICAL, INTENT(in), OPTIONAL :: wlog !! .true. to print warning/error message.
    13851550    TYPE(error) :: ret                    !! Input error.
    1386     CHARACTER(len=*), PARAMETER :: defmsg = '... Using default value: ' 
     1551    CHARACTER(len=*), PARAMETER :: defmsg = '... Using default value: '
    13871552    LOGICAL                     :: zlog
    13881553    ret = err
    1389      zlog = .false. ; IF (PRESENT(wlog)) zlog = wlog
     1554    zlog = .false. ; IF (PRESENT(wlog)) zlog = wlog
    13901555    IF (err == 0) RETURN
    13911556    IF (PRESENT(def)) THEN
     
    14001565  FUNCTION check_i1(err,var,def,wlog) RESULT(ret)
    14011566    !! Check an option value (integer).
    1402     !! 
    1403     !! The method checks an option value and optionally set a default value, __def__ to initialize 
     1567    !!
     1568    !! The method checks an option value and optionally set a default value, __def__ to initialize
    14041569    !! __var__ on error if given.
    14051570    TYPE(error), INTENT(in)       :: err  !! Error object from value getter.
     
    14111576    LOGICAL                     :: zlog
    14121577    ret = err
    1413      zlog = .false. ; IF (PRESENT(wlog)) zlog = wlog
     1578    zlog = .false. ; IF (PRESENT(wlog)) zlog = wlog
    14141579    IF (err == 0) RETURN
    14151580    IF (PRESENT(def)) THEN
     
    14241589  FUNCTION check_s1(err,var,def,wlog) RESULT(ret)
    14251590    !! Check an option value (string).
    1426     !! 
    1427     !! The method checks an option value and optionally set a default value, __def__ to initialize 
     1591    !!
     1592    !! The method checks an option value and optionally set a default value, __def__ to initialize
    14281593    !! __var__ on error if given.
    14291594    TYPE(error), INTENT(in)                      :: err  !! Error object from value getter.
     
    14321597    LOGICAL, INTENT(in), OPTIONAL                :: wlog !! .true. to print warning/error message.
    14331598    TYPE(error) :: ret                                   !! Input error.
    1434     CHARACTER(len=*), PARAMETER :: defmsg = '... Using default value: ' 
     1599    CHARACTER(len=*), PARAMETER :: defmsg = '... Using default value: '
    14351600    LOGICAL                     :: zlog
    1436     ret = err 
     1601    ret = err
    14371602    zlog = .false. ; IF (PRESENT(wlog)) zlog = wlog
    14381603    IF (err == 0) RETURN
Note: See TracChangeset for help on using the changeset viewer.