Hi all,

I started out trying meep on Linux to see if it would do what I wanted. At 
first, I used the Scheme interface, but didn’t like it, so I followed the 
instructions at http://www.fzu.cz/~dominecf/meep/index.html 
<http://www.fzu.cz/~dominecf/meep/index.html> to install the python interface. 
That works well, but my main OS is OS-X (Yosemite), so I worked at getting 
python-meep working in that environment.This post details how I went about 
getting that to work. In the end, I had an rich environment that I’m familiar 
with and I don’t have to boot back and forth between OSes as I do my day’s 
work. As a bonus, meep executes slightly faster on the identical hardware! 

First, install Xcode from the App Store and command line tools using the 
terminal: xcode-select --install

Next, install home-brew:

        ruby -e "$(curl -fsSL 

Finish the homebrew installation with:
        brew doctor
        brew update

Install packages needed to build meep:
        brew install guile
        brew install —with-mpi homebrew/science/hdf5
        brew install homebrew/science/openblas fftw h5utils
        brew install pkg-config
        brew install swig
        brew install automake
        brew install autoconf

Log in as a user with admin privileges. 

Download libctl library from ab-initio: 

Unpack that, cd into libctl-3.2.2 and do the usual 
        sudo make install

Get meep from github: 
        git clone https://github.com/stevengj/meep 

In the cloned code (on 2/1/15), some files needed to be modified to get swig to 
work properly. Specifically, the cloned libctl/Makefile.am caused broken 
libctl/meep_swig_bug_workaround.i, libctl/meep_enum_renames.i and 
libctl/meep_renames.i to be created.

To fix that I modified two lines in libctl/Makefile.am:
        the line after “meep_swig_bug_workaround.i: $(LIBHDRS)” was changed from
        -> (echo "// AUTOMATICALLY GENERATED -- DO NOT EDIT"; grep -h friend 
$(LIBHDRS) | sed 's/^ *friend \+[A-Za-z_0-9:<>]\+[* ]\+\([A-Za-z_0-9:]*\) 
*(.*$$/%ignore \1;/' | grep "%ignore" | sort -u;) > $@
        -> (echo "// AUTOMATICALLY GENERATED -- DO NOT EDIT"; grep -h friend 
$(LIBHDRS) | sed 's/^ *friend  *[[:alpha:]_][[:alnum:]_]*  
*\([[:alpha:]_][[:alnum:]_]*\) *(.*/%ignore \1;/' | grep "%ignore" | sort -u;) 
> $@
        the line after “meep_enum_renames.i: $(LIBHDRS)” was changed from
        -> (echo "// AUTOMATICALLY GENERATED -- DO NOT EDIT"; for f in 
$(LIBHDRS); do egrep "^enum" $$f | sed 's/enum \+\([A-Za-z_0-9:]\+\).*$$/\1/g' 
| while read enum; do cat $$f | tr -d '\n' | sed 's/.*enum \+'$${enum}' 
*{\([^}]*\)}.*/\1/g' | sed 's/= *[0-9]\+//g' |tr -d ' \t' | tr ',' '\n' | sed 
's/^.*$$/'"%rename(meep_$${enum}_\0) meep::\0;/g"; echo; done; done;) > $@
        -> (echo "// AUTOMATICALLY GENERATED -- DO NOT EDIT";for f in 
$(LIBHDRS); do egrep "^enum" $$f | sed 's/enum  *\([^}][^}]*\).*};/\1/g' | tr 
-d "{" | sed 's/, */ /g' | sed 's/ *= *[[:digit:]][[:digit:]]*//g'| while read 
-a array; do varname=$${array[0]};unset "array[0]";for varvalue in 
$${array[@]};do echo "%rename(meep_$${varname}_$$varvalue) meep::$$varvalue;"; 
done;done;done;) > $@

That resulted in good libctl/meep_swig_bug_workaround.i and 
libctl/meep_enum_renames.i when make was run, but to fix libctl/meep_renames.i, 
I punted and just copied that file over from a meep 1.2.1 distribution. 

For the instructions that follow, I used 
<http://www.fzu.cz/~dominecf/meep/index.html> as a guide and made modifications 
to get things to work on OS-X.

Cd into meep and execute
        export CFLAGS=" -fPIC"; export CXXFLAGS=" -fPIC"; export FFLAGS="-fPIC" 
        export CPPFLAGS="-I/usr/local/include" 
        export LD_RUN_PATH="/usr/local/lib"
        ./autogen.sh —-with-mpi --enable-maintainer-mode --enable-shared 
        make  &&  sudo make install

That should take care of the basic meep, but I find it much more convenient to 
deal with Python than Scheme, so I installed python-meep, which started with a 
download of 
The resulting files seemed to require some modification to install in 
/usr/local directories and to work properly:
        in setup-mpi.py inserted after line 9: import numpy as np
        in setup-mpi.py changed the last line to: 
        in setup-mpi.py changed line 16 to: includeDir = ["/usr/local/include”]
        in setup-mpi.py changed line 17 to: includeDir = ["/usr/local/lib”]
        in make-mpi inserted after line 5: export LD_RUN_PATH=/usr/local/lib 
        in meep_mpi.py changed line 4918 to: libmpi = CDLL('libmpi.0.dylib’, 
        in meep_mpi.py changed line 4921 to: libmpi = CDLL('libmpi.dylib’, 
        in meep-site-init.py replaced the # in the first line with //

With those modifications, the installation can proceed:
        cd to python-meep directory
        as a user with admin privileges execute: sudo ./make-mpi 
-I/usr/local/include -L/usr/local/lib

If no errors or omissions have slipped by me, that should get python-meep 
running on OS-X.
meep-discuss mailing list

Reply via email to