/* We don't need to do a regular test of execute, since it just calls EscapedRoutine_RemoveFromSwarm.
 * However, since this is the main public function, test if it can correctly catch bad input data */
void EscapedRoutineSuite_TestExecuteBadInput( EscapedRoutineSuiteData* data ) {
   stJournal->enable = False;
   stJournal->firewallProtected = False;
   pcu_check_assert( Stg_Component_Execute( data->escRoutine, NULL, True ) ); 
   pcu_check_assert( Stg_Component_Execute( data->escRoutine, stJournal, True ) );
   stJournal->enable = True;
   stJournal->firewallProtected = True;
}
예제 #2
0
void Stg_ComponentFactory_ExecuteComponents( Stg_ComponentFactory* self, void* data ) {
   Stg_Component*                         component                    = NULL;
   Index                                  component_I;
   Stream*                                stream;
   
   assert( self );
   
   stream = self->infoStream;

   if( self->componentDict ){
      Journal_Printf( stream, "\nExecuting Stg_Components from the live-component register\n\n" );
      Stream_Indent( stream );
   
      for( component_I = 0; component_I < LiveComponentRegister_GetCount( self->LCRegister ); component_I++ ){
         /* Grab component from register */
         component = LiveComponentRegister_At( self->LCRegister, component_I );
         if( component && !component->hasExecuted ){
            Stg_Component_Execute( component, data, True );
         }
      }
      Stream_UnIndent( stream );
   }
   else{
      Journal_Printf( stream, "No Stg_ComponentList found..!\n" );
   }
}
예제 #3
0
void _GeneralSwarm_UpdateHook( void* timeIntegrator, void* swarm )
{
   GeneralSwarm* self = (GeneralSwarm*)swarm;
   Index                cell;
   Index                point_I;
   GlobalParticle*      particle;

   /* Need to check for escaped particles before the next block. */
   if ( self->escapedRoutine )
   {
      Stg_Component_Execute( self->escapedRoutine, self, True );
   }

   /* Check that particles have not exited the box after advection */
   if ( self->swarmAdvector  )
   {
      for ( point_I = 0; point_I < self->particleLocalCount; ++point_I )
      {
         particle = (GlobalParticle*)Swarm_ParticleAt( self, point_I );
         cell = particle->owningCell;
         Journal_Firewall(
            cell < self->cellLocalCount,
            Journal_MyStream( Error_Type, self ),
            "In func %s: GlobalParticle '%d' outside element. Coord = {%g, %g, %g}\n",
            __func__,
            point_I,
            particle->coord[ I_AXIS ],
            particle->coord[ J_AXIS ],
            particle->coord[ K_AXIS ] );
      }
   }

}
예제 #4
0
int BMI_Run_model (BMI_Model *self)
{

    
	/* Step the context solver */
	Stg_Component_Execute( self->snacContext, 0 /* dummy */, False );
	
    
    return BMI_SUCCESS;
}
예제 #5
0
PyObject* Context_Python_Execute( PyObject* self, PyObject* args ) {
	PyObject*	pyContext;
	Context*	context;
	
	/* Obtain arguements */
	if( !PyArg_ParseTuple( args, "O:", &pyContext ) ) {
		return NULL;
	}
	context = (Context*)( PyCObject_AsVoidPtr( pyContext ) );
	
	/* Run function */
	Stg_Component_Execute( context, 0 /* dummy */, False );
	
	/* Return */
	Py_INCREF( Py_None );
	return Py_None;
}
void SwarmOutputSuite_TestSwarmOutput( SwarmOutputSuiteData* data ) {
   int procToWatch = data->nProcs > 1 ? 1 : 0;

   if( data->rank == procToWatch ) {
      Dictionary*                dictionary;
      Dictionary*                componentDict;
      Stg_ComponentFactory*      cf;
      DomainContext*             context;
      char                       input_file[PCU_PATH_MAX];
      Swarm*                     swarm;
      SwarmOutput*               swarmOutput;
      SpaceFillerParticleLayout* particleLayout;

      pcu_filename_input( "testSwarmOutput.xml", input_file );
      cf = stgMainInitFromXML( input_file, data->comm, NULL );
      context = (DomainContext*) LiveComponentRegister_Get( cf->LCRegister, (Name)"context" );
      dictionary = context->dictionary;

      Journal_ReadFromDictionary( dictionary );
      stgMainBuildAndInitialise( cf  );

      ContextEP_Append( context, AbstractContext_EP_Dt, SwarmOutputSuite_Dt );
      ContextEP_Append( context, AbstractContext_EP_Step, SwarmOutputSuite_MoveParticles );

      componentDict = Dictionary_GetDictionary( dictionary, "components" );
      assert( componentDict );

      AbstractContext_Dump( context );
      Stg_Component_Execute( context, 0, False );

      particleLayout = (SpaceFillerParticleLayout*) LiveComponentRegister_Get( context->CF->LCRegister, (Name)"particleLayout" );
      swarmOutput = (SwarmOutput* ) LiveComponentRegister_Get( context->CF->LCRegister, (Name)"swarmOutput" );
      swarm = (Swarm* ) LiveComponentRegister_Get( context->CF->LCRegister, (Name)"swarm" );

      pcu_check_true( particleLayout->isConstructed && particleLayout->isBuilt && particleLayout->isInitialised );
      pcu_check_true( swarmOutput->isConstructed && swarmOutput->isBuilt && swarmOutput->isInitialised );
      pcu_check_true( swarm->isConstructed && swarm->isBuilt && swarm->isInitialised  );

      pcu_check_streq( swarm->name, swarmOutput->swarm->name );

      stgMainDestroy( cf );
   }
}
예제 #7
0
void stgMainLoop( Stg_ComponentFactory* cf ) {
   /* Run (Solve) phase. */

   /* 
    * Do this by running the contexts, 
    * which manage the entry points which call the _Execute() funcs for the other components.
    */
   unsigned component_i;
   Stg_Component* component;
   AbstractContext* context;
   
   for( component_i = 0; component_i < LiveComponentRegister_GetCount( cf->LCRegister ); component_i++ ) {
      component = LiveComponentRegister_At( cf->LCRegister, component_i );
      if( Stg_CompareType( component, AbstractContext ) ) { 
         context = (AbstractContext*)component;
         Stg_Component_Execute( context, 0, True );
      }
   }
}
int main( int argc, char* argv[] ) {
	MPI_Comm CommWorld;
	int rank;
	int numProcessors;
	int procToWatch;
	Dictionary* dictionary;
	AbstractContext* abstractContext;
	
	/* Initialise MPI, get world info */
	MPI_Init( &argc, &argv );
	MPI_Comm_dup( MPI_COMM_WORLD, &CommWorld );
	MPI_Comm_size( CommWorld, &numProcessors );
	MPI_Comm_rank( CommWorld, &rank );
	
	BaseFoundation_Init( &argc, &argv );
	BaseIO_Init( &argc, &argv );
	BaseContainer_Init( &argc, &argv );
	BaseAutomation_Init( &argc, &argv );
	BaseExtensibility_Init( &argc, &argv );
	BaseContext_Init( &argc, &argv );
	stream = Journal_Register (Info_Type, "myStream");

	/* Redirect the error stream to stdout, so we can check warnings
	appear correctly */
	Stream_SetFileBranch( Journal_GetTypedStream( ErrorStream_Type ), stJournal->stdOut );

	if( argc >= 2 ) {
		procToWatch = atoi( argv[1] );
	}
	else {
		procToWatch = 0;
	}
	if( rank == procToWatch ) Journal_Printf( (void*) stream, "Watching rank: %i\n", rank );

	/* Read input */
	dictionary = Dictionary_New();
	dictionary->add( dictionary, "rank", Dictionary_Entry_Value_FromUnsignedInt( rank ) );
	dictionary->add( dictionary, "numProcessors", Dictionary_Entry_Value_FromUnsignedInt( numProcessors ) );
	
	/* Build the context */
	abstractContext = _AbstractContext_New( 
		sizeof(AbstractContext), 
		"TestContext", 
		MyDelete, 
		MyPrint, 
		NULL,
		NULL, 
		NULL, 
		_AbstractContext_Build, 
		_AbstractContext_Initialise, 
		_AbstractContext_Execute, 
		_AbstractContext_Destroy, 
		"context", 
		True, 
		MySetDt, 
		0, 
		10, 
		CommWorld, 
		dictionary );

	/* add hooks to existing entry points */
	ContextEP_Append( abstractContext, AbstractContext_EP_Dt, MyDt );

	if( rank == procToWatch ) {
		Stream* stream = Journal_Register( InfoStream_Type, AbstractContext_Type );
		Stg_Component_Build( abstractContext, 0 /* dummy */, False );
		Stg_Component_Initialise( abstractContext, 0 /* dummy */, False );
		Context_PrintConcise( abstractContext, stream );
		Stg_Component_Execute( abstractContext, 0 /* dummy */, False );
		Stg_Component_Destroy( abstractContext, 0 /* dummy */, False );
	}
	
	/* Stg_Class_Delete stuff */
	Stg_Class_Delete( abstractContext );
	Stg_Class_Delete( dictionary );
	
	BaseContext_Finalise();
	BaseExtensibility_Finalise();
	BaseAutomation_Finalise();
	BaseContainer_Finalise();
	BaseIO_Finalise();
	BaseFoundation_Finalise();
	
	/* Close off MPI */
	MPI_Finalize();
	
	return 0; /* success */
}
예제 #9
0
파일: main.c 프로젝트: bmi-forum/bmi-pyre
/* Main */
int main( int argc, char* argv[] ) {
	MPI_Comm			CommWorld;
	int				rank;
	int				numProcessors;
	int				procToWatch;
	Dictionary*			dictionary;
	Dictionary*			componentDict;
	XML_IO_Handler*			ioHandler;
	char*				filename;
	Snac_Context*			snacContext;
	int				tmp;

	/* Initialise MPI, get world info */
	MPI_Init( &argc, &argv );
	MPI_Comm_dup( MPI_COMM_WORLD, &CommWorld );
	MPI_Comm_size( CommWorld, &numProcessors );
	MPI_Comm_rank( CommWorld, &rank );
	if( argc >= 3 ) {
		procToWatch = atoi( argv[2] );
	}
	else {
		procToWatch = 0;
	}
	if( rank == procToWatch ) printf( "Watching rank: %i\n", rank );
	
	if (!Snac_Init( &argc, &argv )) {
		fprintf(stderr, "Error initialising StGermain, exiting.\n" );
		exit(EXIT_FAILURE);
	}
	
	/* Snac's init message */
	tmp = Stream_GetPrintingRank( Journal_Register( InfoStream_Type, "Context" ) );
	Stream_SetPrintingRank( Journal_Register( InfoStream_Type, "Context" ), 0 );
	Journal_Printf( /* DO NOT CHANGE OR REMOVE */
		Journal_Register( InfoStream_Type, "Context" ), 
		"Snac. Copyright (C) 2003-2005 Caltech, VPAC & University of Texas.\n" );
	Stream_Flush( Journal_Register( InfoStream_Type, "Context" ) );
	Stream_SetPrintingRank( Journal_Register( InfoStream_Type, "Context" ), tmp );
	MPI_Barrier( CommWorld ); /* Ensures copyright info always come first in output */
	
	
	/* Create the dictionary, and some fixed values */
	dictionary = Dictionary_New();
	Dictionary_Add( dictionary, "rank", Dictionary_Entry_Value_FromUnsignedInt( rank ) );
	Dictionary_Add( dictionary, "numProcessors", Dictionary_Entry_Value_FromUnsignedInt( numProcessors ) );
	
	/* Read input */
	ioHandler = XML_IO_Handler_New();
	if( argc >= 2 ) {
		filename = strdup( argv[1] );
	}
	else {
		filename = strdup( "input.xml" );
	}
	if ( False == IO_Handler_ReadAllFromFile( ioHandler, filename, dictionary ) )
	{
		fprintf( stderr, "Error: Snac couldn't find specified input file %s. Exiting.\n", filename );
		exit( EXIT_FAILURE );
	}
	Journal_ReadFromDictionary( dictionary );

	snacContext = Snac_Context_New( 0.0f, 0.0f, sizeof(Snac_Node), sizeof(Snac_Element), CommWorld, dictionary );
	if( rank == procToWatch ) Dictionary_PrintConcise( dictionary, snacContext->verbose );


	/* Construction phase -----------------------------------------------------------------------------------------------*/
	Stg_Component_Construct( snacContext, 0 /* dummy */, &snacContext, True );
	
	/* Building phase ---------------------------------------------------------------------------------------------------*/
	Stg_Component_Build( snacContext, 0 /* dummy */, False );
	
	/* Initialisaton phase ----------------------------------------------------------------------------------------------*/
	Stg_Component_Initialise( snacContext, 0 /* dummy */, False );
	if( rank == procToWatch ) Context_PrintConcise( snacContext, snacContext->verbose );
	
	/* Step the context solver */
	Stg_Component_Execute( snacContext, 0 /* dummy */, False );
	
	/* Stg_Class_Delete stuff */
	Stg_Component_Destroy( snacContext, 0 /* dummy */, False );
	Stg_Class_Delete( snacContext );
	free( filename );
	Stg_Class_Delete( ioHandler );
	
	Stg_Class_Delete( dictionary );
	
	/* Close off frameworks */
	Snac_Finalise();
	MPI_Finalize();
	
	return 0; /* success */
}
void TimeIntegrationSuite_TestDriver( TimeIntegrationSuiteData* data, char *_name, char *_DerivName0, char *_DerivName1, int _order ) {
   Stg_ComponentFactory* cf;
   Stream*               stream;
   Dictionary*           dictionary;
   TimeIntegrator*       timeIntegrator;
   TimeIntegrand*        timeIntegrand;
   TimeIntegrand*        timeIntegrandList[2];
   DomainContext*        context;
   Variable*             variable;
   Variable*             variableList[2];
   double*               array;
   double*               array2;
   Index                 size0 = 11;
   Index                 size1 = 7;
   Index                 array_I;
   Index                 timestep = 0;
   Index                 maxTimesteps = 10;
   Bool                  simultaneous;
   unsigned              order;
   double                error = 0.0;
   Name                  derivName;
   double                tolerance = 0.001;
   Index                 integrand_I;
   Index                 integrandCount = 2;
   char                  expected_file[PCU_PATH_MAX];

   dictionary = Dictionary_New();
   Dictionary_Add( dictionary, (Dictionary_Entry_Key)"outputPath", Dictionary_Entry_Value_FromString("./output") );
   Dictionary_Add( dictionary, (Dictionary_Entry_Key)"DerivName0", Dictionary_Entry_Value_FromString(_DerivName0) );
   Dictionary_Add( dictionary, (Dictionary_Entry_Key)"DerivName1", Dictionary_Entry_Value_FromString(_DerivName1) );

   context = DomainContext_New( "context", 0, 0, MPI_COMM_WORLD, NULL );
   cf = stgMainConstruct( dictionary, NULL, data->comm, context );
   stgMainBuildAndInitialise( cf );
      
   ContextEP_Append( context, AbstractContext_EP_Dt, TimeIntegrationSuite_GetDt );

   /* Create Stuff */
   order = _order;
   simultaneous = False;
   variableList[0] = Variable_NewVector( "testVariable", (AbstractContext*)context, Variable_DataType_Double, 2, &size0, NULL, (void**)&array, NULL );
   variableList[1] = Variable_NewVector( "testVariable2", (AbstractContext*)context, Variable_DataType_Double, 2, &size1, NULL, (void**)&array2, NULL );
   timeIntegrator = TimeIntegrator_New( "testTimeIntegrator", order, simultaneous, NULL, NULL );
   timeIntegrator->context = context;
   timeIntegrandList[0] = TimeIntegrand_New( "testTimeIntegrand0", context, timeIntegrator, variableList[0], 0, NULL, True );
   timeIntegrandList[1] = TimeIntegrand_New( "testTimeIntegrand1", context, timeIntegrator, variableList[1], 0, NULL, True );

   Journal_Enable_AllTypedStream( True );
   stream = Journal_Register( Info_Type, (Name)"EulerStream"  );
   Stream_RedirectFile( stream, _name );

   Stream_Enable( timeIntegrator->info, False );
   derivName = Dictionary_GetString( dictionary, (Dictionary_Entry_Key)"DerivName0" );
   timeIntegrandList[0]->_calculateTimeDeriv = TimeIntegrationSuite_GetFunctionPtr( derivName  );
   Journal_Printf( stream, "DerivName0 - %s\n", derivName );
   derivName = Dictionary_GetString( dictionary, (Dictionary_Entry_Key)"DerivName1" );
   timeIntegrandList[1]->_calculateTimeDeriv = TimeIntegrationSuite_GetFunctionPtr( derivName  );
   Journal_Printf( stream, "DerivName1 - %s\n", derivName );

   /* Print Stuff to file */
   Journal_PrintValue( stream, order );
   Journal_PrintBool( stream, simultaneous );

   /* Add stuff to EPs */
   TimeIntegrator_AppendSetupEP( timeIntegrator, "start1", TimeIntegrationSuite_TestContextType, CURR_MODULE_NAME, context );
   TimeIntegrator_AppendFinishEP( timeIntegrator, "finish1", TimeIntegrationSuite_TestVariableType, CURR_MODULE_NAME, variableList[0] );
   TimeIntegrator_PrependSetupEP( timeIntegrator, "start0", TimeIntegrationSuite_TestVariableType, CURR_MODULE_NAME, variableList[0] );
   TimeIntegrator_PrependFinishEP( timeIntegrator, "finish0", TimeIntegrationSuite_TestContextType, CURR_MODULE_NAME, context );

   /* Build */
   Stg_Component_Build( variableList[0], context, False );
   Stg_Component_Build( variableList[1], context, False );
   Stg_Component_Build( timeIntegrator, context, False );
   Stg_Component_Build( timeIntegrandList[0], context, False );
   Stg_Component_Build( timeIntegrandList[1], context, False );
   array = Memory_Alloc_Array( double, 2 * size0, "name" );
   array2 = Memory_Alloc_Array( double, 2 * size1, "name" );

   /* Initialise */
   memset( array, 0, sizeof(double) * 2 * size0 );
   memset( array2, 0, sizeof(double) * 2 * size1 );
   Stg_Component_Initialise( timeIntegrator, context, False );
   Stg_Component_Initialise( variableList[0], context, False );
   Stg_Component_Initialise( variableList[1], context, False );
   Stg_Component_Initialise( timeIntegrandList[0], context, False );
   Stg_Component_Initialise( timeIntegrandList[1], context, False );

   for ( timestep = 0.0 ; timestep < maxTimesteps ; timestep ++ ) {
      Journal_Printf( stream, "Step %u - Time = %.3g\n", timestep, context->currentTime );

      Stg_Component_Execute( timeIntegrator, context, True );
      context->currentTime += AbstractContext_Dt( context );

      for ( integrand_I = 0 ; integrand_I < integrandCount ; integrand_I++ ) {
         timeIntegrand   = timeIntegrandList[ integrand_I ];
         variable         = variableList[ integrand_I ];
         for ( array_I = 0 ; array_I < variable->arraySize ; array_I++ ) {
            if ( timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_ConstantTimeDeriv ) {
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 0 ) - 2.0 * array_I * context->currentTime );
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 1 ) + array_I * context->currentTime );
            }
            else if ( timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_ConstantTimeDeriv2 ) {
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 0 ) + 0.5 * array_I * context->currentTime );
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 1 ) - 3 * array_I * context->currentTime );
            }
            else if ( timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_LinearTimeDeriv ) {
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 0 ) - array_I * context->currentTime * context->currentTime );
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 1 ) + 0.5 * array_I * context->currentTime * context->currentTime );
            }
            else if ( timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_LinearTimeDeriv2 ) {
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 0 ) + 0.25 * array_I * context->currentTime * context->currentTime );
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 1 ) - 1.5 * array_I * context->currentTime * context->currentTime );
            }
            else if ( timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_CubicTimeDeriv ) {
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 0 ) - 2.0 * array_I * ( 0.25 * pow( context->currentTime, 4.0 ) - pow( context->currentTime, 3.0)/3.0));
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 1 ) + array_I * ( 0.25 * pow( context->currentTime, 4.0 ) - pow( context->currentTime, 3.0 )/3.0));
            }
            else if ( timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_CubicTimeDeriv2 ) {
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 0 ) + 0.5 * array_I * ( 0.25 * pow( context->currentTime, 4.0 ) - pow( context->currentTime, 3.0)/3.0));
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 1 ) - 3.0 * array_I * ( 0.25 * pow( context->currentTime, 4.0 ) - pow( context->currentTime, 3.0 )/3.0));
            }
            else
               Journal_Firewall( 0 , Journal_Register( Error_Type, (Name)CURR_MODULE_NAME  ), "Don't understand _calculateTimeDeriv = %p\n", timeIntegrand->_calculateTimeDeriv );
         }
      }
   }
   pcu_check_lt( error, tolerance );

   if ( error < tolerance )
      Journal_Printf( stream, "Passed\n" );
   else
      Journal_Printf( stream, "Failed - Error = %lf\n", error );
   
   Journal_Enable_AllTypedStream( False );

   if ( timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_ConstantTimeDeriv
      || timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_ConstantTimeDeriv2 ) {
      pcu_filename_expected( "testTimeIntegrationEulerOutput.expected", expected_file );
   }
   else if ( timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_LinearTimeDeriv
      || timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_LinearTimeDeriv2 ) {
      pcu_filename_expected( "testTimeIntegrationRK2Output.expected", expected_file );
   }
   else if ( timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_CubicTimeDeriv
      || timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_CubicTimeDeriv2 ) {
      pcu_filename_expected( "testTimeIntegrationRK4Output.expected", expected_file );
   }

   pcu_check_fileEq( _name, expected_file );

   /* Destroy stuff */
   Stream_CloseAndFreeFile( stream );
   Memory_Free( array );
   Memory_Free( array2 );
   Stg_Class_Delete( variable );
   _Stg_Component_Delete( timeIntegrator );
   _Stg_Component_Delete( timeIntegrandList[0] );
   _Stg_Component_Delete( timeIntegrandList[1] );
   remove( _name );
}
예제 #11
0
int main( int argc, char* argv[] ) {
	MPI_Comm CommWorld;
	int rank;
	int numProcessors;
	int procToWatch;
	Dictionary* dictionary;
	AbstractContext* abstractContext;
	
	/* Initialise MPI, get world info */
	MPI_Init( &argc, &argv );
	MPI_Comm_dup( MPI_COMM_WORLD, &CommWorld );
	MPI_Comm_size( CommWorld, &numProcessors );
	MPI_Comm_rank( CommWorld, &rank );
	
	BaseFoundation_Init( &argc, &argv );
	BaseIO_Init( &argc, &argv );
	BaseContainer_Init( &argc, &argv );
	BaseAutomation_Init( &argc, &argv );
	BaseExtensibility_Init( &argc, &argv );
	BaseContext_Init( &argc, &argv );
	
	stream =  Journal_Register( InfoStream_Type, "myStream" );

	if( argc >= 2 ) {
		procToWatch = atoi( argv[1] );
	}
	else {
		procToWatch = 0;
	}
	if( rank == procToWatch ) Journal_Printf( (void*) stream, "Watching rank: %i\n", rank );
	
	/* Read input */
	dictionary = Dictionary_New();
	
	/* Build the context */
	abstractContext = _AbstractContext_New( 
		sizeof(AbstractContext), 
		"TestContext", 
		MyDelete, 
		MyPrint, 
		NULL,
		NULL, 
		NULL, 
		_AbstractContext_Build, 
		_AbstractContext_Initialise, 
		_AbstractContext_Execute, 
		_AbstractContext_Destroy, 
		"context", 
		True, 
		MySetDt, 
		0, 
		10, 
		CommWorld, 
		dictionary );

	/* add hooks to existing entry points */
	ContextEP_ReplaceAll( abstractContext, AbstractContext_EP_Build, MyBuild );
	ContextEP_ReplaceAll( abstractContext, AbstractContext_EP_Initialise, MyInitialConditions );
	ContextEP_ReplaceAll( abstractContext, AbstractContext_EP_Solve, MySolve );
	ContextEP_ReplaceAll( abstractContext, AbstractContext_EP_Dt, MyDt );

	if( rank == procToWatch ) {
		Journal_Printf( 
			(void*)stream, 
			"abstractContext->entryPointList->_size: %lu\n", 
			abstractContext->entryPoint_Register->_size );
		Journal_Printf( 
			(void*)stream, 
			"abstractContext->entryPointList->count: %u\n", 
			abstractContext->entryPoint_Register->count );
	}
	
	ContextEP_Append( abstractContext, AbstractContext_EP_Solve, MySolve2 );
	ContextEP_ReplaceAll( abstractContext, AbstractContext_EP_Initialise, MyInitialConditions2 ); 

	if( rank == procToWatch ) {
		stream = Journal_Register( InfoStream_Type, AbstractContext_Type );
		AbstractContext_PrintConcise( abstractContext, stream );
		
		Journal_Printf( 
			(void*)stream, 
			"abstractContext->entryPointList->_size: %lu\n", 
			abstractContext->entryPoint_Register->_size );
		Journal_Printf( 
			(void*)stream, 
			"abstractContext->entryPointList->count: %u\n", 
			abstractContext->entryPoint_Register->count );
	}

	/* Run the context */
	if( rank == procToWatch ) {
		Stg_Component_Build( abstractContext, 0 /* dummy */, False );
		Stg_Component_Initialise( abstractContext, 0 /* dummy */, False );
		Stg_Component_Execute( abstractContext, 0 /* dummy */, False );
		Stg_Component_Destroy( abstractContext, 0 /* dummy */, False );
	}
	
	/* Stg_Class_Delete stuff */
	Stg_Class_Delete( abstractContext );
	Stg_Class_Delete( dictionary );
	
	BaseContext_Finalise();
	BaseExtensibility_Finalise();
	BaseAutomation_Finalise();
	BaseContainer_Finalise();
	BaseIO_Finalise();
	BaseFoundation_Finalise();
	
	/* Close off MPI */
	MPI_Finalize();
	
	return 0; /* success */
}