---
title: "Introduction to SCC"
author: "School of Social Work"
date: "03/11/2019"
output: html_document
---


<br><br>

**Software to connect to the remote server:**<br>

* *Windows:*  MobaXterm: ( [https://mobaxterm.mobatek.net/](https://mobaxterm.mobatek.net/) )<br>
* *Apple OS X:*  Terminal
* *Linux:*  Terminal


**Software to enable graphics (X-Forwarding):**<br>

* *Windows:*  MobaXterm: ( [https://mobaxterm.mobatek.net/](https://mobaxterm.mobatek.net/) )<br>
* *Apple OS X:*  - xQuartz( [https://www.xquartz.org/](https://www.xquartz.org/) )<br>
*Note:* After xQuartz is installed, please logout of your computer and login back again.
<br><br>

**SFTP Clients for File Transfer:**<br>

* *Windows:* MobaXtern, FileZilla 
* *Apple OS X:* Cyberduck, Fetch
<br><br>
More Information about ssh and sftp clients for connecting to the SCC can be found on ( [RCS Website](http://www.bu.edu/tech/support/research/system-usage/getting-started/get-started-file-transfer/) )

## Connecting to the SCC

Use `scc1`, `scc2`, or `scc4` login node to connect to the *Shared Computing Cluster*: <br>`ssh username@scc1.bu.edu`


An example for user *ktrn*: 
```{bash eval=FALSE}
[local prompt] > ssh    ktrn@scc4.bu.edu  # Windows
[local prompt] > ssh -Y ktrn@scc4.bu.edu  # Mac
[local prompt] > ssh -X ktrn@scc4.bu.edu  # Linux
```

<br><br>
Check if graphics works (X-forwarding is enabled):
```{bash eval=FALSE}
[scc2 ~] > xclock &
```
You should see a pop-up window with clock in it:<br><br>
```{r, out.width="250px", echo=FALSE}
knitr::include_graphics("../images/xclock.png")
```

<br>
If you do not see clock:<br>
*Windows:* make sure Xserver icon on the op-left side of MobaXterm is green.<br>
*Apple OS X:* make sure you logout of your computer after you installed xQuartz, start xQuartx (you should see xQuartz icon on the bottom of your screen) and that you use `-Y` with your ssh command when you login to the SCC
<br><br>

## File Transfer

There are a number of ways you can transfer files to the SCC from a local computer and back. See directions on our website:<br>
[http://www.bu.edu/tech/support/research/system-usage/getting-started/get-started-file-transfer/](http://www.bu.edu/tech/support/research/system-usage/getting-started/get-started-file-transfer/)
<br><br>
Example of scp command (from a local terminal window). Transfer a file to the home directory on the SCC:
```{bash eval=FALSE}
[local prompt] date > date.txt
[local prompt] scp date.txt username@scc2.bu.edu:.
```
<br>


To download a file from a website, use wget command, i.e.:
```{bash eval=FALSE}
[scc2 ~] wget http://rcs.bu.edu/classes/cbs/helloWorld.R
```
<br>



## Home Directories
On the SCC, each user has a 10 GB home directory which is backed up nightly and protected by Snapshots. Additional quota is not available for home directories. To check the home directory quota, use the quota -s command:
```{bash eval=FALSE}
[scc2 ~] quota -s
```
```{bash eval=TRUE, echo=FALSE, comment=""}
quota -s ktrn
```
Home directories are private to the user. The permissions are set that only the owner has permissions to view, modify or execute the files in the home directory. Home directories should NOT be used for the production work. Once quota is reached, your jobs will fail and many programs will not run (or even start).
<br><br>

## Project Directories

You can view wich projects you belong to executing command *groups*. You might belong to one or more SCC projects. The first project on your list is your default project.


```{bash eval=FALSE}
[scc2 ~] groups
rcs-user
```

Each SCC project has its *project space*. Use *pquota* command to see the directories associated with the project and their sizes:
```{bash, comment=""}
pquota rcs-user
```


A portion of the Project Disk Space on the SCC is dbGaP compliant for data that requires it (primarily BUMC genomics projects) and can be accessed from all SCC compute nodes but only the scc4.bu.edu login node. The path for these projects start with */restricted*, i.e `/restricted/project/rcs-user`

*projectnb* partition is used for this project:

```{bash, comment="", eval=FALSE}
cd /projectnb/rcs-user    # change directory to the project directory
ls -l                     # check the content of the directory
```

Each memomber of cbs project has his/her own subdirectory in this folder
```{bash, comment="", eval=FALSE}
mkdir katia     # create subdirectory with a name katia
ls -l              # check what folders are there

cd katia        # change current directory to be the one you just created
pwd                # view the current directory path
```
<br><br>

## SCC Text editors
SCC has all standard Linux editors like *emacs*, *vi* (*vim*, *gvim*) and *nano*. There is also a note-pad like editor *gedit*
<br><br>

## Software on the SCC
The module package is available on the Shared Computing Cluster, allowing users to access non-standard tools or alternate versions of standard packages. This is also an alternative way to configure your environment as required by certain packages. You can read more about *module* command usage on our webpage:<br> 
[http://www.bu.edu/tech/support/research/software-and-programming/software-and-applications/modules/](http://www.bu.edu/tech/support/research/software-and-programming/software-and-applications/modules/)

To view all available modules:
```{bash eval=FALSE}
module avail
```

To list all available version for a particular package:
```{bash comment="", eval=FALSE}
module avail R
```
<br><br>

```{bash comment="", eval=FALSE}
module avail sas
```
<br><br>

## Work with R

To select a particular version of R:

<pre>
module load R/3.2.3
</pre>

To view which modules are loaded:
```{bash comment="", eval=FALSE}
module list

```
To start Rstudio:
```{bash eval=FALSE}
rstudio &
```


## SCC Batch System
<br>

### Running an interactive job
Login nodes are most suitable for code development and debugging. Non-interactive batch processing is an environment for running jobs that take more than a few minutes and which require no interactions between the user and the application software. There are occasions where longer duration jobs that require user interaction may arise or additional resources (like high memory nodes) are needed. 
Use *qrsh* command with appropriate options to start an interactive job.

An example workflow for the interactive job is below:
```{bash eval=FALSE}
qrsh -P rcs-user


cd /projectnb/rcs-user/katia    # change working directory
module load R/3.2.3          # load R module
rstudio &
```

Once you finish with running your interactive job, execute *exit* or *logout* to free up the resources.
<br><br>

### Running a batch job
In any text editor create a file which will submit your code to the batch system. A simple example of a file that submits an R job may look like this:

<pre>
#!/bin/bash -l

#Specify project
#$ -P rcs-user

#Request appropriate time ( default 12 hours )
#$ -l h_rt=12:00:00

#Send an email when the job is done or aborted (by default no email is sent)
#$ -m e

# Give job a name
#$ -N hello

#$ Join output and error streams into one file
#$ -j y


#load appropriate envornment
module load R/3.2.3


#execute the program
Rscript myscript.R
</pre>
<br><br>

## SAS

```{bash comment=""}
module avail sas
```


To submit a SAS job your submition script might look like:
<pre>
#!/bin/bash -l

#Specify project
#$ -P rcs-user

#Request appropriate time (default 12 hours; gpu jobs time limit - 2 days (48 hours), cpu jobs - 30 days (720 hours) )
#$ -l h_rt=12:00:00

#Send an email when the job is done or aborted (by default no email is sent)
#$ -m e

# Give job a name
#$ -N hello

#$ Join output and error streams into one file
#$ -j y



#load appropriate envornment
module load sas/9.4

#execute the program
sas -noterminal helloWorld.sas
</pre>
<br><br>



## Stata

```{bash comment=""}
module avail stata
```


To run Stata interactively load appropriate Stata module and execute `xstata` at the prompt.




To submit a Stata job, your submition script might look like:
<pre>
#!/bin/bash -l

#Specify project
#$ -P rcs-user

#Request appropriate time (default 12 hours; gpu jobs time limit - 2 days (48 hours), cpu jobs - 30 days (720 hours) )
#$ -l h_rt=12:00:00

#Send an email when the job is done or aborted (by default no email is sent)
#$ -m e

# Give job a name
#$ -N StataScript

#$ Join output and error streams into one file
#$ -j y

# Request 4 cores for parallel Stata executiong



#load appropriate envornment
module load stata-mp/15

#execute the program
stata-mp -b do helloWorld.do
</pre>
<br><br>



## Track SCC job
```{bash comment="", eval=FALSE}
qstat -u username
```

You can read more about checking the status of submitted jobs on our website:<br>
[http://www.bu.edu/tech/support/research/system-usage/running-jobs/tracking-jobs/](http://www.bu.edu/tech/support/research/system-usage/running-jobs/tracking-jobs/)
<br><br>



## Getting help
Email us at help@scc.bu.edu. <br>
Please include the following information in your email: Your user name, your working directory and detailed description of the problem: what script you are running, what error you are getting etc. There is no need to attach your script to your email.
<br><br>

## Additional Resources
Our website: [http://www.bu.edu/tech/support/research/](http://www.bu.edu/tech/support/research/)<br>
Getting started: [http://www.bu.edu/tech/support/research/system-usage/getting-started/](http://www.bu.edu/tech/support/research/system-usage/getting-started/)<br>
SCC Cheat Sheet (pdf): [http://scv.bu.edu/documents/SCC_CheatSheet.pdf](http://scv.bu.edu/documents/SCC_CheatSheet.pdf)<br>
Running jobs: [http://www.bu.edu/tech/support/research/system-usage/running-jobs/](http://www.bu.edu/tech/support/research/system-usage/running-jobs/)<br><br>


