/****************************************************************/ /* S A S S A M P L E L I B R A R Y */ /* */ /* NAME: hpds2 */ /* TITLE: Example 1 for PROC HPDS2 */ /* Run DS2 Code on Grid - Compute Mandelbrot Set */ /* PRODUCT: HPA */ /* SYSTEM: ALL */ /* KEYS: DS2 code */ /* PROCS: HPDS2 */ /* DATA: */ /* */ /* SUPPORT: */ /* REF: SAS/HPA User's Guide, PROC HPDS2 chapter */ /* MISC: */ /* */ /****************************************************************/ libname applianc &ENGINE server = "&GRIDDATASERVER" user = &USER password = &PASSWORD database = &DATABASE; /* Set up the table that contains one row for each coordinate to compute */ proc ds2; data inp(overwrite=yes); dcl double p q r; dcl integer maxiterate; method init(); dcl int n m; dcl int i j k; dcl double pmin pmax qmin qmax; n = 1024; m = 1024; pmin = -1.5; pmax = -0.5; qmin = -0.5; qmax = 0.5; r = 100.0; maxiterate = 50; do k = 1 to n*m; i = k/m; j = mod(k,m); p = i*(pmax-pmin)/(n-1)+pmin; q = j*(qmax-qmin)/(m-1)+qmin; output; end; end; enddata; run; quit; /* Compute the coordinates */ proc hpds2 data=inp out=applianc.mandelbrot; performance host="&GRIDHOST" install="&GRIDINSTALLLOC"; data DS2GTF.out; dcl int mesh; dcl double x y rr nx ny; keep p q mesh; method run(); set DS2GTF.in; x = p; y = q; rr = r**2; mesh = 0; do while (mesh < maxiterate and (x**2+y**2 < rr)); nx = x**2 - y**2 + p; ny = 2.0*x*y + q; x = nx; y = ny; mesh = mesh+1; end; end; enddata; run; /* Plot the results */ goptions colors= ( CX003366 CX336699 CX6699CC CX99CCFF CX006633 CX339966 CX66CC99 CX99FFCC CX336600 CX669933 CX99CC66 CXCCFF99 CX663300 CX996633 CXCC9966 CXFFCC99 CX660033 CX993366 CXCC6699 CXFF99CC CX003366 CX663399 CX9966CC CXCC99FF CX003366 CX663399 CX9966CC CXCC99FF CX003366 CX663399 CX9966CC CXCC99FF CX003366 CX663399 CX9966CC CXCC99FF CX003366 CX663399 CX9966CC CXCC99FF black ) ; proc gcontour data=applianc.mandelbrot; Title 'Mandelbrot Set'; plot q*p=mesh / nolegend pattern join levels = 5 to 45 ; run;