I am using LAM/MPI version 6.5.6.
I tried "mpicc" also but it gave me the same error.
In /usr/include/mpi++.h: mpi++.h,v 1.1.1.1.2.2
Initially I tried it with 2 processes. It gave the same error. Then I
started checking using only 1 processor. If it would have worked i would
have tried again with 2 processes. i think the problem is datatype
"filetype" is not being created properly.
My code is :
int main( int argc, char *argv[] )
{
int gsizes, distribs, dargs, psizes, rank, size, m, n;
MPI_Datatype filetype;
int local_array_size, num_local_rows, num_local_cols;
int row_procs, col_procs, row_rank, col_rank;
MPI_File fh;
int *local_array;
MPI_Status status;
MPI_Init( &argc, &argv );
m = 1;
MPI_Comm_size( MPI_COMM_WORLD, &size );
if (size != 1)
{
printf( "Communicator size must be 6\n" );
MPI_Abort( MPI_COMM_WORLD, 1 );
}
num_local_rows = 1;
local_array = (int *) malloc( num_local_rows * sizeof(int) );
local_array[0] = 1;
gsizes = m; /* no. of rows in global array */
distribs = MPI_DISTRIBUTE_BLOCK; // block distribution
dargs = MPI_DISTRIBUTE_DFLT_DARG; // default block size
psizes = 1; // no. of processes in vertical dimension of process grid
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Type_create_darray(1, rank, 1, gsizes, distribs, dargs, psizes,
MPI_ORDER_C, MPI_INT, &filetype);
MPI_Type_commit(&filetype);
MPI_File_open(MPI_COMM_WORLD, "testfile", MPI_MODE_CREATE |
MPI_MODE_WRONLY, MPI_INFO_NULL, &fh); printf("5");
MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, "native",
MPI_INFO_NULL);
local_array_size = num_local_rows;
MPI_File_write_all(fh, local_array, local_array_size, MPI_INT,
&status);
MPI_File_close(&fh);
MPI_Finalize();
return 0;
}
If possible, please help.
Thanks in advance.
Bye
|