ls -a to see .bash_profile fileemacs -nw .bash_profile to edit or createalias [alias-name]="[command-to-run]"
Example: alias jhpce="ssh -X amejia@jhpce01.jhsph.edu"
Ctrl-x Ctrl-c then y to exit and saveSet up an alias to get on the jhpce cluster.
emacs -nw myscript.R and entering a couple lines of R code.emacs -nw shellscriptname.sh. Write shell script (example below), then exit and save by typing Ctrl-X Ctrl-C then yqsub shellscriptname.sh#!/bin/sh
#$ -cwd
Rscript Rfilename.R
Submit an R job that computes 2+2.
Array jobs are useful if you want to run the same job in parallel over different subjects, scenarios, simulation iterations, etc. The basic idea is that each array job will have a task ID, and in your R code you will grab this task ID.
t option. For example, if you want your jobs to be indexed 1-10, you’d add #$ -t 1-10k <- as.numeric(Sys.getenv("SGE_TASK_ID")) in your R code to grab the task ID, and use k to determine which subjects, scenarios, etc. to run.Run the following R code in parallel:
subjects <- c("Marie","John","Shelly","Chen")
k <- as.numeric(Sys.getenv("SGE_TASK_ID"))
subject.k <- subjects[k]
print(subject.k)
Sequential jobs are useful if you want to run a series of jobs, where each job should be completed before the next begins.
qsub job1.shqstat and copy the task id, for example 1234.qsub -hold_jid 1234 job2.shRun the following two R jobs sequentially:
a <- "hello world"
save(a, file="~/a.Rdata")
load(file="~/a.Rdata")
print(a)
which matlab to see if the MATLAB module is loaded.module load matlabqrshmatlab -nodisplay to run MATLAB on the command line, or just matlab to open the GUI.exitOpen MATLAB and compute 2+2.
If you want to run a MATLAB job titled myscript.m, create the following shell script, then submit as usual with qsub:
#$ -m e -M amejia@jhsph.edu
#$ -cwd
matlab -r "myscript; exit"
A cautionary not: MATLAB may run code in a parallel environment without being explicitly told to do so, taking up resources on multiple cores!
* If your job is relatively big, you should add a line #$ -pe local [num-cores] to the shell script, where num-cores is the number of cores you think MATLAB might use. * To estimate the number of cores MATLAB used on a previous job, find the email sent to you by root@local. This email should include CPU time and Wallclock time. * If the CPU time is greater than the Wallclock time, this means that multiple cores were used. The number of cores used \(latex \approx\) CPU Time/Wallclock Time.