예제 #1
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 );

	stream = Journal_Register( "info", "myStream" );
	
	if( argc >= 2 ) {
		procToWatch = atoi( argv[1] );
	}
	else {
		procToWatch = 0;
	}

	if ( rank == procToWatch ) {
		NamedObject_Register* reg = NamedObject_Register_New();
	
		NamedObject_Register_Add( reg, TestObject_New( "a" ) );
		NamedObject_Register_Add( reg, TestObject_New( "b" ) );
		NamedObject_Register_Add( reg, TestObject_New( "c" ) );
		NamedObject_Register_Add( reg, TestObject_New( "d" ) );
		NamedObject_Register_Add( reg, TestObject_New( "e" ) );
	
		Print( reg, stream );

		Journal_Printf( stream, "Index of \"b\": %d\n", NamedObject_Register_GetIndex( reg, "b" ) );
		Print( NamedObject_Register_GetByName( reg, "d" ), stream );
		Print( NamedObject_Register_GetByIndex( reg, 2 ), stream );
	}

	BaseFoundation_Finalise();
	
	/* Close off MPI */
	MPI_Finalize();
	
	return 0; /* success */
}
void _FieldVariable_Init( 
   FieldVariable*          self, 
   DomainContext*          context,
   Index                   fieldComponentCount, 
   Dimension_Index         dim,
   Bool                    isCheckpointedAndReloaded,
   char*                   o_units,
   MPI_Comm                communicator, 
   FieldVariable_Register* fV_Register,
   Bool                    useCacheMaxMin ) {
   /* Add ourselves to the register for later retrieval by clients */
   
   self->context                   = context;
   self->fieldComponentCount       = fieldComponentCount;
   self->dim                       = dim;
   self->communicator              = communicator;
   self->fieldVariable_Register    = fV_Register;
   self->isCheckpointedAndReloaded = isCheckpointedAndReloaded;
   self->useCacheMaxMin            = useCacheMaxMin;

   if( o_units ) { 
      /* test if units string is valid */
      Scaling_Parse( o_units );
      /* copy units string */
      self->o_units = StG_Strdup( o_units );
   }

   if( self != NULL && fV_Register != NULL ) {   
      /* Prevent the same field from being added more than once */
      if( NamedObject_Register_GetIndex( fV_Register, self->name ) == -1 )
         FieldVariable_Register_Add( fV_Register, self );
   }   

   self->extensionMgr = ExtensionManager_New_OfExistingObject( self->name, self );
   self->cachedTimestep = -1;
}