The ParaMonte Documentation Website
Current view: top level - kernel/tests - Test_TranGaus_mod.f90 (source / functions) Hit Total Coverage
Test: ParaMonte 1.5.1 :: MPI Parallel Kernel - Code Coverage Report Lines: 39 39 100.0 %
Date: 2021-01-08 13:07:16 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 [TranGaus_mod](@ref trangaus_mod).
      44             : !>  \author Amir Shahmoradi
      45             : 
      46             : module Test_TranGaus_mod
      47             : 
      48             :     use TranGaus_mod
      49             :     use Err_mod, only: Err_type
      50             :     use Test_mod, only: Test_type
      51             :     implicit none
      52             : 
      53             :     private
      54             :     public :: test_TranGaus
      55             : 
      56             :     type(Test_type) :: Test
      57             : 
      58             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      59             : 
      60             : contains
      61             : 
      62             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      63             : 
      64           3 :     subroutine test_TranGaus()
      65             : 
      66             :         implicit none
      67             : 
      68           3 :         Test = Test_type(moduleName=MODULE_NAME)
      69           3 :         call Test%run(test_getTranGaus_1, "test_getTranGaus_1")
      70           3 :         call Test%finalize()
      71             : 
      72           3 :     end subroutine test_TranGaus
      73             : 
      74             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      75             : 
      76           3 :     function test_getTranGaus_1() result(assertion)
      77             : 
      78           3 :         use Constants_mod, only: RK, IK ! , NEGINF_RK, POSINF_RK
      79             :         use String_mod, only: num2str
      80             : 
      81             :         implicit none
      82             :         logical                 :: assertion
      83             :         integer(IK), parameter  :: NSIM = 5000_IK
      84             :         real(RK), parameter     :: avg = 2._RK
      85             :         real(RK), parameter     :: std = 3._RK
      86             :         integer(IK)             :: isim, fileUnit1, fileUnit2, fileUnit3, fileUnit4, fileUnit5
      87             : 
      88           3 :         assertion = .true.
      89             : 
      90           3 :         open(newunit=fileUnit1, file=Test%outDir//"/Test_TranGaus_mod@test_getTranGaus_Low1Upp9Avg2Std3."//num2str(Test%Image%id)//".temp", status="replace")
      91           3 :         open(newunit=fileUnit2, file=Test%outDir//"/Test_TranGaus_mod@test_getTranGaus_Low20Upp30Avg2Std3."//num2str(Test%Image%id)//".temp", status="replace")
      92           3 :         open(newunit=fileUnit3, file=Test%outDir//"/Test_TranGaus_mod@test_getTranGaus_Low-15Upp4Avg2Std3."//num2str(Test%Image%id)//".temp", status="replace")
      93           3 :         open(newunit=fileUnit4, file=Test%outDir//"/Test_TranGaus_mod@test_getTranGaus_Low50Upp55Avg2Std3."//num2str(Test%Image%id)//".temp", status="replace")
      94           3 :         open(newunit=fileUnit5, file=Test%outDir//"/Test_TranGaus_mod@test_getTranGaus_Low-50Upp55Avg2Std3."//num2str(Test%Image%id)//".temp", status="replace") ! test `lowerLim < xmin`
      95           3 :         write(fileUnit1,*) "TranGaus"
      96           3 :         write(fileUnit2,*) "TranGaus"
      97           3 :         write(fileUnit3,*) "TranGaus"
      98           3 :         write(fileUnit4,*) "TranGaus"
      99             : 
     100             :         ! Random variable generation
     101             : 
     102       15003 :         do isim = 1, NSIM
     103       15000 :             write(fileUnit1,*) getTranGaus(lowerLim=1._RK,upperLim=9._RK,avg=avg,std=std)
     104       15000 :             write(fileUnit2,*) getTranGaus(lowerLim=20._RK,upperLim=30._RK,avg=avg,std=std)
     105       15000 :             write(fileUnit3,*) getTranGaus(lowerLim=-15._RK,upperLim=4._RK,avg=avg,std=std)
     106       15000 :             write(fileUnit4,*) getTranGaus(lowerLim=50._RK,upperLim=55._RK,avg=avg,std=std)
     107       15000 :             write(fileUnit5,*) getTranGaus(lowerLim=-50._RK,upperLim=55._RK,avg=avg,std=std)
     108       15000 :             write(fileUnit5,*) getTranGaus(lowerLim=0._RK,upperLim=500._RK,avg=avg,std=std)
     109       15000 :             write(fileUnit5,*) getTranGaus(lowerLim=-5.e2_RK,upperLim=5.e2_RK,avg=avg,std=std)
     110       15000 :             write(fileUnit5,*) getTranGaus(lowerLim=-5.e2_RK,upperLim=0._RK,avg=avg,std=std)
     111       15000 :             write(fileUnit5,*) getTranGaus(lowerLim=100._RK,upperLim=100.1_RK,avg=avg,std=std)
     112       15000 :             write(fileUnit5,*) getTranGaus(lowerLim=9999.8_RK,upperLim=9999.9_RK,avg=avg,std=std)
     113       15000 :             write(fileUnit5,*) getTranGaus(lowerLim=-9999.9_RK,upperLim=-9999.8_RK,avg=avg,std=std)
     114       15000 :             write(fileUnit5,*) getTranGaus(lowerLim=-.001_RK,upperLim=.001_RK,avg=avg,std=std)
     115       15000 :             write(fileUnit5,*) getTranGaus(lowerLim=9999.8_RK,upperLim=9999.9_RK,avg=-avg,std=std)
     116       15000 :             write(fileUnit5,*) getTranGaus(lowerLim=-9999.9_RK,upperLim=-9999.8_RK,avg=-avg,std=std)
     117       15003 :             write(fileUnit5,*) getTranGaus(lowerLim=-.001_RK,upperLim=.001_RK,avg=-avg,std=std)
     118             :         end do
     119           3 :         close(fileUnit1)
     120           3 :         close(fileUnit2)
     121           3 :         close(fileUnit3)
     122           3 :         close(fileUnit4)
     123           3 :         close(fileUnit5)
     124             : 
     125             :         ! ideally, as a test, one could compute the PDF of the Gaussian and compare it to the histogram of the generated points.
     126             :         ! This is not an easy task. For now, we rust the giants.
     127             : 
     128           3 :     end function test_getTranGaus_1
     129             : 
     130             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     131             : 
     132             : end module Test_TranGaus_mod ! LCOV_EXCL_LINE

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