Commit 89f48364 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Let pioInit return on server processes for user cleanup.

parent 2e3a3772
......@@ -223,12 +223,15 @@ int main (int argc, char *argv[])
commModel = pioInit(commGlob, nProcsIO, IOMode, &pioNamespace, 1.0f,
cdiPioNoPostCommSetup);
pioNamespaceSetActive(pioNamespace);
if (commModel != MPI_COMM_NULL)
{
pioNamespaceSetActive(pioNamespace);
#endif
modelRun(commModel);
modelRun(commModel);
#ifdef USE_MPI
}
pioFinalize ();
xt_finalize();
MPI_Finalize ();
......
......@@ -30,6 +30,11 @@ PROGRAM collectdata2003
INTEGER, PARAMETER :: IOMode = PIO_FPGUARD
INTEGER ::commGlob, commModel, error, pio_namespace
#ifdef USE_MPI
LOGICAL :: run_model
#else
LOGICAL, PARAMETER :: run_model = .TRUE.
#endif
! Start parallel environment
#ifdef USE_MPI
......@@ -41,15 +46,16 @@ PROGRAM collectdata2003
! Initialize environment.
commModel = pioInit(commGlob, nProcsIO, IOMode, pio_namespace, 1.1, &
cdiPioNoPostCommSetup)
CALL pioNamespaceSetActive(pio_namespace)
run_model = commModel /= MPI_COMM_NULL
IF (run_model) CALL pioNamespaceSetActive(pio_namespace)
#endif
CALL modelrun ( commModel )
IF (run_model) CALL modelrun ( commModel )
#ifdef USE_MPI
! For parallel IO:
! Cleanup environment.
CALL pioFinalize ()
IF (run_model) CALL pioFinalize ()
CALL xt_finalize
CALL MPI_FINALIZE ( error )
#endif
......
......@@ -265,12 +265,15 @@ int main (int argc, char *argv[])
commModel = pioInit(commGlob, nProcsIO, IOMode, &pioNamespace, 1.0f,
cdiPioNoPostCommSetup);
pioNamespaceSetActive(pioNamespace);
if (commModel != MPI_COMM_NULL)
{
pioNamespaceSetActive(pioNamespace);
#endif
modelRun(commModel);
modelRun(commModel);
#ifdef USE_MPI
}
pioFinalize ();
xt_finalize();
MPI_Finalize ();
......
......@@ -202,12 +202,6 @@ void backendCleanup ( void )
/***************************************************************/
void backendFinalize ( void )
{
commDestroy ();
MPI_Finalize ();
exit ( EXIT_SUCCESS );
}
#endif
/*
* Local Variables:
......
......@@ -13,7 +13,6 @@
void backendCleanup ( void );
void backendInit(void (*postCommSetupActions)(void));
void backendFinalize ( void );
int pioFileOpen(const char *filename, const char *mode);
int pioFileClose ( int );
size_t cdiPioFileWrite(int fileID, const void *restrict buffer, size_t len,
......
......@@ -731,9 +731,7 @@ pioInit(MPI_Comm commGlob, int nProcsIO, int IOMode,
#endif
if ((xtInitByCDI = (!xt_initialized() || xt_finalized())))
{
xt_initialize(commGlob);
}
xt_initialize(commGlob);
commInit ();
commDefCommGlob ( commGlob );
sizeGlob = commInqSizeGlob ();
......@@ -765,10 +763,11 @@ pioInit(MPI_Comm commGlob, int nProcsIO, int IOMode,
namespaceSwitchSet(NSSWITCH_FILE_CLOSE, NSSW_FUNC(pioFileClose));
IOServer(postCommSetupActions);
namespaceDelete(0);
namespaceNew();
commDestroy ();
xt_finalize();
MPI_Finalize ();
exit ( EXIT_SUCCESS );
if (xtInitByCDI)
xt_finalize();
return MPI_COMM_NULL;
}
else
cdiPioClientSetup(&pioNamespace_, pioNamespace);
......@@ -845,6 +844,10 @@ void pioFinalize ( void )
#ifdef USE_MPI
int collID, ibuffer = 1111;
xdebug("%s", "START");
/* pioNamespace_ is unchanged on I/O servers */
if (pioNamespace_ == -1)
return;
namespaceDelete(pioNamespace_);
for ( collID = 0; collID < commInqNProcsColl (); collID++ )
{
......
......@@ -1055,8 +1055,8 @@ void IOServer(void (*postCommSetupActions)(void))
xdebug("%s", "START");
backendInit(postCommSetupActions);
if ( commInqRankNode () == commInqSpecialRankNode ())
backendFinalize ();
if (commInqRankNode() == commInqSpecialRankNode())
return;
commCalc = commInqCommCalc ();
#ifdef HAVE_PARALLEL_NC4
cdiPioEnableNetCDFParAccess();
......
......@@ -213,14 +213,17 @@ int main (int argc, char *argv[])
int pioNamespace;
commModel = pioInit(commGlob, nProcsIO, IOMode, &pioNamespace, 1.0,
cdiPioNoPostCommSetup);
pioNamespaceSetActive(pioNamespace);
if (commModel != MPI_COMM_NULL)
{
pioNamespaceSetActive(pioNamespace);
#else
commModel = -1;
commModel = -1;
#endif
modelRun (setup, commModel);
modelRun (setup, commModel);
#ifdef USE_MPI
}
pioFinalize ();
xt_finalize();
MPI_Finalize ();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment