The ParaMonte Documentation Website
Current view: top level - kernel/tests - Test_GeoCyclicFit_mod.f90 (source / functions) Hit Total Coverage
Test: ParaMonte 1.5.1 :: Serial Kernel - Code Coverage Report Lines: 15 15 100.0 %
Date: 2021-01-08 13:03:42 Functions: 2 2 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 This module contains tests of the module [GeoCyclicFit_mod](@ref geocyclicfit_mod).
      44             : !>  \author Amir Shahmoradi
      45             : 
      46             : module Test_GeoCyclicFit_mod
      47             : 
      48             :     use Test_mod, only: Test_type
      49             :     use GeoCyclicFit_mod
      50             :     implicit none
      51             : 
      52             :     private
      53             :     public :: test_GeoCyclicFit
      54             : 
      55             :     type(Test_type) :: Test
      56             : 
      57             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      58             : 
      59             : contains
      60             : 
      61             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      62             : 
      63           1 :     subroutine test_GeoCyclicFit()
      64             :         implicit none
      65           1 :         Test = Test_type(moduleName=MODULE_NAME)
      66           1 :         call Test%run(test_fitGeoCyclicLogPDF_1, "test_fitGeoCyclicLogPDF_1")
      67           1 :         call Test%finalize()
      68           1 :     end subroutine test_GeoCyclicFit
      69             : 
      70             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      71             : 
      72           1 :     function test_fitGeoCyclicLogPDF_1() result(assertion)
      73           1 :         use Constants_mod, only: IK, RK
      74             :         implicit none
      75             :         logical                     :: assertion
      76             :         integer(IK)                 :: i
      77             :         integer(IK) , parameter     :: nparam = 2_IK
      78             :         integer(IK) , parameter     :: numTrial = 64_IK
      79             :         integer(IK) , parameter     :: maxNumTrial = 64_IK
      80             :         integer(IK) , parameter     :: SuccessStep(numTrial) = [ (i, i = 1, numTrial) ]
      81             :         real(RK)    , parameter     :: LogCount(numTrial) = log( real(  [ 64_IK, 55_IK, 53_IK, 43_IK, 54_IK, 41_IK &
      82             :                                                                         , 45_IK, 55_IK, 50_IK, 42_IK, 48_IK, 52_IK &
      83             :                                                                         , 38_IK, 52_IK, 56_IK, 54_IK, 45_IK, 54_IK &
      84             :                                                                         , 69_IK, 50_IK, 50_IK, 49_IK, 45_IK, 38_IK &
      85             :                                                                         , 45_IK, 34_IK, 55_IK, 51_IK, 49_IK, 49_IK &
      86             :                                                                         , 47_IK, 58_IK, 37_IK, 54_IK, 50_IK, 59_IK &
      87             :                                                                         , 37_IK, 39_IK, 36_IK, 52_IK, 51_IK, 37_IK &
      88             :                                                                         , 44_IK, 46_IK, 37_IK, 29_IK, 41_IK, 39_IK &
      89             :                                                                         , 50_IK, 39_IK, 46_IK, 42_IK, 54_IK, 54_IK &
      90             :                                                                         , 54_IK, 24_IK, 44_IK, 43_IK, 37_IK, 43_IK &
      91             :                                                                         , 53_IK, 47_IK, 50_IK, 42_IK ], kind = RK ))
      92             :         real(RK)    , parameter     :: successProb = 0.7_RK
      93             :         real(RK)    , parameter     :: tolerance = 1.e-6_RK
      94             :         real(RK)                    :: xmin_ref(nparam) = [ 0.31952589641887075E-002_RK, 7.992349027030083_RK ]
      95             :         real(RK)                    :: Difference(nparam)
      96           1 :         type(GeoCyclicFit_type)     :: GeoCyclicFit
      97             : 
      98           1 :         GeoCyclicFit%PowellMinimum = GeoCyclicFit%fit(maxNumTrial, numTrial, SuccessStep, LogCount)
      99           1 :         assertion = .not. GeoCyclicFit%PowellMinimum%Err%occurred
     100           1 :         if (.not. assertion) return
     101             : 
     102           3 :         Difference = abs(GeoCyclicFit%PowellMinimum%xmin - xmin_ref) / abs(xmin_ref)
     103           3 :         assertion = all( Difference < tolerance )
     104             : 
     105           1 :         if (Test%isDebugMode .and. .not. assertion) then
     106             :         ! LCOV_EXCL_START
     107             :             write(Test%outputUnit,"(*(g0,:,' '))")
     108             :             write(Test%outputUnit,"(*(g0,:,' '))") "xmin_ref    =", xmin_ref
     109             :             write(Test%outputUnit,"(*(g0,:,' '))") "xmin        =", GeoCyclicFit%PowellMinimum%xmin
     110             :             write(Test%outputUnit,"(*(g0,:,' '))") "Difference  =", Difference
     111             :             write(Test%outputUnit,"(*(g0,:,' '))")
     112             :         end if
     113             :         ! LCOV_EXCL_STOP
     114             : 
     115           1 :     end function test_fitGeoCyclicLogPDF_1
     116             : 
     117             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     118             : 
     119             : end module Test_GeoCyclicFit_mod

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