Readme file for release of Mesham
------------------------------------------------------------------

This file contains installation instructions. For a the latest instructions, along with language documentation refer to the Mesham website at http://www.mesham.com

This package contains a number of artefacts: the mcc executable is the main Mesham compiler and is executed to compile Mesham code. The includes directory contains header files for the Mesham standard function library calls which may be included in your code. The rtl directory contains components of the runtime library - a header file and two libraries (the .a is a static library, .so a dynamic one) and a static and dynamic library of the libgc garbage collector.

Prerequisites
-----------------------
In order to run and compile Mesham code you need to have an implementation of MPI (version 2) and a C compiler. We suggest MPICH-2 and GCC which are available in source form, binary form or most systems make them available via their package manager (i.e. apt-get.) Refer to your system documentation for the best way to get these packages if you do not already have them installed.

Installation
--------------------
Whilst it is a manual installation procedure, the good news is that this is very simple and will be elementary to anyone familiar with Linux.

It is suggested to download all components which will provide you with the compiler, runtime library and libgc. Unpack the archive and place the mcc (whihc is the main compiler) executable in your chosen location. It is suggested to either add the location to your path environment variable or add a symbolic link from the /usr/bin directory to the mcc binary so that you can call it regardless of the working directory.

Next we need to set up some environment variables to tell the compiler exactly where to find some different aspects. We can set these via the command export varible=value where variable is the name of the environment variable you wish to set and value is the value to set it to. The first environment variable, MESHAM_C_COMPILER, decides which C compiler to use - we suggest mpicc and if you agree then issue export MESHAM_C_COMPILER=mpicc.

Next we are going to set MESHAM_SYS_INCLUDE which points to the Mesham system include files (supplied with the compiler and all archive in the includes directory.) Set this variable to point to the directory containing these .mesh files. MESHAM_C_INCLUDE needs to point to the directory containing the mesham.h header file and will be used by the C compiler. This, along with the runtime library, is supplied in the rtl directory. Lastly, the MESHAM_C_LIBRARY should point to the directory containing the Mesham runtime library and also the libgc library (this can be in the same directory or you can separate the values the via ;.) It it suggested to add these exports to your .bashrc script to avoid excessive typing.

If you do not wish to set these last two environment variables then alternatively you can symlink libmesham.so and libgc.so into your /usr/lib directory and the mesham.h header file into /usr/include.

Now we have done this we are good to go; issue mcc -env which will display the environment variables.

If there are any issues with the libgc version included with this (especially if you are on a 32 bit system) then download this on its own from http://www.mesham.com/article/Download_libgc and use that one

Testing it works
--------------------------
Copy the following code into test.mesh, then compile via mcc -e test.mesh (the -e flag will display any errors reported by the C compiler.) All being well an executable test will appear, run this via mpiexec -np 1 ./test after ensuring your favourite MPI process manager is running.

#include <io>
#include <string>
#include <parallel>

function void main() {
   group 0,1,2,3 {
      print("Hello from process "+itostring(pid())+"\n");
   };
};


All being well, you should see the output (but the order of the lines will vary):

Hello from process 0
Hello from process 2
Hello from process 3
Hello from process 1