forked from mjlaine/mcmcf90
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmcmc.F90
103 lines (78 loc) · 3.36 KB
/
mcmc.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
!!! $Id: mcmc.F90,v 1.40 2012/09/04 14:22:54 mjlaine Exp $
!!! ------------------------------------------------------------------------
!!! mcmc library
!!! File: mcmc.F90
!!! Purpose: the main mcmc module
!!!
!!!
!!! Marko Laine 2001 <[email protected]>
!!! Copyrights licensed under a MIT License.
!!! See the accompanying LICENSE.txt file for terms.
!!!
module mcmcmod
use mcmcprec ! floating point precision
use matutils ! utilities
use matfiles ! writing mat files
use mcmcrand ! random numbers
use mcmcinit ! mcmcinit.nml namelist variables
implicit none
!!!
public
#include "version.h"
!! other global, but (some) private to the module, variables
integer, public, save :: npar ! n:o of parameters
integer, private, dimension(:), allocatable, save :: nobs ! n:o of observations
integer, public, save :: nycol ! n:o of y variables
real(kind=dbl), public, dimension(:,:), allocatable, save :: chain
real(kind=dbl), public, dimension(:,:), allocatable, save :: s2chain
real(kind=dbl), public, dimension(:,:), allocatable, save :: sschain
real(kind=dbl), private, dimension(:), allocatable, save :: par0 ! par removed
real(kind=dbl), private, dimension(:,:), allocatable, save :: R, R2, iC
real(kind=dbl), private, dimension(:), allocatable, save :: qcovstd
real(kind=dbl), private, dimension(:,:), allocatable, save :: cmat0
real(kind=dbl), private, dimension(:,:), allocatable, save :: chaincmat
real(kind=dbl), private, dimension(:), allocatable, save :: chainmean
real(kind=dbl), private, save :: chainwsum ! sum of weights, (change name !!!)
real(kind=dbl), public, dimension(:), allocatable, save :: sigma2 ! error variance
real(kind=dbl), private, dimension(:,:), allocatable, save :: usrfunmat
integer, private, save :: inited = 0 ! have we initialized?
integer, public, save :: MCMC_running = 0 ! are we doing the real thing yet
integer, private, save :: stayed !
integer, private, save :: chainisstuck
integer, private, save :: bndstayed ! stayed because of bounds
integer, private, save :: erstayed ! stayed because of er
integer, private, save :: ncolchain ! columns in chain
integer, public, save :: simuind ! loop index
integer, public, save :: chainind ! indet to current chain index
integer, private, save :: vecss ! vectorized ss and s2
integer, private, save :: draccepted, drtries ! DR
logical, private, save :: nparok = .false.
logical, private, save :: par0ok = .false.
logical, private, save :: cmat0ok = .false.
logical, private, save :: sigma2ok = .false.
interface MCMC_setpar0
module procedure MCMC_setpar0_vec, MCMC_setpar0_n, MCMC_setpar0_file
end interface
interface MCMC_setcmat0
module procedure MCMC_setcmat0_mat, MCMC_setcmat0_pct, MCMC_setcmat0_std, &
MCMC_setcmat0_file
end interface
interface MCMC_setsigma2nobs
module procedure MCMC_setsigma2nobs_sca, MCMC_setsigma2nobs_vec
end interface
contains
!!! the module subroutines are included from external files
#include "MCMC_init.F90"
#include "MCMC_run.F90"
#include "MCMC_run_er.F90"
#include "MCMC_run1.F90"
#include "MCMC_run1_er.F90"
#include "MCMC_run_scam.F90"
#include "MCMC_run_ram.F90"
#include "MCMC_adapt.F90"
#include "MCMC_DRAM.F90"
#include "MCMC_aux.F90"
#include "MCMC_dump.F90"
#include "MCMC_userfun.F90"
#include "MCMC_signal_handler.F90"
end module mcmcmod