How to launch research software applications (Matlab, Stata, R, Mathematica) on Andes and Polaris high-performance linux machines (HPC's)

Launching software from Andes, Polaris:  

See https://services.dartmouth.edu/TDClient/KB/ArticleDet?ID=64641  for more details on running research software on our Linux HPC's such as Andes and Polaris. 

Begin by ensuring that you have FastX installed on your Mac/Win system: https://services.dartmouth.edu/TDClient/KB/ArticleDet?ID=81595
and that you are able to open an Xterm session on andes.dartmouth.edu or polaris.dartmouth.edu.  These can be done using an ssh connection with the -Y option, for example ssh -Y netid@polaris.dartmouth.edu 

At the command prompt ($).  Then, type the following command below to load the software you'd like to use (matlab, stata, R, etc) at the "$" prompt in your terminal window: 

       $ module load matlab

And then the software name to launch the interactive software in a new terminal X Window. 

       $ matlab ​​​​ 

Some software packages have more than one version installed.  Stata is one example.  Type module avail stata to see available versions

       $ module avail stata

       $ module load stata/15 ​​​​ 

       $ xstata 

       $ spss

       $ sas

Note: to use the "Discovery" HPC, there are extra steps involved to create a "batch submission" script.  See https://services.dartmouth.edu/TDClient/1806/Portal/KB/?CategoryID=21754 and https://services.dartmouth.edu/TDClient/1806/Portal/KB/ArticleDet?ID=132372)

Your DartFS file storage system is available at this same command prompt.  You can drag and drop files in, or use a Unix cp or mv command.  Type  ls to view files:
       $    ls

       mydata_on_dartfs_netid.csv
       myRscript.R
       myMatlabMfiles.M  

You can run R script files using the Rscript command. R script files can be developed using RStudio on a Mac or PC. 
       $    Rscript myRscript.R

FastXweb, XQuartz, Terminal 

RStudio Andes8 (not Polaris or Discovery)

Method 1: Launch an Andes8 connection in the FastxBrowser/web client,see https://services.dartmouth.edu/TDClient/1806/Portal/KB/ArticleDet?ID=81595

[GaughanS@andes8 ~]$ rstudio --no-sandbox

Uploaded Image (Thumbnail)

Method 2: Mac's terminal application with XQuartz
(base) f002d69@RJXCK02LJ0 ~ % ssh -Y andes8.dartmouth.edu
[GaughanS@andes8 ~]$ rstudio --no-sandbox

there may be some error messages in the terminal, but in a moment RStudio will open in an X window (xquartz or FastX/FastXweb)

MATLAB .m files

can be run using MATLAB without the graphical interface (the MATLAB GUI does not run on Discovery with srun)

Matlab can be run without the graphical interface
       $    matlab -nodisplay -nojvm -nosplash -nodesktop 

                      <  M A T L A B >  

       >>>  

 

Matlab scripts can be run at the prompt without the graphical interface

          Author a script on your desktop installation of Matlab, and save it to DartFS.  Samlpe script titled "testmfile.m", which contains the following code: 

                       

This script can then be run by logging with your DartFS account and navigating to the directory 
         $ module load matlab       

         $ matlab -nodisplay -nodesktop -nosplash -nojvm -r "run testmfile.m"

Scripts can be written to accept parameters and write to files  

                        
         $  matlab -nodisplay -nodesktop -nosplash -nojvm -r "matlabfunctionwritefile(25)" 

Scripts can also be written to export data out to your DartFS file storage: 

Example:  a script called "script.m" containing the following:
A = magic(5);
outputfile1 = 'output1.xlsx';
writematrix(A,outputfile1,'Sheet',1,'Range','E1:I5');
outputfile2 = '//dartfs-hpc/rc/home/2/username2/output2.xlsx';
writematrix(A,outputfile2,'Sheet',1,'Range','E1:I5');

Then run on Polaris at the command line like this:
[usrname@polaris ~]$ module load matlab
[usrname@polaris ~]$ matlab -nodisplay -nodesktop -nosplash -nojvm -r "run script.m"

This will output files "output1.xlsx" and "output2.xlsx" to the user's home directory.  Note the use of the full file path in the second file - this method could be used to write to subfolders on your DartFS file system.

Syntax examples for submitting a regular job: 
$ matlab -nodisplay -nodesktop -nosplash -nojvm -r "run jobname.m"

Syntax example with Try-Catch-End statement:
$ matlab -nodisplay -nodesktop -nosplash -nojvm -r "try; run('YourScriptName.m'); catch; end; exit";

>> exit or >> ctrl C

Mathematica

[usrname@polaris ~]$ module load mathematica
[usrname@polaris ~]$ module avail mathematica

SSH Terminal and X Window Clients

     Windows / Mac / Linux "FastX" https://services.dartmouth.edu/TDClient/KB/ArticleDet?ID=81595

     Windows:  Gitbash  https://git-scm.com/downloads 

     Mac:  use built-in 'Terminal' Unix Shell 

     See this link for more help with the Andes Polaris Linux HPC machines:  https://services.dartmouth.edu/TDClient/KB/ArticleDet?ID=64641