<html>

<head>
<title> ConfiguringMacOSXforCactus &lt; Vacuum &lt; TWiki</title>
</head>
<body>

<h1>Configuring Mac OS X for Cactus</h1>
<p>
This document explains how to set up a computer running Mac OS X for 
compiling and running Cactus simulations. These instructions 
specifically apply to OS X 10.6 (Snow Leopard). Other versions should be
 similar.
</p>

<h2>Step 1: Install Xcode</h2>
<p>
Download and install the latest version of <a href="http://developer.apple.com/technology/xcode.html" target="_top">Xcode</a> from Apple. The version"Xcode for Mac-only Development" is sufficient.
</p>

<h2>Step 2: Install MacPorts</h2>
<p>
<a href="http://www.macports.org/">MacPorts</a> allows you to install extra libraries and tools not included with OS X. <a href="http://www.macports.org/install.php">Download</a> and install the version for your version of OS X.
</p>

<h2>Step 3: Install git</h2>
<p>
git can be easily installed using MacPorts:
</p>
<pre>sudo port install git-core</pre>

<h2>Step 4: Install gnuplot</h2>
<p>
gnuplot can be easily installed using MacPorts:
</p>
<pre>sudo port install gnuplot</pre>

<h2>Step 5: Install GSL</h2>
<p>
GSL can be easily installed using MacPorts</span>:
</p>
<pre>sudo port install gsl</pre>

<h2>Step 6: Install Visit</h2>
<p>
Visit is used for visualizing the 3D data produced in simulations. 
Download the "Mac OS X - Intel" executable and "Visit install script" 
from <a href="https://wci.llnl.gov/codes/visit/executables.html">here</a>. Make the install script executable
</p>
<pre>chmod +x visit-install</pre>
<p>
then execute it to install visit
</p>
<pre>sudo ./visit-install 1.12.1 darwin-i386 /usr/local/visit</pre>
<p>
where 1.12.1 is the version of Visit you downloaded. Add <code>/usr/local/visit/bin</code> to your <code>$PATH</code> so that you can run Visit by just typing <code>visit</code> on the command line.
</p>

<h2>Step 7: Install HDF5 library</h2>
<p>
The HDF5 format can be used for outputting data from your simulations. 
Both Visit and Mathematica support reading data in HDF5 format. HDF5 can
 be installed by MacPorts using the command
</p>
<pre>sudo port install hdf5-18</pre>

<h2>Step 8: Install Visit Carpet plugin</h2>
<p>
To effectively read the data output by Carpter, Visit requires a plugin.
 The source code for the plugin may be checked out from the Cactus CVS 
repository (using password 'anon'):
</p>
<pre>cvs -d :pserver:cvs_anon@cvs.cactuscode.org:/cactus login
cvs -d :pserver:cvs_anon@cvs.cactuscode.org:/cactus checkout VizTools/visitCarpetHDF5
</pre>
<p>
The plugin requires the HDF5 library, but cannot use the previously installed version for two reasons:
</p>

<ul>
<li> It must be the same version of the HDF5 library that is used by 
Visit. In the case of Visit version 1.12.x, HDF5 library version 1.8.1 
is required.</li>
<li>The current version of Visit is compiled as 32-bit (i386). However, Snow Leopard compiles as 64-bit by default (x86_64).</li>
</ul> 

<p>
For this reason, it is best to compile a usable version of HDF5 by hand: </p>

<ul>
<li> Download the source for <a href="http://www.hdfgroup.org/ftp/HDF5/prev-releases/hdf5-1.8.1/src/hdf5-1.8.1.tar.gz" target="_top">HDF5 1.8.1</a> into <code>VizTools/visitCarpetHDF5</code>.</li>
<li> Extract the source</li>
</ul> 

<pre>cd VizTools/visitCarpetHDF5
tar zxvf hdf5-1.8.1.tar.gz
</pre>

<ul>
<li>Compile this version of HDF5:</li>
</ul> 
<pre>cd hdf5-1.8.1
CFLAGS="-arch i386" CXXFLAGS="-arch i386" LDFLAGS="-arch i386" ./configure --host=i386 --enable-cxx --enable-production --enable-static
make
make install
cd ../
</pre>
<p>
We can now compile the Visit plugin using this version of the hdf5 
library. Before doing so, we need to make a small change to one of the 
files installed by Visit. Edit <code>/usr/local/visit/1.12.1/darwin-i386/include/make-variables</code> and remove the <code>-Wno-long-double</code> from the line starting with <code>PY_CXXFLAGS</code>. Now, compile and install the plugin:
</p><pre>./install
</pre>
<p>
In the window that appears, select the Makefile tab. Ensure the CXXFLAGS includes <code>-I./hdf5-1.8.1/hdf5/include -arch i386</code> and the LDFLAGS include <code>-L./hdf5-1.8.1/hdf5/lib -arch i386</code>, then save and quit. The plugin should now compile and install a location where it can be found by Visit.
</p>

<h2>Step 9: Other libraries </h2>
<p>
There are some other libraries which may be useful and are easily installed using MacPorts (gcc44 is important as it provides gfortran):
</p>
<pre>
sudo port install fftw fftw-3 zlib szip openssl gcc44
</pre>

<h2>Step 10: Configure Cactus</h2>
<p>
In order for Cactus to find all of the installed libraries, make sure 
the your optionlist looks like the following (this is based off the 
version included in simfactory):
</p>
<pre># macbook-gcc

# Whenever this version string changes, the application is configured
# and rebuilt from scratch
VERSION = 2009-11-25

CPP = cpp
FPP = cpp
CC  = gcc
CXX = g++
F77 = gfortran-mp-4.3
F90 = gfortran-mp-4.3

