The ParaMonte Documentation Website
Current view: top level - kernel - SpecBase_MaxNumDomainCheckToStop_mod.f90 (source / functions) Hit Total Coverage
Test: ParaMonte 1.5.1 :: Serial Kernel - Code Coverage Report Lines: 20 20 100.0 %
Date: 2021-01-08 13:03:42 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       2             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       3             : !!!!
       4             : !!!!   MIT License
       5             : !!!!
       6             : !!!!   ParaMonte: plain powerful parallel Monte Carlo library.
       7             : !!!!
       8             : !!!!   Copyright (C) 2012-present, The Computational Data Science Lab
       9             : !!!!
      10             : !!!!   This file is part of the ParaMonte library.
      11             : !!!!
      12             : !!!!   Permission is hereby granted, free of charge, to any person obtaining a 
      13             : !!!!   copy of this software and associated documentation files (the "Software"), 
      14             : !!!!   to deal in the Software without restriction, including without limitation 
      15             : !!!!   the rights to use, copy, modify, merge, publish, distribute, sublicense, 
      16             : !!!!   and/or sell copies of the Software, and to permit persons to whom the 
      17             : !!!!   Software is furnished to do so, subject to the following conditions:
      18             : !!!!
      19             : !!!!   The above copyright notice and this permission notice shall be 
      20             : !!!!   included in all copies or substantial portions of the Software.
      21             : !!!!
      22             : !!!!   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
      23             : !!!!   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
      24             : !!!!   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
      25             : !!!!   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
      26             : !!!!   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
      27             : !!!!   OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
      28             : !!!!   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
      29             : !!!!
      30             : !!!!   ACKNOWLEDGMENT
      31             : !!!!
      32             : !!!!   ParaMonte is an honor-ware and its currency is acknowledgment and citations.
      33             : !!!!   As per the ParaMonte library license agreement terms, if you use any parts of 
      34             : !!!!   this library for any purposes, kindly acknowledge the use of ParaMonte in your 
      35             : !!!!   work (education/research/industry/development/...) by citing the ParaMonte 
      36             : !!!!   library as described on this page:
      37             : !!!!
      38             : !!!!       https://github.com/cdslaborg/paramonte/blob/main/ACKNOWLEDGMENT.md
      39             : !!!!
      40             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      41             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      42             : 
      43             : !> \brief
      44             : !> This module contains the classes and procedures for setting up the `maxNumDomainCheckToStop` attribute of ParaMonte samplers.
      45             : !> For more information, see the description of this attribute in the body of the module.
      46             : !> \author Amir Shahmoradi
      47             : 
      48             : module SpecBase_MaxNumDomainCheckToStop_mod
      49             : 
      50             :     use Constants_mod, only: IK
      51             :     implicit none
      52             : 
      53             :     character(*), parameter         :: MODULE_NAME = "@SpecBase_MaxNumDomainCheckToStop_mod"
      54             : 
      55             :     integer(IK)                     :: maxNumDomainCheckToStop ! namelist input
      56             : 
      57             :     type                            :: MaxNumDomainCheckToStop_type
      58             :         integer(IK)                 :: val
      59             :         integer(IK)                 :: def
      60             :         integer(IK)                 :: null
      61             :         character(:), allocatable   :: desc
      62             :     contains
      63             :         procedure, pass             :: set => setMaxNumDomainCheckToStop, checkForSanity, nullifyNameListVar
      64             :     end type MaxNumDomainCheckToStop_type
      65             : 
      66             :     interface MaxNumDomainCheckToStop_type
      67             :         module procedure                :: constructMaxNumDomainCheckToStop
      68             :     end interface MaxNumDomainCheckToStop_type
      69             : 
      70             :     private :: constructMaxNumDomainCheckToStop, setMaxNumDomainCheckToStop
      71             : 
      72             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      73             : 
      74             : contains
      75             : 
      76             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      77             : 
      78         349 :     function constructMaxNumDomainCheckToStop() result(MaxNumDomainCheckToStopObj)
      79             : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
      80             :         !DEC$ ATTRIBUTES DLLEXPORT :: constructMaxNumDomainCheckToStop
      81             : #endif
      82             :         use Constants_mod, only: IK, NULL_IK
      83             :         use String_mod, only: num2str
      84             :         implicit none
      85             :         type(MaxNumDomainCheckToStop_type) :: MaxNumDomainCheckToStopObj
      86         349 :         MaxNumDomainCheckToStopObj%def = 10000_IK
      87         349 :         MaxNumDomainCheckToStopObj%null = NULL_IK
      88             :         MaxNumDomainCheckToStopObj%desc = &
      89             :         "maxNumDomainCheckToStop is an integer number beyond which the program will stop globally with a fatal error message &
      90             :         &declaring that the maximum number of proposal-out-of-domain-bounds has reached. The counter for this global-stop request &
      91             :         &is reset after a proposal point is accepted as a sample from within the domain of the objective function. &
      92             :         &When out-of-domain sampling happens frequently, it is a strong indication of something fundamentally wrong in the &
      93             :         &simulation. It is, therefore, important to closely inspect and monitor for such frequent out-of-domain samplings. &
      94             :         &This can be done by setting maxNumDomainCheckToStop to an appropriate value determined by the user. &
      95         349 :         &The default value is " // num2str(MaxNumDomainCheckToStopObj%def) // "."
      96         349 :     end function constructMaxNumDomainCheckToStop
      97             : 
      98             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      99             : 
     100         349 :     subroutine nullifyNameListVar(MaxNumDomainCheckToStopObj)
     101             : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
     102             :         !DEC$ ATTRIBUTES DLLEXPORT :: nullifyNameListVar
     103             : #endif
     104             :         implicit none
     105             :         class(MaxNumDomainCheckToStop_type), intent(in)     :: MaxNumDomainCheckToStopObj
     106         349 :         maxNumDomainCheckToStop = MaxNumDomainCheckToStopObj%null
     107         349 :     end subroutine nullifyNameListVar
     108             : 
     109             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     110             : 
     111         353 :     subroutine setMaxNumDomainCheckToStop(MaxNumDomainCheckToStopObj,maxNumDomainCheckToStop)
     112             : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
     113             :         !DEC$ ATTRIBUTES DLLEXPORT :: setMaxNumDomainCheckToStop
     114             : #endif
     115         349 :         use Constants_mod, only: IK
     116             :         implicit none
     117             :         class(MaxNumDomainCheckToStop_type), intent(inout)  :: MaxNumDomainCheckToStopObj
     118             :         integer(IK), intent(in)                             :: maxNumDomainCheckToStop
     119         353 :         MaxNumDomainCheckToStopObj%val = maxNumDomainCheckToStop
     120         353 :         if (MaxNumDomainCheckToStopObj%val==MaxNumDomainCheckToStopObj%null) then
     121         343 :             MaxNumDomainCheckToStopObj%val = MaxNumDomainCheckToStopObj%def
     122             :         end if
     123         353 :     end subroutine setMaxNumDomainCheckToStop
     124             : 
     125             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     126             : 
     127         345 :     subroutine checkForSanity(MaxNumDomainCheckToStop,Err,methodName)
     128             : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
     129             :         !DEC$ ATTRIBUTES DLLEXPORT :: checkForSanity
     130             : #endif
     131         353 :         use Err_mod, only: Err_type
     132             :         use String_mod, only: num2str
     133             :         implicit none
     134             :         class(MaxNumDomainCheckToStop_type), intent(in) :: MaxNumDomainCheckToStop
     135             :         character(*), intent(in)                        :: methodName
     136             :         type(Err_type), intent(inout)                   :: Err
     137             :         character(*), parameter                         :: PROCEDURE_NAME = "@checkForSanity()"
     138         345 :         if ( MaxNumDomainCheckToStop%val<1 ) then
     139           4 :             Err%occurred = .true.
     140             :             Err%msg =   Err%msg // &
     141             :                         MODULE_NAME // PROCEDURE_NAME // ": Error occurred. &
     142             :                         &The input value for variable maxNumDomainCheckToStop must be a positive integer. &
     143             :                         &If you are not sure about the appropriate value for this variable, simply drop it from the input. " // &
     144           4 :                         methodName // " will automatically assign an appropriate value to it.\n\n"
     145             :         end if
     146         690 :     end subroutine checkForSanity
     147             : 
     148             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     149             : 
     150             : end module SpecBase_MaxNumDomainCheckToStop_mod ! LCOV_EXCL_LINE

ParaMonte: Plain Powerful Parallel Monte Carlo Library 
The Computational Data Science Lab
© Copyright 2012 - 2021