R
R scripts are available for
Click here to download sample R scripts, also available on chimera at
/share/apps/training/sample_scripts/R
hello_world.r
write('Hello, World!',stdout())
write('from',stdout())
write(Sys.info()[["nodename"]],stdout())
Script to submit a job
#!/bin/bash
#$-S /bin/bash
#
#$ -l h_rt=01:00:00
#$-q scavenger.smp
#$ -N r_Hello_World
#$ -P SCAVENGER
#$ -pe smp 1
#$ -cwd
## Diagnostic/Logging Information
echo "using $NSLOTS CPUs"
echo `date`# load the R module; change the version if needed
module load R/3.2.3# run R
Rscript --vanilla hello_world.r#Diagnostic/Logging Information
echo "Finish Run"
echo "end time is `date`"
R in parallel
hello_parallel.r
library(pbdMPI, quiet = TRUE)
init()
.comm.size <- comm.size()
.comm.rank <- comm.rank()write(paste('Hello, World! from process ', .comm.rank, 'of', .comm.size) ,stdout())
### Finish
finalize()
Script to submit a parallel job
#!/bin/bash
#$-S /bin/bash
#
#$ -l h_rt=01:00:00
#$-q scavenger.smp
#$ -N r_parallel
#$ -P SCAVENGER
#$ -pe smp 4
#$ -cwd
# Diagnostic/Logging Information
echo "using $NSLOTS CPUs"
echo `date`# load the R module; change the version if needed
module load R/3.2.3
module load openmpi/1.8.3# run R under mpi
mpiexec Rscript --vanilla hello_parallel.r#Diagnostic/Logging Information
echo "Finish Run"
echo "end time is `date`"
On GHPCC
Script to submit a job
#!/bin/bash
# Usage:
#BSUB -J "Sample-R"
#BSUB -R rusage[mem=4096]
#BSUB -q short
#BSUB -W 4:00#BSUB -e samp_r.err
module load R/3.2.2
Rscript --vanilla hello_world.r
#Diagnostic/Logging Information
echo "Finish Run"
echo "end time is `date`"
Script to submit a parallel job
#!/bin/bash
# Usage:
#BSUB -J "R-parallel"
#BSUB -R rusage[mem=4096]
#BSUB -q short
#BSUB -W 4:00#BSUB -e samp_r.err
module load R/3.2.2
module load openmpi/1.6.5Rscript --vanilla hello_parallel.r
#Diagnostic/Logging Information
echo "Finish Run"
echo "end time is `date`"
Healey Library, Lower Level
UMass Boston
100 Morrissey Blvd.
Boston, MA 02125
Book a Consultation
617.287.5399
It-rc@umb.edu