Running MATLAB jobs on the Grid

Setting up MCR on Grid computer

Compiling Example MATLAB Application

For this example, we will be using a version of Mike Ashley's LineAmp progran
which measures calibration line strengths.  The example we will use
is called 'lineamp_detcamp.m' (retrievable from the web link).

Points to note about the M-file are
1) It is a  MATLAB function as scripts are not compilable
2) It has no output parameters to simplify calling from the command line
3) It saves output to files for later retrieval from the Grid computer

If you haven't checked that you can compile, please see the
Basic MATLAB Compilation web page.

The program needs to be compiled on a Linux box.  For this purpose,
we need to use ldas-pcdev1.ligo-wa.caltech.edu, which requires a
grid-enabled SSH.

The steps should be
1) Use grid-enabled SSH to login to ldas-pcdev1 using your grid cert
2) Create a 'lineamp_test' sub-directory off your home directory
3) Put the 'lineamp_detcamp.m' file in the 'lineamp_test' directory
4) Change to that directory
cd lineamp_test
5) Startup MATLAB without a window for speed
$ matlab -nodisplay
6) Compile the program
>> mcc -mv lineamp_detcamp.m
7) Exit MATLAB
>> quit

Local Test of MATLAB Application

To test a compiled MATLAB application on a machine with MATLAB installed, we
need to point the dynamic library path (LD_LIBRARY_PATH) to the MATLAB
installation.  Here is a c-shell script which defines these on ldas-pcdev1.
These is also a bash script

At the command line
source matlab_test_setup.csh for tcsh, csh
          or
source matlab_test_setup.sh for bash

Then try to run the program

./lineamp_detcamp 754562513 600

This should create two files
Line-H1-754562513-600.eps                  - An EPS copy of the plots
Line-H1-754562513-600-results.mat - A MATLAB files of saved variables

NOTE:  There will be a lot of warnings from frgetvect regarding that it
is opening frame files.  This is a brand-new "feature".  One should be
able to disable it using a MATLAB warning OFF msgID command.

Deploying Application to Grid computer

To deploy the application, you need to

1) Install the MATLAB Component Runtime (MCR) libraries on the Grid computer

This typically involves using 'buildmcr' on the machine you compile on (i.e. ldas-pcdev1) to
create a zip file (MCRInstaller.zip) which has the MCR distribution.  However, MATLAB
has had problems with this installer.  They fixed 'buildmcr' in the latest revision, but
it apparently fails to create the correct links to the libraries

Typically, this should only be installed in one (common) place on a Grid computer,
by the sys-admin, so we won't cover this installation.

A known good MCR Installer is available at PSU (MCRInstaller.tgz)

*** For this exercise, the LHO grid computers can still see the MATLAB installation
(but they can't run it).  Thus we can use the same setup (matlab_test_setup) we
used above.

2) Transfer your application to the grid computer

Using grid-enabled file transfer tools (scp), transfer the following files from your
compilation (should be in ~/lineamp_test) to a new sub-directory(we recommend ~/gridtest)
    lineamp_detcamp
    lineamp_detcamp.ctf

Note that you likely will have to make the executable (lineamp_detcamp) an
executable (using chmod 755) after transferring it.

3) Create a script to add MCR to dynamic library

We have provide csh and Bash scripts (matlab_MCR_setup) to do this, BUT for now
we will use the matlab_test_setup  scripts.

Running Application Jobs on Grid computer

We have found that it is easier to submit a shell script which calls the executable
instead of submitting the executable itself.  This simplifies the configuration of
each job with easy addition of environment variables, etc.

Assuming you put the program in ~/gridtest, a shell script to
be submitted to Condor (Lineamp_Grid_Job.sh) is prepared.

I have already created a Condor submit file (lineamp_condor.sub)
to be invoked by condor_submit

The steps required are
1) create a 'latest' sub-directory in your home directory on ldas-grid
2) Modify lineamp_condor.sub to use your home directory on ldas-grid
3) transfer these two files to it
4) Grid SSH into ldas-grid
ssh ldas-grid.ligo-wa.caltech.edu
5) change to directory latest
cd latest
6) Submit to condor
condor_submit lineamp_condor.sub