Esempio n. 1
0
Bool StGermainBase_Init( int* argc, char** argv[] ) {
   char* directory;
   int   tmp;
   
   /* Initialise enough bits and pieces to get IO going */
   BaseFoundation_Init( argc, argv );
   BaseIO_Init( argc, argv );

   /* Write out the copyright message */

   
   Journal_Printf( Journal_Register( DebugStream_Type, "Context" ), "In: %s\n", __func__ );
   tmp = Stream_GetPrintingRank( Journal_Register( InfoStream_Type, "Context" ) );
   Stream_SetPrintingRank( Journal_Register( InfoStream_Type, "Context" ), 0 );
 
   Stream_Flush( Journal_Register( InfoStream_Type, "Context" ) );
   Stream_SetPrintingRank( Journal_Register( InfoStream_Type, "Context" ), tmp );
   
   /* Initialise the remaining bits and pieces */
   BaseContainer_Init( argc, argv );
   BaseAutomation_Init( argc, argv );
   BaseExtensibility_Init( argc, argv );
   BaseContext_Init( argc, argv );
   
   /* Add the StGermain path to the global xml path dictionary */
   directory = Memory_Alloc_Array( char, 200, "xmlDirectory" ) ;
   sprintf( directory, "%s%s", LIB_DIR, "/StGermain" );
   XML_IO_Handler_AddDirectory( "StGermain", directory  );
   Memory_Free( directory );
   
   /* Add the plugin path to the global plugin list */
   ModulesManager_AddDirectory( "StGermain", LIB_DIR );
   
   return True;
}
Esempio n. 2
0
int main( int argc, char* argv[] ) {
	TestSuite*	suite;

	/* Initialise MPI, get world info. */
	MPI_Init( &argc, &argv );

	/* Initialise StGermain. */
	BaseFoundation_Init( &argc, &argv );
	BaseIO_Init( &argc, &argv );
	BaseContainer_Init( &argc, &argv );

	/* Create the test suite. */
	suite = TestSuite_New();
	TestSuite_SetProcToWatch( suite, (argc >= 2) ? atoi( argv[1] ) : 0 );
	TestSuite_SetTests( suite, nTests, tests );

	/* Run the tests. */
	TestSuite_Run( suite );

	/* Destroy test suites. */
	FreeObject( suite );

	/* Finalise StGermain. */
	BaseContainer_Finalise();
	BaseIO_Finalise();
	BaseFoundation_Finalise();

	/* Close off MPI */
	MPI_Finalize();

	return MPI_SUCCESS;
}
int main( int argc, char* argv[] ) {
	MPI_Comm			CommWorld;
	int				rank;
	int				numProcessors;
	int				procToWatch;
	
	
	/* 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 );

	/* Tell the Journal_Firewall to Clean exit, rather than assert */
	Stream_SetFileBranch( Journal_GetTypedStream( ErrorStream_Type ), stJournal->stdOut );
	stJournal->firewallProducesAssert = False;

	if( argc >= 2 ) {
		procToWatch = atoi( argv[1] );
	}
	else {
		procToWatch = 0;
	}
	if( rank == procToWatch ) {
		IndexSet*			is;
		
		printf( "Watching rank: %i\n", rank );
		
		printf( "* Test Construction *\n" );
		is = IndexSet_New( 24 );
		
		printf( "* Test Insertion(Add) over limit *\n" );
		IndexSet_Add( is, 24 );
		printf( "* Shouldn't get here\n" );

		Stg_Class_Delete( is );
	}

	BaseContainer_Finalise();
	BaseIO_Finalise();
	BaseFoundation_Finalise();
	
	/* Close off MPI */
	MPI_Finalize();
	
	return 0; /* success */
}
Esempio n. 4
0
int main( int argc, char* argv[] ) {
	MPI_Comm			CommWorld;
	int				rank;
	int				numProcessors;
	int				procToWatch;
	
	
	/* 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 );

	if( argc >= 2 ) {
		procToWatch = atoi( argv[1] );
	}
	else {
		procToWatch = 0;
	}
	
	if( rank == procToWatch ) {
		IndexMap*		map;
		Index			idx;
		Stream*			stream;
		
		stream = Journal_Register( Info_Type, "myStream" );
		
		map = IndexMap_New();
		for( idx = 0; idx < 100; idx++ )
			IndexMap_Append( map, idx + 1, 100 - idx );
		
		printf( "List Data:\n" );
		for( idx = 0; idx < 100; idx++ )
			printf( "\tlooking for %d, found %d\n", idx + 1, IndexMap_Find( map, idx + 1 ) );
		
		Stg_Class_Delete( map );
	}
	
	BaseContainer_Finalise();
	BaseIO_Finalise();
	BaseFoundation_Finalise();
	
	/* Close off MPI */
	MPI_Finalize();
	
	return 0; /* success */
}
Esempio n. 5
0
int main( int argc, char* argv[] ) {
	MPI_Comm CommWorld;
	int rank;
	int numProcessors;
	Stream* stream;

	Stg_ObjectList* directories;
	PluginLoader* plugin;

	/* 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 );

	/* creating a stream */
	stream =  Journal_Register( Info_Type, __FILE__ );

	directories = Stg_ObjectList_New();
	Stg_ObjectList_PointerAppend( directories, StG_Strdup(LIB_DIR), "default dir", 0, 0, 0 );
	
	plugin = PluginLoader_NewLocal( "LocalPlugin", directories );

	Journal_Firewall( plugin != NULL, stream, "Failed!\n" );

	Journal_Printf( stream, "PluginLoader_GetName(): %s\n", PluginLoader_GetName( plugin ) );
	Print( plugin, stream );

	Stg_Class_Delete( plugin );
	Stg_Class_Delete( directories );
	
	BaseExtensibility_Finalise();
	BaseAutomation_Finalise();
	BaseContainer_Finalise();
	BaseIO_Finalise();
	BaseFoundation_Finalise();

	/* Close off MPI */
	MPI_Finalize();
                                                                                                                                    

	return 0;
}
Esempio n. 6
0
int main( int argc, char* argv[] ) {
	MPI_Comm			CommWorld;
	int				rank;
	int				numProcessors;
	int				procToWatch;
	
	
	/* 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 );

	if( argc >= 2 ) {
		procToWatch = atoi( argv[1] );
	}
	else {
		procToWatch = 0;
	}
	
	if( rank == procToWatch ) {
		List*			list;
		Index			idx;
		Stream*			stream;
		
		stream = Journal_Register( Info_Type, "myStream" );
		
		list = List_New( sizeof(unsigned) );
		for( idx = 0; idx < 100; idx++ ) {
			List_Resize( list, List_Size( list ) + 1 );
			List_ElementAt( list, unsigned, idx ) = 100 - idx;
		}
		
		Print( list, stream );
		
		printf( "List Data:\n" );
		for( idx = 0; idx < 100; idx++ )
			printf( "\telements[%d]: %d\n", idx, List_ElementAt( list, unsigned, idx ) );
		
		Stg_Class_Delete( list );
	}
Esempio n. 7
0
int main( int argc, char *argv[] ) {
	int		rank;
	int		procCount;
	int		procToWatch;
	Stream*		stream;
	
	/* Initialise MPI, get world info */
	MPI_Init( &argc, &argv );
	MPI_Comm_size( MPI_COMM_WORLD, &procCount );
	MPI_Comm_rank( MPI_COMM_WORLD, &rank );
	
	BaseFoundation_Init( &argc, &argv );

	RegressionTest_Init( "Base/Automation/Stg_Component" );
	
	BaseIO_Init( &argc, &argv );
	BaseContainer_Init( &argc, &argv );
	BaseAutomation_Init( &argc, &argv );

	stream = Journal_Register( Info_Type, __FILE__ );
	
	if( argc >= 2 ) {
		procToWatch = atoi( argv[1] );
	}
	else {
		procToWatch = 0;
	}
	if( rank == procToWatch ) {
		Stg_ComponentMeta* metaTest;

		XML_IO_Handler* io;
		Dictionary* allDict;
		Dictionary* compDict;

		CompositeVC* vc;
		
		Journal_Printf( stream, "%s\n", Stg_Component_GetMetadata() );

		metaTest = Stg_Component_CreateMeta( "blah", Variable_Type );
		Stg_Class_Print( metaTest, stream );
		Stg_Class_Delete( metaTest );

		allDict = Dictionary_New();
		io = XML_IO_Handler_New();
		IO_Handler_ReadAllFromFile( io, "data/metatest.xml", allDict );
		compDict = Dictionary_GetDictionary( allDict, "components" );
		vc = CompositeVC_DefaultNew( "vc" );	
		
		metaTest = Stg_Component_Validate( vc, CompositeVC_Type, compDict );
		Stg_Class_Print( metaTest, stream );
		Stg_Class_Delete( metaTest );

		Stg_Class_Delete( io );
		Stg_Class_Delete( compDict );
	}

	
	BaseAutomation_Finalise();
	BaseContainer_Finalise();
	BaseIO_Finalise();

	RegressionTest_Finalise();
	
	BaseFoundation_Finalise();

	
	/* Close off MPI */
	MPI_Finalize();
	
	return 0; /* success */
}
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 */
}
int main( int argc, char* argv[] ) {
	MPI_Comm CommWorld;
	int rank;
	int numProcessors;
	int procToWatch;
	EntryPoint* entryPoint;
	Stream* stream;
	double  result;
	
	/* 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 );

	if( argc >= 2 ) {
		procToWatch = atoi( argv[1] );
	}
	else {
		procToWatch = 0;
	}
	
	/* creating a stream */
	stream =  Journal_Register( InfoStream_Type, "myStream" );
	Stream_SetPrintingRank( stream, procToWatch );
	
	Journal_Printf( stream, "Watching rank: %i\n", rank );
	
	/* Get Maximum of Values */
	entryPoint = EntryPoint_New( testEpName, EntryPoint_Maximum_VoidPtr_CastType );
	EP_Append( entryPoint, Return1 );
	EP_Append( entryPoint, Return89 );
	EP_Append( entryPoint, ReturnNeg43 );
	EP_Append( entryPoint, ReturnZero );
	result = ((EntryPoint_Maximum_VoidPtr_CallCast*) entryPoint->run)( entryPoint, stream );
	Journal_PrintDouble( stream, result );
	Stg_Class_Delete( entryPoint );

	/* Get Minimum of Values */
	entryPoint = EntryPoint_New( testEpName, EntryPoint_Minimum_VoidPtr_CastType );
	EP_Append( entryPoint, Return1 );
	EP_Append( entryPoint, Return89 );
	EP_Append( entryPoint, ReturnNeg43 );
	EP_Append( entryPoint, ReturnZero );
	result = ((EntryPoint_Minimum_VoidPtr_CallCast*) entryPoint->run)( entryPoint, stream );
	Journal_PrintDouble( stream, result );
	Stg_Class_Delete( entryPoint );	

	BaseExtensibility_Finalise();
	BaseAutomation_Finalise();
	BaseContainer_Finalise();
	BaseIO_Finalise();
	BaseFoundation_Finalise();
	
	/* Close off MPI */
	MPI_Finalize();

	return 0; /* success */
}
Esempio n. 10
0
int main( int argc, char* argv[] ) {
	MPI_Comm			CommWorld;
	int				rank;
	int				numProcessors;
	int				procToWatch;
	int **keys;
	
	MaxHeap *heap;
	int i = 0;
	Stream *myStream = NULL;
	
	/* 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 );

	if( argc >= 2 ) {
		procToWatch = atoi( argv[1] );
	}
	else {
		procToWatch = 0;
	}
	
	if( rank == procToWatch ) {
		
		myStream = Journal_Register( InfoStream_Type, "LinkedListStream" );
		data = Memory_Alloc_Array_Unnamed( int, NUM_DATA );
		keys = Memory_Alloc_Array_Unnamed( int*, NUM_INITIAL_DATA );
		
		Journal_Printf( myStream, "\nCreating the Heap\n" );
		for(i=0; i<NUM_INITIAL_DATA; i++){
			data[i] = i;
			keys[i] = &(data[i]);
		}
		
		heap = MaxHeap_New(
					(void**)(keys), sizeof(int),
					NUM_INITIAL_DATA,
					keySwap,
					compareFunction,
					extendArray );

		Journal_Printf( myStream, "\nPrinting the Heap\n" );
		Stg_Class_Print( heap, myStream );
		
		Journal_Printf( myStream, "\nInserting more entries into the Heap\n" );
		for( i=50; i<NUM_DATA; i++ ){
			data[i] = i;
			MaxHeap_Insert( heap, &(data[i]) );
		}
		
		Journal_Printf( myStream, "\nPrinting the Heap\n" );
		Stg_Class_Print( heap, myStream );
		
		Journal_Printf( myStream, "\nExtracting all the entries in the Heap\n" );
		for( i=0; i<NUM_DATA; i++ ){
			printf( "Heap Max %d\n", *(int*)MaxHeap_Extract( (_Heap*)heap ) );
		}
		
		Journal_Printf( myStream, "\nPrinting the Heap\n" );
		Stg_Class_Print( heap, myStream );
	
		Journal_Printf( myStream, "\nDeleting the Heap\n" );
		Stg_Class_Delete( (void*)heap );
		
		Memory_Free( data );
	}
Esempio n. 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 */
}