<repo_name>ins-amu/cluster<file_sep>/matlab-to-update/compile.sh
#!/bin/bash

if [[ -z "$MATLAB" ]]
then
	MATLAB=/soft/matlab2015a
fi

mainscript=$1

if [[ -z "$mainscript" ]]
then
	echo "please provide a script to compile."
	exit 1
fi

echo "starting MATLAB.."
$MATLAB/bin/matlab -nojvm <<EOF
fprintf('compiling $1..\n');
mcc -m $1
fprintf('compilation complete. MCR installer for this version is here:\n');
mcrinstallerfile
EOF
<file_sep>/ssh.md
# SSH

SSH is the protocol usually used to access the cluster. It allows
access to a command line and optionally to run graphical programs
on the cluster, with the GUI showing on your computer.

## Connecting

The first step in using the cluster is connecting. How to connect
depends on your operating system.

### Windows

First download [PuTTY](http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html)

Then fill the cluster IP address `192.168.127.12` followed by your username and password.

### Mac OS X

```bash
ssh username@192.168.127.12
```

### Linux

```bash
ssh username@192.168.127.12
```

## Tips for Mac/Linux

To make things faster when logging in, you can use the following tricks with SSH:

### Define cluster host in `~/.ssh/config`

To avoid typing `user@192.168.127.12` all the time, you can add an entry to the
`.ssh/config` file (create the file if it doesn't exist):

```
Host cluster
    HostName 192.168.127.12
    User user
```

Now you simply type `ssh cluster` and bingo you're in.

### Setup an authorized key

Set up an SSH key if you don't already have one:

```bash
mycomputer $ ssh-keygen
......
```

This will set up a private-public key pair. 

Next, put the public key in the `.ssh/authorized_keys` file on the cluster. 

```bash
mycomputer $ cat .ssh/id_rsa.pub | ssh user@192.168.127.12 'cat - >> ~/.ssh/authorized_keys'
<enter password>
```

Now, `ssh user@192.168.127.12` should not require password.

NB: this is the same key you copy onto GitHub to automate access
to your repositories there (if you use GitHub).
<file_sep>/matlab-to-update/oarsub.sh
#!/bin/bash

# submit jobs to OAR


# build params file
rm -f params.txt
for i in $(seq 1 10);
do
	# these are args to mymain.m
	echo 100 1.5 >> params.txt
done


# submit
oarsub -l walltime=00:05:00 --array-param-file params.txt ./oarjob.sh
<file_sep>/matlab-to-update/oarjob.sh
#!/bin/bash

mcr=/soft/matlab-r2015a-mcr/v85

bash run_mymain.sh $mcr $@
<file_sep>/README.md
# ins-amu cluster

This repo contains documentation and examples for using the cluster.
<file_sep>/matlab-to-update/README.md
# Using MATLAB on the cluster

MATLAB can be used on the cluster by first compiling your main
script and then running it with the MATLAB Compiler Runtime (MCR).

This folder contains a working demo of how to do this:

- `mymain.m` - main MATLAB script for this example
- `params.txt` - list of parameter values per job to run `mymain.m` with
- `compile.sh` - Bash script which compiles your main MATLAB script
- `oarjob.sh` - Bash script to run a single job
- `oarsub.sh` - Bash script to submit all jobs

When you have modified `mymain.m`, you need to run `compile.sh`.

When the compilation is done, you can run `oarsub.sh` to submit your jobs.
