<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div>Dear all,<br><br></div>I'm
trying to use PnetCDF to store the variables (which are 3D arrays) of
my algorithm. Good news is that it seems much simpler than PHDF5 (which I
already implemented); bad news is that I have a MPI error at runtime I
cannot understand.<br>
</div><div>Please find both the error I get and the piece of code I
wrote below. It seems to me that it should be quite simple, but I cannot
figure out what is the problem.<br></div><div><br></div><div>Any help would be greatly appreciated!<br>
</div><div><br></div><div>Best,<br><br></div><div>MBR<br></div><div><br></div><div>The error I get is the following:<br>[mypc:18412] *** An error occurred in MPI_Type_create_subarray<br>[mypc:18412] *** on communicator MPI_COMM_WORLD<br>
[mypc:18412] *** MPI_ERR_ARG: invalid argument of some other kind<br>[mpyc:18412] *** MPI_ERRORS_ARE_FATAL: your MPI job will now abort<br></div><div><br>Here is a simplified version of the subroutine I wrote, which compiles without problems:<br>
<br></div>subroutine output(data,x,y,z,nout,myrank)<br></div> use pnetcdf<br></div><div> use mpi_var ! contains useful variables (idim, ni, etc. see below)<br></div><div><br></div> implicit none<br></div> include 'mpif.h'<br>
<br></div><div> ! idim,jdim,kdim are the number of elements in each dimension<br></div> real(dp),dimension(idim,jdim,kdim) :: data<br></div> real(dp), dimension(idim) :: x<br></div> real(dp), dimension(jdim) :: y<br>
</div>
real(dp), dimension(kdim) :: z<br></div> integer :: nout, myrank<br></div> character(LEN=*) :: filename<br><div><br></div><div> ! PnetCDF variables<br></div><div> integer(kind=MPI_OFFSET_KIND) :: nxtot, nytot, nztot<br>
</div><div> integer :: nout, ncid, xdimid, ydimid, zdimid<br></div><div> integer, dimension(3) :: sdimid<br></div><div> integer :: varid<br></div><div> integer(kind=MPI_OFFSET_KIND), dimension(3) :: dims, start, count<br>
<br></div><div> ! Dimensions; ni,nj,nk are the number of MPI threads per direction<br></div><div> nxtot = nx*ni<br></div><div> nytot = ny*nj<br></div><div> nztot = nz*nk<br><br></div><div> dims = (/ nx, ny, nz /)<br>
<br></div><div> ! Get filename; nout is the number of the current output<br></div><div> call get_filename(nout, filename)<br><br></div><div> ! Create filename<br></div><div> nout = nfmpi_create(MPI_COMM_WORLD, filename, NF_CLOBBER, MPI_INFO_NULL, ncid)<br>
<br> ! Define dimensions<br> nout = nfmpi_def_dim(ncid, "x", nxtot, xdimid)<br> nout = nfmpi_def_dim(ncid, "y", nytot, ydimid)<br> nout = nfmpi_def_dim(ncid, "z", nztot, zdimid)<br> sdimid = (/ xdimid, ydimid, zdimid /)<br>
<br></div><div> ! Create variable<br></div><div> nout = nfmpi_def_var(ncid, "var", NF_DOUBLE, 3, sdimid, varid)<br><br> ! End of definitions<br> nout = nfmpi_enddef(ncid)<br><br></div><div> ! {x,y,z}pos corresponds to the position of the MPI thread in a 3D cartesian grid<br>
</div><div> start = (/ xpos, ypos, zpos /)*dims<br> count = dims<br><br> ! Write data<br> nout = nfmpi_put_vara_double_all(ncid, varid, start, count, data)<br><br> ! Close file<br> nout = nfmpi_close(ncid)<br><br></div>
<div>end subroutine output<br></div></div>