Compiling SimBio

From SimBio - A generic environment for bio-numerical simulations

Jump to: navigation, search

Contents

Compiling SimBio when all dependencies are resolved

cd <simbio root directory>
cd trunk
make clean
make realclean
make Venant

From revision 109 on, it is no longer necessary to compile different SimBio versions for different dipole models. "make Venant" compiles a version that is able to use the full subtraction approach, the Venant approach and also the partial integration approach. Therefore, make Subtraction and make Partialintegration is no longer necessary and changing the dipole model can thus uniquely be indicated only by means of the dipole model setting in the parameterfile. This now gets possible since we checked in the partial integration dipole model without usage of COLSAMM routines. Only for the old/approximate/projected subtraction approach, an own compiled version is still necessary using "make Oldsubtraction", but we do not recommend to use this dipole model, because it is less accurate than the full subtraction approach.

On most standard Linux-installations one or several libraries/programs that SimBio depends on are not installed, in particular g77 and g2c on gcc4.* systems. Below you can find Linux-distribution-dependent instructions on how to install what is missing.

Ubuntu

Ubuntu 18.04 LTS

Contact Persons: Takfarinas Medani

Date 14th of December, 2018

Operating System: 64 bit

Please follow what was written for Ubuntu 16.04 LTS below.

Ubuntu 16.04 LTS

Contact Persons: Carsten Wolters

Date 30th of March, 2017

Operating System: 64 bit

From repository version 107 onwards, after downloading the source code from the homepage http://sourceforge.net/projects/neurofem-simbio, where you can find it under the tab "Code", only the following steps were necessary:

  • Install the packages:
    • $sudo apt-get install csh
    • $sudo apt-get install gfortran
    • $sudo apt-get install mpich
    • $sudo apt-get install f2c
  • Set the following links
    • $sudo ln -s /usr/include/f2c.h /usr/include/g2c.h
    • $sudo ln -s /usr/bin/gfortran /usr/bin/g77

In repository version 106, we checked in all bug fixes to files that have been described below for Ubuntu versions 9.10 up to 16.04 LTS that seemed reasonable also for other operating systems.

How to install SimBio without using f2c:

Contact Person: Anne Hanrath

Date: 27th of April 2017

  • Install the packages:
    • $sudo apt-get install csh
    • $sudo apt-get install gfortran
    • $sudo apt-get install mpich

Then make sure you have the packages 'sed' and 'find' on your machine (should be, they are standard on Ubuntu Systems)

  • go into ??/SimBio/trunk, then run the following command (substituting the ?? with the corresponding path on your machine):
    • $find ??/SimBio/trunk/ -type f -exec sed -i 's/lg2c/lgfortran/g' {} \;
    • $find ??/SimBio/trunk/ -type f -exec sed -i 's/g77/gfortran/g' {} \;

This will substitute lg2c with lgfortran and g77 with gfortran in all files which are in ??/SimBio/trunk/..

  • then go to ??/SimBio/trunk/misc/neurofem/NeuroFEM.h, ??/SimBio/trunk/misc/neurofem/NeuroFEM_Extern.h and ??/SimBio/trunk/misc/neurofem/NeuroFEM_Inc.h and substitute '#include <g2c.h>' with '#include <fortran.h>'. It might be, that your computer does not know fortran.h. I fixed this with copying fortran.h into ??/SimBio/trunk/misc, but it might also be, that you just can use '#include <cfortran>' or '#include <?/fortran>', but i have to test this

Ubuntu 16.04 LTS

Contact Persons: Sophie Schrader and Carsten Wolters

Date 10th of March, 2017

Operating System: 64 bit

For repository versions 105 and below, after downloading the source code from the homepage http://sourceforge.net/projects/neurofem-simbio, where you can find it under the tab "Code" , I basically followed Carsten's description for Ubuntu 12.04 with some adjustments. The following steps were necessary:

  • Install the following packages:
    • $sudo apt-get install csh
    • $sudo apt-get install gfortran
    • $sudo apt-get install mpich
    • $sudo apt-get install f2c
  • Set the following links
    • $sudo ln -s /usr/include/f2c.h /usr/include/g2c.h
    • $sudo ln -s /usr/bin/gfortran /usr/bin/g77
  • Change some files like shown below by Felix for Ubuntu 10.04. To do so, go to section "Ubuntu 9.10 and 10.04" below and follow the steps described in the last section called "Some files have to be changed:...".
  • Like Johannes found out for 11.04, remove the "-static" flag in the uif3 target (the line following the line starting with "uif3: ...") in the files ./uif/Makefile_linux_opt and ./uif/Makefile_linux_dbx.
  • Additionally, change a few lines in "./trunk/toolbox/container/CON_SparseVector_t.h":
Old Code (line 73 - 76):

CON_SparseVector_t(unsigned length, unsigned nonZeroEntriesPerRow);
void allocate(unsigned length, unsigned nonZeroEntriesPerRow);
void insert(unsigned column, const T &value);
bool finishInsertMode(int newWidth);

New Code (lines 73 - 76):

CON_SparseVector_t(unsigned length, unsigned nonZeroEntriesPerRow = 0);
void allocate(unsigned length, unsigned nonZeroEntriesPerRow = 0);
void insert(unsigned column, const T &value);
bool finishInsertMode(int newWidth = -1);
Old Code (lines 137 - 139):

template <class T>
CON_SparseVector_t<T>::CON_SparseVector_t(unsigned length,
      unsigned nonZeroEntriesPerRow = 0)

New Code (lines 137 - 139):

template <class T>
CON_SparseVector_t<T>::CON_SparseVector_t(unsigned length,
      unsigned nonZeroEntriesPerRow)
Old Code (lines 144 - 146):

template <class T>
inline void CON_SparseVector_t<T>::allocate(unsigned length,
      unsigned nonZeroEntriesPerRow = 0)

New Code (lines 144 - 146):

template <class T>
inline void CON_SparseVector_t<T>::allocate(unsigned length,
      unsigned nonZeroEntriesPerRow)
Old Code (lines 185 - 186):

template <class T>
bool CON_SparseVector_t<T>::finishInsertMode(int newWidth = -1)

New Code (lines 185 - 186):

template <class T>
bool CON_SparseVector_t<T>::finishInsertMode(int newWidth)

Ubuntu 12.04

Contact Person: Carsten Wolters

Date 24th of Feb, 2015

Operating System: 64 bit


  • I followed the descriptions from Felix for Ubuntu 10.04 and could build SimBio successfully without much trouble.
  • On my system, I needed to get the following packages:
    • $sudo apt-get install gfortran
    • $sudo apt-get install mpich2
    • $sudo apt-get install f2c
  • Then, I needed to set the following links:
    • $sudo ln -s /usr/include/f2c.h /usr/include/g2c.h
    • $sudo ln -s /usr/bin/gfortran /usr/bin/g77
    • $sudo ln -s /usr/bin/mpicc /usr/bin/mpiCC
  • I changed some files like shown below by Felix for Ubuntu 10.04.
  • As a last step, like Johannes found out for 11.04 (see below), I also had to remove the "-static" flag in the uif3 target (the line following the line starting with "uif3: ...") in the files ./uif/Makefile_linux_opt or ./uif/Makefile_linux_dbx, respectively.

Ubuntu 11.04

Contact Person: Johannes Vorwerk

Date 13th of May, 2011

Operating System: 64 bit

You can mainly follow the steps for Ubuntu 10.04. You further have to remove the "-static" flag in the uif3 target (the line following the line starting with "uif3: ...") in the file ./uif/Makefile_linux_opt or ./uif/Makefile_linux_dbx, respectively.

Minor annotation (issued by Burkhard Maess and Dominic Portain, 11th of April, 2012):

If compiling throws the error "cast from ‘ompi_communicator_t*’ to ‘int’ loses precision", change line 1274 in trunk/toolbox/simulator/fem/SIM_SimulatorEEGMEGNeuroFEMParPiluts_c.cpp:

(before) integer comsol = (int) MPI_COMM_WORLD;
(after) integer comsol = (uint32) MPI_COMM_WORLD;

Annotation (Johannes, 28th of May, 2015): A cleaner way to solve this is

(before) integer comsol = (int) MPI_COMM_WORLD;
(after) integer comsol = *((int*)(MPI_COMM_WORLD));

as uint32 is not defined on all systems.

The makefiles for compiling Neurofem don't always work as expected. To force use of the correct flags, follow this procedure before the Simbio compilation:

cd neurofem
make clean
cp Makefile_linux_dbx_Partialintegration Makefile
make

Ubuntu 9.10 and 10.04

Contact person: Felix Lucka

Date: 09th of Oktober 2010

