Skip to content

Commit

Permalink
Merge pull request ESMCI#1466 from NCAR/ejh_new_free_iosystem
Browse files Browse the repository at this point in the history
added PIOc_free_iosystem()
  • Loading branch information
edhartnett authored Jun 5, 2019
2 parents 56cd15b + ac9612b commit f96b039
Show file tree
Hide file tree
Showing 46 changed files with 81 additions and 58 deletions.
2 changes: 1 addition & 1 deletion examples/c/darray_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ int main(int argc, char* argv[])

/* Finalize the IO system. Only call this from the computation tasks. */
printf("%d %s Freeing PIO resources\n", my_rank, TEST_NAME);
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem(iosysid)))
ERR(ret);
} /* endif comp_task */

Expand Down
2 changes: 1 addition & 1 deletion examples/c/darray_no_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ int main(int argc, char* argv[])

/* Finalize the IO system. */
printf("rank: %d Freeing PIO resources...\n", my_rank);
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem(iosysid)))
ERR(ret);

/* Finalize the MPI library. */
Expand Down
4 changes: 2 additions & 2 deletions examples/c/examplePio.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ struct examplePioClass* epc_closeFile( struct examplePioClass* this )
This function frees the memory used in this example. It calls the
ParallelIO library function PIOc_freedecomp() to free
decomposition resources. Then calles PIOc_finalize() and
decomposition resources. Then calles PIOc_free_iosystem() and
MPI_finalize() to free library resources.
@param [in] this Pointer to self.
Expand All @@ -457,7 +457,7 @@ struct examplePioClass* epc_cleanUp( struct examplePioClass* this )
free(this->compdof);

PIOc_freedecomp(this->pioIoSystem, this->iodescNCells);
PIOc_finalize(this->pioIoSystem);
PIOc_free_iosystem(this->pioIoSystem);
MPI_Finalize();

return this;
Expand Down
6 changes: 5 additions & 1 deletion src/clib/pio.h
Original file line number Diff line number Diff line change
Expand Up @@ -840,9 +840,13 @@ extern "C" {
int PIOc_Init_Intracomm(MPI_Comm comp_comm, int num_iotasks, int stride, int base, int rearr,
int *iosysidp);

/* Shut down iosystem and free all associated resources. */
/** Shut down an iosystem and free all associated resources. Use
* PIOc_free_iosystem() instead. */
int PIOc_finalize(int iosysid);

/* Shut down an iosystem and free all associated resources. */
int PIOc_free_iosystem(int iosysid);

/* Set error handling for entire io system. */
int PIOc_Set_IOSystem_Error_Handling(int iosysid, int method);

Expand Down
18 changes: 18 additions & 0 deletions src/clib/pio_spmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,24 @@ int pio_swapm(void *sendbuf, int *sendcounts, int *sdispls, MPI_Datatype *sendty
return PIO_NOERR;
}

/**
* Clean up internal data structures, and free MPI resources,
* associated with an IOSystem. This is the old name for
* PIOc_free_iosystem(). This function is maintained for backward
* compatibility. Use PIOc_free_iosystem() for new code.
*
* @param iosysid: the io system ID provided by PIOc_Init_Intracomm()
* or PIOc_init_async().
* @returns 0 for success or non-zero for error.
* @ingroup PIO_finalize_c
* @author Jim Edwards, Ed Hartnett
*/
int
PIOc_finalize(int iosysid)
{
return PIOc_free_iosystem(iosysid);
}

/**
* Provides the functionality of MPI_Gatherv with flow control
* options. This function is not currently used, but we hope it will
Expand Down
9 changes: 5 additions & 4 deletions src/clib/pioc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1131,16 +1131,17 @@ PIOc_set_hint(int iosysid, const char *hint, const char *hintval)
}

/**
* Clean up internal data structures, free MPI resources, and exit the
* pio library.
* Clean up internal data structures, and free MPI resources,
* associated with an IOSystem.
*
* @param iosysid: the io system ID provided by PIOc_Init_Intracomm().
* @param iosysid: the io system ID provided by PIOc_Init_Intracomm()
* or PIOc_init_async().
* @returns 0 for success or non-zero for error.
* @ingroup PIO_finalize_c
* @author Jim Edwards, Ed Hartnett
*/
int
PIOc_finalize(int iosysid)
PIOc_free_iosystem(int iosysid)
{
iosystem_desc_t *ios;
int niosysid; /* The number of currently open IO systems. */
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_async_3proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ int main(int argc, char **argv)
/* Finalize the IO system. Only call this from the computation tasks. */
for (int c = 0; c < COMPONENT_COUNT; c++)
{
if ((ret = PIOc_finalize(iosysid[c])))
if ((ret = PIOc_free_iosystem(iosysid[c])))
ERR(ret);
}
} /* endif comp_task */
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_async_4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ int main(int argc, char **argv)

/* Finalize the IO system. Only call this from the computation tasks. */
for (int c = 0; c < COMPONENT_COUNT; c++)
if ((ret = PIOc_finalize(iosysid[c])))
if ((ret = PIOc_free_iosystem(iosysid[c])))
ERR(ret);
} /* endif comp_task */

Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_async_manyproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ int main(int argc, char **argv)

