<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://oldwiki.scinet.utoronto.ca/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Leon</id>
	<title>oldwiki.scinet.utoronto.ca - User contributions [en-gb]</title>
	<link rel="self" type="application/atom+xml" href="https://oldwiki.scinet.utoronto.ca/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Leon"/>
	<link rel="alternate" type="text/html" href="https://oldwiki.scinet.utoronto.ca/index.php/Special:Contributions/Leon"/>
	<updated>2026-06-06T11:07:54Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.12</generator>
	<entry>
		<id>https://oldwiki.scinet.utoronto.ca/index.php?title=R_Statistical_Package&amp;diff=8167</id>
		<title>R Statistical Package</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.scinet.utoronto.ca/index.php?title=R_Statistical_Package&amp;diff=8167"/>
		<updated>2015-12-18T23:24:11Z</updated>

		<summary type="html">&lt;p&gt;Leon: /* Running R on the GPC */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Running R on the GPC==&lt;br /&gt;
[http://www.r-project.org/ R] is powerful statistical and plotting software available on the [[GPC_Quickstart|GPC]] in the [[Software_and_Libraries|module]] R.  In fact, there are currently six R modules installed, 2.13.1, 2.14.1, 2.15.1, 3.0.0, 3.0.1 and 3.1.1.  While 2.15.1 is the default, we do recommend making the transition to a newer version, which you load by specifying the version number explicitly:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ module load intel R/3.0.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
(The intel module is a prerequesite for the R module).  If you will be using Rmpi, you will need to load the openmpi module as well.&lt;br /&gt;
&lt;br /&gt;
Many optional packages are available for R which add functionality for specific domains; they are available through the [http://cran.r-project.org/mirrors.html Comprehensive R Archive Network (CRAN)]. &lt;br /&gt;
&lt;br /&gt;
R provides an easy way for users to install the libraries they need in their home directories rather than having them installed system-wide; there are so many  potential optional  packages for R people could potentially want, we recommend users who want additional packages to proceed this way.  This is almost certainly the easiest way to deal with the wide range of packages, ensure they're up to date, and ensure that users package choices don't conflict. &lt;br /&gt;
&lt;br /&gt;
In general, you can install those that you need yourself in your home directory; eg, &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ R &lt;br /&gt;
&amp;gt; install.packages(&amp;quot;package-name&amp;quot;, dependencies = TRUE)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will download and compile the source for the packages you need in your home  directory under &amp;lt;tt&amp;gt;${HOME}/R/x86_64-unknown-linux-gnu-library/2.11/&amp;lt;/tt&amp;gt; (you can specify another directory with a lib= option.)  Then take a look at  help(&amp;quot;.libPaths&amp;quot;) to make sure that R knows where to look for  the packages you've compiled. Note that you must install packages with logged into a development node as write access to the library folder is not available to a standard node on the cluster. &lt;br /&gt;
&lt;br /&gt;
Note that during the installation you may get warnings that the packages cannot be installed in e.g. /scinet/gpc/Applications/R/3.0.1/lib64/R/bin/. But after those messages, R should have succeeded in installing the package into your home directory.&lt;br /&gt;
&lt;br /&gt;
=== Running serial R jobs ===&lt;br /&gt;
&lt;br /&gt;
As with all serial jobs, if your R computation do not use multiple cores, you should bundle them up so the 8 cores of a nodes are all performing work.  Examples of this can be found on the [[User_Serial]] page.&lt;br /&gt;
&lt;br /&gt;
== Saving images from R in compute jobs ==&lt;br /&gt;
&lt;br /&gt;
To make use of the graphics capability of R, R insists on having an X server running, even if you're just writing to a file.  There is no X server on the compute nodes, and you'd get a message like&lt;br /&gt;
&lt;br /&gt;
 unable to open connection to X11 display ''&lt;br /&gt;
&lt;br /&gt;
To get around this issue, you can run a 'virtual' X server on the compute nodes by adding the following commands at the start of your job script:&lt;br /&gt;
&lt;br /&gt;
 # Make virtual X server command called Xvfb available:&lt;br /&gt;
 module load Xlibraries&lt;br /&gt;
  &lt;br /&gt;
 # Select a unique display number:&lt;br /&gt;
 let DISPLAYNUM=$UID%65274&lt;br /&gt;
 export DISPLAY=&amp;quot;:$DISPLAYNUM&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
 # Start the virtual X server&lt;br /&gt;
 Xvfb $DISPLAY -fp $SCINET_FONTPATH -ac 2&amp;gt;/dev/null &amp;amp;&lt;br /&gt;
&lt;br /&gt;
After this, run R or Rscript as usual. The virtual X server will be running in the background and will get killed which your job is done. Alternatively, you may want to kill it explicitly at the end of you job script  using &lt;br /&gt;
&lt;br /&gt;
 # Kill any remaining Xvfb server&lt;br /&gt;
 pkill -u $UID Xvfb&lt;br /&gt;
&lt;br /&gt;
== Rmpi (R with MPI) ==&lt;br /&gt;
&lt;br /&gt;
All the newer R installations on the GPC have Rmpi installed by default using OpenMPI.  Be sure to load the OpenMPI module if you wish to use Rmpi.&lt;br /&gt;
&lt;br /&gt;
=== Installing Rmpi, version 2.13.1 ===&lt;br /&gt;
&lt;br /&gt;
Version 2.13.1 does not have the Rmpi library as a standard package, which means you have to install it yourself if you are using that version.  The same is true if you want to use IntelMPI instead of OpenMPI.  &lt;br /&gt;
&lt;br /&gt;
Installing the Rmpi package can be a bit challenging, since some additional parameters need to be given to the installation, which contain the path to various header files and libraries. These paths differ depending on what [[GPC_MPI_Versions|MPI version]] you are using.   &lt;br /&gt;
&lt;br /&gt;
The various MPI versions on the GPC are loaded with the [[Software_and_Libraries|module]] command. So the first thing to do is to decide what mpi version to use (openmpi or intelmpi), and to type the corresponding &amp;quot;module load&amp;quot; command on the command-line (as well as in your jobs scripts).&lt;br /&gt;
&lt;br /&gt;
Because the MPI modules define all the paths in environment variables, the following line seem to work for installations of all openmpi versions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; install.packages(&amp;quot;Rmpi&amp;quot;,&lt;br /&gt;
                   configure.args =&lt;br /&gt;
                   c(paste(&amp;quot;--with-Rmpi-include=&amp;quot;,Sys.getenv(&amp;quot;SCINET_MPI_INC&amp;quot;),sep=&amp;quot;&amp;quot;),&lt;br /&gt;
                     paste(&amp;quot;--with-Rmpi-libpath=&amp;quot;,Sys.getenv(&amp;quot;SCINET_MPI_LIB&amp;quot;),sep=&amp;quot;&amp;quot;),&lt;br /&gt;
                     &amp;quot;--with-Rmpi-type=OPENMPI&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For intelmpi, you only need to change &amp;lt;tt&amp;gt;OPENMPI&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;MPICH2&amp;lt;/tt&amp;gt; in the last line.&lt;br /&gt;
&lt;br /&gt;
=== Running Rmpi ===&lt;br /&gt;
&lt;br /&gt;
To start using R with Rmpi, make sure you have all require modules loaded (e.g. &amp;lt;tt&amp;gt;module load intel openmpi R/2.14.1&amp;lt;/tt&amp;gt;), then launch it with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpirun -np 1 R --no-save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
which starts one master mpi process, but starts up the infrastructure to be able to spawn additional processes.&lt;br /&gt;
&lt;br /&gt;
== Creating an R cluster ==&lt;br /&gt;
&lt;br /&gt;
The 'parallel' package allows you to use R to launch individual serial subjobs across multiple nodes.  This section describes how this is accomplished.&lt;br /&gt;
&lt;br /&gt;
=== Creating your Rscript wrapper ===&lt;br /&gt;
&lt;br /&gt;
The first thing to do is create a wrapper for Rscript.  This needs to be done because the R module needs to be loaded on all nodes, but the submission script only loads modules on the head node of the job.  The wrapper script, let's call it MyRscript.sh, is short:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
module load intel/13.1.1 R/3.0.1&lt;br /&gt;
${SCINET_R_BIN}/Rscript --no-restore &amp;quot;$@&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The &amp;quot;--no-restore&amp;quot; flag prevents Rscript from loading your &amp;quot;workspace image&amp;quot;, if you have one saved.  Loading the image causes problems for the cluster.&lt;br /&gt;
&lt;br /&gt;
Once you've created your wrapper, make it executable:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ chmod u+x MyRscript.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Your wrapper is now ready to be used.&lt;br /&gt;
&lt;br /&gt;
=== The cluster R code ===&lt;br /&gt;
The R code which we will run consists of two parts, the code which launches the cluster, and does pre- and post-analysis, and the code which is run on the individual cluster &amp;quot;nodes&amp;quot;.  Here is some code which demonstrates this functionality.  Let's call it MyClusterCode.R.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
######################################################&lt;br /&gt;
#&lt;br /&gt;
#  worker code&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
# first define the function which will be run on all the cluster nodes.  This is just a test function.  &lt;br /&gt;
# Put your real worker code here.&lt;br /&gt;
testfunc &amp;lt;- function(a) {&lt;br /&gt;
&lt;br /&gt;
  # this part is just to waste time&lt;br /&gt;
  b &amp;lt;- 0&lt;br /&gt;
  for (i in 1:10000) {&lt;br /&gt;
      b &amp;lt;- b + 1&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  s &amp;lt;- Sys.info()['nodename']&lt;br /&gt;
  return(paste0(s, &amp;quot; &amp;quot;, a[1], &amp;quot; &amp;quot;, a[2]))&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
######################################################&lt;br /&gt;
#&lt;br /&gt;
#  head node code&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
# Create a bunch of index pairs to feed to the worker function.  These could be parameters,&lt;br /&gt;
# or whatever your code needs to vary across jobs.  Note that the worker function only &lt;br /&gt;
# takes a single argument; each entry in the list must contain all the information &lt;br /&gt;
# that the function needs to run.  In this example, each entry contains a list which&lt;br /&gt;
# contains two pieces of information, a pair of indices.&lt;br /&gt;
indexlist &amp;lt;- list()&lt;br /&gt;
index &amp;lt;- 1&lt;br /&gt;
for (i in 1:10) {&lt;br /&gt;
  for (j in 1:10) {&lt;br /&gt;
     indexlist[index] &amp;lt;- list(c(i,j))&lt;br /&gt;
     index &amp;lt;- index +1&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
# Now set up the cluster.&lt;br /&gt;
&lt;br /&gt;
# First load the parallel library.&lt;br /&gt;
library(parallel)&lt;br /&gt;
&lt;br /&gt;
# Next find all the nodes which the scheduler has given to us.&lt;br /&gt;
# These are listed in the file which is indicated by the PBS_NODEFILE&lt;br /&gt;
# environment variable.&lt;br /&gt;
nodefile &amp;lt;- Sys.getenv(&amp;quot;PBS_NODEFILE&amp;quot;)&lt;br /&gt;
hostnames &amp;lt;- readLines(nodefile)&lt;br /&gt;
&lt;br /&gt;
# Now launch the cluster, using the list of nodes and our Rscript&lt;br /&gt;
# wrapper.&lt;br /&gt;
cl &amp;lt;- makePSOCKcluster(names = hostnames, rscript = &amp;quot;/path/to/your/MyRscript.sh&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Now run the worker code, using the parameter list we created above.&lt;br /&gt;
result &amp;lt;- clusterApplyLB(cl, indexlist, testfunc)&lt;br /&gt;
&lt;br /&gt;
# The results of all the jobs will now be put in the 'result' variable,&lt;br /&gt;
# in the order they were specified in the 'indexlist' variable.&lt;br /&gt;
&lt;br /&gt;
# Don't forget to stop the cluster when you're finished.&lt;br /&gt;
stopCluster(cl)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can, of course, add any post-processing code you need to the above code.&lt;br /&gt;
&lt;br /&gt;
=== Submitting an R cluster job ===&lt;br /&gt;
You are now ready to submit your job to the GPC queue.  The submission script is like most others:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#PBS -l nodes=3:ppn=8                                                         &lt;br /&gt;
#PBS -l walltime=5:00:00&lt;br /&gt;
#PBS -N MyRCluster&lt;br /&gt;
&lt;br /&gt;
cd $PBS_O_WORKDIR&lt;br /&gt;
module load intel/13.1.1 R/3.0.1&lt;br /&gt;
${SCINET_R_BIN}/Rscript --no-restore MyClusterCode.R&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Be sure to use whatever number of nodes, length of time, etc., is appropriate for your job.&lt;/div&gt;</summary>
		<author><name>Leon</name></author>
	</entry>
	<entry>
		<id>https://oldwiki.scinet.utoronto.ca/index.php?title=HPSS&amp;diff=6454</id>
		<title>HPSS</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.scinet.utoronto.ca/index.php?title=HPSS&amp;diff=6454"/>
		<updated>2013-09-16T20:36:14Z</updated>

		<summary type="html">&lt;p&gt;Leon: First step is to get a HPSS account&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''High Performance Storage System''' =&lt;br /&gt;
&lt;br /&gt;
The High Performance Storage System ([http://www.hpss-collaboration.org/index.shtml HPSS]) is a tape-backed hierarchical storage system that will provide a significant portion of the allocated storage space at SciNet. It is a repository for archiving data that is not being actively used. Data can be returned to the active GPFS filesystem when it is needed. &lt;br /&gt;
&lt;br /&gt;
Because this system is intended for large data storage, it is accessible only to groups who have been awarded storage space at SciNet beyond 5TB in the yearly RAC resource allocation round.&lt;br /&gt;
&lt;br /&gt;
Access and transfer of data into and out of HPSS is done under the control of the user, whose interaction is expected to be scripted and submitted as a batch job, using one or more of the following utilities:&lt;br /&gt;
* [http://www.mgleicher.us/GEL/hsi HSI] is a client with an ftp-like functionality which can be used to archive and retrieve large files. It is also useful for browsing the contents of HPSS.&lt;br /&gt;
* [http://www.mgleicher.us/GEL/htar HTAR] is a utility that creates tar formatted archives directly into HPSS. It also creates a separate index file (.idx) that can be accessed and browsed quickly.&lt;br /&gt;
* [https://support.scinet.utoronto.ca/wiki/index.php/ISH ISH] is a TUI utility that can perform an inventory of the files and directories in your tarballs.&lt;br /&gt;
&lt;br /&gt;
We're currently running HPSS v 7.3.3 patch 6, and HSI/HTAR version 4.0.1.2&lt;br /&gt;
&lt;br /&gt;
== '''Why should I use and trust HPSS?''' ==&lt;br /&gt;
* 10+ years history, used by about 40 facilities in the [http://www.top500.org “Top 500”] HPC list&lt;br /&gt;
* very reliable, data redundancy and data insurance built-in.&lt;br /&gt;
* highly scalable, reasonable performance at SciNet - Ingest: ~24 TB/day, Recall: ~12 TB/day (aggregated)&lt;br /&gt;
* HSI/HTAR clients also very reliable and used on several HPSS sites. ISH was written at SciNet.&lt;br /&gt;
* [[Media:HPSS_rationale_SNUG.pdf|HPSS fits well with the Storage Capacity Expansion Plan at SciNet]] (pdf presentation)&lt;br /&gt;
&lt;br /&gt;
== '''Guidelines''' ==&lt;br /&gt;
* Expanded storage capacity is provided on tape -- a media that is not suited for storing small files. Files smaller than ~200MB should be grouped into tarballs with tar or htar.&lt;br /&gt;
* Optimal performance for aggregated transfers and allocation on tapes is obtained with tarballs of size around 100GB.&lt;br /&gt;
* We strongly urge that you use the sample scripts we are providing as the basis for your job submissions.&lt;br /&gt;
* Make sure to check the application's exit code and returned logs for errors after any data transfer or tarball creation process&lt;br /&gt;
&lt;br /&gt;
== '''New to the System?'''  ==&lt;br /&gt;
The first step is to email scinet support and request an HPSS account (or else you will get &amp;quot;Error - authentication/initialization failed&amp;quot; and 71 exit codes). &lt;br /&gt;
&lt;br /&gt;
THIS set of instructions on the wiki is the best and most compressed &amp;quot;manual&amp;quot; we have. It may seem a bit overwhelming at first, because of all the job script templates we make available below (they are here so you don't have to think &lt;br /&gt;
too much, just copy and paste), but if you approach the index at the top as a &amp;quot;case switch&amp;quot; mechanism for what you intend to do, everything falls in place.&lt;br /&gt;
&lt;br /&gt;
Try this sequence:&lt;br /&gt;
&lt;br /&gt;
1) [https://support.scinet.utoronto.ca/wiki/index.php/HPSS#Deleting_with_an_interactive_HSI_session take a look around HPSS using an interactive HSI session]&lt;br /&gt;
&lt;br /&gt;
(most linux shell commands have an equivalent in HPSS)&lt;br /&gt;
&lt;br /&gt;
2) [https://support.scinet.utoronto.ca/wiki/index.php/HPSS#Sample_tarball_create archive a small test directory using HTAR]&lt;br /&gt;
&lt;br /&gt;
2a) use step 1) to see what happened&lt;br /&gt;
&lt;br /&gt;
3) [https://support.scinet.utoronto.ca/wiki/index.php/HPSS#Sample_data_offload archive a file using hsi]&lt;br /&gt;
&lt;br /&gt;
3a) use step 1) to see what happened&lt;br /&gt;
&lt;br /&gt;
4) [https://support.scinet.utoronto.ca/wiki/index.php/HPSS#Sample_transferring_directories archive a small test directory using HSI]&lt;br /&gt;
&lt;br /&gt;
4a) use step 1) to see what happened&lt;br /&gt;
&lt;br /&gt;
5) now try the other cases and so on. In a couple of hours you'll be in pretty good shape.&lt;br /&gt;
&lt;br /&gt;
== '''Bridge between BGQ and HPSS''' ==&lt;br /&gt;
&lt;br /&gt;
BGQ users may transfer material to/from HPSS via the GPC archive queue. On the HPSS gateway node (gpc-archive01), the BGQ GPFS file systems are mounted under a single mounting point /bgq (/bgq/scratch and /bgq/home).&lt;br /&gt;
&lt;br /&gt;
== '''Access Through the Queue System'''  ==&lt;br /&gt;
All access to the archive system is done through the [[Moab|GPC queue system]].&lt;br /&gt;
&lt;br /&gt;
* Job submissions should be done to the 'archive' queue&lt;br /&gt;
* Short jobs are limited to 1H walltime by default. Long jobs (&amp;gt; 1H) are limited to 72H walltime.&lt;br /&gt;
*  Users are limited to only 1 long job and 1 short job at the same time.&lt;br /&gt;
* There can only be 5 long jobs running at any given time overall. Remaining submissions will be placed on hold for the time being. So far we have not seen a need for overall limit on short jobs.&lt;br /&gt;
&lt;br /&gt;
The status of pending jobs can be monitored with showq specifying the archive queue:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
showq -w class=archiveshort&lt;br /&gt;
OR&lt;br /&gt;
showq -w class=archivelong&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Scripted File Transfers ===&lt;br /&gt;
File transfers in and out of the HPSS should be scripted into jobs and submitted to the ''archive'' queue. See generic example below.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#PBS -l walltime=72:00:00&lt;br /&gt;
#PBS -q archive&lt;br /&gt;
#PBS -N htar_create_tarball_in_hpss&lt;br /&gt;
#PBS -j oe&lt;br /&gt;
#PBS -m e&lt;br /&gt;
 &lt;br /&gt;
echo &amp;quot;Creating a htar of finished-job1/ directory tree into HPSS&amp;quot;&lt;br /&gt;
&lt;br /&gt;
trap &amp;quot;echo 'Job script not completed';exit 129&amp;quot; TERM INT&lt;br /&gt;
# Note that your initial directory in HPSS will be $ARCHIVE&lt;br /&gt;
 &lt;br /&gt;
DEST=$ARCHIVE/finished-job1.tar&lt;br /&gt;
 &lt;br /&gt;
# htar WILL overwrite an existing file with the same name so check beforehand.&lt;br /&gt;
&lt;br /&gt;
hsi ls $DEST &amp;amp;&amp;gt; /dev/null&lt;br /&gt;
status=$?&lt;br /&gt;
&lt;br /&gt;
if [ $status == 0 ]; then   &lt;br /&gt;
    echo 'File $DEST already exists. Nothing has been done'&lt;br /&gt;
    exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
cd $SCRATCH/workarea/ &lt;br /&gt;
htar -cpf $ARCHIVE/finished-job1.tar finished-job1/ &lt;br /&gt;
status=$?&lt;br /&gt;
 &lt;br /&gt;
trap - TERM INT&lt;br /&gt;
 &lt;br /&gt;
if [ ! $status == 0 ]; then&lt;br /&gt;
   echo 'HTAR returned non-zero code.'&lt;br /&gt;
   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
   exit $status&lt;br /&gt;
else&lt;br /&gt;
   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
'''Note:''' Always trap the execution of your jobs for abnormal terminations, and be sure to return the exit code&lt;br /&gt;
&lt;br /&gt;
=== Job Dependencies ===&lt;br /&gt;
&lt;br /&gt;
Typically data will be recalled to /scratch when it is needed for analysis. Job dependencies can be constructed so that analysis jobs wait in the queue for data recalls before starting. The qsub flag is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-W depend=afterok:&amp;lt;JOBID&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
where JOBID is the job number of the archive recalling job that must finish successfully before the analysis job can start.&lt;br /&gt;
&lt;br /&gt;
Here is a short cut for generating the dependency (lookup [https://support.scinet.utoronto.ca/wiki/index.php/HPSS#Sample_data_recall data-recall.sh samples]):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gpc04 $ qsub $(qsub data-recall.sh | awk -F '.' '{print &amp;quot;-W depend=afterok:&amp;quot;$1}') job-to-work-on-recalled-data.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''HTAR''' ==&lt;br /&gt;
''' Please aggregate small files (&amp;lt;~200MB) into tarballs or htar files. '''&lt;br /&gt;
&lt;br /&gt;
HTAR is a utility that is used for aggregating a set of files and directories, by using a sophisticated multithreaded buffering scheme to write files directly from GPFS into HPSS, creating an archive file that conforms to the POSIX TAR specification, thereby achieving a high rate of performance. HTAR does not do gzip compression, however it already has a built-in checksum algorithm.&lt;br /&gt;
&lt;br /&gt;
'''Caution'''&lt;br /&gt;
* Files larger than 68 GB cannot be stored in an HTAR archive. If you attempt to start a transfer with any files larger than 68GB the whole HTAR session will fail, and you'll get a notification listing all those files, so that you can transfer them with HSI. unintentionally overwriting the htar destination file in HPSS&lt;br /&gt;
* Files with pathnames too long will be skipped (greater than 100 characters), so as to conform with TAR protocol [[(POSIX 1003.1 USTAR)]] -- Note that the HTAR will erroneously indicate success, however will produce exit code 70. For now, you can check for this type of error by &amp;quot;grep Warning my.output&amp;quot; after the job has completed.&lt;br /&gt;
* Unlike with cput/cget in HSI, &amp;quot;prompt before overwrite&amp;quot;, this is not the default with (h)tar. Be careful not to unintentionally overwrite a previous htar destination file in HPSS. There could be a similar situation when extracting material back into GPFS and overwriting the originals. Be sure to double-check the logic in your scripts.&lt;br /&gt;
* Check the HTAR exit code and log file before removing any files from the GPFS active filesystems.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== HTAR Usage ===&lt;br /&gt;
* To write the ''file1'' and ''file2'' files to a new archive called ''files.tar'' in the default HPSS home directory, and preserve mask attributes (-p), enter:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    htar -cpf files.tar file1 file2&lt;br /&gt;
OR&lt;br /&gt;
    htar -cpf $ARCHIVE/files.tar file1 file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* To write a ''subdirA'' to a new archive called ''subdirA.tar'' in the default HPSS home directory, enter:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    htar -cpf subdirA.tar subdirA&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* To extract all files from the archive file called ''proj1.tar'' in HPSS into the ''project1/src'' directory in GPFS, and use the time of extraction as the modification time, enter:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    htar -xpmf proj1.tar project1/src&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* To display the names of the files in the ''out.tar'' archive file within the HPSS home directory, enter (the out.tar.idx file will be queried):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    htar -vtf out.tar&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more details please check the '''[http://www.mgleicher.us/GEL/htar/ HTAR - Introduction]''' or the '''[http://www.mgleicher.us/GEL/htar/htar_man_page.html HTAR Man Page]''' online&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==== Sample tarball create ====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#PBS -l walltime=72:00:00&lt;br /&gt;
#PBS -q archive&lt;br /&gt;
#PBS -N htar_create_tarball_in_hpss&lt;br /&gt;
#PBS -j oe&lt;br /&gt;
#PBS -m e&lt;br /&gt;
 &lt;br /&gt;
trap &amp;quot;echo 'Job script not completed';exit 129&amp;quot; TERM INT&lt;br /&gt;
# Note that your initial directory in HPSS will be /archive/$(id -gn)/$(whoami)/&lt;br /&gt;
&lt;br /&gt;
DEST=$ARCHIVE/finished-job1.tar&lt;br /&gt;
&lt;br /&gt;
# htar WILL overwrite an existing file with the same name so check beforehand.&lt;br /&gt;
 &lt;br /&gt;
hsi ls $DEST &amp;amp;&amp;gt; /dev/null&lt;br /&gt;
status=$?&lt;br /&gt;
 &lt;br /&gt;
if [ $status == 0 ]; then   &lt;br /&gt;
    echo 'File $DEST already exists. Nothing has been done'&lt;br /&gt;
    exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
cd $SCRATCH/workarea/ &lt;br /&gt;
htar -cpf $DEST finished-job1/ &lt;br /&gt;
status=$?&lt;br /&gt;
 &lt;br /&gt;
trap - TERM INT&lt;br /&gt;
 &lt;br /&gt;
if [ ! $status == 0 ]; then&lt;br /&gt;
   echo 'HTAR returned non-zero code.'&lt;br /&gt;
   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
   exit $status&lt;br /&gt;
else&lt;br /&gt;
   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you attempt to start a transfer with any files larger than 68GB the whole HTAR session will fail, and you'll get a notification listing all those files, so that you can transfer them with HSI. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
----------------------------------------&lt;br /&gt;
INFO: File too large for htar to handle: finished-job1/file1 (86567185745 bytes)&lt;br /&gt;
INFO: File too large for htar to handle: finished-job1/file2 (71857244579 bytes)&lt;br /&gt;
ERROR: 2 oversize member files found - please correct and retry&lt;br /&gt;
ERROR: [FATAL] error(s) generating filename list &lt;br /&gt;
HTAR: HTAR FAILED&lt;br /&gt;
###WARNING  htar returned non-zero exit status&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sample tarball list ====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#PBS -l walltime=72:00:00&lt;br /&gt;
#PBS -q archive&lt;br /&gt;
#PBS -N htar_list_tarball_in_hpss&lt;br /&gt;
#PBS -j oe&lt;br /&gt;
#PBS -m e&lt;br /&gt;
 &lt;br /&gt;
trap &amp;quot;echo 'Job script not completed';exit 129&amp;quot; TERM INT&lt;br /&gt;
# Note that your initial directory in HPSS will be $ARCHIVE&lt;br /&gt;
&lt;br /&gt;
DEST=$ARCHIVE/finished-job1.tar&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
htar -tvf $DEST&lt;br /&gt;
status=$?&lt;br /&gt;
&lt;br /&gt;
trap - TERM INT&lt;br /&gt;
 &lt;br /&gt;
if [ ! $status == 0 ]; then&lt;br /&gt;
   echo 'HTAR returned non-zero code.'&lt;br /&gt;
   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
   exit $status&lt;br /&gt;
else&lt;br /&gt;
   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sample tarball extract ====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#PBS -l walltime=72:00:00&lt;br /&gt;
#PBS -q archive&lt;br /&gt;
#PBS -N htar_extract_tarball_from_hpss&lt;br /&gt;
#PBS -j oe&lt;br /&gt;
#PBS -m e&lt;br /&gt;
 &lt;br /&gt;
trap &amp;quot;echo 'Job script not completed';exit 129&amp;quot; TERM INT&lt;br /&gt;
# Note that your initial directory in HPSS will be $ARCHIVE&lt;br /&gt;
 &lt;br /&gt;
cd $SCRATCH/recalled-from-hpss&lt;br /&gt;
htar -xpmf $ARCHIVE/finished-job1.tar&lt;br /&gt;
status=$?&lt;br /&gt;
 &lt;br /&gt;
trap - TERM INT&lt;br /&gt;
 &lt;br /&gt;
if [ ! $status == 0 ]; then&lt;br /&gt;
   echo 'HTAR returned non-zero code.'&lt;br /&gt;
   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
   exit $status&lt;br /&gt;
else&lt;br /&gt;
   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''HSI''' ==&lt;br /&gt;
&lt;br /&gt;
HSI may be the primary client with which some users will interact with HPSS. It provides an ftp-like interface for archiving and retrieving tarballs or [https://support.scinet.utoronto.ca/wiki/index.php/HPSS#Sample_transferring_directories directory trees]. In addition it provides a number of shell-like commands that are useful for examining and manipulating the contents in HPSS. The most commonly used commands will be:&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
  | cput &lt;br /&gt;
  | Conditionally saves or replaces a HPSSpath file to GPFSpath if the GPFS version is new or has been updated&lt;br /&gt;
 cput [options] GPFSpath [: HPSSpath]&lt;br /&gt;
|-&lt;br /&gt;
  | cget &lt;br /&gt;
  | Conditionally retrieves a copy of a file from HPSS to GPFS only if a GPFS version does not already exist. &lt;br /&gt;
 cget [options] [GPFSpath :] HPSSpath&lt;br /&gt;
|-&lt;br /&gt;
  | cd,mkdir,ls,rm,mv&lt;br /&gt;
  | Operate as one would expect on the contents of HPSS.&lt;br /&gt;
|-&lt;br /&gt;
  | lcd,lls&lt;br /&gt;
  | ''Local'' commands to GPFS&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*There are 3 distinctions about HSI that you should keep in mind, and that can generate a bit of confusion when you're first learning how to use it:&lt;br /&gt;
** HSI doesn't currently support renaming directories paths during transfers on-the-fly, therefore the syntax for cput/cget may not work as one would expect in some scenarios, requiring some workarounds.&lt;br /&gt;
** HSI has an operator &amp;quot;:&amp;quot; which separates the GPFSpath and HPSSpath, and must be surrounded by whitespace (one or more space characters)&lt;br /&gt;
** The order for referring to files in HSI syntax is different from FTP. In HSI the general format is always the same, GPFS first, HPSS second, cput or cget:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
     GPFSfile : HPSSfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For example, when using HSI to store the tarball file from GPFS into HPSS, then recall it to GPFS, the following commands could be used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    cput tarball-in-GPFS : tarball-in-HPSS&lt;br /&gt;
    cget tarball-recalled : tarball-in-HPSS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
unlike with FTP, where the following syntax would be used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    put tarball-in-GPFS tarball-in-HPSS &lt;br /&gt;
    get tarball-in-HPSS tarball-recalled&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Simple commands can be executed on a single line.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    hsi &amp;quot;mkdir LargeFilesDir; cd LargeFilesDir; cput tarball-in-GPFS : tarball-in-HPSS&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* More complex sequences can be performed using an except such as this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    hsi &amp;lt;&amp;lt;EOF&lt;br /&gt;
      mkdir LargeFilesDir&lt;br /&gt;
      cd LargeFilesDir&lt;br /&gt;
      cput tarball-in-GPFS : tarball-in-HPSS&lt;br /&gt;
      lcd $SCRATCH/LargeFilesDir2/&lt;br /&gt;
      cput -Ruph *  &lt;br /&gt;
    end&lt;br /&gt;
    EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The commands below are equivalent, but we recommend that you always use full path, and organize the contents of HPSS, where the default HSI directory placement is $ARCHIVE:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    hsi cput tarball&lt;br /&gt;
    hsi cput tarball : tarball&lt;br /&gt;
    hsi cput $SCRATCH/tarball : $ARCHIVE/tarball&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* There are no known issues renaming files on-the-fly:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    hsi cput $SCRATCH/tarball1 : $ARCHIVE/tarball2&lt;br /&gt;
    hsi cget $SCRATCH/tarball3 : $ARCHIVE/tarball2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* However the syntax forms such as the ones below will fail, since they rename the directory paths.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   hsi cput -Ruph $SCRATCH/LargeFilesDir : $ARCHIVE/LargeFilesDir     (FAILS)&lt;br /&gt;
OR&lt;br /&gt;
   hsi cget -Ruph $SCRATCH/LargeFilesDir : $ARCHIVE/LargeFilesDir2    (FAILS)&lt;br /&gt;
OR&lt;br /&gt;
   hsi cput -Ruph $SCRATCH/LargeFilesDir/* : $ARCHIVE/LargeFilesDir2  (FAILS)&lt;br /&gt;
OR&lt;br /&gt;
   hsi cget -Ruph $SCRATCH/LargeFilesDir : $ARCHIVE/LargeFilesDir     (FAILS)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One workaround is the following 2-steps process, where you do a &amp;quot;lcd &amp;quot; in GPFS first, and recursively transfer the whole directory (-R), keeping the same name. You may use '-u' option to resume a previously disrupted session, and the '-p' to  preserve timestamp, and '-h' to keep the links.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    hsi &amp;lt;&amp;lt;EOF&lt;br /&gt;
      lcd $SCRATCH&lt;br /&gt;
      cget -Ruph LargeFilesDir&lt;br /&gt;
    end&lt;br /&gt;
    EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another workaround is do a &amp;quot;lcd&amp;quot; into the GPFSpath first and a &amp;quot;cd&amp;quot; in the HPSSpath, but transfer the files individually with the '*' wild character. This option lets you change the directory name:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    hsi &amp;lt;&amp;lt;EOF&lt;br /&gt;
      lcd $SCRATCH/LargeFilesDir&lt;br /&gt;
      mkdir $ARCHIVE/LargeFilesDir2&lt;br /&gt;
      cd $ARCHIVE/LargeFilesDir2&lt;br /&gt;
      cput -Ruph *  &lt;br /&gt;
    end&lt;br /&gt;
    EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Documentation === &lt;br /&gt;
Complete documentation on HSI is available from the Gleicher Enterprises links below. You may peruse those links and come with alternative syntax forms. You may even be already familiar with HPSS/HSI from other HPC facilities, that may or not have procedures similar to ours. HSI doesn't always work as expected when you go outside of our recommended syntax, so '''we strongly urge that you use the sample scripts we are providing as the basis''' for your job submissions&lt;br /&gt;
* [http://www.mgleicher.us/GEL/hsi/ HSI Introduction]&lt;br /&gt;
* [http://www.mgleicher.us/GEL/hsi/hsi_man_page.html man hsi]&lt;br /&gt;
* [https://support.scinet.utoronto.ca/wiki/index.php/HSI_help hsi help]&lt;br /&gt;
* [http://www.mgleicher.us/GEL/hsi/hsi-exit-codes.html exit codes] &lt;br /&gt;
'''Note:''' HSI returns the highest-numbered exit code, in case of multiple operations in the same hsi session. You may use '/scinet/gpc/bin/exit2msg $status' to translate those codes into intelligible messages&lt;br /&gt;
&lt;br /&gt;
=== Typical Usage Scripts===&lt;br /&gt;
The most common interactions will be ''putting'' data into HPSS, examining the contents (ls,ish), and ''getting'' data back onto GPFS for inspection or analysis.&lt;br /&gt;
&lt;br /&gt;
==== Sample '''data offload''' ====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# This script is named: data-offload.sh&lt;br /&gt;
#PBS -l walltime=72:00:00&lt;br /&gt;
#PBS -q archive&lt;br /&gt;
#PBS -N offload&lt;br /&gt;
#PBS -j oe&lt;br /&gt;
#PBS -me&lt;br /&gt;
&lt;br /&gt;
trap &amp;quot;echo 'Job script not completed';exit 129&amp;quot; TERM INT&lt;br /&gt;
# individual tarballs already exist&lt;br /&gt;
&lt;br /&gt;
/usr/local/bin/hsi  -v &amp;lt;&amp;lt;EOF1&lt;br /&gt;
mkdir put-away&lt;br /&gt;
cd put-away&lt;br /&gt;
cput $SCRATCH/workarea/finished-job1.tar.gz : finished-job1.tar.gz&lt;br /&gt;
end&lt;br /&gt;
EOF1&lt;br /&gt;
status=$?&lt;br /&gt;
if [ ! $status == 0 ];then&lt;br /&gt;
   echo 'HSI returned non-zero code.'&lt;br /&gt;
   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
   exit $status&lt;br /&gt;
else&lt;br /&gt;
   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
/usr/local/bin/hsi  -v &amp;lt;&amp;lt;EOF2&lt;br /&gt;
mkdir put-away&lt;br /&gt;
cd put-away&lt;br /&gt;
cput $SCRATCH/workarea/finished-job2.tar.gz : finished-job2.tar.gz&lt;br /&gt;
end&lt;br /&gt;
EOF2&lt;br /&gt;
status=$?&lt;br /&gt;
if [ ! $status == 0 ];then&lt;br /&gt;
   echo 'HSI returned non-zero code.'&lt;br /&gt;
   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
   exit $status&lt;br /&gt;
else&lt;br /&gt;
   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
trap - TERM INT&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Note:''' as in the above example, we recommend that you capture the (highest-numbered) exit code for each hsi session independently. And remember, you may improve your exit code verbosity by adding the excerpt below to your scripts:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if [ ! $status == 0 ];then&lt;br /&gt;
   echo 'HSI returned non-zero code.'&lt;br /&gt;
   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
   exit $status&lt;br /&gt;
else&lt;br /&gt;
   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sample '''data list''' ====&lt;br /&gt;
A very trivial way to list the contents of HPSS would be to just submit the HSI 'ls' command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# This script is named: data-list.sh&lt;br /&gt;
#PBS -l walltime=1:00:00&lt;br /&gt;
#PBS -q archive&lt;br /&gt;
#PBS -N hpss_ls&lt;br /&gt;
#PBS -j oe&lt;br /&gt;
#PBS -me&lt;br /&gt;
&lt;br /&gt;
/usr/local/bin/hsi -v &amp;lt;&amp;lt;EOF&lt;br /&gt;
cd put-away&lt;br /&gt;
ls -R&lt;br /&gt;
end&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
''Warning: if you have a lot of files, the ls command will take a long time to complete. For instance, about 400,000 files can be listed in about an hour. Adjust the walltime accordingly, and be on the safe side.''&lt;br /&gt;
&lt;br /&gt;
However, we provide a much more useful and convenient way to explore the contents of HPSS with the inventory shell [[ISH]]. This example creates an index of all the files in a user's portion of the namespace. The list is placed in the directory /home/$(whoami)/.ish_register that can be inspected from the gpc-devel nodes.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# This script is named: data-list.sh&lt;br /&gt;
#PBS -l walltime=1:00:00&lt;br /&gt;
#PBS -q archive&lt;br /&gt;
#PBS -N hpss_index&lt;br /&gt;
#PBS -j oe&lt;br /&gt;
#PBS -me&lt;br /&gt;
&lt;br /&gt;
INDEX_DIR=$HOME/.ish_register&lt;br /&gt;
if ! [ -e &amp;quot;$INDEX_DIR&amp;quot; ]; then&lt;br /&gt;
  mkdir -p $INDEX_DIR&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
export ISHREGISTER=&amp;quot;$INDEX_DIR&amp;quot;&lt;br /&gt;
/scinet/gpc/bin/ish hindex&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
''Note: the above warning on collecting the listing for many files applies here too.''&lt;br /&gt;
&lt;br /&gt;
This index can be browsed or searched with ISH on the development nodes.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
gpc-f104n084-$ /scinet/gpc/bin/ish ~/.ish_register/hpss.igz &lt;br /&gt;
[ish]hpss.igz&amp;gt; help&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ISH is a powerful tool that is also useful for creating and browsing indices of tar and htar archives, so please look at the [[ISH|documentation]] or built in help.&lt;br /&gt;
&lt;br /&gt;
==== Sample '''data recall''' ====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# This script is named: data-recall.sh&lt;br /&gt;
#PBS -l walltime=72:00:00&lt;br /&gt;
#PBS -q archive&lt;br /&gt;
#PBS -N recall_files&lt;br /&gt;
#PBS -j oe&lt;br /&gt;
#PBS -me&lt;br /&gt;
&lt;br /&gt;
trap &amp;quot;echo 'Job script not completed';exit 129&amp;quot; TERM INT&lt;br /&gt;
&lt;br /&gt;
mkdir -p $SCRATCH/recalled-from-hpss&lt;br /&gt;
&lt;br /&gt;
# individual tarballs previously organized in HPSS inside the put-away-on-2010/ folder&lt;br /&gt;
hsi  -v &amp;lt;&amp;lt; EOF&lt;br /&gt;
cget $SCRATCH/recalled-from-hpss/Jan-2010-jobs.tar.gz : $ARCHIVE/put-away-on-2010/Jan-2010-jobs.tar.gz&lt;br /&gt;
cget $SCRATCH/recalled-from-hpss/Feb-2010-jobs.tar.gz : $ARCHIVE/put-away-on-2010/Feb-2010-jobs.tar.gz&lt;br /&gt;
end&lt;br /&gt;
EOF&lt;br /&gt;
status=$?&lt;br /&gt;
&lt;br /&gt;
trap - TERM INT&lt;br /&gt;
&lt;br /&gt;
if [ ! $status == 0 ]; then&lt;br /&gt;
   echo 'HSI returned non-zero code.'&lt;br /&gt;
   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
   exit $status&lt;br /&gt;
else&lt;br /&gt;
   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We should emphasize that a single ''cget'' of multiple files (rather than several separate gets) allows HSI to do optimization, as in the following example:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# This script is named: data-recall.sh&lt;br /&gt;
#PBS -l walltime=72:00:00&lt;br /&gt;
#PBS -q archive&lt;br /&gt;
#PBS -N recall_files_optimized&lt;br /&gt;
#PBS -j oe&lt;br /&gt;
#PBS -me&lt;br /&gt;
&lt;br /&gt;
trap &amp;quot;echo 'Job script not completed';exit 129&amp;quot; TERM INT&lt;br /&gt;
mkdir -p $SCRATCH/recalled-from-hpss&lt;br /&gt;
&lt;br /&gt;
# individual tarballs previously organized in HPSS inside the put-away-on-2010/ folder&lt;br /&gt;
hsi  -v &amp;lt;&amp;lt; EOF&lt;br /&gt;
lcd $SCRATCH/recalled-from-hpss/&lt;br /&gt;
cd $ARCHIVE/put-away-on-2010/&lt;br /&gt;
cget Jan-2010-jobs.tar.gz Feb-2010-jobs.tar.gz&lt;br /&gt;
end&lt;br /&gt;
EOF&lt;br /&gt;
status=$?&lt;br /&gt;
&lt;br /&gt;
trap - TERM INT&lt;br /&gt;
 &lt;br /&gt;
if [ ! $status == 0 ]; then&lt;br /&gt;
   echo 'HSI returned non-zero code.'&lt;br /&gt;
   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
   exit $status&lt;br /&gt;
else&lt;br /&gt;
   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sample '''transferring directories''' ====&lt;br /&gt;
Remember, it's not possible to rename directories on-the-fly:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hsi cget -Ruph $SCRATCH/LargeFiles-recalled : $ARCHIVE/LargeFiles    (FAILS)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One workaround is transfer the whole directory (and sub-directories) recursively:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# This script is named: data-recall.sh&lt;br /&gt;
#PBS -l walltime=72:00:00&lt;br /&gt;
#PBS -q archive&lt;br /&gt;
#PBS -N recall_directories&lt;br /&gt;
#PBS -j oe&lt;br /&gt;
#PBS -me&lt;br /&gt;
&lt;br /&gt;
trap &amp;quot;echo 'Job script not completed';exit 129&amp;quot; TERM INT&lt;br /&gt;
&lt;br /&gt;
mkdir -p $SCRATCH/recalled&lt;br /&gt;
&lt;br /&gt;
hsi  -v &amp;lt;&amp;lt; EOF&lt;br /&gt;
lcd $SCRATCH/recalled&lt;br /&gt;
cd $ARCHIVE/&lt;br /&gt;
cget -Ruph LargeFiles&lt;br /&gt;
end&lt;br /&gt;
EOF&lt;br /&gt;
status=$?&lt;br /&gt;
 &lt;br /&gt;
trap - TERM INT&lt;br /&gt;
 &lt;br /&gt;
if [ ! $status == 0 ]; then&lt;br /&gt;
   echo 'HSI returned non-zero code.'&lt;br /&gt;
   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
   exit $status&lt;br /&gt;
else&lt;br /&gt;
   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another workaround is to transfer files and subdirectories individually with the &amp;quot;*&amp;quot; wild character:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# This script is named: data-recall.sh&lt;br /&gt;
#PBS -l walltime=72:00:00&lt;br /&gt;
#PBS -q archive&lt;br /&gt;
#PBS -N recall_directories&lt;br /&gt;
#PBS -j oe&lt;br /&gt;
#PBS -me&lt;br /&gt;
&lt;br /&gt;
trap &amp;quot;echo 'Job script not completed';exit 129&amp;quot; TERM INT&lt;br /&gt;
&lt;br /&gt;
mkdir -p $SCRATCH/LargeFiles-recalled&lt;br /&gt;
&lt;br /&gt;
hsi  -v &amp;lt;&amp;lt; EOF&lt;br /&gt;
lcd $SCRATCH/LargeFiles-recalled&lt;br /&gt;
cd $ARCHIVE/LargeFiles&lt;br /&gt;
cget -Ruph *&lt;br /&gt;
end&lt;br /&gt;
EOF&lt;br /&gt;
status=$?&lt;br /&gt;
 &lt;br /&gt;
trap - TERM INT&lt;br /&gt;
 &lt;br /&gt;
if [ ! $status == 0 ]; then&lt;br /&gt;
   echo 'HSI returned non-zero code.'&lt;br /&gt;
   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
   exit $status&lt;br /&gt;
else&lt;br /&gt;
   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* For more details please check the '''[http://www.mgleicher.us/GEL/hsi/ HSI Introduction]''', the '''[http://www.mgleicher.us/GEL/hsi/hsi_man_page.html HSI Man Page]''' or the or the [https://support.scinet.utoronto.ca/wiki/index.php/HSI_help '''hsi help''']&lt;br /&gt;
&lt;br /&gt;
== '''[[ISH|ISH]]''' ==&lt;br /&gt;
=== [[ISH|Documentation and Usage]] ===&lt;br /&gt;
 &lt;br /&gt;
== '''File and directory management''' ==&lt;br /&gt;
=== Moving/renaming ===&lt;br /&gt;
* you may use 'mv' or 'cp' in the same way as the linux version.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#PBS -l walltime=72:00:00&lt;br /&gt;
#PBS -q archive&lt;br /&gt;
#PBS -N deletion_script&lt;br /&gt;
#PBS -j oe&lt;br /&gt;
#PBS -m e&lt;br /&gt;
 &lt;br /&gt;
echo &amp;quot;HPSS file and directory management&amp;quot;&lt;br /&gt;
&lt;br /&gt;
trap &amp;quot;echo 'Job script not completed';exit 129&amp;quot; TERM INT&lt;br /&gt;
&lt;br /&gt;
/usr/local/bin/hsi -v &amp;lt;&amp;lt;EOF1&lt;br /&gt;
    mkdir $ARCHIVE/2011&lt;br /&gt;
    mv $ARCHIVE/oldjobs $ARCHIVE/2011&lt;br /&gt;
    cp -r $ARCHIVE/almostfinished/*done $ARCHIVE/2011&lt;br /&gt;
end&lt;br /&gt;
EOF1&lt;br /&gt;
status=$?&lt;br /&gt;
 &lt;br /&gt;
trap - TERM INT&lt;br /&gt;
 &lt;br /&gt;
if [ ! $status == 0 ]; then&lt;br /&gt;
   echo 'HSI returned non-zero code.'&lt;br /&gt;
   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
   exit $status&lt;br /&gt;
else&lt;br /&gt;
   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Deletions ===&lt;br /&gt;
==== Recommendations ====&lt;br /&gt;
* Be careful with the use of 'cd' commands to non-existing directories before the 'rm' command. Results may be unpredictable&lt;br /&gt;
* Avoid the use of the stand alone wild character '''*'''. If necessary, whenever possible have it bound to common patterns, such as '*.tmp', so to limit unintentional mis-happens&lt;br /&gt;
* Avoid using relative paths, even the env variable $ARCHIVE. Better to explicitly expand the full paths in your scripts&lt;br /&gt;
* Avoid using recursive/looped deletion instructions on $SCRATCH contents from the archive job scripts. Even on $ARCHIVE contents, it may be better to do it as an independent job submission, after you have verified that the original ingestion into HPSS finished without any issues.&lt;br /&gt;
&lt;br /&gt;
==== Typical example ====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#PBS -l walltime=72:00:00&lt;br /&gt;
#PBS -q archive&lt;br /&gt;
#PBS -N deletion_script&lt;br /&gt;
#PBS -j oe&lt;br /&gt;
#PBS -m e&lt;br /&gt;
 &lt;br /&gt;
echo &amp;quot;Deletion of an outdated directory tree into HPSS&amp;quot;&lt;br /&gt;
&lt;br /&gt;
trap &amp;quot;echo 'Job script not completed';exit 129&amp;quot; TERM INT&lt;br /&gt;
# Note that the initial directory in HPSS ($ARCHIVE) has the path explicitly expanded&lt;br /&gt;
&lt;br /&gt;
/usr/local/bin/hsi -v &amp;lt;&amp;lt;EOF1&lt;br /&gt;
    rm /archive/s/scinet/pinto/*.tmp&lt;br /&gt;
    rm -R /archive/s/scinet/pinto/obsolete&lt;br /&gt;
end&lt;br /&gt;
EOF1&lt;br /&gt;
status=$?&lt;br /&gt;
 &lt;br /&gt;
trap - TERM INT&lt;br /&gt;
 &lt;br /&gt;
if [ ! $status == 0 ]; then&lt;br /&gt;
   echo 'HSI returned non-zero code.'&lt;br /&gt;
   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
   exit $status&lt;br /&gt;
else&lt;br /&gt;
   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Deleting with an interactive HSI session ====&lt;br /&gt;
* You may feel more comfortable acquiring an interactive shell, starting an HSI session and proceeding with your deletions that way. Keep in mind, you're restricted to 1H.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gpc-f103n084-$ qsub -q archive -I&lt;br /&gt;
qsub: waiting for job 11611291.gpc-sched to start&lt;br /&gt;
qsub: job 11611291.gpc-sched ready&lt;br /&gt;
&lt;br /&gt;
----------------------------------------&lt;br /&gt;
Begin PBS Prologue Mon May 28 13:15:28 EDT 2012 1338225328&lt;br /&gt;
Job ID:		11611291.gpc-sched&lt;br /&gt;
Username:	pinto&lt;br /&gt;
Group:		scinet&lt;br /&gt;
Nodes:		gpc-archive01&lt;br /&gt;
End PBS Prologue Mon May 28 13:15:28 EDT 2012 1338225328&lt;br /&gt;
----------------------------------------&lt;br /&gt;
hpss-archive01-$ hsi&lt;br /&gt;
******************************************************************&lt;br /&gt;
*     Welcome to HPSS@SciNet - High Perfomance Storage System    *&lt;br /&gt;
*                                                                *&lt;br /&gt;
*        Contact Information: support@scinet.utoronto.ca         *&lt;br /&gt;
*  NOTE: do not transfer SMALL FILES with HSI. Use HTAR instead  *&lt;br /&gt;
*              CHECK THE INTEGRITY OF YOUR TARBALLS              *&lt;br /&gt;
******************************************************************&lt;br /&gt;
Username: pinto  UID: 10010  Acct: 10010(10010) Copies: 2 Firewall: off [hsi.4.0.1 Thu Mar 22 11:44:03 EDT 2012] &lt;br /&gt;
[HSI]/archive/s/scinet/pinto-&amp;gt; rm -R junk&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''HPSS for the 'Watchmaker' ''' ==&lt;br /&gt;
=== Efficient alternative to htar ===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#PBS -l walltime=72:00:00&lt;br /&gt;
#PBS -q archive&lt;br /&gt;
#PBS -N tar_create_tarball_in_hpss_with_hsi_by_piping&lt;br /&gt;
#PBS -j oe&lt;br /&gt;
#PBS -m e&lt;br /&gt;
 &lt;br /&gt;
trap &amp;quot;echo 'Job script not completed';exit 129&amp;quot; TERM INT&lt;br /&gt;
# Note that your initial directory in HPSS will be $ARCHIVE&lt;br /&gt;
&lt;br /&gt;
# When using a pipeline like this&lt;br /&gt;
set -o pipefail &lt;br /&gt;
&lt;br /&gt;
# to put&lt;br /&gt;
tar -c $SCRATCH/mydir | hsi cput - : $ARCHIVE/mydir.tar&lt;br /&gt;
status=$?&lt;br /&gt;
if [ ! $status == 0 ]; then&lt;br /&gt;
   echo 'TAR+HSI+piping returned non-zero code.'&lt;br /&gt;
   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
   exit $status&lt;br /&gt;
else&lt;br /&gt;
   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# to immediately generate an index&lt;br /&gt;
ish hindex $ARCHIVE/mydir.tar&lt;br /&gt;
status=$?&lt;br /&gt;
if [ ! $status == 0 ]; then&lt;br /&gt;
   echo 'ISH returned non-zero code.'&lt;br /&gt;
   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
   exit $status&lt;br /&gt;
else&lt;br /&gt;
   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# to get&lt;br /&gt;
#cd $SCRATCH&lt;br /&gt;
#hsi cget - : $ARCHIVE/mydir.tar | tar -xv &lt;br /&gt;
#status=$?&lt;br /&gt;
# if [ ! $status == 0 ]; then&lt;br /&gt;
#   echo 'TAR+HSI+piping returned non-zero code.'&lt;br /&gt;
#   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
#   exit $status&lt;br /&gt;
#else&lt;br /&gt;
#   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
#fi&lt;br /&gt;
&lt;br /&gt;
trap - TERM INT&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
'''Notes:''' &lt;br /&gt;
* Combining commands in this fashion, besides being HPSS-friendly, should not be that noticeably slower than the recursive put with HSI that stores each file one by one. However, reading the files back from tape in this format will be many times faster. It would also overcome the current 68GB limit on the size of stored files that we have with htar.&lt;br /&gt;
* To top things off, we recommend indexing with ish (in the same script) immediately after the tarball creation , while it resides in the HPSS cache. It would be as if htar was used.&lt;br /&gt;
* To ensure that an error at any stage of the pipeline shows up in the returned status use: ''set -o pipefail'' (The default is to return the status of the last command in the pipeline and this is not what you want.)&lt;br /&gt;
&lt;br /&gt;
=== Multi-threaded gzip'ed compression with pigz ===&lt;br /&gt;
We compiled multi-threaded implementation of gzip called pigz (http://zlib.net/pigz/). It's now part of the &amp;quot;extras&amp;quot; module. It can also be used on any compute or devel nodes. This makes the execution of the previous version of the script much quicker than if you were to use 'tar -cfz'. In addition, by piggy-backing ISH to the end of the script, it will know what to do with the just created mydir.tar.gz compressed tarball.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#PBS -l walltime=72:00:00&lt;br /&gt;
#PBS -q archive&lt;br /&gt;
#PBS -N tar_create_compressed_tarball_in_hpss_with_hsi_by_piping&lt;br /&gt;
#PBS -j oe&lt;br /&gt;
#PBS -m e&lt;br /&gt;
 &lt;br /&gt;
trap &amp;quot;echo 'Job script not completed';exit 129&amp;quot; TERM INT&lt;br /&gt;
# Note that your initial directory in HPSS will be $ARCHIVE&lt;br /&gt;
&lt;br /&gt;
# When using a pipeline like this&lt;br /&gt;
set -o pipefail &lt;br /&gt;
&lt;br /&gt;
load module extras&lt;br /&gt;
&lt;br /&gt;
# to put&lt;br /&gt;
tar -c $SCRATCH/mydir | pigz | hsi cput - : $ARCHIVE/mydir.tar.gz&lt;br /&gt;
status=$?&lt;br /&gt;
if [ ! $status == 0 ]; then&lt;br /&gt;
   echo 'TAR+PIGZ+HSI+piping returned non-zero code.'&lt;br /&gt;
   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
   exit $status&lt;br /&gt;
else&lt;br /&gt;
   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Content Verification ===&lt;br /&gt;
&lt;br /&gt;
==== HTAR CRC checksums ====&lt;br /&gt;
Specifies that HTAR should generate CRC checksums when creating the archive.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#PBS -l walltime=72:00:00&lt;br /&gt;
#PBS -q archive&lt;br /&gt;
#PBS -N htar_create_tarball_in_hpss_with_checksum_verification&lt;br /&gt;
#PBS -j oe&lt;br /&gt;
#PBS -m e&lt;br /&gt;
 &lt;br /&gt;
trap &amp;quot;echo 'Job script not completed';exit 129&amp;quot; TERM INT&lt;br /&gt;
# Note that your initial directory in HPSS will be $ARCHIVE&lt;br /&gt;
 &lt;br /&gt;
cd $SCRATCH/workarea&lt;br /&gt;
&lt;br /&gt;
# to put&lt;br /&gt;
htar -cpf $ARCHIVE/finished-job1.tar -Hcrc -Hverify=1 finished-job1/&lt;br /&gt;
&lt;br /&gt;
# to get&lt;br /&gt;
#mkdir $SCRATCH/verification&lt;br /&gt;
#cd $SCRATCH/verification&lt;br /&gt;
#htar -Hcrc -xvpmf $ARCHIVE/finished-job1.tar &lt;br /&gt;
&lt;br /&gt;
status=$?&lt;br /&gt;
 &lt;br /&gt;
trap - TERM INT&lt;br /&gt;
 &lt;br /&gt;
if [ ! $status == 0 ]; then&lt;br /&gt;
   echo 'HTAR returned non-zero code.'&lt;br /&gt;
   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
   exit $status&lt;br /&gt;
else&lt;br /&gt;
   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Current HSI version - Checksum built-in ====&lt;br /&gt;
&lt;br /&gt;
[http://www.mgleicher.us/GEL/hsi/hsi_reference_manual_2/checksum-feature.html More usage details here]&lt;br /&gt;
&lt;br /&gt;
MD5 is the standard Hashing Algorithm for the HSI build at SciNet.&lt;br /&gt;
&lt;br /&gt;
The checksum algorithm is very CPU-intensive. Although the checksum code is compiled with a high level of compiler optimization, transfer rates can be significantly reduced when checksum creation or verification is in effect. The amount of degradation in transfer rates depends on several factors, such as  processor speed, network transfer speed, and speed of the local filesystem (GPFS).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#PBS -l walltime=72:00:00&lt;br /&gt;
#PBS -q archive&lt;br /&gt;
#PBS -N MD5_checksum_verified_transfer&lt;br /&gt;
#PBS -j oe&lt;br /&gt;
#PBS -me&lt;br /&gt;
&lt;br /&gt;
thefile=&amp;lt;GPFSpath&amp;gt;&lt;br /&gt;
storedfile=&amp;lt;HPSSpath&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Generate checksum on fly (-c on)&lt;br /&gt;
hsi -q put -c on $thefile : $storedfile&lt;br /&gt;
pid=$!&lt;br /&gt;
&lt;br /&gt;
# Check the exit code of the HSI process  &lt;br /&gt;
status=$?&lt;br /&gt;
&lt;br /&gt;
if [ ! $status == 0 ]; then&lt;br /&gt;
   echo 'HSI returned non-zero code.'&lt;br /&gt;
   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
   exit $status&lt;br /&gt;
else&lt;br /&gt;
   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# verify checksum&lt;br /&gt;
hsi lshash $storedfile&lt;br /&gt;
status=$?&lt;br /&gt;
 &lt;br /&gt;
if [ ! $status == 0 ]; then&lt;br /&gt;
   echo 'HSI returned non-zero code.'&lt;br /&gt;
   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
   exit $status&lt;br /&gt;
else&lt;br /&gt;
   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# get the file back with checksum&lt;br /&gt;
hsi get -c on $storedfile&lt;br /&gt;
status=$?&lt;br /&gt;
 &lt;br /&gt;
if [ ! $status == 0 ]; then&lt;br /&gt;
   echo 'HSI returned non-zero code.'&lt;br /&gt;
   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
   exit $status&lt;br /&gt;
else&lt;br /&gt;
   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Prior to HSI version 4.0.1.1 ====&lt;br /&gt;
&lt;br /&gt;
This will checksum the contents of the HPSSpath against the original GPFSpath after the transfer has finished.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#PBS -l walltime=72:00:00&lt;br /&gt;
#PBS -q archive&lt;br /&gt;
#PBS -N checksum_verified_transfer&lt;br /&gt;
#PBS -j oe&lt;br /&gt;
#PBS -me&lt;br /&gt;
&lt;br /&gt;
thefile=&amp;lt;GPFSpath&amp;gt;&lt;br /&gt;
storedfile=&amp;lt;HPSSpath&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Generate checksum on fly using a named pipe so that file is only read from GPFS once&lt;br /&gt;
mkfifo /tmp/NPIPE&lt;br /&gt;
cat $thefile  | tee /tmp/NPIPE | hsi -q put - : $storedfile &amp;amp;&lt;br /&gt;
pid=$!&lt;br /&gt;
md5sum /tmp/NPIPE |tee /tmp/$fname.md5&lt;br /&gt;
rm -f  /tmp/NPIPE&lt;br /&gt;
&lt;br /&gt;
# Check the exit code of the HSI process  &lt;br /&gt;
wait $pid&lt;br /&gt;
status=$?&lt;br /&gt;
&lt;br /&gt;
if [ ! $status == 0 ]; then&lt;br /&gt;
   echo 'HSI returned non-zero code.'&lt;br /&gt;
   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
   exit $status&lt;br /&gt;
else&lt;br /&gt;
   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# change filename to stdin in checksum file&lt;br /&gt;
sed -i.1 &amp;quot;s+/tmp/NPIPE+-+&amp;quot; /tmp/$fname.md5&lt;br /&gt;
&lt;br /&gt;
# verify checksum&lt;br /&gt;
hsi -q get - : $storedfile  | md5sum -c  /tmp/$fname.md5&lt;br /&gt;
status=$?&lt;br /&gt;
 &lt;br /&gt;
if [ ! $status == 0 ]; then&lt;br /&gt;
   echo 'HSI returned non-zero code.'&lt;br /&gt;
   /scinet/gpc/bin/exit2msg $status&lt;br /&gt;
   exit $status&lt;br /&gt;
else&lt;br /&gt;
   echo 'TRANSFER SUCCESSFUL'&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''User provided Content/Suggestions''' ==&lt;br /&gt;
=== '''[[HPSS-by-pomes|Packing up large data sets and putting them on HPSS]]''' ===&lt;br /&gt;
(Pomés group recommendations)&lt;br /&gt;
&lt;br /&gt;
[[Data Management|BACK TO Data Management]]&lt;/div&gt;</summary>
		<author><name>Leon</name></author>
	</entry>
</feed>