Created
May 7, 2014 08:49
-
-
Save kmader/a49814356c7e707bb0dc to your computer and use it in GitHub Desktop.
Basic Condor Script for Running a Mandelbrot, stolen from https://computing.ee.ethz.ch/Services/Condor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################## | |
## | |
## Mandelbrot pictures with MATLAB and Condor | |
## Filename: mandelbrot.condor | |
## | |
################################################################## | |
# | |
# For this example, variables not used by Condor are marked my_* | |
# | |
universe = vanilla | |
getenv = True # MATLAB needs local environment | |
#initialdir = /home/foo/src/matlab | |
my_prefix = Mandel | |
# | |
# Seek max floating point performance | |
# | |
Rank = Kflops | |
# | |
# Mandelbrot Constants | |
# | |
my_procs = 30 | |
my_res = 512 | |
my_x = 0.87485 | |
my_y = 0.75145 | |
my_log_r0 = 1.5 | |
my_log_r1 = -12 | |
# | |
# MATLAB does all the math there, | |
# Condor just does string substitution | |
# | |
my_log_r = ( $(my_log_r0) + ($(my_log_r1) - $(my_log_r0))*$(Process)/$(my_procs) ) | |
my_r = exp( $(my_log_r) ) | |
my_x1 = ( $(my_x) - $(my_r) ) | |
my_x2 = ( $(my_x) + $(my_r) ) | |
my_y1 = ( $(my_y) - $(my_r) ) | |
my_y2 = ( $(my_y) + $(my_r) ) | |
# | |
# The name of the image file we want MATLAB to write | |
# | |
my_file = $(my_prefix).$(Process).jpg | |
# | |
# For MATLAB and other SEPP packages, the executable must be a script wrapper. | |
# | |
executable = mandelbrot.sh | |
arguments = mandelplot($(my_res), $(my_x1), $(my_x2), $(my_y1), $(my_y2), '$(my_file)') | |
# | |
# To redirect stdout and/or stderr to /dev/null, comment these out. | |
# | |
log = $(my_prefix).log | |
output = $(my_prefix).$(Process).out | |
error = $(my_prefix).$(Process).err | |
# | |
# Lastly, tell condor how many jobs to queue up. | |
# | |
queue $(my_procs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% | |
% Filename: mandelbrot.m | |
% | |
function [m]=mandelbrot(edge,x1,x2,y1,y2) | |
maxloop=64; | |
maxsize=16; | |
if edge<1 | |
edge=10; | |
end | |
m=zeros(edge); | |
ystep=(y2-y1)/edge; | |
xstep=(x2-x1)/edge; | |
iy=1; | |
for y=y1:ystep:y2 | |
ix=1; | |
for x=x1:xstep:x2 | |
mx=x; | |
my=y; | |
for i=1:maxloop | |
realnum=mx*mx; | |
imagnum=my*my; | |
if(realnum+imagnum)>maxsize | |
break | |
end | |
my=(mx*my)+y; | |
mx=(realnum-imagnum)*.5 +x; | |
end | |
m(iy,ix)=maxloop-i; | |
ix=ix+1; | |
end | |
iy=iy+1; | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Filename: mandelbrot.sh | |
# | |
# We use a shell wrapper for two reasons: | |
# | |
# 1) By using "$*" we ensure that the matlab command string is | |
# passed as a single argument even if it contains spaces. | |
# | |
# 2) Condor changes argv[0], which causes problems for SEPP. Hence, | |
# whenever we run a program from /usr/sepp/bin/* we must use a | |
# shell script wrapper. | |
# | |
exec /usr/sepp/bin/matlab -nojvm -nodisplay -nodesktop -nosplash -r "$*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% | |
% Filename: mandelplot.m | |
% | |
function mandelplot(edge,x1,x2,y1,y2,filename) | |
x=[x1:(x2-x1)/edge:x2]; | |
y=[y1:(y2-y1)/edge:y2]; | |
m=zeros(edge); | |
m=mandelbrot(edge,x1,x2,y1,y2); | |
%clf;surf(x,y,m) | |
%axis tight; | |
%shading interp; map=colormap; | |
%map(1,3)=0; | |
%colormap(map); | |
%view(2) | |
imwrite(m,filename); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment