Difference between revisions of "How to MEX MSlice"

From Mslice
Jump to navigationJump to search
 
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
To create the right Fortran library files, one needs to MEX the Fortran files included with the mslice distribution. Each distribution will have the files MEXed in the correct format for that distribution. However, if you're a developer or if you want to use a system not currently supported, you can MEX the files yourself. These .f90 files are included with every distribution.  
+
To create the mex files from the Fortran and C code, you need to MEX the Fortran and C source code files included with the mslice distribution. Each distribution will have the files MEXed in the correct format for that distribution. However, if you're a developer or if you want to use a system not currently supported, you can MEX the files yourself. These Fortran and C files are included with every distribution.  
  
  
Line 6: Line 6:
 
If using an operating system that does not currently have a release of mslice, then you can MEX mslice yourself (if possible). You need to have:
 
If using an operating system that does not currently have a release of mslice, then you can MEX mslice yourself (if possible). You need to have:
  
* g95 Fortran compiler (or equivalent) OR Intel Fortran Compiler that is compatible with your version of Matlab.
+
* A Fortran compiler compiler that is compatible with your version of Matlab.
 
* Matlab 7.1 or above
 
* Matlab 7.1 or above
 +
 +
* Current development version of Mslice is available from the svn repository at [https://svn.isis.rl.ac.uk/mslice/trunk (Mslice trunk)]. You need to ask the development team if you want to access this. The stable version of the source code is provided at the [[Download_and_setup_MSlice | download page.]]
  
  
 
To MEX the files yourself:
 
To MEX the files yourself:
  
* [[Download and setup MSlice|Download any Windows distribution]] of mslice and unzip to a folder of your choice.
+
* [[Download and setup MSlice#Matlab Version 32 Bit|Download any Windows distribution]] of mslice and unzip to a folder of your choice.
 
* [[Download and setup MSlice#Matlab Version|Follow the setup instructions]].
 
* [[Download and setup MSlice#Matlab Version|Follow the setup instructions]].
 
* Open Matlab
 
* Open Matlab
* Type >> mslice_mex('bit') where bit is either 32 for a 32 bit system or 64 for a 64 bit system (must be a string).
+
* Type >> mslice_mex.
* You will be asked once for your fortran compiler - when asked to show installed compilers, select 'y' and then select either the Intel Fortran compiler or G95 compiler. If neither of these is on the list then you can not MEX the files yourself. Consult your computing services about aquiring one of these compilers.  
+
* You will be asked to configure your Fortran or C compiler. You have to select Fortran or C compiler under Windows, which will build Fortran or C part of the Mslice accordingly. You may ignore this if your Fortran and C compilers are already configured under Unix.  
* You will then be asked for your c compiler. Choose an appropriate compiler in the same way
+
* You will then be asked for your C compiler. Choose an appropriate compiler in the same way.
* A success or fail message will be displayed.
+
* A success or fail message will be displayed. If fail , you can try to build code with different mslice_mex options, which you can get from mslice_mex description. Or contact Mslice support team who will probably be able to help you.
 +
 
 +
== Note to users of recent 64-bit versions of Matlab under Ubuntu64 and 64-bit Mac (September 2011)==
 +
 
 +
The default compiler under Unix-type OS is gfortran, but the default configuration options for Matlab 64-bit instructs the compiler to generate 4-bit pointers. This lead to normal compilation of the mex files but crash after you try to do anything. To avoid this you have to modify your mexopt.sh file (usually located in your ~/.matlab/R201Xx folder) and force Fortran preprocessor to use 8-bit pointers. For gfortran4.4 it would mean adding option -D__x86_64__ to
 +
  $FFLAG='-fexceptions -fbackslash -D__x86_64__'
 +
line in Fortran configuration chapter.

Latest revision as of 11:54, 6 October 2014

To create the mex files from the Fortran and C code, you need to MEX the Fortran and C source code files included with the mslice distribution. Each distribution will have the files MEXed in the correct format for that distribution. However, if you're a developer or if you want to use a system not currently supported, you can MEX the files yourself. These Fortran and C files are included with every distribution.


How To MEX

If using an operating system that does not currently have a release of mslice, then you can MEX mslice yourself (if possible). You need to have:

  • A Fortran compiler compiler that is compatible with your version of Matlab.
  • Matlab 7.1 or above
  • Current development version of Mslice is available from the svn repository at (Mslice trunk). You need to ask the development team if you want to access this. The stable version of the source code is provided at the download page.


To MEX the files yourself:

  • Download any Windows distribution of mslice and unzip to a folder of your choice.
  • Follow the setup instructions.
  • Open Matlab
  • Type >> mslice_mex.
  • You will be asked to configure your Fortran or C compiler. You have to select Fortran or C compiler under Windows, which will build Fortran or C part of the Mslice accordingly. You may ignore this if your Fortran and C compilers are already configured under Unix.
  • You will then be asked for your C compiler. Choose an appropriate compiler in the same way.
  • A success or fail message will be displayed. If fail , you can try to build code with different mslice_mex options, which you can get from mslice_mex description. Or contact Mslice support team who will probably be able to help you.

Note to users of recent 64-bit versions of Matlab under Ubuntu64 and 64-bit Mac (September 2011)

The default compiler under Unix-type OS is gfortran, but the default configuration options for Matlab 64-bit instructs the compiler to generate 4-bit pointers. This lead to normal compilation of the mex files but crash after you try to do anything. To avoid this you have to modify your mexopt.sh file (usually located in your ~/.matlab/R201Xx folder) and force Fortran preprocessor to use 8-bit pointers. For gfortran4.4 it would mean adding option -D__x86_64__ to

  $FFLAG='-fexceptions -fbackslash -D__x86_64__'

line in Fortran configuration chapter.