-1

Im trying to compile the below code in JDK but it doesnt seem to compile, i am getting error not a statement on line 41 even though it is.

The line causing error is:

long endTime = System.currentTimeMillis();

Here is the code:

import mpi.*;

public class MultidimMatrix {

public static final int N = 10;

public static void main (String args[]){

MPI.Init(args);

long startTime = System.currentTimeMillis();

int rank = MPI.COMM_WORLD.Rank();
int size = MPI.COMM_WORLD.Size();
int tag = 10, peer = (rank==0) ? 1:0;

if(rank == 0) {
double [][] a = new double [N][N];

for(int i = 0; i < N; i++)
    for(int j = 0; j < N; j++)
     a[i][j] = 10.0;

Object[] sendObjectArray = new Object[1];
sendObjectArray[0] = (Object) a;
MPI.COMM_WORLD.Send(sendObjectArray, 0, 1, MPI.OBJECT, peer, tag);
} else if(rank == 1){
double [][] b = new double [N][N];

for(int i = 0; i < N; i++)
for(int j = 0; j < N; i++)
b[i][j] = 0;

Object[] recvObjectArray = new Object[1];
MPI.COMM_WORLD.Recv(recvObjectArray, 0, 1, MPI.OBJECT, peer, tag);
b = (double[][]) recvObjectArray[0];

for(int i = 0; i < 4; i++){
for(int j = 0; j < N; i++)

long endTime = System.currentTimeMillis();
System.out.print(b[i][j]+"\t");
System.out.println("\n");
System.out.println("Calculated in " +
                           (endTime - startTime) + " milliseconds");
    }
    }
          MPI.Finalize() ;
        }
      }

Any help is greatly appreciated!

user3411002
  • 783
  • 3
  • 9
  • 27

1 Answers1

3

You have

for(int j = 0; j < N; i++)

should be

for(int j = 0; j < N; i++) {

You should keep your source formatted properly - most IDE's can do this automatically (on save or from keyboard command). This problem was obvious after formatting.

OldCurmudgeon
  • 64,482
  • 16
  • 119
  • 213