MathCode C++/F90 installation instructions for Linux and MacOSX machines.
License administration

MathCode C++ Version 1.4.9,

MathCode F90 Version 1.2.9,

22 October 2018

Installation is explained step by step. Please follow these steps for successful MathCode C++/F90 installation.

·        MathCode C++: Requires C++ compiler on Linux, MacOSX.

·        MathCode F90: Requires Fortran90 compilers on Linux, MacOSX.

·        Further instructions.

Required C++ compilers on Linux

Linux distributions include a c++ compiler.

Required C++ compilers on MacOSX

You need the GCC compiler which is included in free XCode tool : https://developer.apple.com/xcode/

MacOSX version 10.13.* with Apple LLVM 10.0.0 (clang 1000.10.44.2) was tested.

Required Fortran90 compilers on Linux

You have a choice between three compilers, but only gfortran supported by MathCode Team.

·        The gfortran compiler, part of GCC toolkit, a stable and freely available tool used in wide community of users. Available in recent releases of GCC for Linux. 

·        (not supported) The g95 compiler, separate freely available development, used in previous MathCode F90 releases. Visit g95 downloads and chose Linux x86-64 (32 bit DI) for 64-bit  or Linux x86  for 32-bit.

·        (not supported) The ifort compiler, Intel Fortran, for Linux only, freely available for non-commercial software development here.

One of these compilers is needed before you start installation. You will be asked about the compiler you chose during installation.  To switch between the compilers you have to reinstall the tool.

Required Fortran90 compilers on MacOSX

You have a choice between three compilers, but only gfortran supported by MathCode Team..

·        The gfortran compiler based on GCC toolkit, a stable and freely available tool used in wide community of users. It is not included in XCode (at the time of writing) and must be installed separately. This page  http://gcc.gnu.org/wiki/GFortranBinaries#MacOS contains, this link: link with gfortran 6.3 for Sierra (macOS 10.12).

·        (not supported) The g95 compiler, separate freely available development, used in previous MathCode F90 releases. Visit g95 downloads and chose  x86 OSX

·        (not supported) The ifort compiler, Intel Fortran for MacOSX is not available for non-commercial software development at the time of writing.

One of these compilers is needed before you start installation. You will be asked about the compiler you chose during installation.  To switch between the compilers you have to reinstall the tool.

Installing G95 properly on Linux and MacOSX

MathCode F90 requires the G95 compiler. It is available from http://www.g95.org..

G95 version 0.91 (March 2008) was tested on 32-bit Linux machines

G95 version 0.94 (January 2013) called “Linux x86-64(32 bit DI)” was tested on 64-bit Linux machines

Choose a directory for installation.

In order to make possible for other users to run g95 you should grant read permissions for this directory.

