diff --git a/src/mergemesh_pmmg.c b/src/mergemesh_pmmg.c index 95174dd4..a7821a28 100644 --- a/src/mergemesh_pmmg.c +++ b/src/mergemesh_pmmg.c @@ -1098,7 +1098,7 @@ int PMMG_gather_parmesh( PMMG_pParMesh parmesh, int **rcv_next_node_comm, PMMG_pExt_comm **rcv_ext_node_comm ) { - size_t pack_size_tot; + size_t pack_size_tot,next_disp; int *rcv_pack_size,ier,ier_glob,k,*displs,ier_pack; int nprocs,root,pack_size; char *rcv_buffer,*buffer,*ptr; @@ -1145,7 +1145,17 @@ int PMMG_gather_parmesh( PMMG_pParMesh parmesh, displs[0] = 0; for ( k=1; kINT_MAX){ + /* The displacements argument to MPI_Gatherv() is an array of int + * (signed) so the number of elements must be smaller than 2^31. + * To get around this we must pack more data in a single element + * or use multiple messages. + */ + fprintf(stderr, " ## Error: too many elements for MPI_Gatherv()\n"); + MPI_Abort(parmesh->comm, 1); /* error detected only on root */ + } + displs[k] = next_disp; } pack_size_tot = (size_t)(displs[nprocs-1])+(size_t)(rcv_pack_size[nprocs-1]); assert ( pack_size_tot < SIZE_MAX && "SIZE_MAX overflow" ); diff --git a/src/parmmg.h b/src/parmmg.h index 8fe336b1..a9a4d79b 100644 --- a/src/parmmg.h +++ b/src/parmmg.h @@ -289,12 +289,14 @@ static const int PMMG_MVIFCS_NLAYERS = 2; #define ERROR_AT(msg1,msg2) \ - fprintf( stderr, msg1 msg2 " function: %s, file: %s, line: %d \n", \ - __func__, __FILE__, __LINE__ ) + fprintf( stderr, "%s %s function: %s, file: %s, line: %d \n", \ + msg1, msg2, __func__, __FILE__, __LINE__ ) #define MEM_CHK_AVAIL(mesh,bytes,msg) do { \ if ( (mesh)->memCur + (bytes) > (mesh)->memMax ) { \ - ERROR_AT(msg," Exceeded max memory allowed: "); \ + char diag[1024]; \ + snprintf(diag, 1024, " Allocation of %ld bytes exceeds max %ld: ", bytes, (mesh)->memMax); \ + ERROR_AT(msg, diag); \ stat = PMMG_FAILURE; \ } else if ( (mesh)->memCur + (bytes) < 0 ) { \ ERROR_AT(msg," Tried to free more mem than allocated: " ); \