/* Finalize the IO system. Only call this from the computation tasks. */
for (int c = 0; c < COMPONENT_COUNT; c++)
if ((ret = PIOc_finalize(iosysid[c])))
if ((ret = PIOc_free_iosystem(iosysid[c])))
ERR(ret);
} /* endif comp_task */
} /* endif my_rank < TARGET_NTASKS */
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_async_mpi.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* This program tests some MPI functionality that is used in PIO. This
* runs on three processors, and does the same MPI commands that are
* done when async mode is used, with 1 IO task, and two computation
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_async_multi2.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ int main(int argc, char **argv)

/* Finalize the IO system. Only call this from the computation tasks. */
for (int c = 0; c < COMPONENT_COUNT; c++)
if ((ret = PIOc_finalize(iosysid[c])))
if ((ret = PIOc_free_iosystem(iosysid[c])))
ERR(ret);
} /* endif comp_task */
} /* endif my_rank < TARGET_NTASKS */
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_async_multicomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ int main(int argc, char **argv)

/* Finalize the IO system. Only call this from the computation tasks. */
for (int c = 0; c < COMPONENT_COUNT; c++)
if ((ret = PIOc_finalize(iosysid[c])))
if ((ret = PIOc_free_iosystem(iosysid[c])))
ERR(ret);
} /* endif comp_task */
} /* endif my_rank < TARGET_NTASKS */
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_async_perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ int main(int argc, char **argv)
return ret;

/* Finalize PIO system. */
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem(iosysid)))
return ret;

/* Free the computation conomponent communicator. */
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_async_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ int main(int argc, char **argv)

/* Finalize the IO system. Only call this from the computation tasks. */
for (int c = 0; c < COMPONENT_COUNT; c++)
if ((ret = PIOc_finalize(iosysid[c])))
if ((ret = PIOc_free_iosystem(iosysid[c])))
ERR(ret);
} /* endif comp_task */
} /* endif my_rank < TARGET_NTASKS */
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_common.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Common test code for PIO C tests.
*
* Ed Hartnett
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_darray.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ int main(int argc, char **argv)
return ret;

/* Finalize PIO system. */
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem(iosysid)))
return ret;
} /* next rearranger */
} /* endif my_rank < TARGET_NTASKS */
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_darray_1d.c
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ int main(int argc, char **argv)
}

/* Finalize PIO system. */
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem(iosysid)))
return ret;
} /* next rearranger */

Expand Down
4 changes: 2 additions & 2 deletions tests/cunit/test_darray_2sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ int run_async_tests(MPI_Comm test_comm, int my_rank, int num_iotypes, int *iotyp
ERR(ret);

/* Finalize PIO system. */
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem(iosysid)))
return ret;

/* Free the computation conomponent communicator. */
Expand Down Expand Up @@ -548,7 +548,7 @@ int run_noasync_tests(MPI_Comm test_comm, int my_rank, int num_iotypes, int *iot
ERR(ret);

/* Finalize PIO system. */
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem(iosysid)))
return ret;

return PIO_NOERR;
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_darray_3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ int main(int argc, char **argv)
return ret;

/* Finalize PIO system. */
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem(iosysid)))
return ret;

} /* next rearranger */
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_darray_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ int main(int argc, char **argv)
return ret;

/* Finalize PIO system. */
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem (iosysid)))
return ret;

/* Free the computation conomponent communicator. */
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_darray_async_many.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ int main(int argc, char **argv)
return ret;

/* Finalize PIO system. */
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem(iosysid)))
return ret;

/* Free the computation conomponent communicator. */
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_darray_async_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ int main(int argc, char **argv)
return ret;

