The ParaMonte Documentation Website
Current view: top level - kernel - ParaDXXX_mod@Input_smod.inc.f90 (source / functions) Hit Total Coverage
Test: ParaMonte 1.5.1 :: MPI Parallel Kernel - Code Coverage Report Lines: 34 36 94.4 %
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
      44             : !> This file implements the body of the `Input_smod` submodules of the `ParaDRAM_mod` and `ParaDISE_mod` modules.
      45             : !>
      46             : !> \remark
      47             : !> This module requires preprocessing, prior to compilation.
      48             : !>
      49             : !> \author Amir Shahmoradi
      50             : 
      51             :     ! ParaMonte namelist variables
      52             :     use SpecBase_SampleSize_mod                         , only: sampleSize
      53             :     use SpecBase_RandomSeed_mod                         , only: randomSeed
      54             :     use SpecBase_Description_mod                        , only: description
      55             :     use SpecBase_OutputFileName_mod                     , only: outputFileName
      56             :     use SpecBase_OutputDelimiter_mod                    , only: outputDelimiter
      57             :     use SpecBase_ChainFileFormat_mod                    , only: chainFileFormat
      58             :     use SpecBase_VariableNameList_mod                   , only: variableNameList
      59             :     use SpecBase_RestartFileFormat_mod                  , only: restartFileFormat
      60             :     use SpecBase_OutputColumnWidth_mod                  , only: outputColumnWidth
      61             :     use SpecBase_OverwriteRequested_mod                 , only: overwriteRequested
      62             :     use SpecBase_OutputRealPrecision_mod                , only: outputRealPrecision
      63             :     use SpecBase_SilentModeRequested_mod                , only: silentModeRequested
      64             :     use SpecBase_DomainLowerLimitVec_mod                , only: domainLowerLimitVec
      65             :     use SpecBase_DomainUpperLimitVec_mod                , only: domainUpperLimitVec
      66             :     use SpecBase_ParallelizationModel_mod               , only: parallelizationModel
      67             :     use SpecBase_InputFileHasPriority_mod               , only: inputFileHasPriority
      68             :     use SpecBase_ProgressReportPeriod_mod               , only: progressReportPeriod
      69             :     use SpecBase_targetAcceptanceRate_mod               , only: targetAcceptanceRate
      70             :     use SpecBase_MpiFinalizeRequested_mod               , only: mpiFinalizeRequested
      71             :     use SpecBase_MaxNumDomainCheckToWarn_mod            , only: maxNumDomainCheckToWarn
      72             :     use SpecBase_MaxNumDomainCheckToStop_mod            , only: maxNumDomainCheckToStop
      73             :     use SpecBase_SystemInfoFilePath_mod                 , only: systemInfoFilePath
      74             :     use SpecBase_InterfaceType_mod                      , only: interfaceType
      75             : 
      76             :     ! ParaMCMC namelist variables
      77             :     use SpecMCMC_ChainSize_mod                          , only: chainSize
      78             :     use SpecMCMC_ScaleFactor_mod                        , only: scaleFactor
      79             :     use SpecMCMC_StartPointVec_mod                      , only: startPointVec
      80             :     use SpecMCMC_ProposalModel_mod                      , only: proposalModel
      81             :     use SpecMCMC_proposalStartCovMat_mod                , only: proposalStartCovMat
      82             :     use SpecMCMC_proposalStartCorMat_mod                , only: proposalStartCorMat
      83             :     use SpecMCMC_proposalStartStdVec_mod                , only: proposalStartStdVec
      84             :     use SpecMCMC_SampleRefinementCount_mod              , only: sampleRefinementCount
      85             :     use SpecMCMC_sampleRefinementMethod_mod             , only: sampleRefinementMethod
      86             :     use SpecMCMC_RandomStartPointRequested_mod          , only: randomStartPointRequested
      87             :     use SpecMCMC_RandomStartPointDomainLowerLimitVec_mod, only: randomStartPointDomainLowerLimitVec
      88             :     use SpecMCMC_RandomStartPointDomainUpperLimitVec_mod, only: randomStartPointDomainUpperLimitVec
      89             : 
      90             :     ! ParaDRAM namelist variables
      91             :     use SpecDRAM_AdaptiveUpdateCount_mod                , only: adaptiveUpdateCount
      92             :     use SpecDRAM_AdaptiveUpdatePeriod_mod               , only: adaptiveUpdatePeriod
      93             :     use SpecDRAM_greedyAdaptationCount_mod              , only: greedyAdaptationCount
      94             :     use SpecDRAM_DelayedRejectionCount_mod              , only: delayedRejectionCount
      95             :     use SpecDRAM_BurninAdaptationMeasure_mod            , only: burninAdaptationMeasure
      96             :     use SpecDRAM_delayedRejectionScaleFactorVec_mod     , only: delayedRejectionScaleFactorVec
      97             : 
      98             :     implicit none
      99             : 
     100             :     character(*), parameter :: SUBMODULE_NAME = MODULE_NAME // "@Input_smod"
     101             : 
     102             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     103             : #if defined PARADRAM
     104             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     105             : 
     106             : ! This will be used in the read statement
     107             : #define ParaDXXX ParaDRAM
     108             : ! This will be used in the declaration of the parent object
     109             : #define ParaDXXX_type ParaDRAM_type
     110             : ! This will be used in the namelist declaration
     111             : #define NAMELIST ParaDRAM
     112             : #include "ParaDXXX_mod@Input_smod.nml.inc.f90"
     113             : #undef NAMELIST
     114             : 
     115             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     116             : #elif defined PARADISE
     117             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     118             : 
     119             : ! This will be used in the read statement
     120             : #define ParaDXXX ParaDISE
     121             : ! This will be used in the declaration of the parent object
     122             : #define ParaDXXX_type ParaDISE_type
     123             : ! This will be used in the namelist declaration
     124             : #define NAMELIST ParaDISE
     125             : #include "ParaDXXX_mod@Input_smod.nml.inc.f90"
     126             : #undef NAMELIST
     127             : 
     128             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     129             : #else
     130             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     131             : #error "Unrecognized sampler in ParaDXXX_mod@Input_mod.inc.f90"
     132             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     133             : #endif
     134             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     135             : 
     136             : #define NAMELIST paradxxx
     137             : #include "ParaDXXX_mod@Input_smod.nml.inc.f90"
     138             : #undef NAMELIST
     139             : 
     140             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     141             : 
     142             : contains
     143             : 
     144             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     145             : 
     146             :     !> \brief
     147             :     !> This procedure is a method of [ParaDRAM_type](@ref paradram_type) and [ParaDISE_type](@ref paradise_type) classes.
     148             :     !> Read the input file and assign the simulation specification variables.
     149             :     !>
     150             :     !> @param[inout]    self    :   An object of class [ParaDRAM_type](@ref paradram_type) or [ParaDISE_type](@ref paradise_type).
     151             :     !> @param[in]       nd      :   The number of dimensions of the domain of the objective function.
     152             :     !>
     153             :     !> \remark
     154             :     !> This procedure requires preprocessing.
     155        1047 :     module subroutine getSpecFromInputFile(self,nd)
     156             : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
     157             :         !DEC$ ATTRIBUTES DLLEXPORT :: getSpecFromInputFile
     158             : #endif
     159             :         use Constants_mod, only: IK, RK
     160             :         use String_mod, only: num2str
     161             : 
     162             :         implicit none
     163             :         class(ParaDXXX_type), intent(inout) :: self
     164             :         integer(IK), intent(in)             :: nd
     165             :         character(*), parameter             :: PROCEDURE_NAME = SUBMODULE_NAME//"@getSpecFromInputFile()"
     166             : 
     167             :         ! initialize/nullify all general input options
     168             : 
     169        1047 :         call self%SpecBase%nullifyNameListVar(nd)
     170        1047 :         call self%SpecMCMC%nullifyNameListVar(nd)
     171        1047 :         call self%SpecDRAM%nullifyNameListVar(nd)
     172             : 
     173             :         ! read input options if input file is provided
     174             : 
     175        1047 :         blockReadInputFile: if (self%inputFileArgIsPresent) then
     176             : 
     177         486 :             blockInputFileType: if (self%InputFile%isInternal) then
     178             : 
     179             :                 ! read input file as an internal file
     180             : 
     181         462 :                 read(self%InputFile%Path%original,nml=ParaDXXX,iostat=self%InputFile%Err%stat)
     182         462 :                 self%Err = self%InputFile%getReadErr(self%InputFile%Err%stat,self%InputFile%Path%modified)
     183             : 
     184         462 :                 if (self%Err%occurred) then
     185             : 
     186          24 :                     if ( is_iostat_end(self%Err%stat) .or. is_iostat_eor(self%Err%stat) ) then
     187             : 
     188             :                         ! search for the paradxxx namelist group in the file.
     189             : 
     190          24 :                         call self%warnUserAboutMissingNamelist(namelist = self%name)
     191          24 :                         read(self%InputFile%Path%original,nml=paradxxx,iostat=self%InputFile%Err%stat) ! WARNING: "paradxxx" is NOT the same as fpp macro name "ParaDXXX". This is a real namelist name.
     192          24 :                         self%Err = self%InputFile%getReadErr(self%InputFile%Err%stat,self%InputFile%Path%modified)
     193             : 
     194             :                     end if
     195             : 
     196          24 :                     if (self%Err%occurred) then
     197             : 
     198           0 :                         if (is_iostat_end(self%Err%stat) .or. is_iostat_eor(self%Err%stat)) then
     199             : 
     200           0 :                             call self%warnUserAboutMissingNamelist(namelist = "ParaDXXX")
     201             : 
     202             :                         else
     203             : 
     204             :                             ! LCOV_EXCL_START
     205             :                             read(self%InputFile%Path%original,nml=ParaDXXX) ! let the compiler print diagnostic messages, should any error happen.
     206             :                             ! LCOV_EXCL_STOP
     207             : 
     208             :                         end if
     209             : 
     210             :                     end if
     211             : 
     212             :                 end if
     213             : 
     214             :             else blockInputFileType ! the input file is external
     215             : 
     216             :                 ! close input file if it is open
     217             : 
     218          24 :                 if (self%InputFile%isOpen) then
     219             :                     ! LCOV_EXCL_START
     220             :                     close(unit=self%InputFile%unit,iostat=self%InputFile%Err%stat)
     221             :                     self%Err = self%InputFile%getCloseErr(self%InputFile%Err%stat)
     222             :                     if (self%Err%occurred) then
     223             :                         self%Err%msg =  PROCEDURE_NAME // ": Error occurred while attempting to close the user-provided input file='" // &
     224             :                                         self%InputFile%Path%modified // "', unit=" // num2str(self%InputFile%unit) // ".\n" // &
     225             :                                         self%Err%msg
     226             :                         return
     227             :                     end if
     228             :                     ! LCOV_EXCL_STOP
     229             :                 end if
     230             : 
     231             :                 ! open input file
     232             : 
     233             :                 open( newunit = self%InputFile%unit       &
     234             :                     , file = self%InputFile%Path%modified &
     235             :                     , status = self%InputFile%status      &
     236             :                     , iostat = self%InputFile%Err%stat    &
     237             : #if defined INTEL_COMPILER_ENABLED && defined OS_IS_WINDOWS
     238             :                     , SHARED &
     239             : #endif
     240          24 :                     )
     241          24 :                 self%Err = self%InputFile%getOpenErr(self%InputFile%Err%stat)
     242          24 :                 if (self%Err%occurred) then
     243             :                     ! LCOV_EXCL_START
     244             :                     self%Err%msg =  PROCEDURE_NAME // ": Error occurred while attempting to open the user-provided input file='" // &
     245             :                                     self%InputFile%Path%modified // "', unit=" // num2str(self%InputFile%unit) // ".\n" // &
     246             :                                     self%Err%msg
     247             :                     return
     248             :                     ! LCOV_EXCL_STOP
     249             :                 end if
     250             : 
     251             :                 ! read input file
     252             : 
     253          24 :                 read(self%InputFile%unit,nml=ParaDXXX,iostat=self%InputFile%Err%stat)
     254          24 :                 self%Err = self%InputFile%getReadErr(self%InputFile%Err%stat,self%InputFile%Path%modified)
     255             : 
     256          24 :                 if (self%Err%occurred) then
     257             : 
     258          18 :                     if ( is_iostat_end(self%Err%stat) .or. is_iostat_eor(self%Err%stat) ) then
     259             : 
     260             :                         ! search for the paradxxx namelist group in the file.
     261             : 
     262          18 :                         rewind(self%InputFile%unit)
     263          18 :                         call self%warnUserAboutMissingNamelist(namelist = self%name)
     264          18 :                         read(self%InputFile%unit, nml=paradxxx, iostat=self%InputFile%Err%stat) ! WARNING: "paradxxx" is NOT the same as fpp macro name "ParaDXXX"
     265          18 :                         self%Err = self%InputFile%getReadErr(self%InputFile%Err%stat,self%InputFile%Path%modified)
     266             : 
     267             :                     end if
     268             : 
     269          18 :                     if (self%Err%occurred) then
     270             : 
     271           6 :                         if (is_iostat_end(self%Err%stat) .or. is_iostat_eor(self%Err%stat)) then
     272             : 
     273           6 :                             call self%warnUserAboutMissingNamelist(namelist = "ParaDXXX")
     274             : 
     275             :                         else ! attempt to read the file one more time, without error handling, so that the compiler prints out the error message.
     276             : 
     277             :                             ! LCOV_EXCL_START
     278             :                             rewind(self%InputFile%unit)
     279             :                             read(self%InputFile%unit, nml=ParaDXXX)
     280             :                             ! LCOV_EXCL_STOP
     281             : 
     282             :                         end if
     283             : 
     284             :                     end if
     285             : 
     286             :                 end if
     287             : 
     288             :                 ! close input file
     289             : 
     290          24 :                 close(unit=self%InputFile%unit,iostat=self%InputFile%Err%stat)
     291             :                 ! LCOV_EXCL_START
     292             :                 self%Err = self%InputFile%getCloseErr(self%InputFile%Err%stat)
     293             :                 if (self%Err%occurred) then
     294             :                     self%Err%msg =  PROCEDURE_NAME // ": Error occurred while attempting to close the user-provided input file='" // &
     295             :                                     self%InputFile%Path%modified // "', unit=" // num2str(self%InputFile%unit) // ".\n" // &
     296             :                                     self%Err%msg
     297             :                     return
     298             :                 end if
     299             :                 ! LCOV_EXCL_STOP
     300             : 
     301             :             end if blockInputFileType
     302             : 
     303             :         end if blockReadInputFile
     304             : 
     305             :         ! setup SpecBase variables that have been read form the input file
     306             : 
     307        1047 :         call self%SpecBase%setFromInputFile(Err = self%Err)
     308             :         ! LCOV_EXCL_START
     309             :         if (self%Err%occurred) then
     310             :             self%Err%msg = PROCEDURE_NAME // self%Err%msg
     311             :             return
     312             :         end if
     313             :         ! LCOV_EXCL_STOP
     314             : 
     315             :         ! setup SpecMCMC variables that have been read form the input file
     316             : 
     317        1047 :         call self%SpecMCMC%setFromInputFile(Err = self%Err)
     318             :         ! LCOV_EXCL_START
     319             :         if (self%Err%occurred) then
     320             :             self%Err%msg = PROCEDURE_NAME // self%Err%msg
     321             :             return
     322             :         end if
     323             :         ! LCOV_EXCL_STOP
     324             : 
     325             :         ! setup SpecDRAM variables that have been read form the input file
     326             : 
     327        1047 :         call self%SpecDRAM%setFromInputFile( self%Err )
     328             :         ! LCOV_EXCL_START
     329             :         if (self%Err%occurred) then
     330             :             self%Err%msg = PROCEDURE_NAME // self%Err%msg
     331             :             return
     332             :         end if
     333             :         ! LCOV_EXCL_STOP
     334             : 
     335        1047 :     end subroutine getSpecFromInputFile
     336             : 
     337             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     338             : 
     339             : #undef ParaDXXX_type
     340             : #undef ParaDXXX
     341             : 

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