Jython/Example

From ScientificComputing
Revision as of 16:52, 6 December 2016 by Sfux (talk | contribs) (Created page with "As an example for running a Jython job, we are printing out the mathematical constants <math>\Pi<math> and <math>e</math>. For this, we are using the following Jython script:...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

As an example for running a Jython job, we are printing out the mathematical constants \Pi<math> and <math>e. For this, we are using the following Jython script:

[leonhard@euler06 ~]$ ls
test.py
[leonhard@euler06 ~]$ cat test.py 
import math

print "Pi = %r" % math.pi
print "e = %r" % math.e

First you need to load the required modules for Jython:

[leonhard@euler06 ~]$ module load gcc/4.8.2 python/2.7.6 java/1.8.0_31 jython/2.7.0

then you can submit the job

[leonhard@euler06 ~]$ bsub -n 1 -W 0:05 -R "rusage[mem=128]" "jython test.py"
Generic job.
Job <33655748> is submitted to queue <normal.4h>.
[leonhard@euler06 ~]$ bjobs
JOBID      USER        STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME
33655748   leonhard    PEND  normal.4h  euler06                 *n test.py Dec  6 15:49
[leonhard@euler06 ~]$ bjobs
JOBID      USER        STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME
33655748   leonhard    RUN   normal.4h  euler06     e1359       *n test.py Dec  6 15:49
[leonhard@euler06 ~]$ bjobs
No unfinished job found
[leonhard@euler06 ~]$ grep -A1 "Pi =" lsf.o33655748 
Pi = 3.141592653589793
e = 2.718281828459045

The resource usage summary of the job can also be found in the LSF log file.