Operating system: 64 bit

  • Many needed packages are not contained in the normal distributions any more. Make sure you have "svn", "csh", "mpich2", "gfortran" and "g++". Under 10.04 you may need other packages as well, my version of 10.04 was upgraded from 9.10.
  • You need to set some links:
    • $sudo ln -s /usr/bin/mpicc /usr/bin/mpiCC
    • $sudo ln -s /usr/bin/gfortran /usr/bin/g77
    • $sudo ln -s "path_to_f2c.h" /usr/include/g2c.h (search for the file f2c.h and link it to g2c.h in this manner)
  • Some files have to be changed:
    • In "./trunk/toolbox/grid/libmetis/rename.h" change the line "#define log2 __log2" into "#define log2 __log2_metis"
    • In "./trunk/toolbox/grid/libparmetis/rename.h" change the line "#define log2 log2__" into "#define log2 log2_metis__" (Beware, that it have to be 2 underscores at the end!)
    • In "./trunk/uif/Makefile" change the line "EXTRA_LIBS = -lm -lg2c -lpthread -lstdc++" into "EXTRA_LIBS = -lgfortran -lm -lpthread -lstdc++"
    • Do the same as in the previous point with "./trunk/uif/Makefile_linux_opt" and "./trunk/uif/Makefile_linux_dbx"
    • In "./trunk/toolbox/linearalgebra/libsol/ransol.f" change these lines:
New code: 
c=======================================================================
c
      function ransol(idum)
c
c-----------------------------------------------------------------------
c---random number generator nach donald e. knuth
c---aus: numerical recipes,b.p.flannery,w.h.press/cambridge university 
c---press
c-----------------------------------------------------------------------
      save ma,inext,inextp
     
      parameter (mbig=1000000000,mseed=161803398,mz=0,fac=1./mbig)
      dimension ma(55)
      data iff /0/
      real ransol = 0.0
      real fac = 0.0
c      save ma,inext,inextp
Old Code

c=======================================================================
c
      function ransol(idum)
c
c-----------------------------------------------------------------------
c---random number generator nach donald e. knuth
c---aus: numerical recipes,b.p.flannery,w.h.press/cambridge university 
c---press
c-----------------------------------------------------------------------
      
      parameter (mbig=1000000000,mseed=161803398,mz=0,fac=1./mbig)
      dimension ma(55)
       data iff /0/
      real ransol, fac
      save ma,inext,inextp

Ubuntu 8.10 (Intrepid Ibex)

Contact person: Olaf Steinstraeter

Date: 20th of March 2009

Operating system: 64 bit

  • Get "csh" if don't have it.
  • Get "mpich 1.2.7".
  • The next step is a bit more tricky than with 8.04 since g77 is no longer available in the usual package-repositories. This is how we solved it:
    • Installed and compiled gcc3.3.5:
      • Unpack gcc-3.3.5 source packages (core and fortran are needed)
      • Compile the package in a different directory !
      • Use the following line to configure:
        • export CFLAGS=-m64
        • <directory of the sources>/configure --prefix=/usr/local/gcc-3.3.5 --disable-multilib --enable-languages=f77
      • make bootstrap
      • make install
    • In /usr/include, set the following link: ln -s /usr/local/gcc-3.3.5/lib/gcc-lib/x86_64-unknown-linux-gnu/3.3.5/include/g2c.h g2c.h
    • Set the following link: ln -s /usr/local/gcc-3.3.5/lib64/libg2c.* /usr/lib/.


Ubuntu 8.10 (Intrepid Ibex)

Contact person: Olaf Steinstraeter

Date: 19th of March 2009

Operating system: 32 bit

  • Get "csh" if don't have it.
  • Get "mpich 1.2.7" since "mpich2" is not jet available for 8.10.
  • The next step is a bit more tricky than with 8.04 since g77 is no longer available in the usual package-repositories. This is how we solved it (but the following only works for 32bit systems):
    • We used the compatibility package "compat-g77-3.3.5-42.1.i586.rpm" from an older SUSE-Linux
    • Get "alien" from the usual repositories, it allows you to convert packages for other distributions into debian packages
    • Install compatibility package with alien: $sudo alien -i compat-g77-3.3.5-42.1.i586.rpm
    • Now we need to link the file "g2c.h": $sudo ln -s /usr/lib/gcc-lib/i586-suse-linux/3.3.5/include/g2c.h /usr/include/g2c.h


Ubuntu 8.04 Hardy (mpich 1.2.7)

Contact persons: Thomas Dierkes, Benjamin Lanfer (Stephan Lau, Simon Vogrin)
Date: 24.03.2009
Operating System: Ubuntu 8.04 Hardy, 64 bit

Install csh and/or the Message Passing Interface mpiCC (if missing)

sudo apt-get install tcsh
sudo apt-get install libmpich1.0-dev
sudo ln -s /usr/lib/mpich/bin/mpiCC /usr/bin/mpiCC 
sudo ln -s /usr/lib/mpich/bin/mpiCC /usr/bin/mpicc 

Install g77 and the g2c library

sudo apt-get install g77

Install g++

sudo apt-get install g++

Red Hat

Fedora 10

