Difference between revisions of "Programming/Perl"
From HPC
m (Pysdlb moved page Programming/Perl to Perl without leaving a redirect) |
m |
||
Line 2: | Line 2: | ||
Perl is a family of high-level, general-purpose, interpreted, dynamic programming languages. The languages in this family presently are Perl 5 and Perl 6. | Perl is a family of high-level, general-purpose, interpreted, dynamic programming languages. The languages in this family presently are Perl 5 and Perl 6. | ||
+ | |||
+ | When programming with Perl in a HPC environment you will need to change the first line from: | ||
+ | |||
+ | <pre style="background-color: #C8C8C8; color: black; border: 2px solid black; font-family: monospace, sans-serif;"> | ||
+ | #!/usr/bin/perl | ||
+ | </pre> | ||
+ | |||
+ | To | ||
+ | |||
+ | <pre style="background-color: #C8C8C8; color: black; border: 2px solid black; font-family: monospace, sans-serif;"> | ||
+ | #!/usr/bin/env perl | ||
+ | </pre> | ||
Line 7: | Line 19: | ||
=== Programming example === | === Programming example === | ||
− | <pre style="background-color: #C8C8C8; color: black; border: 2px solid | + | <pre style="background-color: #C8C8C8; color: black; border: 2px solid green; font-family: monospace, sans-serif;"> |
#!/usr/bin/env perl | #!/usr/bin/env perl |
Revision as of 09:40, 2 February 2017
Programming Details
Perl is a family of high-level, general-purpose, interpreted, dynamic programming languages. The languages in this family presently are Perl 5 and Perl 6.
When programming with Perl in a HPC environment you will need to change the first line from:
#!/usr/bin/perl
To
#!/usr/bin/env perl
Programming example
#!/usr/bin/env perl # # VIPER - HPC # ICTD Department # Hull University # # Written by DBird 25/12/2017 # ---------------- Modules ------------------------------------------ use strict; # perform error checking # ---------------- Variables ---------------------------------------- my ($i); # ------------------------------------------------------------------- # ---------------- Main Program ------------------------------------- # ------------------------------------------------------------------- for($i = 0; $i < 1000; $i++) { print "A-->$i\n"; } # ---------------- finish up and exit ------------------------------- exit;
Note this program does not contain any MPI directives and is shown simply for demonstrative purposes. Although PERL does support MPI, it's implementation is quite limited compared to C, C++ and Fortran.
Running the program
The program could be executed in the following way for test purposes on the login node:
module load perl/5.24.0 perl testPerl.pl
Batch example
#!/bin/bash #SBATCH -J openPERL-node #SBATCH -N 1 #SBATCH --ntasks-per-node 20 #SBATCH -D /home/user/PERL #SBATCH -o %N.%j.%a.out #SBATCH -e %N.%j.%a.err #SBATCH -p compute #SBATCH --exclusive echo $SLURM_JOB_NODELIST module purge module load perl/5.24.0 export I_MPI_DEBUG=5 export I_MPI_FABRICS=shm:tmi export I_MPI_FALLBACK=no perl /home/user/PERL/demoPERL.pl
[username@login01 ~]$ sbatch demoPERL.job Submitted batch job 289352