コード例 #1
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;
}
コード例 #2
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 );
	
	if( argc >= 2 ) {
		procToWatch = atoi( argv[1] );
	}
	else {
		procToWatch = 0;
	}
	if( rank == procToWatch ) {
		XML_IO_Handler*		io_handler = XML_IO_Handler_New();
		Dictionary*		dictionary = Dictionary_New();
		Dictionary_Index 	index;
		Stream*			stream = Journal_Register( InfoStream_Type, XML_IO_Handler_Type );
		
		/* use the base class functions */
		printf( "\ntest of raw data file:\n" );
		IO_Handler_ReadAllFromFile( io_handler, "data/rawdata.xml", dictionary ); 

		printf( "\ndictionary now contains:\n" );
		printf( "Dictionary:\n" );
		printf( "\tsize: %u\n", dictionary->size );
		printf( "\tdelta: %u\n", dictionary->delta );
		printf( "\tcount: %u\n", dictionary->count );
		printf( "\tentryPtr[0-%u]: {\n", dictionary->count );
		for( index = 0; index < dictionary->count; index++ ) {
			printf( "\t\t" );
			Dictionary_Entry_Print( dictionary->entryPtr[index], stream ); 
			printf( "\n" );
		}
		printf( "\t}\n" );


		/* Dictionary_Entry_Value_SetEncoding( Dictionary_Get( dictionary, "boundary_conditions2" ), RawASCII ); */

		IO_Handler_WriteAllToFile( io_handler, "data/newrawdata.xml", dictionary );
		Stg_Class_Delete( io_handler );
		Stg_Class_Delete( dictionary );
	}

	BaseIO_Finalise();
	BaseFoundation_Finalise();

	/* Close off MPI */
	MPI_Finalize();
	
	return EXIT_SUCCESS;
}
コード例 #3
0
ファイル: Finalise.c プロジェクト: bmi-forum/bmi-pyre
Bool Base_Finalise( void ) {
	Journal_Printf( Journal_Register( DebugStream_Type, "Context" ), "In: %s\n", __func__ ); /* DO NOT CHANGE OR REMOVE */
	
	BaseContext_Finalise();
	BaseExtensibility_Finalise();
	BaseAutomation_Finalise();
	BaseContainer_Finalise();
	BaseIO_Finalise();
	BaseFoundation_Finalise();
	
	return True;
}
コード例 #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 );

	/* 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 */
}
コード例 #5
0
ファイル: testIndexMap.c プロジェクト: bmi-forum/bmi-pyre
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 */
}
コード例 #6
0
ファイル: testPlugin.c プロジェクト: bmi-forum/bmi-pyre
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;
}
コード例 #7
0
int main( int argc, char* argv[] ) {
	Dictionary* dictionary;
	Stream* stream;
	
	MPI_Init( &argc, &argv );
	BaseFoundation_Init( &argc, &argv );
	BaseIO_Init( &argc, &argv );
	stream = Journal_Register (Info_Type, "myStream");
	Stream_RedirectFile( stream, "dictionaryOutput.dat" );

	dictionary = Dictionary_New();

	Dictionary_ReadAllParamFromCommandLine( dictionary, argc, argv );
	Print( dictionary, stream );
	
	Stg_Class_Delete( dictionary );
	
	BaseIO_Finalise();
	BaseFoundation_Finalise();
	MPI_Finalize();
	
	return EXIT_SUCCESS;
}
コード例 #8
0
/* Note: this function is a duplicate of StGermain_Finalise currently - since StGermain_Finalise doesn't call Base_Finalise */
Bool StGermainBase_Finalise( void ) {
   Journal_Printf( Journal_Register( DebugStream_Type, "Context" ), "In: %s\n", __func__ ); 
   
   /* Delete the global objects : xmlSearchPaths and moduleDirectories */
   Stg_ObjectList_DeleteAllObjects( moduleDirectories );
   Stg_Class_Delete( moduleDirectories );
   moduleDirectories=NULL;
   
   Stg_ObjectList_DeleteAllObjects( Project_XMLSearchPaths );
   Stg_Class_Delete( Project_XMLSearchPaths );
   Project_XMLSearchPaths=NULL;

   /* Finalise all the bits and pieces */
   BaseContext_Finalise();
//#if 0
   BaseExtensibility_Finalise();
//#endif
   BaseAutomation_Finalise();
   BaseContainer_Finalise();
   BaseIO_Finalise();
   BaseFoundation_Finalise();

   return True;
}
コード例 #9
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 */
}
コード例 #10
0
ファイル: testJournal1.c プロジェクト: bmi-forum/bmi-pyre
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 );
	
	if( argc >= 2 ) {
		procToWatch = atoi( argv[1] );
	}
	else {
		procToWatch = 0;
	}
	if( rank == procToWatch )
	{
		Stream* myInfo;
		Stream* myDebug;		
		Stream* myDump;
		Stream* myError;
		
		Stream* allNew;

		myInfo = Journal_Register( Info_Type, "MyInfo" );
		myDebug = Journal_Register( Debug_Type, "MyDebug" );
		myDump = Journal_Register( Dump_Type, "MyDump" );
		myError = Journal_Register( Error_Type, "MyError" );
		
		allNew = Journal_Register( "My own stream", "allNew" );
		
		printf( "TEST: \"HELLO\" should appear\n" );
		Journal_Printf( myInfo, "%s\n", "HELLO" );
		printf( "TEST: \"WORLD\" should NOT appear\n" );
		Journal_Printf( myDebug, "%s\n", "HELLO" );
		printf( "TEST: \"HELLO\" should NOT appear\n" );
		Journal_Printf( myDump, "%s\n", "HELLO" );
		printf( "TEST: \"WORLD\" should NOT appear\n" );
		Journal_Printf( myError, "%s\n", "HELLO" );

		printf( "Turning off myInfo\n" );
		Journal_Enable_NamedStream( Info_Type, "MyInfo" , False );
		
		printf( "TEST: \"HELLO\" should NOT appear\n" );
		Journal_Printf( myInfo, "%s\n", "HELLO" );

		printf( "Turning on Dump\n"  );
		Journal_Enable_TypedStream( Dump_Type, True );
		Journal_Enable_NamedStream( Dump_Type, "MyDump", True );
		
		printf( "TEST: \"HELLO\" should appear\n" );
		Journal_Printf( myDump, "%s\n", "HELLO" );
		
		printf( "Turning off Journal\n" );
		stJournal->enable = False;

		printf( "TEST: \"HELLO\" should NOT appear\n" );		
		Journal_Printf( myDump, "%s\n", "HELLO" );
		
		stJournal->enable = True;
		
		Journal_Enable_NamedStream( Info_Type, "MyInfo", True );
		
		printf( "TEST: DPrintf\n" );
		Journal_DPrintf( myInfo, "DPrintf\n" );	
	}

	Memory_Print();
	
	BaseIO_Finalise();

	BaseFoundation_Finalise();

	/* Close off MPI */
	MPI_Finalize();
	
	return EXIT_SUCCESS;
}
コード例 #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 (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 */
}
コード例 #12
0
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 */
}
コード例 #13
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 );

    if( argc >= 2 ) {
        procToWatch = atoi( argv[1] );
    }
    else {
        procToWatch = 0;
    }
    if( rank == procToWatch )
    {
        Stream* infoTest1;
        Stream* infoTest2;
        Stream* debugTest1;
        Stream* debugTest2;
        Stream* dumpTest1;
        Stream* dumpTest2;
        Stream* newTest1;
        Stream* newTest2;

        Stream* fileTest1;
        Stream* fileTest2;

        Stream* propTest1;
        Stream* propTest2;

        Dictionary* dictionary = Dictionary_New();
        XML_IO_Handler* io_handler = XML_IO_Handler_New();

        infoTest1 = Journal_Register( Info_Type, "test1" );
        infoTest2 = Journal_Register( Info_Type, "test2" );
        debugTest1 = Journal_Register( Debug_Type, "test1" );
        debugTest2 = Journal_Register( Debug_Type, "test2" );
        dumpTest1 = Journal_Register( Dump_Type, "test1" );
        dumpTest2 = Journal_Register( Dump_Type, "test2" );

        IO_Handler_ReadAllFromFile( io_handler, "data/journal.xml", dictionary );

        Journal_ReadFromDictionary( dictionary );

        newTest1 = Journal_Register( Info_Type, "test1.new1" );
        newTest2 = Journal_Register( Info_Type, "test1.new2" );

        Journal_Printf( infoTest1, "infoTest1\n" );
        Journal_Printf( infoTest2, "infoTest2\n" );
        Journal_Printf( debugTest1, "debugTest1\n" );
        Journal_Printf( debugTest2, "debugTest2\n" );
        Journal_Printf( dumpTest1, "dumpTest1\n" );
        Journal_Printf( dumpTest2, "dumpTest2\n" );
        Journal_PrintfL( newTest1, 3, "newTest1\n" );
        Journal_PrintfL( newTest1, 4, "newTest1\n" );
        Journal_Printf( newTest2, "newTest2\n" );

        fileTest1 = Journal_Register( "newtype", "hello" );
        fileTest2 = Journal_Register( "newtype", "other" );

        Journal_Printf( fileTest1, "yay!" );
        Journal_Printf( fileTest2, "double yay!" );

        propTest1 = Journal_Register( Info_Type, "propertiestest1" );
        propTest2 = Journal_Register( Info_Type, "propertiestest2" );

        Print( propTest1, infoTest1 );
        Print( propTest2, infoTest1 );

        Stg_Class_Delete( io_handler );
        Stg_Class_Delete( dictionary );
    }

    BaseIO_Finalise();
    BaseFoundation_Finalise();

    /* Close off MPI */
    MPI_Finalize();

    return EXIT_SUCCESS;
}
コード例 #14
0
int main( int argc, char* argv[] ) {
	
	Stream*				stream = NULL;
	Dictionary*			dictionary;
	Dictionary_Entry_Value*		tmpVal0;
	Dictionary_Entry_Value*		tmpVal1; 
	
	MPI_Init( &argc, &argv );
	BaseFoundation_Init( &argc, &argv );
	BaseIO_Init( &argc, &argv );
	stream = Journal_Register (Info_Type, "myStream");

	dictionary = Dictionary_New();

	tmpVal0 = Dictionary_Entry_Value_NewStruct();
	tmpVal1 = Dictionary_Entry_Value_NewStruct();
	Dictionary_Entry_Value_AddMember( tmpVal1, "name", Dictionary_Entry_Value_FromString( "bill" ) );
	Dictionary_Entry_Value_AddMember( tmpVal1, "value", Dictionary_Entry_Value_FromDouble( 1.0f ) );
	Dictionary_Entry_Value_AddMember( tmpVal0, "inside", tmpVal1 );
	tmpVal1 = Dictionary_Entry_Value_NewList();
	Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "bottom" ) );
	Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "top" ) );
	Dictionary_Entry_Value_AddMember( tmpVal0, "list_one", tmpVal1 );
	Dictionary_Add( dictionary, "one", tmpVal0 );
	
	tmpVal0 = Dictionary_Entry_Value_NewStruct();
	tmpVal1 = Dictionary_Entry_Value_NewStruct();
	Dictionary_Entry_Value_AddMember( tmpVal1, "new_name", Dictionary_Entry_Value_FromString( "frank" ) );
	Dictionary_Entry_Value_AddMember( tmpVal1, "value", Dictionary_Entry_Value_FromDouble( 2.0f ) );
	Dictionary_Entry_Value_AddMember( tmpVal0, "inside", tmpVal1 );
	tmpVal1 = Dictionary_Entry_Value_NewList();
	Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "left" ) );
	Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "right" ) );
	Dictionary_Entry_Value_AddMember( tmpVal0, "list_one", tmpVal1 );
	Dictionary_AddMerge( dictionary, "one", tmpVal0, Dictionary_MergeType_Append );
	
	Print( dictionary, stream );
	Stg_Class_Delete( dictionary );
	
	dictionary = Dictionary_New();
	
	tmpVal0 = Dictionary_Entry_Value_NewStruct();
	tmpVal1 = Dictionary_Entry_Value_NewStruct();
	Dictionary_Entry_Value_AddMember( tmpVal1, "name", Dictionary_Entry_Value_FromString( "bill" ) );
	Dictionary_Entry_Value_AddMember( tmpVal1, "value", Dictionary_Entry_Value_FromDouble( 1.0f ) );
	Dictionary_Entry_Value_AddMember( tmpVal0, "inside", tmpVal1 );
	tmpVal1 = Dictionary_Entry_Value_NewList();
	Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "bottom" ) );
	Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "top" ) );
	Dictionary_Entry_Value_AddMember( tmpVal0, "list_one", tmpVal1 );
	Dictionary_Add( dictionary, "one", tmpVal0 );
	
	tmpVal0 = Dictionary_Entry_Value_NewStruct();
	tmpVal1 = Dictionary_Entry_Value_NewStruct();
	Dictionary_Entry_Value_AddMember( tmpVal1, "new_name", Dictionary_Entry_Value_FromString( "frank" ) );
	Dictionary_Entry_Value_AddMember( tmpVal1, "value", Dictionary_Entry_Value_FromDouble( 2.0f ) );
	Dictionary_Entry_Value_AddMember( tmpVal0, "inside", tmpVal1 );
	tmpVal1 = Dictionary_Entry_Value_NewList();
	Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "left" ) );
	Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "right" ) );
	Dictionary_Entry_Value_AddMember( tmpVal0, "list_one", tmpVal1 );
	Dictionary_AddMerge( dictionary, "one", tmpVal0, Dictionary_MergeType_Merge );
	
	Print( dictionary, stream );
	Stg_Class_Delete( dictionary );
	
	dictionary = Dictionary_New();
	
	tmpVal0 = Dictionary_Entry_Value_NewStruct();
	tmpVal1 = Dictionary_Entry_Value_NewStruct();
	Dictionary_Entry_Value_AddMember( tmpVal1, "name", Dictionary_Entry_Value_FromString( "bill" ) );
	Dictionary_Entry_Value_AddMember( tmpVal1, "value", Dictionary_Entry_Value_FromDouble( 1.0f ) );
	Dictionary_Entry_Value_AddMember( tmpVal0, "inside", tmpVal1 );
	tmpVal1 = Dictionary_Entry_Value_NewList();
	Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "bottom" ) );
	Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "top" ) );
	Dictionary_Entry_Value_AddMember( tmpVal0, "list_one", tmpVal1 );
	Dictionary_Add( dictionary, "one", tmpVal0 );
	
	tmpVal0 = Dictionary_Entry_Value_NewStruct();
	tmpVal1 = Dictionary_Entry_Value_NewStruct();
	Dictionary_Entry_Value_AddMember( tmpVal1, "new_name", Dictionary_Entry_Value_FromString( "frank" ) );
	Dictionary_Entry_Value_AddMember( tmpVal1, "value", Dictionary_Entry_Value_FromDouble( 2.0f ) );
	Dictionary_Entry_Value_AddMember( tmpVal0, "inside", tmpVal1 );
	tmpVal1 = Dictionary_Entry_Value_NewList();
	Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "left" ) );
	Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "right" ) );
	Dictionary_Entry_Value_AddMember( tmpVal0, "list_one", tmpVal1 );
	Dictionary_AddMerge( dictionary, "one", tmpVal0, Dictionary_MergeType_Replace );
	
	Print( dictionary, stream );
	Stg_Class_Delete( dictionary );
	
	BaseIO_Finalise();
	BaseFoundation_Finalise();
	MPI_Finalize();
	
	return EXIT_SUCCESS;
}
コード例 #15
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 */
}