### This file is a quick installation for Solaris, Linux, and Mac OS X.
### See `INSTALL.win.src' for a source installation for Windows system.
### See `INSTALL.win.bin' for a binary installation for Windows system.

--- 'OpenMPI' Installation:
   Obtain 'OpenMPI' from 'http://www.open-mpi.org/'

     > tar zxvf openmpi-1.5.4.tar.gz
     > cd openmpi-1.5.4
     > ./configure
     > ./make
     > ./make install

   These install files to '/usr/local/bin', '/usr/local/lib', and
   '/usr/local/include' etc.  i.e. ${MPI_ROOT} is '/usr/local'.


--- Set environment variables:
   For 'csh' or 'tcsh', I would set

     > setenv PATH /usr/local/bin:$PATH
     > setenv LD_LIBRARY_PATH /usr/local/lib:$LD_LIBRARY_PATH

   For 'sh', 'bash', or 'ksh', I would set

     > export PATH=/usr/local/bin:$PATH
     > export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

   - 'PATH' is to make sure I can run 'mpiexec', 'mpirun', or 'orterun'.
   - 'LD_LIBRARY_PATH' is to make sure I can reach 'libmpi.so'.

   *** The other way is to modify '/etc/ld.so.conf' and to use the command
       'ldconfig' to update the system searhing path for 'libmpi.so'.


--- Test 'OpenMPI':
   In order to test if 'OpenMPI' works correctly, I simply run

     > mpiexec -np 2 hostname

   and this should show host name twice if environment variables are correct.


--- 'pbdPROF' Installation:
0. Download and extract 'pbdPROF'

     > tar zxvf pbdPROF_0.1-0.tar.gz

1. Default Installation:
   This should work with most platforms with 'OpenMPI' installed. The
   configuration is based on 'Rmpi' but detect the flags and libraries from
   'mpicc --showme:*' which is more portable.

     > R CMD INSTALL pbdPROF

2. Non-default Installation:

     > R CMD INSTALL pbdPROF \
     +   --configure-args="--with-Rmpi-type=OPENMPI \
     +                     --with-mpi=/usr/local"

3. Unusual Installation:
   Suppose 'PATH' and 'LD_LIBRARY_ATH' are set, but I don't use default paths
   to header files and libraries, then I can install 'pbdPROF' by

     > R CMD INSTALL pbdPROF \
     +   --configure-args="--with-Rmpi-type=OPENMPI \
     +                     --with-Rmpi-include=/usr/local/ompi/include  \
     +                     --with-Rmpi-libpath=/usr/local/ompi/lib" \

   Note that I still need 'PATH' and 'LD_LIBRARY_PATH' to be set correctly in
   this case.


### `INSTALL.win.src'.

--- 'Rtools' Installation:
   Download 'Rtools216.exe' from 'http://cran.r-project.org/bin/windows/Rtools/'
   and click it to install to

     'C:\Rtools'


--- 'MPICH2' Installation:
   Download 'MPICH2' from 'http://www.mcs.anl.gov/research/projects/mpich2/'.
   'mpich2-1.4.1p1-win-ia32.msi' for 32 bits and
   'mpich2-1.4.1p1-win-x86-64.msi' for 64 bits.
   Click it and install them to the default directory

   - 64-bits: 'C:\Program Files\MPICH2'.
   - 32-bits: 'C:\Program Files (x86)\MPICH2'.


--- Set environment variables:
   Suppose 'R', 'Rtools', and 'MPICH2' are all installed by default. I have
   a batch file 'set_mpisrc.bat' as the following to set the environment
   variables. In short, 'MPI_ROOT' should be set to 'mpiexec.exe', and added
   to 'PATH'.

@ECHO OFF
SET R_HOME=C:\Program Files\R\R-2.15.1
SET RTOOLS=C:\Rtools\bin\
SET MINGW=C:\Rtools\gcc-4.6.3\bin
SET MPI_ROOT_64=C:\Program Files\MPICH2
SET MPI_ROOT_32=C:\Program Files (x86)\MPICH2
:X64
set MPI_ROOT=%MPI_ROOT_64%
IF "%1"=="64" GOTO END 
:WIN32
set MPI_ROOT=%MPI_ROOT_32%
:END
IF NOT DEFINED PATH_ORG SET PATH_ORG=%PATH%
SET PATH=%R_HOME%;%R_HOME%\BIN\;%RTOOLS%;%MINGW%;%MPI_ROOT%\BIN\;%PATH_ORG%


--- Test 'MPICH2':
   In order to test if 'MPICH2' works correctly, I run

   -- 64-bits
     C:/> set_mpisrc 64
     C:/> mpiexec -np 2 hostname.exe
   -- 32-bits
     C:/> set_mpisrc 32
     C:/> mpiexec -np 2 hostname.exe

   and this should list two host names twice if environment variables are
   correct. User's id and password may be required to launch MPICH2.


--- 'pbdPROF' Installation:
   Default Installation:

     C:/> set_mpisrc
     C:/> tar zxvf pbdPROF_0.1-0.tar.gz
     C:/> R CMD INSTALL --build pbdPROF
     C:/> R CMD INSTALL pbdPROF_0.1-0.zip


--- Test 'pbdPROF':
   Suppose all environments are set correctly, I can run test examples by

   -- 64-bits
     C:/> set_mpisrc 64
     C:/> cd pbdPROF\examples\test_spmd\
     C:/> sh 00_test_all.win
   -- 32-bits
     C:/> set_mpisrc 32
     C:/> cd pbdPROF\examples\test_spmd\
     C:/> sh 00_test_all.win


### `INSTALL.win.bin'.

--- 'MPICH2' Installation:
   Download 'MPICH2' from 'http://www.mcs.anl.gov/research/projects/mpich2/'.
   'mpich2-1.4.1p1-win-ia32.msi' for 32 bits and
   'mpich2-1.4.1p1-win-x86-64.msi' for 64 bits.
   Click it and install them to the default directory

   - 64-bits: 'C:\Program Files\MPICH2'.
   - 32-bits: 'C:\Program Files (x86)\MPICH2'.


--- Set environment variables:
   Suppose 'R' and 'MPICH2' are all installed by default. I have a batch
   file 'set_mpi.bat' as the following to set the environment variables.
   In short, 'MPI_ROOT' should be set to 'mpiexec.exe', and added to 'PATH'.

@ECHO OFF
SET R_HOME=C:\Program Files\R\R-2.15.1
SET MPI_ROOT=C:\Program Files\MPICH2
IF NOT DEFINED PATH_ORG SET PATH_ORG=%PATH%
SET PATH=%R_HOME%;%R_HOME%\BIN\;%MPI_ROOT%\BIN\;%PATH_ORG%


--- Test 'MPICH2':
   In order to test if 'MPICH2' works correctly, I run

     C:/> set_mpi
     C:/> mpiexec -np 2 hostname.exe

   and this should list two host names if environment variables are
   correct. User id and password may be required to launch 'MPICH2'.


--- 'pbdPROF' Installation:
   Default Installation:

     C:/> set_mpi
     C:/> R CMD INSTALL pbdPROF_0.1-0.zip


--- Test 'pbdPROF':
   Suppose all environments are set correctly, I can run test examples by

     C:/> set_mpi
     C:/> mpiexec -np 2 Rscript.exe -e "library(pbdPROF);init();finalize()"
