https://www.cdslab.org/paramonte/fortran/2
Current view: top level - main - pm_batse.F90 (source / functions) Hit Total Coverage
Test: ParaMonte 2.0.0 :: Serial Fortran - Code Coverage Report Lines: 0 1 0.0 %
Date: 2024-04-08 03:18:57 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       2             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       3             : !!!!                                                                                                                            !!!!
       4             : !!!!    ParaMonte: Parallel Monte Carlo and Machine Learning Library.                                                           !!!!
       5             : !!!!                                                                                                                            !!!!
       6             : !!!!    Copyright (C) 2012-present, The Computational Data Science Lab                                                          !!!!
       7             : !!!!                                                                                                                            !!!!
       8             : !!!!    This file is part of the ParaMonte library.                                                                             !!!!
       9             : !!!!                                                                                                                            !!!!
      10             : !!!!    LICENSE                                                                                                                 !!!!
      11             : !!!!                                                                                                                            !!!!
      12             : !!!!       https://github.com/cdslaborg/paramonte/blob/main/LICENSE.md                                                          !!!!
      13             : !!!!                                                                                                                            !!!!
      14             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      15             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      16             : 
      17             : !>  \brief
      18             : !>  This module contains procedures and generic interfaces for modeling data and
      19             : !>  detectors of the BATSE Gamma-Ray satellite onboard the NASA Compton Gamma-Ray Observatory.<br>
      20             : !>
      21             : !>  \details
      22             : !>  The Compton Gamma Ray Observatory (CGRO) was a space observatory detecting photons with energies from 20 keV to 30 GeV, in Earth orbit from 1991 to 2000.<br>
      23             : !>  The observatory featured four main telescopes in one spacecraft, covering X-rays and gamma rays, including various specialized sub-instruments and detectors.<br>
      24             : !>  Following 14 years of effort, the observatory was launched from Space Shuttle Atlantis during STS-37 on April 5, 1991, and operated until its deorbit on June 4, 2000.<br>
      25             : !>  It was deployed in low Earth orbit at 450 km (280 mi) to avoid the Van Allen radiation belt.<br>
      26             : !>  It was the heaviest astrophysical payload ever flown at that time at 16,300 kilograms (35,900 lb).<br>
      27             : !>
      28             : !>  Instruments
      29             : !>  ===========
      30             : !>
      31             : !>  CGRO carried a complement of four instruments that covered an unprecedented six orders of the electromagnetic spectrum, from 20 keV to 30 GeV.<br>
      32             : !>  Only the major instrument of interest to this module is discussed below.<br>
      33             : !>
      34             : !>  BATSE
      35             : !>  -----
      36             : !>
      37             : !>  \image html pm_batse.gif width=500
      38             : !>
      39             : !>  The Burst and Transient Source Experiment (BATSE) by the NASA Marshall Space Flight Center searched
      40             : !>  the sky for gamma-ray bursts (20 to >600 keV) and conducted full-sky surveys for long-lived sources.<br>
      41             : !>  It consisted of eight identical detector modules, one at each of the satellite corners.<br>
      42             : !>  Each module consisted of both a NaI(Tl) Large Area Detector (LAD) covering the 20 keV to ~2 MeV range, 50.48 cm in dia by 1.27 cm thick,
      43             : !>  and a 12.7 cm dia by 7.62 cm thick NaI Spectroscopy Detector, which extended the upper energy range to 8 MeV, all surrounded by a
      44             : !>  plastic scintillator in active anti-coincidence to veto the large background rates due to cosmic rays and trapped radiation.<br>
      45             : !>  Sudden increases in the LAD rates triggered a high-speed data storage mode, the details of the burst being read out to telemetry later.<br>
      46             : !>  Bursts were typically detected at rates of roughly one per day over the 9-year CGRO mission.<br>
      47             : !>  A strong burst could result in the observation of many thousands of gamma-rays within a time interval ranging from ~0.1 s up to about 100 s.<br>
      48             : !>
      49             : !>  Other instruments
      50             : !>  -----------------
      51             : !>
      52             : !>  See the references below.<br>
      53             : !>
      54             : !>  \see
      55             : !>  [pm_distBand](@ref pm_distBand)<br>
      56             : !>  Kaneko, 2005, Spectral studies of gamma-ray burst prompt emission.<br>
      57             : !>  [Shahmoradi and Nemiroff, 2015, MNRAS, 451:4645-4662.](https://www.cdslab.org/pubs/2015_Shahmoradi_I.pdf)<br>
      58             : !>
      59             : !>  \test
      60             : !>  [test_pm_batse](@ref test_pm_batse)<br>
      61             : !>
      62             : !>  \finmain
      63             : !>
      64             : !>  \author
      65             : !>  \FatemehBagheri, Tuesday April 30, 2019, 12:58 PM, SEIR, UTA
      66             : 
      67             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      68             : 
      69             : module pm_batse
      70             : 
      71             :     use pm_kind, only: SK, IK, RKD, RKB
      72             : 
      73             :     implicit none
      74             : 
      75             :     character(*, SK), parameter :: MODULE_NAME = "@pm_batse"
      76             : 
      77             :     real(RKB)       , parameter :: LOG_TEN = log(10._RKB)
      78             :     real(RKB)       , parameter :: MIN_LOG10PH53_4_LOGPBOLZERO  = 4.92_RKB
      79             :     real(RKB)       , parameter :: MAX_LOG10PH53_4_LOGPBOLZERO  = 6.318167895318538_RKB
      80             :     real(RKB)       , parameter :: MAX_LOGPH53_4_LOGPBOLZERO    = MAX_LOG10PH53_4_LOGPBOLZERO * LOG_TEN
      81             :     real(RKB)       , parameter :: MIN_LOGPH53_4_LOGPBOLZERO    = MIN_LOG10PH53_4_LOGPBOLZERO * LOG_TEN
      82             :     real(RKB)       , parameter :: DIF_LOGPH53_4_LOGPBOLZERO    = MAX_LOGPH53_4_LOGPBOLZERO - MIN_LOGPH53_4_LOGPBOLZERO
      83             : 
      84             :     ! Parameters for the effective peak flux of SGRBs (P64ms conversion to P1024):
      85             : 
      86             : !   ! The scale of the change in BATSE efficiency for different GRB durations.
      87             : !   real(RKB)       , parameter :: THRESH_ERFC_BASE             = +0.146314238936889_RKB
      88             : !
      89             : !   ! The scale of the change in BATSE efficiency for different GRB durations.
      90             : !   real(RKB)       , parameter :: THRESH_ERFC_AMP              = +0.570285374263156_RKB
      91             : !
      92             : !   ! Mean duration in the Error function used to model the connection between the peak fluxes in 64 and 1024 ms.
      93             : !   real(RKB)       , parameter :: THRESH_ERFC_AVG              = -0.480811530417719_RKB
      94             : !
      95             : !   ! scale of the duration in the Error function used to model the connection between the peak fluxes in 64 and 1024 ms.
      96             : !   real(RKB)       , parameter :: THRESH_ERFC_STD              = +1.292443569094922_RKB
      97             : 
      98             :     real(RKB)       , parameter :: LOGPF53_MINUS_LOGPBOL        = 11.328718657530706_RKB
      99             :     real(RKB)       , parameter :: LOG10PF53_MINUS_LOG10PBOL    = LOGPF53_MINUS_LOGPBOL / LOG_TEN
     100             : 
     101             :     !>  The scale of the change in BATSE efficiency for different SGRB durations.
     102             :     real(RKB)       , parameter :: THRESH_ERFC_BASE             = +0.146314238936889_RKB * LOG_TEN
     103             : 
     104             :     !>  The scale of the change in BATSE efficiency for different GRB durations.
     105             :     real(RKB)       , parameter :: THRESH_ERFC_AMP              = +0.282313526464596_RKB * LOG_TEN ! Serfc
     106             : 
     107             :     !>  Mean duration in the Error function used to model the connection between the peak fluxes in 64 and 1024 ms.
     108             :     real(RKB)       , parameter :: THRESH_ERFC_AVG              = -0.483553339256463_RKB * LOG_TEN  ! meandur
     109             : 
     110             :     !>  Scale of the duration in the Error function used to model the connection between the peak fluxes in 64 and 1024 ms.
     111             :     real(RKB)       , parameter :: THRESH_ERFC_STD              = 1.0514698984694800_RKB * LOG_TEN  ! scaledur
     112             : 
     113             :     !>  Inverse scale of the duration in the Error function used to model the connection between the peak fluxes in 64 and 1024 ms.
     114             :     real(RKB)       , parameter :: THRESH_ERFC_STD_INV          = 1._RKB / THRESH_ERFC_STD       ! inverse scaledur
     115             : 
     116             :     ! The height of the ERFC function.
     117             :     real(RKB)       , parameter :: THRESH_ERFC_HEIGHT           = 2 * THRESH_ERFC_AMP
     118             : 
     119             :     !>  Correction that must be added to logPbol64ms to convert it to effective peak flux.
     120             :     !   Effective LogPbol limit above which trigger efficiency is 100%, for any Log(Epk) and Log(dur). It is equivalent to maximum Log(Pbol) at very long durations.
     121             :     real(RKB)       , parameter :: THRESH_LOGPBOL64_CORRECTION  = DIF_LOGPH53_4_LOGPBOLZERO - MIN_LOGPH53_4_LOGPBOLZERO + THRESH_ERFC_HEIGHT ! equivalent to lpb_correction
     122             : 
     123             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     124             : 
     125             :     !>  \brief
     126             :     !>  This is the derived type for generating objects that contain attributes of BATSE catalog GRBs.<br>
     127             :     !>
     128             :     !>  \test
     129             :     !>  [test_pm_batse](@ref test_pm_batse)
     130             :     !>
     131             :     !>  \finmain{getCorrectionLogEffPPF}
     132             :     !>
     133             :     !>  \author
     134             :     !>  \AmirShahmoradi, Oct 16, 2009, 11:14 AM, Michigan
     135             :     type :: grb_type
     136             :         real(RKD) :: pbol    = -huge(0._RKD) ! < \public The scalar `real` of kind \RKD, containing a measure of the bolometric energy flux of a BATSE GRB event.
     137             :         real(RKD) :: epeak   = -huge(0._RKD) ! < \public The scalar `real` of kind \RKD, containing a measure of the spectral peak energy of a BATSE GRB event.
     138             :         real(RKD) :: sbol    = -huge(0._RKD) ! < \public The scalar `real` of kind \RKD, containing a measure of the bolometric energy fluence of a BATSE GRB event.
     139             :         real(RKD) :: t90     = -huge(0._RKD) ! < \public The scalar `real` of kind \RKD, containing a measure of the duration of a BATSE GRB event.
     140             :         real(RKD) :: pph1024 = -huge(0._RKD) ! < \public The scalar `real` of kind \RKD, containing a measure of the peak 1024ms photon flux of a BATSE GRB event in the BATSE nominal detection energy window \f$[50, 300]\f$.
     141             :     end type
     142             : 
     143             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     144             : 
     145             :     !>  \brief
     146             :     !>  Generate and return the correction required for converting an input **natural-log** peak photon flux in 64ms timescale in
     147             :     !>  the BATSE detection energy range to an effective triggering peak photon flux in the same energy range.<br>
     148             :     !>
     149             :     !>  \details
     150             :     !>  See the *Eqn A4 of Shahmoradi and Nemiroff 2015, MNRAS, Short versus long gamma-ray bursts* for more details.<br>
     151             :     !>  The observed T90 duration of the event is necessary as input to account for varying duration of short GRBs.<br>
     152             :     !>
     153             :     !>  \param[in]  logT90  :   The input scalar, or array of arbitrary rank, of type `real` of kind \RKALL,
     154             :     !>                          containing the natural logarithm of the T90 duration-definition measure of a GRB in units of seconds.<br>
     155             :     !>
     156             :     !>  \return
     157             :     !>  `correction`        :   The output scalar or array of the same rank as the input argument of same type and kind as the input argument,
     158             :     !>                          containing the correction that must be subtracted from the natural logarithm of a given 64ms peak flux
     159             :     !>                          to convert it to an effective 1024ms triggering peak flux.
     160             :     !>
     161             :     !>  \interface{getCorrectionLogEffPPF}
     162             :     !>  \code{.F90}
     163             :     !>
     164             :     !>      use pm_batse, only: getCorrectionLogEffPPF
     165             :     !>
     166             :     !>      correction = getCorrectionLogEffPPF(logT90)
     167             :     !>
     168             :     !>  \endcode
     169             :     !>
     170             :     !>  \pure
     171             :     !>
     172             :     !>  \elemental
     173             :     !>
     174             :     !>  \note
     175             :     !>  The following relationship holds: `logPPF64 - getCorrectionLogEffPPF(logT90) = logPPF1024 - THRESH_ERFC_BASE`.<br>
     176             :     !>
     177             :     !>  \see
     178             :     !>  [getLogPbol](@ref pm_batse::getLogPbol)<br>
     179             :     !>  [getLogPF53](@ref pm_batse::getLogPF53)<br>
     180             :     !>  [getLog10PF53](@ref pm_batse::getLog10PF53)<br>
     181             :     !>  [getLogEffPPF](@ref pm_batse::getLogEffPPF)<br>
     182             :     !>  [getCorrectionLogEffPPF](@ref pm_batse::getCorrectionLogEffPPF)<br>
     183             :     !>
     184             :     !>  \test
     185             :     !>  [test_pm_batse](@ref test_pm_batse)
     186             :     !>
     187             :     !>  \finmain{getCorrectionLogEffPPF}
     188             :     !>
     189             :     !>  \author
     190             :     !>  \AmirShahmoradi, Oct 16, 2009, 11:14 AM, Michigan
     191             :     interface getCorrectionLogEffPPF
     192             : 
     193             :     !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     194             : 
     195             : #if RK5_ENABLED
     196             :     pure elemental module function getCorrectionLogEffPPF_RK5(logT90) result(correction)
     197             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     198             :         !DEC$ ATTRIBUTES DLLEXPORT :: getCorrectionLogEffPPF_RK5
     199             : #endif
     200             :         use pm_kind, only: RKC => RK5
     201             :         real(RKC)   , intent(in)    :: logT90
     202             :         real(RKC)                   :: correction
     203             :     end function
     204             : #endif
     205             : 
     206             : #if RK4_ENABLED
     207             :     pure elemental module function getCorrectionLogEffPPF_RK4(logT90) result(correction)
     208             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     209             :         !DEC$ ATTRIBUTES DLLEXPORT :: getCorrectionLogEffPPF_RK4
     210             : #endif
     211             :         use pm_kind, only: RKC => RK4
     212             :         real(RKC)   , intent(in)    :: logT90
     213             :         real(RKC)                   :: correction
     214             :     end function
     215             : #endif
     216             : 
     217             : #if RK3_ENABLED
     218             :     pure elemental module function getCorrectionLogEffPPF_RK3(logT90) result(correction)
     219             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     220             :         !DEC$ ATTRIBUTES DLLEXPORT :: getCorrectionLogEffPPF_RK3
     221             : #endif
     222             :         use pm_kind, only: RKC => RK3
     223             :         real(RKC)   , intent(in)    :: logT90
     224             :         real(RKC)                   :: correction
     225             :     end function
     226             : #endif
     227             : 
     228             : #if RK2_ENABLED
     229             :     pure elemental module function getCorrectionLogEffPPF_RK2(logT90) result(correction)
     230             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     231             :         !DEC$ ATTRIBUTES DLLEXPORT :: getCorrectionLogEffPPF_RK2
     232             : #endif
     233             :         use pm_kind, only: RKC => RK2
     234             :         real(RKC)   , intent(in)    :: logT90
     235             :         real(RKC)                   :: correction
     236             :     end function
     237             : #endif
     238             : 
     239             : #if RK1_ENABLED
     240             :     pure elemental module function getCorrectionLogEffPPF_RK1(logT90) result(correction)
     241             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     242             :         !DEC$ ATTRIBUTES DLLEXPORT :: getCorrectionLogEffPPF_RK1
     243             : #endif
     244             :         use pm_kind, only: RKC => RK1
     245             :         real(RKC)   , intent(in)    :: logT90
     246             :         real(RKC)                   :: correction
     247             :     end function
     248             : #endif
     249             : 
     250             :     !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     251             : 
     252             :     end interface getCorrectionLogEffPPF
     253             : 
     254             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     255             : 
     256             :     !>  \brief
     257             :     !>  Generate and return the conversion of an input natural logarithm of peak photon flux in 64ms timescale to
     258             :     !>  an effective triggering peak photon flux both in the BATSE detection energy range \f$[50, 300]\kev\f$.<br>
     259             :     !>
     260             :     !>  \details
     261             :     !>  See the *Eqn A4 of Shahmoradi and Nemiroff 2015, MNRAS, Short versus long gamma-ray bursts* for more details.<br>
     262             :     !>  The observed T90 duration of the event is necessary as input to account for varying duration of short GRBs and their effects on the triggering mechanism.<br>
     263             :     !>
     264             :     !>  \param[in]  logPPF64    :   The input scalar, or array of the same rank as other input array-valued arguments, of type `real` of kind \RKALL,
     265             :     !>                              containing the natural logarithm of the 64ms Peak Photon Flux of an event in units of \f$[\ms{photons} / \ms{sec}]\f$.<br>
     266             :     !>  \param[in]  logT90      :   The input scalar, or array of the same rank as other input array-valued arguments, of the same type and kind as `logPPF64`,
     267             :     !>                              containing the natural logarithm of the T90 duration-definition measure of a GRB in units of seconds.<br>
     268             :     !>
     269             :     !>  \return
     270             :     !>  `logEffPPF`             :   The output scalar or array of the same rank as the input arguments of same type and kind as the input arguments,
     271             :     !>                              containing the natural logarithm of the effective 1024ms triggering peak photon flux in the BATSE nominal
     272             :     !>                              detection energy range, such that the effects of multiple triggering timescale of BATSE detectors
     273             :     !>                              are compensated for, as if all BATSE GRBs with different observed durations were detected
     274             :     !>                              by the same duration-agnostic gamma-ray detector and triggering mechanism.
     275             :     !>
     276             :     !>  \interface{getLogEffPPF}
     277             :     !>  \code{.F90}
     278             :     !>
     279             :     !>      use pm_batse, only: getLogEffPPF
     280             :     !>
     281             :     !>      logEffPPF = getLogEffPPF(logPPF64, logT90)
     282             :     !>
     283             :     !>  \endcode
     284             :     !>
     285             :     !>  \pure
     286             :     !>
     287             :     !>  \elemental
     288             :     !>
     289             :     !>  \note
     290             :     !>  The following relationship holds: `logPPF64 - getCorrectionLogEffPPF(logT90) = logPPF1024 - THRESH_ERFC_BASE`.<br>
     291             :     !>
     292             :     !>  \see
     293             :     !>  [getLogPbol](@ref pm_batse::getLogPbol)<br>
     294             :     !>  [getLogPF53](@ref pm_batse::getLogPF53)<br>
     295             :     !>  [getLog10PF53](@ref pm_batse::getLog10PF53)<br>
     296             :     !>  [getLogEffPPF](@ref pm_batse::getLogEffPPF)<br>
     297             :     !>  [getCorrectionLogEffPPF](@ref pm_batse::getCorrectionLogEffPPF)<br>
     298             :     !>
     299             :     !>  \test
     300             :     !>  [test_pm_batse](@ref test_pm_batse)
     301             :     !>
     302             :     !>  \finmain{getLogEffPPF}
     303             :     !>
     304             :     !>  \author
     305             :     !>  \AmirShahmoradi, Oct 16, 2009, 11:14 AM, Michigan
     306             :     interface getLogEffPPF
     307             : 
     308             :     !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     309             : 
     310             : #if RK5_ENABLED
     311             :     pure elemental module function getLogEffPPF_RK5(logPPF64, logT90) result(logEffPPF)
     312             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     313             :         !DEC$ ATTRIBUTES DLLEXPORT :: getLogEffPPF_RK5
     314             : #endif
     315             :         use pm_kind, only: RKC => RK5
     316             :         real(RKC)   , intent(in)    :: logPPF64, logT90
     317             :         real(RKC)                   :: logEffPPF
     318             :     end function
     319             : #endif
     320             : 
     321             : #if RK4_ENABLED
     322             :     pure elemental module function getLogEffPPF_RK4(logPPF64, logT90) result(logEffPPF)
     323             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     324             :         !DEC$ ATTRIBUTES DLLEXPORT :: getLogEffPPF_RK4
     325             : #endif
     326             :         use pm_kind, only: RKC => RK4
     327             :         real(RKC)   , intent(in)    :: logPPF64, logT90
     328             :         real(RKC)                   :: logEffPPF
     329             :     end function
     330             : #endif
     331             : 
     332             : #if RK3_ENABLED
     333             :     pure elemental module function getLogEffPPF_RK3(logPPF64, logT90) result(logEffPPF)
     334             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     335             :         !DEC$ ATTRIBUTES DLLEXPORT :: getLogEffPPF_RK3
     336             : #endif
     337             :         use pm_kind, only: RKC => RK3
     338             :         real(RKC)   , intent(in)    :: logPPF64, logT90
     339             :         real(RKC)                   :: logEffPPF
     340             :     end function
     341             : #endif
     342             : 
     343             : #if RK2_ENABLED
     344             :     pure elemental module function getLogEffPPF_RK2(logPPF64, logT90) result(logEffPPF)
     345             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     346             :         !DEC$ ATTRIBUTES DLLEXPORT :: getLogEffPPF_RK2
     347             : #endif
     348             :         use pm_kind, only: RKC => RK2
     349             :         real(RKC)   , intent(in)    :: logPPF64, logT90
     350             :         real(RKC)                   :: logEffPPF
     351             :     end function
     352             : #endif
     353             : 
     354             : #if RK1_ENABLED
     355             :     pure elemental module function getLogEffPPF_RK1(logPPF64, logT90) result(logEffPPF)
     356             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     357             :         !DEC$ ATTRIBUTES DLLEXPORT :: getLogEffPPF_RK1
     358             : #endif
     359             :         use pm_kind, only: RKC => RK1
     360             :         real(RKC)   , intent(in)    :: logPPF64, logT90
     361             :         real(RKC)                   :: logEffPPF
     362             :     end function
     363             : #endif
     364             : 
     365             :     !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     366             : 
     367             :     end interface getLogEffPPF
     368             : 
     369             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     370             : 
     371             :     !>  \brief
     372             :     !>  Generate and return the conversion of an input natural logarithm of photon flux/fluence over a given time in the BATSE detection energy
     373             :     !>  range \f$[50, 300]\kev\f$ to a bolometric (\f$[0.0001, 20000]\kev\f$) energy flux/fluence in units of \f$\ergs\f$ over the same time.<br>
     374             :     !>
     375             :     !>  \details
     376             :     !>  See the *Eqn A4 of Shahmoradi and Nemiroff 2015, MNRAS, Short versus long gamma-ray bursts* for more details.<br>
     377             :     !>
     378             :     !>  \param[in]  logEpk      :   The input scalar, or array of the same rank as other input array-valued arguments, of the same type and kind as `logPPF64`,
     379             :     !>                              containing the natural logarithm of the spectral peak energy of the GRB in units of \f$\ergs\f$.<br>
     380             :     !>  \param[in]  logPF53     :   The input scalar, or array of the same rank as other input array-valued arguments, of type `real` of kind \RKALL,
     381             :     !>                              containing the natural logarithm of the Photon Flux of an event in units of \f$[\ms{photons} / \ms{sec}]\f$.<br>
     382             :     !>
     383             :     !>  \return
     384             :     !>  `logPbol`               :   The output scalar or array of the same rank as the input arguments of same type and kind as the input arguments,
     385             :     !>                              containing the natural logarithm of the bolometric (\f$[0.0001, 20000]\kev\f$) energy flux of the GRB event
     386             :     !>                              in units of \f$\ergs\f$ over the same time interval.<br>
     387             :     !>
     388             :     !>  \interface{getLogPbol}
     389             :     !>  \code{.F90}
     390             :     !>
     391             :     !>      use pm_batse, only: getLogPbol
     392             :     !>
     393             :     !>      logPbol = getLogPbol(logEpk, logPF53)
     394             :     !>
     395             :     !>  \endcode
     396             :     !>
     397             :     !>  \pure
     398             :     !>
     399             :     !>  \elemental
     400             :     !>
     401             :     !>  \see
     402             :     !>  [getLogPbol](@ref pm_batse::getLogPbol)<br>
     403             :     !>  [getLogPF53](@ref pm_batse::getLogPF53)<br>
     404             :     !>  [getLog10PF53](@ref pm_batse::getLog10PF53)<br>
     405             :     !>  [getLogEffPPF](@ref pm_batse::getLogEffPPF)<br>
     406             :     !>  [setBandEnergy](@ref pm_distBand::setBandEnergy)<br>
     407             :     !>  [setBandPhoton](@ref pm_distBand::setBandPhoton)<br>
     408             :     !>  [getCorrectionLogEffPPF](@ref pm_batse::getCorrectionLogEffPPF)<br>
     409             :     !>
     410             :     !>  \example{getLogPbol}
     411             :     !>  \include{lineno} example/pm_batse/getLogPbol/main.F90
     412             :     !>  \compilef{getLogPbol}
     413             :     !>  \output{getLogPbol}
     414             :     !>  \include{lineno} example/pm_batse/getLogPbol/main.out.F90
     415             :     !>  \postproc{getLogPbol}
     416             :     !>  \include{lineno} example/pm_batse/getLogPbol/main.py
     417             :     !>  \vis{getLogPbol}
     418             :     !>  \image html pm_batse/getLogPbol/getLogPbol.RK.png width=700
     419             :     !>
     420             :     !>  \test
     421             :     !>  [test_pm_batse](@ref test_pm_batse)
     422             :     !>
     423             :     !>  \finmain{getLogPbol}
     424             :     !>
     425             :     !>  \author
     426             :     !>  \AmirShahmoradi, Wednesday June 27, 2012, 7:15 PM, Institute for Fusion Studies, The University of Texas at Austin.<br>
     427             :     interface getLogPbol
     428             : 
     429             :     !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     430             : 
     431             : #if RK5_ENABLED
     432             :     pure elemental module function getLogPbol_RK5(logEpk, logPF53) result(logPbol)
     433             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     434             :         !DEC$ ATTRIBUTES DLLEXPORT :: getLogPbol_RK5
     435             : #endif
     436             :         use pm_kind, only: RKC => RK5
     437             :         real(RKC)   , intent(in)    :: logEpk, logPF53
     438             :         real(RKC)                   :: logPbol
     439             :     end function
     440             : #endif
     441             : 
     442             : #if RK4_ENABLED
     443             :     pure elemental module function getLogPbol_RK4(logEpk, logPF53) result(logPbol)
     444             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     445             :         !DEC$ ATTRIBUTES DLLEXPORT :: getLogPbol_RK4
     446             : #endif
     447             :         use pm_kind, only: RKC => RK4
     448             :         real(RKC)   , intent(in)    :: logEpk, logPF53
     449             :         real(RKC)                   :: logPbol
     450             :     end function
     451             : #endif
     452             : 
     453             : #if RK3_ENABLED
     454             :     pure elemental module function getLogPbol_RK3(logEpk, logPF53) result(logPbol)
     455             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     456             :         !DEC$ ATTRIBUTES DLLEXPORT :: getLogPbol_RK3
     457             : #endif
     458             :         use pm_kind, only: RKC => RK3
     459             :         real(RKC)   , intent(in)    :: logEpk, logPF53
     460             :         real(RKC)                   :: logPbol
     461             :     end function
     462             : #endif
     463             : 
     464             : #if RK2_ENABLED
     465             :     pure elemental module function getLogPbol_RK2(logEpk, logPF53) result(logPbol)
     466             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     467             :         !DEC$ ATTRIBUTES DLLEXPORT :: getLogPbol_RK2
     468             : #endif
     469             :         use pm_kind, only: RKC => RK2
     470             :         real(RKC)   , intent(in)    :: logEpk, logPF53
     471             :         real(RKC)                   :: logPbol
     472             :     end function
     473             : #endif
     474             : 
     475             : #if RK1_ENABLED
     476             :     pure elemental module function getLogPbol_RK1(logEpk, logPF53) result(logPbol)
     477             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     478             :         !DEC$ ATTRIBUTES DLLEXPORT :: getLogPbol_RK1
     479             : #endif
     480             :         use pm_kind, only: RKC => RK1
     481             :         real(RKC)   , intent(in)    :: logEpk, logPF53
     482             :         real(RKC)                   :: logPbol
     483             :     end function
     484             : #endif
     485             : 
     486             :     !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     487             : 
     488             :     end interface getLogPbol
     489             : 
     490             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     491             : 
     492             :     !>  \brief
     493             :     !>  Generate and return the conversion of an input natural logarithm of a bolometric (\f$[0.0001, 20000]\kev\f$) energy flux/fluence
     494             :     !>  in units of \f$\ergs\f$ over a given time to the photon flux/fluence over the same time in the BATSE detection energy range \f$[50, 300]\kev\f$.<br>
     495             :     !>
     496             :     !>  \details
     497             :     !>  See the *Eqn A4 of Shahmoradi and Nemiroff 2015, MNRAS, Short versus long gamma-ray bursts* for more details.<br>
     498             :     !>
     499             :     !>  \param[in]  logEpk      :   The input scalar, or array of the same rank as other input array-valued arguments, of the same type and kind as `logPPF64`,
     500             :     !>                              containing the natural logarithm of the spectral peak energy of the GRB in units of \f$\ergs\f$.<br>
     501             :     !>  \param[in]  logPbol     :   The input scalar or array of the same rank as the input arguments of same type and kind as `logPPF64`,
     502             :     !>                              containing the natural logarithm of the bolometric (\f$[0.0001, 20000]\kev\f$) energy flux of the GRB event
     503             :     !>                              in units of \f$\ergs\f$ over the same time interval.<br>
     504             :     !>
     505             :     !>  \return
     506             :     !>  `logPF53`               :   The output scalar, or array of the same rank as other input array-valued arguments, of type `real` of kind \RKALL,
     507             :     !>                              containing the natural logarithm of the Photon Flux of an event in units of \f$[\ms{photons} / \ms{sec}]\f$.<br>
     508             :     !>
     509             :     !>  \interface{getLogPF53}
     510             :     !>  \code{.F90}
     511             :     !>
     512             :     !>      use pm_batse, only: getLogPF53
     513             :     !>
     514             :     !>      logPF53 = getLogPF53(logEpk, logPbol)
     515             :     !>
     516             :     !>  \endcode
     517             :     !>
     518             :     !>  \pure
     519             :     !>
     520             :     !>  \elemental
     521             :     !>
     522             :     !>  \see
     523             :     !>  [getLogPbol](@ref pm_batse::getLogPbol)<br>
     524             :     !>  [getLogPF53](@ref pm_batse::getLogPF53)<br>
     525             :     !>  [getLog10PF53](@ref pm_batse::getLog10PF53)<br>
     526             :     !>  [getLogEffPPF](@ref pm_batse::getLogEffPPF)<br>
     527             :     !>  [setBandEnergy](@ref pm_distBand::setBandEnergy)<br>
     528             :     !>  [setBandPhoton](@ref pm_distBand::setBandPhoton)<br>
     529             :     !>  [getCorrectionLogEffPPF](@ref pm_batse::getCorrectionLogEffPPF)<br>
     530             :     !>
     531             :     !>  \example{getLogPF53}
     532             :     !>  \include{lineno} example/pm_batse/getLogPF53/main.F90
     533             :     !>  \compilef{getLogPF53}
     534             :     !>  \output{getLogPF53}
     535             :     !>  \include{lineno} example/pm_batse/getLogPF53/main.out.F90
     536             :     !>  \postproc{getLogPF53}
     537             :     !>  \include{lineno} example/pm_batse/getLogPF53/main.py
     538             :     !>  \vis{getLogPF53}
     539             :     !>  \image html pm_batse/getLogPF53/getLogPF53.RK.png width=700
     540             :     !>
     541             :     !>  \test
     542             :     !>  [test_pm_batse](@ref test_pm_batse)
     543             :     !>
     544             :     !>  \finmain{getLogPF53}
     545             :     !>
     546             :     !>  \author
     547             :     !>  \AmirShahmoradi, Wednesday June 27, 2012, 7:15 PM, Institute for Fusion Studies, The University of Texas at Austin.<br>
     548             :     interface getLogPF53
     549             : 
     550             :     !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     551             : 
     552             : #if RK5_ENABLED
     553             :     pure elemental module function getLogPF53_RK5(logEpk, logPbol) result(logPF53)
     554             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     555             :         !DEC$ ATTRIBUTES DLLEXPORT :: getLogPF53_RK5
     556             : #endif
     557             :         use pm_kind, only: RKC => RK5
     558             :         real(RKC)   , intent(in)    :: logEpk, logPbol
     559             :         real(RKC)                   :: logPF53
     560             :     end function
     561             : #endif
     562             : 
     563             : #if RK4_ENABLED
     564             :     pure elemental module function getLogPF53_RK4(logEpk, logPbol) result(logPF53)
     565             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     566             :         !DEC$ ATTRIBUTES DLLEXPORT :: getLogPF53_RK4
     567             : #endif
     568             :         use pm_kind, only: RKC => RK4
     569             :         real(RKC)   , intent(in)    :: logEpk, logPbol
     570             :         real(RKC)                   :: logPF53
     571             :     end function
     572             : #endif
     573             : 
     574             : #if RK3_ENABLED
     575             :     pure elemental module function getLogPF53_RK3(logEpk, logPbol) result(logPF53)
     576             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     577             :         !DEC$ ATTRIBUTES DLLEXPORT :: getLogPF53_RK3
     578             : #endif
     579             :         use pm_kind, only: RKC => RK3
     580             :         real(RKC)   , intent(in)    :: logEpk, logPbol
     581             :         real(RKC)                   :: logPF53
     582             :     end function
     583             : #endif
     584             : 
     585             : #if RK2_ENABLED
     586             :     pure elemental module function getLogPF53_RK2(logEpk, logPbol) result(logPF53)
     587             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     588             :         !DEC$ ATTRIBUTES DLLEXPORT :: getLogPF53_RK2
     589             : #endif
     590             :         use pm_kind, only: RKC => RK2
     591             :         real(RKC)   , intent(in)    :: logEpk, logPbol
     592             :         real(RKC)                   :: logPF53
     593             :     end function
     594             : #endif
     595             : 
     596             : #if RK1_ENABLED
     597             :     pure elemental module function getLogPF53_RK1(logEpk, logPbol) result(logPF53)
     598             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     599             :         !DEC$ ATTRIBUTES DLLEXPORT :: getLogPF53_RK1
     600             : #endif
     601             :         use pm_kind, only: RKC => RK1
     602             :         real(RKC)   , intent(in)    :: logEpk, logPbol
     603             :         real(RKC)                   :: logPF53
     604             :     end function
     605             : #endif
     606             : 
     607             :     !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     608             : 
     609             :     end interface getLogPF53
     610             : 
     611             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     612             : 
     613             :     !>  \brief
     614             :     !>  \legacy
     615             :     !>  This generic interface is identical to the generic interface [getLogPF53](@ref pm_batse::getLogPF53)
     616             :     !>  with the only difference that all input and output arguments must be in \f$\log_{10}(\cdot)\f$ instead of natural logarithm.
     617             :     !>
     618             :     !>  \details
     619             :     !>  See the documentation of [getLogPF53](@ref pm_batse::getLogPF53) for more information.<br>
     620             :     !>
     621             :     !>  \param[in]  log10Epk    :   The input scalar, or array of the same rank as other input array-valued arguments, of the same type and kind as `logPPF64`,
     622             :     !>                              containing the log10 of the spectral peak energy of the GRB in units of \f$\ergs\f$.<br>
     623             :     !>  \param[in]  log10Pbol   :   The input scalar or array of the same rank as the input arguments of same type and kind as `logPPF64`,
     624             :     !>                              containing the log10 of the bolometric (\f$[0.0001, 20000]\kev\f$) energy flux of the GRB event
     625             :     !>                              in units of \f$\ergs\f$ over the same time interval.<br>
     626             :     !>
     627             :     !>  \return
     628             :     !>  `log10PF53`             :   The output scalar, or array of the same rank as other input array-valued arguments, of type `real` of kind \RKALL,
     629             :     !>                              containing the log10 of the Photon Flux of an event in units of \f$[\ms{photons} / \ms{sec}]\f$.<br>
     630             :     !>
     631             :     !>  \interface{getLog10PF53}
     632             :     !>  \code{.F90}
     633             :     !>
     634             :     !>      use pm_batse, only: getLog10PF53
     635             :     !>
     636             :     !>      log10PF53 = getLog10PF53(log10Epk, log10Pbol)
     637             :     !>
     638             :     !>  \endcode
     639             :     !>
     640             :     !>  \pure
     641             :     !>
     642             :     !>  \elemental
     643             :     !>
     644             :     !>  \see
     645             :     !>  [getLogPbol](@ref pm_batse::getLogPbol)<br>
     646             :     !>  [getLogPF53](@ref pm_batse::getLogPF53)<br>
     647             :     !>  [getLog10PF53](@ref pm_batse::getLog10PF53)<br>
     648             :     !>  [getLogEffPPF](@ref pm_batse::getLogEffPPF)<br>
     649             :     !>  [setBandEnergy](@ref pm_distBand::setBandEnergy)<br>
     650             :     !>  [setBandPhoton](@ref pm_distBand::setBandPhoton)<br>
     651             :     !>  [getCorrectionLogEffPPF](@ref pm_batse::getCorrectionLogEffPPF)<br>
     652             :     !>
     653             :     !>  \test
     654             :     !>  [test_pm_batse](@ref test_pm_batse)
     655             :     !>
     656             :     !>  \finmain{getLog10PF53}
     657             :     !>
     658             :     !>  \author
     659             :     !>  \AmirShahmoradi, Wednesday June 27, 2012, 7:15 PM, Institute for Fusion Studies, The University of Texas at Austin.<br>
     660             :     interface getLog10PF53
     661             : 
     662             :     !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     663             : 
     664             : #if RK5_ENABLED
     665             :     pure elemental module function getLog10PF53_RK5(log10Epk, log10Pbol) result(log10PF53)
     666             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     667             :         !DEC$ ATTRIBUTES DLLEXPORT :: getLog10PF53_RK5
     668             : #endif
     669             :         use pm_kind, only: RKC => RK5
     670             :         real(RKC)   , intent(in)    :: log10Epk, log10Pbol
     671             :         real(RKC)                   :: log10PF53
     672             :     end function
     673             : #endif
     674             : 
     675             : #if RK4_ENABLED
     676             :     pure elemental module function getLog10PF53_RK4(log10Epk, log10Pbol) result(log10PF53)
     677             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     678             :         !DEC$ ATTRIBUTES DLLEXPORT :: getLog10PF53_RK4
     679             : #endif
     680             :         use pm_kind, only: RKC => RK4
     681             :         real(RKC)   , intent(in)    :: log10Epk, log10Pbol
     682             :         real(RKC)                   :: log10PF53
     683             :     end function
     684             : #endif
     685             : 
     686             : #if RK3_ENABLED
     687             :     pure elemental module function getLog10PF53_RK3(log10Epk, log10Pbol) result(log10PF53)
     688             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     689             :         !DEC$ ATTRIBUTES DLLEXPORT :: getLog10PF53_RK3
     690             : #endif
     691             :         use pm_kind, only: RKC => RK3
     692             :         real(RKC)   , intent(in)    :: log10Epk, log10Pbol
     693             :         real(RKC)                   :: log10PF53
     694             :     end function
     695             : #endif
     696             : 
     697             : #if RK2_ENABLED
     698             :     pure elemental module function getLog10PF53_RK2(log10Epk, log10Pbol) result(log10PF53)
     699             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     700             :         !DEC$ ATTRIBUTES DLLEXPORT :: getLog10PF53_RK2
     701             : #endif
     702             :         use pm_kind, only: RKC => RK2
     703             :         real(RKC)   , intent(in)    :: log10Epk, log10Pbol
     704             :         real(RKC)                   :: log10PF53
     705             :     end function
     706             : #endif
     707             : 
     708             : #if RK1_ENABLED
     709             :     pure elemental module function getLog10PF53_RK1(log10Epk, log10Pbol) result(log10PF53)
     710             : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     711             :         !DEC$ ATTRIBUTES DLLEXPORT :: getLog10PF53_RK1
     712             : #endif
     713             :         use pm_kind, only: RKC => RK1
     714             :         real(RKC)   , intent(in)    :: log10Epk, log10Pbol
     715             :         real(RKC)                   :: log10PF53
     716             :     end function
     717             : #endif
     718             : 
     719             :     !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     720             : 
     721             :     end interface getLog10PF53
     722             : 
     723             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     724             : 
     725             : contains
     726             : 
     727             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     728             : 
     729             : !    !> Return all log of data in natural (Neper) base.
     730             : !    !>
     731             : !    !> \param[in]   inFilePath  :   The path to the input BATSE file.
     732             : !    !> \param[in]   outFilePath :   The path to the output BATSE file.
     733             : !    !> \param[in]   isLgrb      :   A logical flag indicating what type of input file is being processed.
     734             : !    ! integer(IK)     , parameter :: NLGRB = 1366_IK, NSGRB = 565_IK, NVAR = 4_IK
     735             : !
     736             : !    ! GRB attributes
     737             : !    type :: Event_type
     738             : !        real(RK) :: logPbol, logEpk, logSbol, logT90, logPF53
     739             : !    end type Event_type
     740             : !
     741             : !    type :: GRB_type
     742             : !        integer(IK) :: count
     743             : !        type(Event_type), allocatable :: Event(:)
     744             : !        !type(Event_type) :: Event(NLGRB)
     745             : !    end type GRB_type
     746             : !
     747             : !    !>  \cond excluded
     748             : !#if CAF_ENABLED
     749             : !    type(GRB_type) :: GRB[*]
     750             : !#else
     751             : !    type(GRB_type) :: GRB
     752             : !#endif
     753             : !    !>  \endcond excluded
     754             : !
     755             : !    integer(IK), allocatable :: Trigger(:)
     756             : !    !integer(IK) :: Trigger(NLGRB)
     757             : !    !integer(IK) :: TriggerSGRB(NSGRB)
     758             : !
     759             : !    subroutine readDataGRB(inFilePath,outFilePath,isLgrb)
     760             : !#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
     761             : !        !DEC$ ATTRIBUTES DLLEXPORT :: readDataGRB
     762             : !#endif
     763             : !
     764             : !        use pm_parallelism, only: image_type
     765             : !        use pm_kind, only: IK, LK, RK
     766             : !        implicit none
     767             : !        character(*, SK), intent(in)    :: inFilePath, outFilePath
     768             : !        integer(IK)                     :: inFileUnit, outFileUnit, igrb
     769             : !        logical(LK)     , intent(in)    :: isLgrb
     770             : !        type(image_type)                :: image
     771             : !
     772             : !        image = image_type()
     773             : !
     774             : !        if (isLgrb) then
     775             : !            GRB%count = NLGRB
     776             : !        else
     777             : !            GRB%count = NSGRB
     778             : !        end if
     779             : !
     780             : !        if (allocated(GRB%Event)) deallocate(GRB%Event); allocate(GRB%Event(GRB%count))
     781             : !        if (allocated(Trigger)) deallocate(Trigger); allocate(Trigger(GRB%count))
     782             : !
     783             : !        open( newunit = inFileUnit & ! LCOV_EXCL_LINE
     784             : !            , file = inFilePath & ! LCOV_EXCL_LINE
     785             : !            , status = "old" & ! LCOV_EXCL_LINE
     786             : !#if __INTEL_COMPILER && WINDOWS_ENABLED
     787             : !            , SHARED & ! LCOV_EXCL_LINE
     788             : !#endif
     789             : !            )
     790             : !
     791             : !        if (image%is%first) then
     792             : !        ! LCOV_EXCL_START
     793             : !            open(newunit=outFileUnit,file=outFilePath,status="replace")
     794             : !            write(outFileUnit,"(9a30)"  ) "trigger"             &
     795             : !                                        , "logPbol_1eV_20MeV"   &
     796             : !                                        , "logSbol_1eV_20MeV"   &
     797             : !                                        , "logEpk"              &
     798             : !                                        , "logEPR1024"          &
     799             : !                                        , "logEFR"              &
     800             : !                                        , "logFPR1024"          &
     801             : !                                        , "logT90"              &
     802             : !                                        , "logEffPF53"
     803             : !        end if
     804             : !        ! LCOV_EXCL_STOP
     805             : !
     806             : !        ! skip the header row in the input file
     807             : !        read(inFileUnit,*)
     808             : !
     809             : !        ! read BATSE GRB data
     810             : !        do igrb = 1, GRB%count
     811             : !
     812             : !            read(inFileUnit,*   ) Trigger(igrb)             & ! LCOV_EXCL_LINE
     813             : !                                , GRB%Event(igrb)%logPF53   &
     814             : !                                , GRB%Event(igrb)%logEpk    &
     815             : !                                , GRB%Event(igrb)%logSbol   &
     816             : !                                , GRB%Event(igrb)%logT90
     817             : !
     818             : !            ! convert all values to logarithm in base Neper
     819             : !
     820             : !            GRB%Event(igrb)%logPF53 = LOG_TEN * GRB%Event(igrb)%logPF53
     821             : !            GRB%Event(igrb)%logEpk  = LOG_TEN * GRB%Event(igrb)%logEpk
     822             : !            GRB%Event(igrb)%logSbol = LOG_TEN * GRB%Event(igrb)%logSbol
     823             : !            GRB%Event(igrb)%logT90  = LOG_TEN * GRB%Event(igrb)%logT90
     824             : !
     825             : !            ! convert photon count data to energy in units of ergs
     826             : !
     827             : !            GRB%Event(igrb)%logPbol = getLogPbol( GRB%Event(igrb)%logEpk, GRB%Event(igrb)%logPF53 )
     828             : !            if (isLgrb) then
     829             : !                GRB%Event(igrb)%logSbol = getLogPbol( GRB%Event(igrb)%logEpk, GRB%Event(igrb)%logSbol )
     830             : !            else
     831             : !                GRB%Event(igrb)%logPF53 = GRB%Event(igrb)%logPF53 - THRESH_ERFC_AMP * erfc( (GRB%Event(igrb)%logT90-THRESH_ERFC_AVG) * THRESH_ERFC_STD_INV )
     832             : !            end if
     833             : !
     834             : !            ! write the converted data to output file
     835             : !
     836             : !            if (image%is%first) then
     837             : !            ! LCOV_EXCL_START
     838             : !                write(outFileUnit,"(I30,8E30.6)") Trigger(igrb)                                     &
     839             : !                                                , GRB%Event(igrb)%logPbol                           &
     840             : !                                                , GRB%Event(igrb)%logSbol                           &
     841             : !                                                , GRB%Event(igrb)%logEpk                            &
     842             : !                                                , GRB%Event(igrb)%logEpk-GRB%Event(igrb)%logPbol    &
     843             : !                                                , GRB%Event(igrb)%logEpk-GRB%Event(igrb)%logSbol    &
     844             : !                                                , GRB%Event(igrb)%logSbol-GRB%Event(igrb)%logPbol   &
     845             : !                                                , GRB%Event(igrb)%logT90                            &
     846             : !                                                , GRB%Event(igrb)%logPF53
     847             : !
     848             : !            end if
     849             : !            ! LCOV_EXCL_STOP
     850             : !
     851             : !        end do
     852             : !
     853             : !        if (image%is%first) close(outFileUnit)
     854             : !
     855             : !        close(inFileUnit)
     856             : !
     857             : !!#if CAF_ENABLED
     858             : !!        sync images(*)
     859             : !!
     860             : !!    else
     861             : !!
     862             : !!        sync images(1)
     863             : !!        do igrb = 1, GRB%count
     864             : !!            GRB%Event(igrb)%logPbol = GRB[1]%Event(igrb)%logPbol
     865             : !!            GRB%Event(igrb)%logSbol = GRB[1]%Event(igrb)%logSbol
     866             : !!            GRB%Event(igrb)%logPF53 = GRB[1]%Event(igrb)%logPF53
     867             : !!            GRB%Event(igrb)%logEpk  = GRB[1]%Event(igrb)%logEpk
     868             : !!            GRB%Event(igrb)%logT90  = GRB[1]%Event(igrb)%logT90
     869             : !!        end do
     870             : !!
     871             : !!    end if
     872             : !!#endif
     873             : !
     874             : !    end subroutine readDataGRB
     875             : !
     876             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     877             : 
     878           0 : end module pm_batse

ParaMonte: Parallel Monte Carlo and Machine Learning Library 
The Computational Data Science Lab
© Copyright 2012 - 2024