Commit de155de9 authored by Deike Kleberg's avatar Deike Kleberg
Browse files

Interims solution, namespace has local file.

parent 03cbe474
......@@ -55,6 +55,7 @@ int nodeSizes[nNodes] = {1};
int nStreams = 4;
int streamSizes[4] = {2,5,1,3};
int vlistSizes[11] = {5,1,7,3,2,47,11,11,5,47,1 };
int hlf[] = { 1, 0 };
void modelRun ()
{
......@@ -72,11 +73,10 @@ void modelRun ()
int zaxisID3;
int taxisID2, taxisID3, taxisID4, taxisID5;
int instID, modelID;
int localtableID, nudgingtableID;
if ( ddebug >= 3 ) xdebug ( fnName );
namespaceSetNumber ( 2 );
namespaceInit ( 2, hlf );
namespaceSetActive ( 0 );
// Create a regular lon/lat grid
gridID = gridCreate(GRID_LONLAT, nlon*nlat);
......@@ -174,7 +174,7 @@ void modelRun ()
streamWriteVar(streamID, varID2, var2, nmiss);
}
reshArrayPrint ();
//reshArrayPrint ();
// Close the output stream
streamClose(streamID);
......@@ -185,7 +185,6 @@ void modelRun ()
zaxisDestroy(zaxisID1);
zaxisDestroy(zaxisID2);
gridDestroy(gridID);
return;
}
......@@ -215,7 +214,7 @@ int main (int argc, char *argv[])
modelRun ();
//pioFinalize ();
pioFinalize ();
#ifdef USE_MPI
MPI_Finalize ();
#endif
......
......@@ -205,7 +205,7 @@ extern "C" {
int pioInit ( int, int, int );
void pioFinalize ( void );
void namespaceSetNumber ( int );
void namespaceInit ( int, int * );
int namespaceGetNumber ( void );
void namespaceSetActive ( int );
int namespaceGetActive ( void );
......
......@@ -20,6 +20,7 @@ size_t getpagesize(void);
#include "file.h"
/* begin deike */
#include "namespace.h"
#ifdef USE_MPI
#include "pio.h"
......@@ -1066,12 +1067,15 @@ int fileOpen(const char *filename, const char *mode)
bfile_t *fileptr = NULL;
/* begin deike */
if ( ! namespaceHasLocalFile ( namespaceGetActive ()))
return 0;
#ifdef USE_MPI
if ( ! TEST_LOCAL )
if ( memcmp ( mode, "w", 1 ) == 0 && pioinfo->type != PIO_NONE )
return pioFileOpenW ( filename );
#endif
/* end deike */
/* end deike */
FILE_INIT
......@@ -1162,6 +1166,8 @@ int fileClose(int fileID)
bfile_t *fileptr;
/* begin deike */
if ( ! namespaceHasLocalFile ( namespaceGetActive ()))
return 0;
#ifdef USE_MPI
if ( ! TEST_LOCAL )
if ( pioinfo->type != PIO_NONE )
......
......@@ -4,9 +4,13 @@
#include <stdio.h>
#include "cdi.h"
#include "namespace.h"
#include "pio_util.h"
static int nNamespaces = 1;
static int activeNamespace;
static int activeNamespace = 0;
static int HLF = 1;
static int * hasLocalFile = &HLF;
enum {
intbits = sizeof(int) * CHAR_BIT,
......@@ -63,12 +67,26 @@ namespaceTuple_t namespaceIdxDecode ( int code )
}
void namespaceSetNumber ( int nspn )
void namespaceInit ( int nspn, int * argHasLocalFile )
{
int i;
assert(nspn <= NUM_NAMESPACES && nspn >= 1 );
nNamespaces = nspn;
if ( nspn > 1 )
{
hasLocalFile = xmalloc ( nspn * sizeof ( int ));
for ( i = 0; i < nspn; i++ ) hasLocalFile[i] = argHasLocalFile[i];
}
}
void namespaceCleanup ( void )
{
if ( nNamespaces > 1 ) free ( hasLocalFile );
}
int namespaceGetNumber ()
{
return nNamespaces;
......@@ -88,3 +106,12 @@ int namespaceGetActive ()
{
return activeNamespace;
}
int namespaceHasLocalFile ( int nId )
{
if ( nId >= nNamespaces || nId < 0 )
abort ();
return hasLocalFile[nId];
}
......@@ -7,9 +7,11 @@ typedef struct {
}namespaceTuple_t;
void namespaceShowbits ( int n, char *name );
int namespaceIdxEncode ( namespaceTuple_t tin );
int namespaceIdxEncode2 ( int, int );
namespaceTuple_t namespaceIdxDecode ( int code );
void namespaceShowbits ( int, char * );
int namespaceIdxEncode ( namespaceTuple_t );
int namespaceIdxEncode2 ( int, int );
namespaceTuple_t namespaceIdxDecode ( int );
int namespaceHasLocalFile ( int );
void namespaceCleanup ( void );
#endif
......@@ -16,6 +16,7 @@
#include "pio_rpc.h"
#include "pio_server.h"
#include "cdi.h"
#include "namespace.h"
#endif
/*****************************************************************************/
......@@ -79,6 +80,7 @@ MPI_Comm pioInit_c ( MPI_Comm comm, int nIOP, int mode )
{
IOServer ( commModel, mode );
commsIOCleanup ();
namespaceCleanup ();
MPI_Finalize ();
exit ( 0 );
}
......@@ -366,16 +368,17 @@ void pioFinalize ()
char fnName[] = "pioFinalize()";
int i, ibuffer = 1111;
if ( ddebug >= 1 )
myDebug ( __FILE__, fnName, __LINE__ );
if ( ddebug >= 1 ) xdebug ( fnName );
for ( i = 0; i < nProcsIO; i++ )
MPI_Send ( &ibuffer, 1, MPI_INT, nProcsCalc, FINALIZE, *( commsIO + i ));
commsIOCleanup ();
#endif
namespaceCleanup ();
return;
#endif
}
/************************************************************************/
......@@ -597,6 +597,7 @@ int streamOpen(const char *filename, const char *filemode, int filetype)
if ( ! filename || ! filemode || filetype < 0 ) return (CDI_EINVAL);
switch (filetype)
{
#if defined (HAVE_LIBGRIB)
......
......@@ -65,6 +65,7 @@ int grib2ltypeToZaxisType(int grib_ltype)
}
/* begin deike */
#include "namespace.h"
#ifdef USE_MPI
#include "pio.h"
......@@ -578,10 +579,15 @@ int grbWriteVarSliceDP(int streamID, int varID, int levelID, const double *data,
nbytes = grbSzip(filetype, gribbuffer, nbytes);
/* begin deike */
if ( ! namespaceHasLocalFile ( namespaceGetActive ()))
return 0;
#ifdef USE_MPI
if ( pioinfo->type != PIO_NONE && ! TEST_LOCAL )
nwrite = pioFileWrite ( fileID, tsID, gribbuffer, nbytes );
if ( ! TEST_LOCAL )
{
if ( pioinfo->type != PIO_NONE )
nwrite = pioFileWrite ( fileID, tsID, gribbuffer, nbytes );
}
else
nwrite = fileWrite(fileID, gribbuffer, nbytes);
#else
......
Supports Markdown
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