Skip to content

Instantly share code, notes, and snippets.

@PhDP
Created November 25, 2011 23:10
Show Gist options
  • Save PhDP/1394635 to your computer and use it in GitHub Desktop.
Save PhDP/1394635 to your computer and use it in GitHub Desktop.
SGE script
# Generate shell scripts for SGE.
def create_script(id, x, s, r, c, jpc):
f = open("job%(id_)d.sh" % {'id_' : id}, 'w')
f.write("#---------------------------Start program.job------------------------\n" \
"#!/bin/bash\n" \
"\n" \
"# The name of the job, can be whatever makes sense to you\n" \
"#$ -N phdp-c%(c_)dr%(r_).2f\n" \
"\n" \
"# Redirect output stream to this file.\n" \
"#$ -o phdp-c%(c_)dr%(r_).2f.txt\n" \
"\n" \
"# Redirect error stream to this file.\n" \
"#$ -e sge_error-c%(c_)dr%(r_).2f.txt\n" \
"\n" \
"# The batchsystem should use the current directory as working directory.\n" \
"# Both files (output.dat and error.dat) will be placed in the current\n" \
"# directory. The batchsystem assumes to find the executable in this directory.\n" \
"#$ -cwd\n" \
"\n" \
"# This is the file to be executed.\n" \
"./ssne -x=%(x_)d -r=%(r_).2f -s=%(s_).2f -c=%(c_)d -jpc=%(jpc_)d -o=c%(c_)dr%(r_).2f-\n" \
"\n#---------------------------End program.sge------------------------\n"
% {'x_' : x, "r_" : r, "s_" : s, "c_" : c, "jpc_" : jpc})
f.close()
sim_id = 0
for v0 in range(1, 4):
r = 0.25 * v0
for c in [5, 10, 25, 50, 125]:
create_script(sim_id, 32, 0.15, r, c, 100000 / c)
sim_id += 1
f = open("run.sh", 'w')
f.write("#---------------------------Start script------------------------\n" \
"#!/bin/bash\n" \
"\n" \
"# The SGE jobs to be executed.\n" \
"for (( i = 0 ; i < %(sim)d; ++i ))\n" \
"do\n" \
"qsub job$i.sh\n" \
"done\n" \
"\n#---------------------------End script------------------------\n"
% {"sim" : sim_id})
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment