diff --git a/Cassiopee/XCore/XCore/AdaptMesh/MeshComm.cpp b/Cassiopee/XCore/XCore/AdaptMesh/MeshComm.cpp index 4fc2ad6f6..d52259080 100644 --- a/Cassiopee/XCore/XCore/AdaptMesh/MeshComm.cpp +++ b/Cassiopee/XCore/XCore/AdaptMesh/MeshComm.cpp @@ -150,7 +150,7 @@ E_Int *map_cell_graph(Mesh *M, E_Int *cwgts) E_Int *cmap = IntArray(M->nc); - if (M->pid == 0) puts("Partitionning graph..."); + if (M->pid == 0) puts("Partitioning graph..."); ret = SCOTCH_dgraphPart(&graph, M->npc, &strat, cmap); if (ret != 0) { @@ -191,6 +191,16 @@ struct xyz { static E_Int Mesh_redistribute(Mesh *M, E_Int *cmap) { + if (M->pid == 0) puts("Verifying mesh integrity..."); + + Mesh_set_orientation(M); + + if (M->pid == 0) { + puts("Mesh integrity OK"); + fflush(stdout); + } + + // Allocate contiguous count arrays E_Int count_size = M->npc; @@ -1507,4 +1517,4 @@ E_Int Mesh_load_balance(Mesh *M) MPI_Allreduce(&M->nf, &gnf, 1, XMPI_INT, MPI_SUM, MPI_COMM_WORLD); return gret; -} \ No newline at end of file +} diff --git a/Cassiopee/XCore/XCore/common/mem.cpp b/Cassiopee/XCore/XCore/common/mem.cpp index b6ff78614..a52017271 100644 --- a/Cassiopee/XCore/XCore/common/mem.cpp +++ b/Cassiopee/XCore/XCore/common/mem.cpp @@ -18,31 +18,36 @@ */ #include "mem.h" -void *xmalloc(size_t nbytes, const char *file, E_Int line) +void *xmalloc(E_Int nbytes, const char *file, E_Int line) { - assert(nbytes >= 0); - void *ptr = malloc(nbytes); - if (ptr == NULL && nbytes > 0) { - fprintf(stderr, "\n Failed to allocate %.2f MB in file %s, line " SF_D_ "\n\n", - nbytes/1000000., file, line); - assert(0); - //abort(); - } - return ptr; + if (nbytes < 0) { + fprintf(stderr, "trying to allocate a negative amount (%.2f) of bytes in file %s:%d\n", + nbytes/1000000.f, file, line); + abort(); + } + void *ptr = malloc(nbytes); + if (ptr == NULL && nbytes > 0) { + fprintf(stderr, "\n Failed to allocate %.2f MB in file %s, line " SF_D_ "\n\n", + nbytes/1000000., file, line); + abort(); + } + return ptr; } -void *xcalloc(size_t count, size_t size, const char *file, E_Int line) +void *xcalloc(E_Int count, E_Int size, const char *file, E_Int line) { - assert(count >= 0); - assert(size >= 0); - void *ptr = calloc(count, size); - if (ptr == NULL && size > 0) { - fprintf(stderr, "\n Failed to allocate %.2f MB in file %s, line " SF_D_ "\n\n", - count*size/1000000., file, line); - assert(0); - //abort(); - } - return ptr; + if (count < 0) { + fprintf(stderr, "xcalloc: count (%d) is negative in file %s:%d\n", count, file, line); + abort(); + } + + void *ptr = calloc(count, size); + if (ptr == NULL && size > 0) { + fprintf(stderr, "\n Failed to allocate %.2f MB in file %s, line " SF_D_ "\n\n", + count*size/1000000., file, line); + abort(); + } + return ptr; } void xfree(void *ptr, const char *file, E_Int line) @@ -53,16 +58,20 @@ void xfree(void *ptr, const char *file, E_Int line) } } -void *xresize(void *ptr, size_t nbytes, const char *file, E_Int line) +void *xresize(void *ptr, E_Int nbytes, const char *file, E_Int line) { - //assert(ptr); - assert(nbytes >= 0); - ptr = realloc(ptr, nbytes); - if (ptr == NULL && nbytes > 0) { - fprintf(stderr, "\n Failed to allocate %.2f MB in file %s, line " SF_D_ "\n\n", - nbytes/1000000., file, line); - assert(0); - //abort(); - } - return ptr; + + if (nbytes < 0) { + fprintf(stderr, "trying to resize to a negative amount (%.2f) of bytes in file %s:%d\n", + nbytes/1000000.f, file, line); + abort(); + } + + ptr = realloc(ptr, nbytes); + if (ptr == NULL && nbytes > 0) { + fprintf(stderr, "\n Failed to allocate %.2f MB in file %s, line " SF_D_ "\n\n", + nbytes/1000000., file, line); + abort(); + } + return ptr; } diff --git a/Cassiopee/XCore/XCore/common/mem.h b/Cassiopee/XCore/XCore/common/mem.h index 27c124eda..992af2fa4 100644 --- a/Cassiopee/XCore/XCore/common/mem.h +++ b/Cassiopee/XCore/XCore/common/mem.h @@ -34,9 +34,9 @@ #define XRESIZE(ptr, nbytes) \ xresize((ptr), (nbytes), __FILE__, __LINE__) -void *xmalloc(size_t , const char *, E_Int); -void *xcalloc(size_t, size_t, const char *, E_Int); +void *xmalloc(E_Int, const char *, E_Int); +void *xcalloc(E_Int, E_Int, const char *, E_Int); void xfree(void *, const char *, E_Int); -void *xresize(void *, size_t, const char *, E_Int); +void *xresize(void *, E_Int, const char *, E_Int); -#endif \ No newline at end of file +#endif