PDL turns Perl into a free, large N-dimensional array-oriented, numerical language similar to IDL and MATLAB. One can write simple perl expressions to manipulate entire numerical arrays all at once. Simple interactive shells, pdl2 and perldl, are provided for use from the command line along with the PDL module for use in Perl scripts.
Vendor website: http://pdl.perl.org/
PDL is part of the LSA contributed software library. To use it, you must first load the lsa module, then the pdl module.
You can either load the lsa module separately, as in
$ module load lsa $ module load pdl
or together, as in
$ module load lsa pdl
Running PDL interactively
Since Flux is designed and optimized for batch computing, running interactive programs with graphical user interface on Flux can be very slow. It is therefore recommended that you do not run PDL interactively on Flux. Instead, use PDL from non-interactive Perl scripts and have your scripts save any generated graphics to files which you can view on your local computer. Instructions for doing this are in the section “Running PDL from PBS” section below.
If you do need to start an interactive graphical PDL session on Flux, make sure you are running an X Windows server on your local workstation, log in to Flux using X Windows forwarding (from a Linux or Mac workstation, you would do this by using the -X option with your ssh command), load the pdl module, and then either start the PDL shell by running “perldl”, or start an interactive job on the cluster.
Here is an example of running PDL interactively on the Flux login nodes. Be sure to replace “uniqname” with your uniqname in the ssh command below:
[uniqname@flux-login2 ~]$ module load lsa pdl [uniqname@flux-login2 ~]$ module load pdl Note well: loading pgplot/5.2.2/g77 gnuplot/4.6.0 gsl/1.15, as these are required by PDL [uniqname@flux-login2 ~]$ perldl perlDL shell v1.357 PDL comes with ABSOLUTELY NO WARRANTY. For details, see the file 'COPYING' in the PDL distribution. This is free software and you are welcome to redistribute it under certain conditions, see the same file for details. ReadLines, NiceSlice, MultiLines enabled Reading PDL/default.perldlrc... Found docs database /home/software/rhel6/lsa/pdl/2.007/lib64/perl5/PDL/pdldoc.db Type 'help' for online help Type 'demo' for online demos Loaded PDL v2.007 (supports bad values) Note: AutoLoader not enabled ('use PDL::AutoLoader' recommended) pdl>
As always, please be sure to not run long or intensive computations on the cluster login nodes, as this can cause problems for other users, and processes using too many resources on the login nodes are automatically terminated, which could cause you to lose work.
If you need to do any significant interactive work with PDL, you can start an interactive job. The following example asks for a single core (since PDL is not inherently parallel) with 4 GB of memory for up to 2 hours. Be sure to change the name of the allocation from example_flux to an allocation you are authorized to use, as well as changing uniqname in the ssh command to your uniqname.
[uniqname@flux-login2 ~]$ module load lsa pdl Note well: loading pgplot/5.2.2/g77 gnuplot/4.6.0 gsl/1.15, as these are required by PDL [uniqname@flux-login2 ~]$ qsub -I -X -V -l nodes=1:ppn=1,pmem=4000mb,walltime=02:00:00,qos=flux -A example_flux -q flux qsub: waiting for job 11191615.nyx.arc-ts.umich.edu to start qsub: job 11191615.nyx.arc-ts.umich.edu ready [uniqname@nyx5618 ~]$ cd $PBS_O_WORKDIR [uniqname@nyx5618 uniqname]$ perldl perlDL shell v1.357 PDL comes with ABSOLUTELY NO WARRANTY. For details, see the file 'COPYING' in the PDL distribution. This is free software and you are welcome to redistribute it under certain conditions, see the same file for details. ReadLines, NiceSlice, MultiLines enabled Reading PDL/default.perldlrc... Found docs database /home/software/rhel6/lsa/pdl/2.007/lib64/perl5/PDL/pdldoc.db Type 'help' for online help Type 'demo' for online demos Loaded PDL v2.007 (supports bad values) Note: AutoLoader not enabled ('use PDL::AutoLoader' recommended) pdl>
Running PDL from PBS
The following is an example of how to run PDL in batch mode via PBS.
For this example, we will be following the first few steps in the “Whirling through the Whirlpool” section of the PDL book at http://pdl.perl.org/?page=FirstSteps
Start by logging into Flux and running the following commands to load the PDL module and get a copy of the example files:
$ cd ~ $ module load lsa pdl $ cp -r $PDL_EXAMPLES . $ cd pdl-examples
If you run the command “ls -l” to view the contents of the current directory, you should see the following:
[uniqname@flux-login2 pdl-examples]$ ls -l total 2088 -rw------- 1 uniqname lsa 511 Oct 16 11:12 example.pbs -rwx------ 1 uniqname lsa 305 Oct 16 11:12 example.pl -rw------- 1 uniqname lsa 1054080 Oct 16 11:12 m51_flatfield.fits -rw------- 1 uniqname lsa 1054080 Oct 16 11:12 m51_raw.fits [uniqname@flux-login2 pdl-examples]$
Next, edit the example.pbs file and change example_flux to be the name of a Flux allocation you have access to on the “#PBS -A” line, and change uniqname to your uniqname on the “#PBS -M” line:
#!/bin/bash #### PBS preamble #PBS -N pdl_example #PBS -M email@example.com #PBS -m abe #PBS -l nodes=1:ppn=1,pmem=4000mb,walltime=00:15:00 #PBS -j oe #PBS -V #PBS -A example_flux #PBS -l qos=flux #PBS -q flux #### End PBS preamble # Show list of CPUs you ran on, if you're running under PBS if [ -n "$PBS_NODEFILE" ]; then cat $PBS_NODEFILE; fi # Change to the directory you submitted from if [ -n "$PBS_O_WORKDIR" ]; then cd $PBS_O_WORKDIR; fi # Put your job commands after this line ./example.pl
The above PBS file requests 1 cores and 4 GB of memory for 15 minutes. You should adjust these resources as necessary for non-example jobs that you run. This job runs the Perl script in the example.pl file:
#!/usr/bin/perl use PDL; use PDL::Graphics::PGPLOT; $a = rfits("m51_raw.fits"); $flat = rfits("m51_flatfield.fits"); $gal = $a / $flat; # write the result as a fits file: wfits($gal, 'fixed_gal.fits'); # also create a PNG image: $id = dev("fixed_gal.png/PNG"); imag($gal, 0, 300); close_window($id);
This code reads in a galaxy image, applies field correction, and writes the resulting image as both a FITS file as well as a PNG file; the PNG version is created with enhanced contrast.
To submit this job, run the following command:
$ qsub example.pbs
After the job runs, you will have two new files in the pbs-examples directory: fixed_gal.fits and
fixed_gal.png These can be downloaded from Flux and viewed on your local workstation. Any error messages from the job will be in the file pdl_example.oXXXXXXXX where XXXXXXXX is the job number of the job that ran; if everything worked properly, this file will just contain a single line with the name of the compute node the job ran on.
Additional information is available on the PDL web site: http://pdl.perl.org/
For any Flux-specific assistance running PDL, contact firstname.lastname@example.org.