Skip to content

Commit

Permalink
moving to async netcdf integration
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed Aug 22, 2019
1 parent 86ad446 commit ef98cca
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 23 deletions.
42 changes: 27 additions & 15 deletions src/clib/pioc_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -1922,6 +1922,22 @@ PIOc_writemap_from_f90(const char *file, int ndims, const int *gdims,
MPI_Comm_f2c(f90_comm));
}

/**
* Change the ncid of a file in the netCDF C library. This requires a
* knowledge of netCDF internals.
*
* @param ncidp Pointer to current ncid.
* @param pio_ncid The new ncid we want.
*
* @returns 0 for success, error code otherwise.
* @author Ed Hartnett
*/
int
change_ncid(int *ncidp, int pio_ncid)
{
return PIO_NOERR;
}

/**
* Create a new file using pio. This is an internal function that is
* called by both PIOc_create() and PIOc_createfile(). Input
Expand Down Expand Up @@ -2087,28 +2103,24 @@ PIOc_createfile_int(int iosysid, int *ncidp, int *iotype, const char *filename,
PLOG((3, "createfile bcast pio_next_ncid %d", pio_next_ncid));
}

/* Assign the PIO ncid. */
file->pio_ncid = pio_next_ncid++;

/* With the netCDF integration layer, the ncid is assigned for PIO
* by the netCDF dispatch layer code. So it is passed in. In
* normal PIO operation, the ncid is generated here. */
if (use_ext_ncid)
{
/* Use the ncid passed in from the netCDF dispatch code. */
file->pio_ncid = *ncidp;

/* To prevent PIO from reusing the same ncid, if someone
* starting mingling netcdf integration PIO and regular PIO
* code. */
pio_next_ncid = file->pio_ncid + 1;
/* The ncid was assigned on the computational
* processors. Change the ncid to one that I/O and
* computational components can agree on. */
if ((ierr = change_ncid(*ncidp, file->pio_ncid)))
return pio_err(NULL, file, ierr, __FILE__, __LINE__);
}
else
{
/* Assign the PIO ncid. */
file->pio_ncid = pio_next_ncid++;
PLOG((2, "file->fh = %d file->pio_ncid = %d", file->fh, file->pio_ncid));
PLOG((2, "file->fh = %d file->pio_ncid = %d", file->fh, file->pio_ncid));

/* Return the ncid to the caller. */
*ncidp = file->pio_ncid;
}
/* Return the ncid to the caller. */
*ncidp = file->pio_ncid;

/* Add the struct with this files info to the global list of
* open files. */
Expand Down
5 changes: 0 additions & 5 deletions tests/ncint/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ if RUN_TESTS
TESTS = run_tests.sh
endif # RUN_TESTS

# if RUN_TESTS
# # Tests will run from a bash script.
# TESTS = run_tests.sh
# endif # RUN_TESTS

# Distribute the test script.
EXTRA_DIST = run_tests.sh

Expand Down
2 changes: 1 addition & 1 deletion tests/ncint/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trap exit INT TERM

printf 'running PIO tests...\n'

PIO_TESTS='tst_pio_udf'
PIO_TESTS='tst_pio_udf tst_pio_async'

success1=true
success2=true
Expand Down
4 changes: 2 additions & 2 deletions tests/ncint/tst_pio_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ main(int argc, char **argv)
if (my_rank)
{
/* Create a file with a 3D record var. */
if (nc_create(FILE_NAME, NC_UDF0, &ncid)) PERR;
/* if (nc_create(FILE_NAME, NC_UDF0, &ncid)) PERR; */
/* if (nc_def_dim(ncid, DIM_NAME_UNLIMITED, dimlen[0], &dimid[0])) PERR; */
/* if (nc_def_dim(ncid, DIM_NAME_X, dimlen[1], &dimid[1])) PERR; */
/* if (nc_def_dim(ncid, DIM_NAME_Y, dimlen[2], &dimid[2])) PERR; */
Expand Down Expand Up @@ -106,7 +106,7 @@ main(int argc, char **argv)
/* if (data_in[i] != my_data[i]) PERR; */

/* Close file. */
if (nc_close(ncid)) PERR;
/* if (nc_close(ncid)) PERR; */

/* /\* Free resources. *\/ */
/* free(data_in); */
Expand Down

0 comments on commit ef98cca

Please sign in to comment.