+ Barrier barr;
+ barr = new Barrier("128.195.175.84");
+ double[] col_k, col_j;
+ double t;
+ int j,k,kp1,l,nm1;
+ int info;
+ int slice,ilow,iupper;
+ // gaussian elimination with partial pivoting
+ info = 0;
+ int nlocal;
+ int lid;
+ atomic {
+ //System.printString("Atomic #1\t");
+ nlocal=n;
+ lid=id;
+ }
+
+
+ nm1 = nlocal - 1;
+ if (nm1 >= 0) {
+ //System.printString("nm1 = " +nm1+ "\n");
+ for (k = 0; k < nm1; k++) {
+ atomic {
+ //System.printString("Atomic #2\t");
+ col_k = a[k];
+ kp1 = k + 1;
+ // find l = pivot index
+ l = idamax(nlocal-k,col_k,k,1) + k;
+ if(lid==0) {
+ ipvt[k] = l;
+ }
+ }
+ // synchronise threads
+ Barrier.enterBarrier(barr);
+
+ // zero pivot implies this column already triangularized
+ boolean b;
+ atomic {
+ //System.printString("Atomic #3\t");
+ b=col_k[l]!=0;
+ }
+ if (b) {
+ Barrier.enterBarrier(barr);
+ // interchange if necessary
+ if(lid == 0 ) {
+ if (l != k) {
+ atomic {
+ t = col_k[l];
+ col_k[l] = col_k[k];
+ col_k[k] = t;
+ }
+ }
+ }
+ // synchronise threads
+ Barrier.enterBarrier(barr);
+ // compute multipliers
+ // t = -1.0/col_k[k];
+ if(lid == 0) {
+ atomic {
+ t = -1.0/col_k[k];
+ dscal(nlocal-(kp1),t,col_k,kp1,1);
+ }
+ }
+
+ // synchronise threads
+ Barrier.enterBarrier(barr);
+
+ // row elimination with column indexing
+ atomic {
+ //System.printString("Atomic #4\t");
+ slice = ((nlocal-kp1) + nthreads-1)/nthreads;
+ ilow = (lid*slice)+kp1;
+ iupper = ((lid+1)*slice)+kp1;
+ if (iupper > nlocal ) iupper=nlocal;
+ if (ilow > nlocal ) ilow=nlocal;
+ //System.printString("ilow= " + ilow + " iupper= " + iupper + "\n");
+ for (j = ilow; j < iupper; j++) {
+ col_j = a[j];
+ t = col_j[l];
+ if (l != k) {
+ col_j[l] = col_j[k];
+ col_j[k] = t;
+ }
+ daxpy(nlocal-(kp1),t,col_k,kp1,1,
+ col_j,kp1,1);
+ }
+ }
+
+ // synchronise threads
+ Barrier.enterBarrier(barr);
+ } else {
+ info = k;
+ }
+ Barrier.enterBarrier(barr);