Skip to content

Commit

Permalink
Merge branch 'master' into ejh_even_more_docs_2
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett authored Jun 6, 2019
2 parents 4b7a1fa + cf2c4a7 commit e5190c8
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 169 deletions.
2 changes: 2 additions & 0 deletions cmake_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
#ifndef _PIO_CONFIG_
#define _PIO_CONFIG_
/* Set to avoid warning in intel19 compiler wrt strnlen */
#define _GNU_SOURCE

/** The major part of the version number. */
#define PIO_VERSION_MAJOR @VERSION_MAJOR@
Expand Down
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ AC_DEFINE([INCLUDE_CMAKE_FCI], [1], [defined by CMake build])
# All builds are on LINUX.
AC_DEFINE([LINUX], [1], [defined by CMake build])

# Define to solve intel compiler warning.
AC_DEFINE([_GNU_SOURCE], [1], [solve strnlen declared implicitly warning on intel compiler])

# Check for netCDF library.
AC_CHECK_LIB([netcdf], [nc_create], [], [AC_MSG_ERROR([Can't find or link to the netcdf library.])])

Expand Down
6 changes: 1 addition & 5 deletions src/clib/pio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions src/clib/pio_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
159 changes: 0 additions & 159 deletions src/clib/pioc_sc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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).
Expand Down
4 changes: 2 additions & 2 deletions tests/cunit/test_iosystem3.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ int main(int argc, char **argv)
int num_flavors; /* Number of PIO netCDF flavors in this build. */
int flavor[NUM_FLAVORS]; /* iotypes for the supported netCDF IO flavors. */
int rearranger[NUM_REARRANGERS] = {PIO_REARR_BOX, PIO_REARR_SUBSET};

/* Figure out iotypes. */
if ((ret = get_iotypes(&num_flavors, flavor)))
ERR(ret);
Expand Down Expand Up @@ -314,7 +314,7 @@ int main(int argc, char **argv)
ERR(ret);

} /* next iotype */

/* Finalize PIO systems. */
if (even_comm != MPI_COMM_NULL)
if ((ret = PIOc_free_iosystem(even_iosysid)))
Expand Down

0 comments on commit e5190c8

Please sign in to comment.