diff options
author | tradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a> | 2003-10-24 09:29:50 +0000 |
---|---|---|
committer | tradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a> | 2003-10-24 09:29:50 +0000 |
commit | d4b102046fd1bc4e39236c7e34424bc68a1b2827 (patch) | |
tree | f4411d2c303623d430b3cf838723dacc857c65e1 /src | |
parent | 7cecc5d27d922318ed3f91da65574916bfec0b85 (diff) |
Fixed a problem with recovering small distributed grid arrays
which have zero size on some processors.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOFlexIO/trunk@292 ebee0441-1374-4afa-a3b5-247f3ba15b9a
Diffstat (limited to 'src')
-rw-r--r-- | src/RestoreFile.c | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/src/RestoreFile.c b/src/RestoreFile.c index dbc1351..09ecea3 100644 --- a/src/RestoreFile.c +++ b/src/RestoreFile.c @@ -97,7 +97,7 @@ int IOFlexIOi_RecoverVariables (cGH *GH, fileinfo_t *file) pGExtras *extras; CCTK_INT info[3]; int dim, npoints, vtype; - void *buffer; + void *buffer, *data; int *chunkdims, *chunkorigin; int element_size, flexio_type; MPI_Datatype mpi_type; @@ -113,7 +113,7 @@ int IOFlexIOi_RecoverVariables (cGH *GH, fileinfo_t *file) ioUtilGH = CCTK_GHExtension (GH, "IO"); #ifdef CCTK_MPI - pughGH = (const pGH *) PUGH_pGH (GH); + pughGH = PUGH_pGH (GH); nprocs = CCTK_nProcs (GH); #endif @@ -213,9 +213,10 @@ int IOFlexIOi_RecoverVariables (cGH *GH, fileinfo_t *file) /* get the pGExtras pointer as a shortcut */ extras = ((pGA ***) pughGH->variables)[vindex][timelevel]->extras; + data = CCTK_VarDataPtrI (GH, timelevel, vindex); /* get the dimension of the variable */ - dim = CCTK_GroupDimI (CCTK_GroupIndexFromVarI (vindex)); + dim = CCTK_GroupDimFromVarI (vindex); chunkorigin = malloc (2*dim * sizeof (int)); chunkdims = chunkorigin + dim; @@ -224,26 +225,27 @@ int IOFlexIOi_RecoverVariables (cGH *GH, fileinfo_t *file) read others data into buffer and communicate it */ if (! file->unchunked || gtype == CCTK_SCALAR) { - FLEXIO_ERROR (IOread (file->fid, - CCTK_VarDataPtrI (GH, timelevel, vindex))); + FLEXIO_ERROR (IOread (file->fid, data)); } else { - for (i = 0; i < dim; i++) + if (extras->rnpoints[file->ioproc] > 0) { - chunkdims[i] = extras->rnsize[file->ioproc][i]; - chunkorigin[i] = extras->lb[file->ioproc][i]; - } + for (i = 0; i < dim; i++) + { + chunkdims[i] = extras->rnsize[file->ioproc][i]; + chunkorigin[i] = extras->lb[file->ioproc][i]; + } - FLEXIO_ERROR (IOreadChunk (file->fid, chunkdims, chunkorigin, - CCTK_VarDataPtrI (GH, timelevel, vindex))); + FLEXIO_ERROR (IOreadChunk (file->fid, chunkdims, chunkorigin,data)); + } } /* read data for non-IO processors */ if (gtype == CCTK_SCALAR) { npoints = 1; - buffer = CCTK_VarDataPtrI (GH, timelevel, vindex); + buffer = data; } else { @@ -256,7 +258,7 @@ int IOFlexIOi_RecoverVariables (cGH *GH, fileinfo_t *file) npoints = extras->rnpoints[file->ioproc + proc]; } } - buffer = malloc (npoints * element_size); + buffer = npoints > 0 ? malloc (npoints * element_size) : NULL; } for (proc = file->ioproc + 1; @@ -265,6 +267,8 @@ int IOFlexIOi_RecoverVariables (cGH *GH, fileinfo_t *file) { if (gtype != CCTK_SCALAR) { + npoints = extras->rnpoints[proc]; + if (! file->unchunked) { /* Also increment dataset counter here !!! */ @@ -279,7 +283,7 @@ int IOFlexIOi_RecoverVariables (cGH *GH, fileinfo_t *file) FLEXIO_ERROR (IOread (file->fid, buffer)); } - else + else if (npoints > 0) { for (i = 0; i < dim; i++) { @@ -290,20 +294,21 @@ int IOFlexIOi_RecoverVariables (cGH *GH, fileinfo_t *file) FLEXIO_ERROR (IOreadChunk (file->fid, chunkdims, chunkorigin, buffer)); } - - npoints = extras->rnpoints[proc]; } /* and finally send the index and the data */ info[0] = vindex; info[1] = timelevel; info[2] = npoints; CACTUS_MPI_ERROR (MPI_Send (info, 3, PUGH_MPI_INT, proc, STARTUPBASE, pughGH->PUGH_COMM_WORLD)); - CACTUS_MPI_ERROR (MPI_Send (buffer, npoints, mpi_type, proc, - STARTUPBASE, pughGH->PUGH_COMM_WORLD)); + if (npoints > 0) + { + CACTUS_MPI_ERROR (MPI_Send (buffer, npoints, mpi_type, proc, + STARTUPBASE, pughGH->PUGH_COMM_WORLD)); + } } /* free allocated chunk */ - if (gtype != CCTK_SCALAR) + if (buffer != data) { free (buffer); } @@ -353,10 +358,13 @@ int IOFlexIOi_RecoverVariables (cGH *GH, fileinfo_t *file) } /* receive following data from my IO processor */ - mpi_type = PUGH_MPIDataType (pughGH, CCTK_VarTypeI (vindex)); - CACTUS_MPI_ERROR (MPI_Recv (CCTK_VarDataPtrI (GH, timelevel, vindex), - npoints, mpi_type, file->ioproc, - STARTUPBASE, pughGH->PUGH_COMM_WORLD, &ms)); + if (npoints > 0) + { + mpi_type = PUGH_MPIDataType (pughGH, CCTK_VarTypeI (vindex)); + CACTUS_MPI_ERROR (MPI_Recv (CCTK_VarDataPtrI (GH, timelevel, vindex), + npoints, mpi_type, file->ioproc, + STARTUPBASE, pughGH->PUGH_COMM_WORLD, &ms)); + } } #endif } |