Storing temporary files with TMPDIR

Using shared /tmp/var/tmp or similar shared directories to hold temporary files can increase the risk of your own programs and other users' programs failing when no more space is available. Compilers and utilities often create such temporary files without your knowledge of their size or number.

Specifying your own directory for temporary files can help you avoid the problem.

In interactive use on the login nodes, the default TMPDIR is /glade/scratch/username. You can change that by running the commands shown below on your command line when you log in or by setting the variable in your start file.

For batch use, however, CISL recommends setting TMPDIR within each batch script for all batch jobs. Include these commands as the first two executable lines of your batch script after the #PBS directives or #SBATCH directives.

For csh and tcsh users

setenv TMPDIR /glade/scratch/username/temp
mkdir -p $TMPDIR

For bash and ksh users

export TMPDIR=/glade/scratch/username/temp
mkdir -p $TMPDIR