Commit 4573f9ce authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Refactor reshListPrint.

parent 92a1f01d
......@@ -171,7 +171,18 @@ defineModel(int instID)
modelDef(instID, 0, "myModel");
}
void modelRun ( MPI_Comm comm )
static void
printResources()
{
FILE *fp = fopen("reshArrayModel.txt", "w");
if (!fp)
xabort("%s", "could not open file");
reshListPrint(fp);
fclose(fp);
}
static void modelRun ( MPI_Comm comm )
{
int gridID, zaxisID, taxisID, instID, vlistID, streamID;
......@@ -204,7 +215,7 @@ void modelRun ( MPI_Comm comm )
differ = reshListCompare ( 0, 1 );
printf ( "The resource arrays %s.\n", differ ? "differ" : "are equal" );
reshListPrint ( "reshArrayModel" );
printResources();
pioNamespaceSetActive ( 0 );
streamClose(streamID);
......
......@@ -860,8 +860,6 @@ void pioEndDef ( void )
varsMapNDeco ( commInqNNodes (), commInqNodeSizes ());
reshListPrint ( "reshListModel" );
if ( rankGlob < commInqNProcsColl ())
{
MPI_Comm comm = commInqCommsIO ( rankGlob );
......
......@@ -928,9 +928,23 @@ void IOServer ()
reshUnpackResources(buffer, size, &commCalc);
xdebug("%s", "");
free ( buffer );
if ( ddebug > 0 && commInqRankGlob () == nProcsModel )
reshListPrint ( "reshListIOServer" );
serverWinCreate ();
{
int rankGlob = commInqRankGlob();
if ( ddebug > 0 && rankGlob == nProcsModel)
{
static const char baseName[] = "reshListIOServer.",
suffix[] = ".txt";
/* 9 digits for rank at most */
char buf[sizeof (baseName) + 9 + sizeof (suffix) + 1];
snprintf(buf, sizeof (buf), "%s%d%s", baseName, rankGlob,
suffix);
FILE *fp = fopen(buf, "w");
xassert(fp);
reshListPrint(fp);
fclose(fp);
}
}
serverWinCreate ();
break;
case WRITETS:
......
......@@ -154,9 +154,6 @@ void printArray ( const char *, char *, const void *, int, int, const char *, co
if ( ddebug == MAXDEBUG ) \
printArray ( debugString, ps, array, n, datatype, __func__, __FILE__, __LINE__ )
void reshListPrint ( char * );
#endif
/*
* Local Variables:
......
......@@ -588,36 +588,13 @@ int reshListCompare ( int nsp0, int nsp1 )
/**************************************************************/
void reshListPrint ( char * filename )
void reshListPrint(FILE *fp)
{
int i, j, temp;
listElem_t * curr;
FILE * fp;
LIST_INIT();
#ifdef USE_MPI
{
int root = 0;
if ( commInqIsProcIO () == 0 )
{
if ( commInqRankModel () != root ) return;
}
else if ( commInqRankPio () != root ) return;
}
#endif
if ( filename )
{
fp = fopen ( filename, "w" );
if ( ! fp )
{
xdebug("%s", "could not open file" );
fp = stdout;
}
}
else
fp = stdout;
temp = namespaceGetActive ();
......@@ -650,7 +627,6 @@ void reshListPrint ( char * filename )
fprintf ( fp, "#\n# end global resource list" \
"\n#\n##########################################\n\n" );
fclose ( fp );;
pioNamespaceSetActive ( temp );
}
......
......@@ -56,6 +56,7 @@ int reshGetStatus ( cdiResH, resOps * );
void reshLock ( void );
void reshUnlock ( void );
int reshListCompare(int nsp0, int nsp1);
void reshListPrint(FILE *fp);
#endif
/*
......
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