R

Install Spack

$ cd
$ git clone https://github.com/sjtuhpcc/spack.git
$ cd spack
$ ./bootstrap.sh user --install

Add the following settings to ~/.bashrc or ~/.bash_profile.

# Spack package management
if [ -d "$HOME/spack" ]; then
    export SPACK_ROOT=$HOME/spack
    source $SPACK_ROOT/share/spack/setup-env.sh
fi  

Build R via Spack

$ spack install r+external-lapack %gcc@5.4.0 ^openblas threads=openmp

Load R and install R modules

Load R.

$ source <( spack module loads --dependencies r+external-lapack %gcc@5.4.0 ^openblas threads=openmp )
$ which R

Delete existing R libs.

$ rm -rf ~/.R* ~/Rlib*

Install R modules.

$ source <( spack module loads --dependencies r %gcc@5.4.0 )
$ R --version
R version 3.5.0 (2018-04-23) -- "Joy in Playing"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
> source("https://bioconductor.org/biocLite.R")                    
...  
Bioconductor version 3.7 (BiocInstaller 1.30.0), ?biocLite for help
> biocLite()                  
...

A SLURM job sample for R

Usage: sbatch job.slurm

#!/bin/bash

#SBATCH -J R
#SBATCH -p cpu
#SBATCH --mail-type=end
#SBATCH --mail-user=YOU@EMAIL.COM
#SBATCH -o %j.out
#SBATCH -e %j.err
#SBATCH -n 1
#SBATCH --exclusive

source /usr/share/Modules/init/bash

# Spack
if [ -d "$HOME/spack" ]; then
        export SPACK_ROOT=$HOME/spack
        source $SPACK_ROOT/share/spack/setup-env.sh
fi

source <( spack module loads --dependencies r+external-lapack %gcc@5.4.0 ^openblas threads=openmp )

R hello.r