# -fmudflapth does not work with current gcc 4.2.0
# -march=prescott and -march=core2 lead to an ICE
# -march=native prevents undefined references to ___sync_fetch_and_add_4
# -malign-double may lead to crashes in Fortran I/O
CPPFLAGS = -DMPICH_IGNORE_CXX_SEEK
FPPFLAGS = -traditional
CFLAGS   = -g3 -fshow-column -mmacosx-version-min=10.5 -m128bit-long-double -std=gnu99
CXXFLAGS = -g3 -fshow-column -mmacosx-version-min=10.5 -m128bit-long-double -I/opt/local/include
F77FLAGS = -g3 -fshow-column -mmacosx-version-min=10.5 -m128bit-long-double -fcray-pointer
F90FLAGS = -g3 -fshow-column -mmacosx-version-min=10.5 -m128bit-long-double -fcray-pointer

LDFLAGS = /System/Library/Frameworks/vecLib.framework/vecLib -L/opt/local/lib/gcc43 -lgfortran

C_LINE_DIRECTIVES = yes
F_LINE_DIRECTIVES = yes

REAL16_KIND = 10

DEBUG           = no
CPP_DEBUG_FLAGS = -DCARPET_DEBUG
FPP_DEBUG_FLAGS = -DCARPET_DEBUG
C_DEBUG_FLAGS   = -fbounds-check -ftrapv -fstack-protector-all
CXX_DEBUG_FLAGS = -fbounds-check -ftrapv -fstack-protector-all
F77_DEBUG_FLAGS = -fbounds-check -ftrapv -fstack-protector-all
F90_DEBUG_FLAGS = -fbounds-check -ftrapv -fstack-protector-all

# Changing ANSI C semantics:
# -funsafe-loop-optimizations -ffast-math-errno -fassociative-math
# Graphite optimisations are not implemented:
# -floop-interchange -floop-strip-mine -floop-block
OPTIMISE           = yes
CPP_OPTIMISE_FLAGS = # -DCARPET_OPTIMISE -DNDEBUG
FPP_OPTIMISE_FLAGS = # -DCARPET_OPTIMISE -DNDEBUG
C_OPTIMISE_FLAGS   = -O2
CXX_OPTIMISE_FLAGS = -O2
F77_OPTIMISE_FLAGS = -O2
F90_OPTIMISE_FLAGS = -O2

PROFILE           = no
CPP_PROFILE_FLAGS =
FPP_PROFILE_FLAGS =
C_PROFILE_FLAGS   = -pg
CXX_PROFILE_FLAGS = -pg
F77_PROFILE_FLAGS = -pg
F90_PROFILE_FLAGS = -pg

# -Wuninitialized is not supported without -O
WARN           = no
#CPP_WARN_FLAGS = -Wall
#FPP_WARN_FLAGS = -Wall
#C_WARN_FLAGS   = -Wall
#CXX_WARN_FLAGS = -Wall
#F77_WARN_FLAGS = -Wall
#F90_WARN_FLAGS = -Wall



BLAS_DIR  = /System/Library/Frameworks/vecLib.framework
BLAS_LIBS = gfortran

FFTW_DIR  = /opt/local
FFTW_LIBS = drfftw dfftw m

#CURL_DIR = /opt/local

#FLICKCURL_DIR = /Users/eschnett/flickcurl-1.10

GSL     = yes
GSL_DIR = /opt/local

HDF5      = yes
HDF5_DIR  = /opt/local
LIBSZ_DIR = /opt/local

LAPACK      = yes
LAPACK_DIR  = /System/Library/Frameworks/vecLib.framework
LAPACK_LIBS =

MPI              = OpenMPI
MPI_LIBS         = mpi
#OPENMPI_DIR      = /opt/local/lib/openmpi
#OPENMPI_INC_DIR  = /opt/local/include
#OPENMPI_LIB_DIR  = /opt/local/lib

OPENMP           = yes
CPP_OPENMP_FLAGS = -fopenmp
FPP_OPENMP_FLAGS = -fopenmp
C_OPENMP_FLAGS   = -fopenmp
CXX_OPENMP_FLAGS = -fopenmp
F77_OPENMP_FLAGS = -fopenmp
F90_OPENMP_FLAGS = -fopenmp

#PETSC           = yes
#PETSC_DIR       = /opt/local/lib/petsc 
#PETSC_ARCH      = macx
#PETSC_ARCH_LIBS = X11   mpich   gfortran   dl   pthread

PTHREADS = yes

SSL_DIR = /opt/local

X_LIB_DIR = /usr/X11R6/lib
</pre>

<h2>Step 11: Install Globus Tools (gsissh, GridFTP, myproxy, etc.)</h2>
<p>
In order to access any of the TeraGrid
  machines (eg. Kraken), you will need to first install the Global 
Tools. These must currently be compiled from source as follows:
</p>
<ul>
<li> Download the <a href="http://www.globus.org/toolkit/downloads/5.0.0/#source">source package</a>.
</li>
<li> Extract the files:
</li>
</ul> 
<pre>tar zxvf gt5.0.0-all-source-installer.tar.bz2
</pre> 
<ul>
<li> cd to the directory where you extract the files and build gsi-ssh, GridFTP, myproxy
</li>
</ul> 
<pre>./configure --prefix=/usr/local
sudo make gsi-myproxy gsi-openssh gridftp
sudo make install
</pre>
<ul>
<li> Add the the following lines your <code>~/.bash_profile</code> and then run <code>source ~/.bash_profile</code>:
</li>
</ul> 
<pre>export GLOBUS_LOCATION=/usr/local
export MYPROXY_SERVER=myproxy.teragrid.org
export MYPROXY_SERVER_PORT=7514
source $GLOBUS_LOCATION/etc/globus-user-env.sh
</pre>

</body>
</html>