viernes, 4 de junio de 2010

How To Set Environment Variables in PBS Batch Scripts?

In order to use certain software packages on the Shared Computing Clusters, it is necessary to set one or more environment variables. This is accomplished automatically with the module command. It is often necessary, however, for these environment variables to be visible from within a PBS batch script, yet the module command does not work from within a batch script on a compute node. The following document describes the preferred way of setting environment variables inside a PBS batch script:
Inheriting Environment Variables
The preferred way of setting environment variables in a PBS batch script is to simply have the script inherit the environment of the parent shell from the login node. For example, you might execute the following command on a login node: module load mpich. This will set the necessary environment variables to use the mpich package. In order for these variables to be inherited in the PBS batch script that will execute on a compute node, include the #PBS -V option in the batch script as follows:
#!/bin/bash
#PBS -N Test
#PBS -l nodes=2:ppn=1
#PBS -S /bin/bash
<u><strong>#PBS -V</strong></u>
#PBS -m abe
#PBS -o /home/username/workingdir
#PBS -e /home/username/workingdir
echo "I ran on:"
cat $PBS_NODEFILE
mpiexec ./myjob.exe
When the job is submitted it will inherit all environment variables that were set in the parent shell on the login node, not just those set by the module command . Care should be taken to make sure that there are no other environment variables in the parent shell that could cause problems in the batch script.

No hay comentarios: