diff --git a/src/clib/pioc.c b/src/clib/pioc.c index eff9feba4ce..63462c5ff5b 100644 --- a/src/clib/pioc.c +++ b/src/clib/pioc.c @@ -693,8 +693,9 @@ int PIOc_init_decomp(int iosysid, int pio_type, int ndims, const int *gdimlen, i const PIO_Offset *compmap, int *ioidp, int rearranger, const PIO_Offset *iostart, const PIO_Offset *iocount) { - PIO_Offset compmap_1_based[maplen]; + PIO_Offset *compmap_1_based; int *rearrangerp = NULL; + int ret; LOG((1, "PIOc_init_decomp iosysid = %d pio_type = %d ndims = %d maplen = %d", iosysid, pio_type, ndims, maplen)); @@ -703,6 +704,10 @@ int PIOc_init_decomp(int iosysid, int pio_type, int ndims, const int *gdimlen, i if (rearranger) rearrangerp = &rearranger; + /* Allocate storage for compmap that's one-based. */ + if (!(compmap_1_based = malloc(sizeof(PIO_Offset) * maplen))) + return PIO_ENOMEM; + /* Add 1 to all elements in compmap. */ for (int e = 0; e < maplen; e++) { @@ -711,8 +716,12 @@ int PIOc_init_decomp(int iosysid, int pio_type, int ndims, const int *gdimlen, i } /* Call the legacy version of the function. */ - return PIOc_InitDecomp(iosysid, pio_type, ndims, gdimlen, maplen, compmap_1_based, - ioidp, rearrangerp, iostart, iocount); + ret = PIOc_InitDecomp(iosysid, pio_type, ndims, gdimlen, maplen, compmap_1_based, + ioidp, rearrangerp, iostart, iocount); + + free(compmap_1_based); + + return ret; } /** diff --git a/src/clib/pioc_support.c b/src/clib/pioc_support.c index edbdf5f5f37..ecf52c862a5 100644 --- a/src/clib/pioc_support.c +++ b/src/clib/pioc_support.c @@ -1154,7 +1154,10 @@ int PIOc_read_nc_decomp(int iosysid, const char *filename, int *ioidp, MPI_Comm /* Now initialize the iodesc on each task for this decomposition. */ if (!ret) { - PIO_Offset compmap[task_maplen[my_rank]]; + PIO_Offset *compmap; + + if (!(compmap = malloc(sizeof(PIO_Offset) * task_maplen[my_rank]))) + return PIO_ENOMEM; /* Copy array into PIO_Offset array. Make it 1 based. */ for (int e = 0; e < task_maplen[my_rank]; e++) @@ -1163,6 +1166,8 @@ int PIOc_read_nc_decomp(int iosysid, const char *filename, int *ioidp, MPI_Comm /* Initialize the decomposition. */ ret = PIOc_InitDecomp(iosysid, pio_type, ndims, global_dimlen, task_maplen[my_rank], compmap, ioidp, NULL, NULL, NULL); + + free(compmap); } /* Free resources. */ diff --git a/tests/cunit/test_perf2.c b/tests/cunit/test_perf2.c index 61d3099fca9..e42e4a45b8c 100644 --- a/tests/cunit/test_perf2.c +++ b/tests/cunit/test_perf2.c @@ -33,8 +33,8 @@ #define NDIM3 3 /* The length of our sample data along each dimension. */ -#define X_DIM_LEN 256 -#define Y_DIM_LEN 256 +#define X_DIM_LEN 512 +#define Y_DIM_LEN 512 #define Z_DIM_LEN 64 /* This is the length of the map for each task. */