This archive contains the BARCAST+AMS implementation as discussed by 
Werner, J.P. and Tingley, M.P.
Clim. Past Discuss., 10, 4499-4533, 2014
www.clim-past-discuss.net/10/4499/2014/
doi:10.5194/cpd-10-4499-2014

The code is based on BARCAST by M.P. Tingley (Tingley and Huybers, JClim, 2010). It
was adapted to R and Fortran by J.P. Werner, and extended for parallel tempering in
this article. 

  This program, i.e. everything under the fortran_branch and helper_programs
  is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

The code is licensed under the GPL except for the third party libraries and parts
that are in the local_libs directory. These are packaged only "as is" and "for your
information". The licenses and websites where to obtain the code and documentation
are mentioned below.


Compilation
-----------

To compile the code go into the directory local_libs, type in 
 make all
then, in the directory fortran_branch type in
 make T_Updater.so

To run the code, start R and then (in the fortran_branch directory)
source("BARCASTMainCode_Rmpi.R")
Run.Barcast( "../example_data", "BARCASTINPUTvNewMeth1_ADMs.R")

The command Run.Barcast takes several inputs of which only the first two are mandatory:
BARCAST.datdir      directory where the input data resides, will also be the output directory
BARCAST.infilename  file name of input data
pre.Sampler.Its     how many steps of temperature updates to run before the full Gibbs
                    sampler is started
Sampler.Its         number of iterations to run the Gibbs sampler
swap.interval       attempt to swap the state of the chains every number of steps
nChains             number of chains to run
invTemp.min         minimum inverse temperature
CurrCont            continue from a past state (untested for the RMPI implementation)

See the file BARCASTINPUTvNewMeth1_ADMs.R on how the data structure should be looking
like, or the files ConstructTestDatavNM.R and create_t_test.R under helper_programs
on how to construct them.


Files in local_libs and their licenses
--------------------------------------
blassm.f  formats.f  matvec.f
  These three files are part of SPARSKIT
  http://www-users.cs.umn.edu/~saad/software/SPARSKIT/ (C) Yousef Saad and licensed
  under the GNU Lesser General Public License v. 2.1.
  They were truncated to provide only the functions needed for BARCAST, but linking
  to the full version should be possible.

random.f90
  Author: Alan Miller
         CSIRO Division of Mathematical & Information Sciences
         Private Bag 10, Clayton South MDC
         Clayton 3169, Victoria, Australia
  Phone: (+61) 3 9545-8016      Fax: (+61) 3 9545-8080
  e-mail: amiller @ bigpond.net.au
  http://jblevins.org/mirror/amiller/
  "The code is released into the public domain", for license information see
  the homepage above

ziggurat.f90
  Marsaglia & Tsang generator for random normals & random exponentials.
  Translated from C by Alan Miller (amiller@bigpond.net.au)
  Marsaglia, G. & Tsang, W.W. (2000) `The ziggurat method for generating
  random variables', J. Statist. Software, v5(8).
  This is an electronic journal which can be downloaded from:
  http://www.jstatsoft.org/v05/i08
  
  Rewritten by A. Miller, see info at http://jblevins.org/mirror/amiller/ for
  license information

