From 42a43de8b37e85ddbeb57c60586b41dd22a86df8 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Thu, 6 Jun 2019 09:36:50 -0600 Subject: [PATCH 1/2] removed unused functions --- src/clib/pio.h | 6 +- src/clib/pioc_sc.c | 159 --------------------------------------------- 2 files changed, 1 insertion(+), 164 deletions(-) diff --git a/src/clib/pio.h b/src/clib/pio.h index bfe4cfb33a0..bdde365025f 100644 --- a/src/clib/pio.h +++ b/src/clib/pio.h @@ -1207,8 +1207,6 @@ extern "C" { int *buf); int PIOc_get_vard_float(int ncid, int varid, int decompid, const PIO_Offset recnum, float *buf); - /* int PIOc_get_vard_long(int ncid, int varid, int decompid, const PIO_Offset recnum, */ - /* long *buf); */ int PIOc_get_vard_double(int ncid, int varid, int decompid, const PIO_Offset recnum, double *buf); int PIOc_get_vard_uchar(int ncid, int varid, int decompid, const PIO_Offset recnum, @@ -1222,7 +1220,7 @@ extern "C" { int PIOc_get_vard_ulonglong(int ncid, int varid, int decompid, const PIO_Offset recnum, unsigned long long *buf); - /* Data writes - vara. */ + /* Data writes - vard. */ int PIOc_put_vard(int ncid, int varid, int decompid, const PIO_Offset recnum, const void *buf); int PIOc_put_vard_text(int ncid, int varid, int decompid, const PIO_Offset recnum, @@ -1233,8 +1231,6 @@ extern "C" { const short *op); int PIOc_put_vard_int(int ncid, int varid, int decompid, const PIO_Offset recnum, const int *op); - /* int PIOc_put_vard_long(int ncid, int varid, int decompid, const PIO_Offset recnum, */ - /* const long *op); */ int PIOc_put_vard_float(int ncid, int varid, int decompid, const PIO_Offset recnum, const float *op); int PIOc_put_vard_double(int ncid, int varid, int decompid, const PIO_Offset recnum, diff --git a/src/clib/pioc_sc.c b/src/clib/pioc_sc.c index f1d365db981..e5c5db4840f 100644 --- a/src/clib/pioc_sc.c +++ b/src/clib/pioc_sc.c @@ -46,33 +46,6 @@ long long lgcd(long long a, long long b) return lgcd(b % a, a); } -/** - * Return the gcd of elements in an int array. - * - * @param nain length of the array - * @param ain an array of length nain - * @returns greatest common divisor. - */ -int gcd_array(int nain, int *ain) -{ - int i; - int bsize = 1; - - for (i = 0; i < nain; i++) - if (ain[i] <= 1) - return bsize; - - bsize = ain[0]; - i = 1; - while (i < nain && bsize > 1) - { - bsize = gcd(bsize, ain[i]); - i++; - } - - return bsize; -} - /** * Return the greatest common devisor of array ain as int_64. * @@ -147,138 +120,6 @@ void compute_one_dim(int gdim, int ioprocs, int rank, PIO_Offset *start, *count = lcount; } -/** - * Look for the largest block of data for io which can be expressed in - * terms of start and count (account for gaps). - * - * @param arrlen - * @param arr_in - * @returns the size of the block - */ -PIO_Offset GCDblocksize_gaps(int arrlen, const PIO_Offset *arr_in) -{ - int numblks = 0; /* Number of blocks. */ - int numtimes = 0; /* Number of times adjacent arr_in elements differ by != 1. */ - int numgaps = 0; /* Number of gaps. */ - int j; /* Loop counter. */ - int ii; /* Loop counter. */ - int n; - PIO_Offset bsize; /* Size of the block. */ - PIO_Offset bsizeg; /* Size of gap block. */ - PIO_Offset blklensum; /* Sum of all block lengths. */ - PIO_Offset *del_arr = NULL; /* Array of deltas between adjacent elements in arr_in. */ - - /* Check inputs. */ - pioassert(arrlen > 0 && arr_in, "invalid input", __FILE__, __LINE__); - - if (arrlen > 1) - { - if (!(del_arr = malloc((arrlen - 1) * sizeof(PIO_Offset)))) - return pio_err(NULL, NULL, PIO_ENOMEM, __FILE__, __LINE__); - } - - /* Count the number of contiguous blocks in arr_in. If any if - these blocks is of size 1, we are done and can return. - Otherwise numtimes is the number of blocks. */ - for (int i = 0; i < arrlen - 1; i++) - { - del_arr[i] = arr_in[i + 1] - arr_in[i]; - if (del_arr[i] != 1) - { - numtimes++; - if ( i > 0 && del_arr[i - 1] > 1) - { - free(del_arr); - del_arr = NULL; - return(1); - } - } - } - - /* If numtimes is 0 the all of the data in arr_in is contiguous - * and numblks=1. Not sure why I have three different variables - * here, seems like n,numblks and numtimes could be combined. */ - numblks = numtimes + 1; - if (numtimes == 0) - n = numblks; - else - n = numtimes; - - /* If numblks==1 then the result is arrlen and you can return. */ - bsize = (PIO_Offset)arrlen; - if (numblks > 1) - { - PIO_Offset blk_len[numblks]; - PIO_Offset gaps[numtimes]; - - /* If numblks > 1 then numtimes must be > 0 and this if block - * isn't needed. */ - if (numtimes > 0) - { - ii = 0; - for (int i = 0; i < arrlen - 1; i++) - if (del_arr[i] > 1) - gaps[ii++] = del_arr[i] - 1; - numgaps = ii; - } - - /* If numblks > 1 then arrlen must be > 1 */ - PIO_Offset *loc_arr = calloc(arrlen - 1, sizeof(PIO_Offset)); - if (!loc_arr) - return pio_err(NULL, NULL, PIO_ENOMEM, __FILE__, __LINE__); - - j = 0; - /* If numblks > 1 then n must be <= (arrlen - 1) */ - for (int i = 0; i < n; i++) - loc_arr[i] = 1; - - for (int i = 0; i < arrlen - 1; i++) - if(del_arr[i] != 1) - loc_arr[j++] = i; - - /* This is handled differently from the Fortran version in PIO1, - * since array index is 1-based in Fortran and 0-based in C. - * Original Fortran code: blk_len(1) = loc_arr(1) - * Converted C code (incorrect): blk_len[0] = loc_arr[0]; - * Converted C code (correct): blk_len[0] = loc_arr[0] + 1; - * For example, if loc_arr[0] is 2, the first block actually - * has 3 elements with indices 0, 1 and 2. */ - blk_len[0] = loc_arr[0] + 1; - blklensum = blk_len[0]; - /* If numblks > 1 then numblks must be <= arrlen */ - for(int i = 1; i < numblks - 1; i++) - { - blk_len[i] = loc_arr[i] - loc_arr[i - 1]; - blklensum += blk_len[i]; - } - free(loc_arr); - loc_arr = NULL; - blk_len[numblks - 1] = arrlen - blklensum; - - /* Get the GCD in blk_len array. */ - bsize = lgcd_array(numblks, blk_len); - - /* I don't recall why i needed these next two blocks, I - * remember struggling to get this right in all cases and I'm - * afraid that the end result is that bsize is almost always - * 1. */ - if (numgaps > 0) - { - bsizeg = lgcd_array(numgaps, gaps); - bsize = lgcd(bsize, bsizeg); - } - - /* ??? */ - if (arr_in[0] > 0) - bsize = lgcd(bsize, arr_in[0]); - } - - free(del_arr); - del_arr = NULL; - - return bsize; -} - /** * Look for the largest block of data for io which can be expressed in * terms of start and count (ignore gaps). From c37033647360df406c01f2414cd03225f4e17ce7 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Thu, 6 Jun 2019 10:05:47 -0600 Subject: [PATCH 2/2] removed unneeded prototype for removed function --- src/clib/pio_internal.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/clib/pio_internal.h b/src/clib/pio_internal.h index 09ee497ab5b..2cac4d3da96 100644 --- a/src/clib/pio_internal.h +++ b/src/clib/pio_internal.h @@ -255,9 +255,6 @@ extern "C" { /* Find greatest commond divisor for long long. */ long long lgcd (long long a, long long b ); - /* Find greatest commond divisor in an array. */ - int gcd_array(int nain, int *ain); - /* Convert a global coordinate value into a local array index. */ PIO_Offset coord_to_lindex(int ndims, const PIO_Offset *lcoord, const PIO_Offset *count);