Contact person: Carsten Wolters

Date: 18th of March 2009

Operating system: 32 bit

  • Step 1 (Installing mpich2):
    • yum info mpich2
    • yum install mpich2-devel.i386
    • Say "yes" for also installing all dependencies, i.e., mpich2-libs, mpich2, mpich2-devel
    • I then had to set the link: ln -s /etc/alternatives/mpicc /usr/bin/mpiCC
    • Comment of Thomas Dierkes: The older version mpich1.2.7 is also working fine with SimBio on Fedora 10.
  • Step 2 (Installing g77):
    • Install the compat-gcc-34-g77 package on Fedora10 which provides support for compiling Fortran 77 programs with the GNU Compiler Collection.
    • I had to set the link: ln -s /usr/lib/gcc/i386-redhat-linux/3.4.6/include/g2c.h /usr/include/g2c.h
    • I then had to set the link: ln -s /usr/lib/gcc/i386-redhat-linux/3.4.6/libg2c.a /usr/lib/libg2c.a

Suse

Contact person: Olaf Steinstraeter

Debian

Contact person: Moritz Dannhauer

Gentoo (gcc4.* and gcc3.4.6)

Contact person: Stephan Lau
Date: 06.01.2010
Operating Systems:
- 32 bit, Linux-2.6.27-gentoo-r7, gcc-4.1.2, glibc-2.6.1-r0
- 64 bit, Linux-2.6.29-gentoo-r5, gcc-4.1.2, glibc-2.6.1

Install csh and/or the Message Passing Interface mpiCC (if missing)

emerge tcsh
emerge mpich2
ln -s /usr/bin/mpicc /usr/bin/mpiCC 

If your Gentoo-Installation is based on gcc3.4.6, you can start compiling.

Gcc4.* users: Install g77 and the g2c library

Because Fortran77 is in general not supported from gcc4.0.0 onwards, we install it by installing gcc3.4.6 and setting a symbolic link to it:

emerge =gcc-3.4.6-r2
ln -s /usr/bin/g77-3.4.6 /usr/bin/g77

For the same reason, the g2c library is missing. So we create links to g2c.h and libg2c.* like this for 32 bit systems:

ln -s /usr/lib/gcc/i686-pc-linux-gnu/3.4.6/libg2c.* /usr/lib/
ln -s /usr/lib/gcc/i686-pc-linux-gnu/3.4.6/include/g2c.h /usr/include/g2c.h

or like this for 64 bit systems:

ln -s /usr/lib/gcc/x86_64-pc-linux-gnu/3.4.6/libg2c.* /usr/lib/
ln -s /usr/lib/gcc/x86_64-pc-linux-gnu/3.4.6/include/g2c.h /usr/include/g2c.h

You can check the bug report for the current situation.

Mac

Contact person: Sarang Dalal
Date: 06.06.2011

Install XCode (Apple Developer Tools) if not already installed. XCode 4 for Lion can be downloaded for free from the App Store. (XCode 3 should also work for older MacOS versions.)

Install F2C

SimBio expects "g2c" so make a symbolic link:

ln -s /usr/local/include/f2c.h /usr/local/include/g2c.h

Install cmake, gfortran, and open-mpi via Homebrew or MacPorts

mkdir build
cd build
ccmake ../trunk

In ccmake, configure:

G2C_INCLUDE_PATH = /usr/local/include
G2C_LIB = /usr/local/lib/libf2c.a

I also had to modify trunk/application/uif/uif1_c.h and uif1_c.cpp to use IP_OPT_OptimizerSimplex_c.h rather than OPT_OptimizerSimplex_c.h.

Then run make.

For me (Sarang Dalal), this got pretty far, but failed on:

[ 82%] Building CXX object toolbox/simulator/fem/CMakeFiles/neurofem.dir/SIM_SimulatorEEGMEGNeuroFEMParPiluts_c.cpp.o
...
SimBio/trunk/toolbox/simulator/fem/SIM_SimulatorEEGMEGNeuroFEMParPiluts_c.cpp:1274: error: cast from ‘ompi_communicator_t*’ to ‘int’ loses precision
make[2]: *** [toolbox/simulator/fem/CMakeFiles/neurofem.dir/SIM_SimulatorEEGMEGNeuroFEMParPiluts_c.cpp.o] Error 1
make[1]: *** [toolbox/simulator/fem/CMakeFiles/neurofem.dir/all] Error 2

I worked around this by modifying the referenced cast from (int) to (long), and the entire build then successfully compiles. But I'm not sure if this is a bad idea, numerically!!!

Other systems

The most generic method is described under Ubuntu 8.10 (Intrepid Ibex) 64bit

Personal tools