Eberly College of Science Mathematics Department, Center for Interdisciplinary Mathematics
REU banner

Managing computing jobs

Here's a program for calculating pi

#!/usr/bin/env python
"""
a little implementation of our pi calculator
using montecarlo integration

Arguments:
    -n #    means use this many points
    -e #    means use 2**# many points
    -t ""   adds a tag to the output
"""

from numpy import floor, pi
from numpy.random import rand
import sys

e = 4
n = 2L**e
tag = ''
for ai, a in enumerate(sys.argv):
    if '-e' == a:
        e = int(sys.argv[ai+1])
        n = 2L**e
    elif '-n' == a:
        n = int(sys.argv[ai+1])
    elif '-t' == a:
        tag = sys.argv[ai+1]

x = rand(n)
y = rand(n)
m = sum(1-floor(x*x+y*y))
pi_est = 4.*(m/n)
if len(tag)>0:
    print tag, n, m, pi_est, abs(pi-pi_est)
else:
    print n, m, pi_est, abs(pi-pi_est)

Save this code to a new file called montecarlo.py

Using multicores for highly parallel tasks

SSH

Breaking news, June 2, 2015: Microsoft's power shell has just decided to support OpenSSH !!! So ssh skills became more valuable.

O'Reilly's snail book on ssh. (a take-off on the classic dragon book)

Penn state has a Linux cluster that students can use to experiment with remote computing. See Linux cluster docs This is a baby version of the services supplied by our Institute for cyberscience. Here are the two basic commands.

Unfortunately, one of the pains in using the linux cluster is that you can not make scripts executable, so to run your code on the remote machine, you'll have to use the command "python montecarlo.py ..."

Public/Private keys

Here is a good write-up on using ssh with public keys instead of passwords. (Remember, you can find out how a command works by typing "man" and the command name)

Presentation links