/* Finalize PIO system. */
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem(iosysid)))
return ret;

/* Free the computation conomponent communicator. */
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_darray_fill.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ int main(int argc, char **argv)
} /* next fill value test case */

/* Finalize PIO iosysid. */
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem(iosysid)))
return ret;
} /* next rearranger */
} /* endif my_rank < TARGET_NTASKS */
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_darray_frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ int main(int argc, char **argv)
return ret;

/* Finalize PIO system. */
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem(iosysid)))
return ret;
} /* next rearranger */
} /* endif my_rank < TARGET_NTASKS */
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_darray_multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ int main(int argc, char **argv)
return ret;

/* Finalize PIO system. */
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem(iosysid)))
return ret;
} /* next rearranger */
} /* endif my_rank < TARGET_NTASKS */
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_darray_multivar.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ int main(int argc, char **argv)
return ret;

/* Finalize PIO system. */
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem(iosysid)))
return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_darray_multivar2.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ int main(int argc, char **argv)
return ret;

/* Finalize PIO system. */
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem(iosysid)))
return ret;

} /* endif my_rank < TARGET_NTASKS */
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_darray_multivar3.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ int main(int argc, char **argv)
ERR(ret);

/* Finalize PIO system. */
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem(iosysid)))
return ret;

} /* endif my_rank < TARGET_NTASKS */
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_decomp_frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ int main(int argc, char **argv)
} /* next rearranger */

/* Finalize PIO system. */
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem(iosysid)))
return ret;

} /* endif my_rank < TARGET_NTASKS */
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_decomp_uneven.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ int main(int argc, char **argv)
}

/* Finalize PIO system. */
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem(iosysid)))
return ret;

} /* next rearranger */
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_decomps.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ int main(int argc, char **argv)
ERR(ret);

/* Finalize PIO systems. */
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem(iosysid)))
ERR(ret);
} /* next io test */
} /* next rearranger */
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_intercomm2.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ int main(int argc, char **argv)
} /* next netcdf flavor */

/* Finalize the IO system. Only call this from the computation tasks. */
if ((ret = PIOc_finalize(iosysid[my_comp_idx])))
if ((ret = PIOc_free_iosystem(iosysid[my_comp_idx])))
ERR(ret);
}
} /* my_rank < TARGET_NTASKS */
Expand Down
6 changes: 3 additions & 3 deletions tests/cunit/test_iosystem2.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ int main(int argc, char **argv)
ERR(ret);

/* This should fail. */
if (PIOc_finalize(iosysid + TEST_VAL_42) != PIO_EBADID)
if (PIOc_free_iosystem(iosysid + TEST_VAL_42) != PIO_EBADID)
ERR(ERR_WRONG);

/* Initialize another PIO system. */
Expand Down Expand Up @@ -201,11 +201,11 @@ int main(int argc, char **argv)
MPIERR(ret);

/* Finalize PIO system. */
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem(iosysid)))
ERR(ret);

/* Finalize PIO system. */
if ((ret = PIOc_finalize(iosysid_world)))
if ((ret = PIOc_free_iosystem(iosysid_world)))
ERR(ret);
} /* my_rank < TARGET_NTASKS */

Expand Down
4 changes: 2 additions & 2 deletions tests/cunit/test_iosystem2_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,12 @@ int main(int argc, char **argv)
MPIERR(ret);

/* Finalize PIO odd/even intracomm. */
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem(iosysid)))
ERR(ret);


/* Finalize PIO world intracomm. */
if ((ret = PIOc_finalize(iosysid_world)))
if ((ret = PIOc_free_iosystem(iosysid_world)))
ERR(ret);
}/* my_rank < TARGET_NTASKS */

Expand Down
4 changes: 2 additions & 2 deletions tests/cunit/test_iosystem2_simple2.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ int main(int argc, char **argv)
MPIERR(ret);

/* Finalize PIO odd/even intracomm. */
if ((ret = PIOc_finalize(iosysid)))
if ((ret = PIOc_free_iosystem(iosysid)))
ERR(ret);

/* Finalize PIO world intracomm. */
if ((ret = PIOc_finalize(iosysid_world)))
if ((ret = PIOc_free_iosystem(iosysid_world)))
ERR(ret);
} /* my_rank < TARGET_NTASKS */

Expand Down
Loading

0 comments on commit f96b039

Please sign in to comment.