Unpack the downloaded tarball (e.g. g95-x86-linuxosx.tgz) in a directory of your choice:   tar -zxvf g95-x86-linuxosx.tgz

 Create a symbolic link from a directory in your $PATH (e.g. ~/bin) to the executable:

 ln -s $PWD/g95-install/bin/*g95* ~/bin/g95

 You should now be able to run g95 from command line and create executables.

As an alternative, in order to make possible for other users to run g95 you should use a common directory which is present in everyone's $PATH, and create a symbolic link with name /usr/bin/g95 or /usr/local/bin/g95 :

 sudo ln -s $PWD/g95-install/bin/*g95* /usr/bin/g95

In this case make sure that $PWD is readable for other users.

Installing G95 properly, specific for MacOSX

You need access to g95 from within Mathematica. Please try the commands

Run[“g95  --version > tmp”]

!! tmp

to see whether g95  available from Mathematica.

In MacOSX environment you start normally Mathematica using an icon before any adjustments to your PATH are applied.

Therefore, for Mathematica the directory $HOME/bin will not occur in the path (even if you tell that in your $HOME/.profile).

The following command creates a symbolic link such way that g95 is directly available from Mathematica in /usr/bin :

sudo ln -s $PWD/g95-install/bin/*g95* /usr/bin/g95

 If you have no administrative rights you can adjust "g95" everywhere it is mentioned in the make-files System/* and lib/sheep/*

 

Check your Mathematica, GCC version on Linux

MathCode will work on any Linux distribution with the proper tools installed.

Mathematica 11.2, 11.3 are supported on computers with Linux (64-bit).

Check your Mathematica, GCC version on MacOSX

Mathematica 11.2, 11.3 are supported.

You need the GCC compiler which is included in free XCode tool.

MacOSX version 10.13.* with Apple LLVM 10.0.0 (clang 1000.10.44.2) was tested.

MathCode relies on compatibility between clang and GCC  versions.

If you have a different GCC version please read the See Using different GCC version..

Further instructions

.

Determine your $MachineID

The $MachineID is needed for registration. It is the identity of the machine you want a license for. To find out your $MachineID, evaluate the following in Mathematica:

$MachineID

Obtain license key for purchased license

You should register to get a key file that will enable you to use the software. If you purchased the software you can register it online at the following URL: /register.html

Please do not use this page for demo (trial) licenses.

When you start installation of MathCode you can click the button Register to register your software. Within three business days you should receive an e-mail with the key file attached. Save the attachment to a file. Remember where you saved it; you will need to select this location during MathCode C++ installation.

Obtaining license key for demo (trial) license

You apply for demo (trial) license using online demo request form at /products/mathcode/ and click on Download Free Trial. When you start installation of MathCode you should not click the Register button to register your software. Within three business days you should receive an e-mail with the key file attached. Save the attachment to a file. Remember where you saved it; you will need to select this location during MathCode C++ installation.

Previous MathCode installations

You can have only one MathCode installation available in your UNIX account at a time. It is bound to your home directory. The setup will disable any previous installation of MathCode C++ or MathCode F90. The current installation is determined by settings in file (which is created during installation): 

·        Linux : ~/.Mathematica/Applications/MathCode.m

·        MacOSX:  ~/Library/Mathematica/Applications/MathCode.m

Different Mathematica installations

An installed MathCode can be used with only one Mathematica installation. If you switch to a different Mathematica version you must re-install MathCode. Otherwise difficult linking error messages will occur.

Check for the latest release

Since MathCode relies on many other software products that often change their versions and properties please always download the latest version from the address you get from us together with your key file; currently it is /products/mathcode/

Decide whether you need personal installation or root installation.

We recommend you to log in with your personal user name and install MathCode under your own home directory. MathCode will be available for you only. On Linux machines it is possible to install MathCode in system directory such as /usr/local/MathCode, and make it available for all users of certain Mathematica installation, but it causes additional security problems. As a root you can adjust the Mathematica installation for this purpose. The Demos and Licensing subdirectories of MathCode installation should be writable for all users. Otherwise the licensing system and demos will not work. On MacOSX machines you should install MathCode under your own home directory.

Installation procedure

Go to the linux directory on the MathCode CD or obtain the latest release from  www.wolfram.com or  www.mathcore.com.

You obtain file mathcode-linux[macosx]-version.tar

Use command

tar -xvf mathcode-linux[macosx]-version.tar

to unpack this archive.

Run the file install.system, either by ./install.system (preferred) or sh install.system (if the file is not flagged as executable on the CD) and follow the on-screen instructions.

If you have any special settings (PATH, GCC flags etc.) when you compile the runtime library, these settings should be preserved when you use MathCode C++ for compilation. Please run the test Demos/Verify/testlinux.m after installation.

Parallel installations

You can install several installations of MathCode, but only one of them (the latest one) will be used within Mathematica.

Uninstall

At the end of installation the script tells the name of a file (uninstall-system.sh) which contains commands for uninstall.         

Using different GCC version

If you have a different GCC release, then installation may stop. Please install another gcc toolkit and place its directory first in the path, so that shell commands "gcc" and "g++" invoke the tools of different version. Execute the command Run["echo $PATH"] from Mathematica to see the actual path.

 In addition to this you will need to set up a symbolic link so that commands invoked from within Mathematica sessions search for correct g++ binary of correct gcc version. When shell commands are executed from within Mathematica, a modified path is used. Execute the command Run["echo $PATH"] from Mathematica to see the actual path. Typical commands to adjust the g++ in use can be:

su

cd /usr/local/Wolfram/Mathematica/6.0/Executables

ln -s /usr/local/gcc/3.3.4/bin/g++ .

ln -s /usr/local/gcc/3.3.4/bin/gcc .

Using a different Fortran90 compiler

The MathCode Support provides you with scripts needed for different Fortran90 compiler as a consultancy service.

License management

What are licenses?

For each machine you wish to run MathCode on, you should obtain one key file containing the license. MathCode uses the same MathID as Mathematica does to distinguish between machines. A key file is a text file containing a mix of letters and digits. Key files should be put into the Licensing subdirectory of the MathCode installation. The names of the key files do not matter.

Adding a license

When you register for a new MathCode license, you will receive a file that should be put in the Licensing subdirectory of your MathCode installation.

The license index file

MathCode will use an index file index.m in the Licensing directory to speed up license lookups. If a new license is added, index.m is rebuilt automatically as needed. If you experience problems with the licensing, you can remove the index.m file, forcing MathCode to rebuild it on the next license check. For a site installation, users might not have write permissions to the Licensing subdirectory. In this case, the system administrator should rebuild the index file by evaluating the following in Mathematica:

Needs["MathCode`"];

RebuildIndex[ToFileName[{$MCRoot,"Licensing"}]];

If index.m didn't exist, you will se an error message about opening it. This error message can safely be ignored.         

 

More on compiler definitions

The file MathCodeConfig.m in the main MathCode directory controls the MathCode runtime configuration. This file is really a Mathematica package that contains some configuration directives; currently DefineCompiler[] and DefaultCompiler[].

 DefineCompiler[] is used to associate a symbolic compiler name (a string) with a make file, a command template, and a build command. You don't normally need to bother with these details. DefaultCompiler[] is used to select the default compiler definition for a language. Currently the only languages supported for code generation are C++ and Fortran90.

In MathCodeConfig.m you might find a line

DefaultCompiler["C++"->"mingw32"];

This tells MathCode to use the included "mingw32"compiler definition when generating C++ code. If you wish to use Visual C++ instead (assuming you are on the Windows platform), you should change this to read:

DefaultCompiler["C++"->"vc60"];

If there are several DefaultCompiler definitions, the last one is taken into account. Using a different compiler can be easier than that, with the new options to CompilePackage[], MakeBinary[] and BuildCode[].

CompilePackage[] takes a Language option (currently only C++ and Fortran90 are supported). MathCode will then use the default compiler for the specified language. Example:

CompilePackage[Language->"C++"]; MakeBinary[] takes a Compiler option; the option value should be one of the symbolic names (strings) defined using DefineCompiler[]. The Compiler option to MakeBinary[] overrides the default compiler specified for the selected language. Example:

MakeBinary[Compiler->"g++"];

As usual, BuildCode[]can be given both CompilePackage[] and MakeBinary[] options. The following example will generate C++ code and use the "CC" compiler to compile it, overriding any default specification:

BuildCode[Language->"C++", Compiler->"CC"];

The above example assumes that you are using MathCode C++ on Linux.