void _ModulesManager_Print( void* modulesManager, Stream* stream ) {
   ModulesManager* self = (ModulesManager*)modulesManager;
   Index           i;
   
   /* General info */
   Journal_Printf( (void*) stream, "%s (ptr): %p\n", ModulesManager_Type, self );
   
   /* Print parent */
   _Stg_Class_Print( self, stream );

   if( moduleDirectories->count > 0 ) {
      Journal_Printf( stream, "Search Path:\n" );
      Stream_Indent( stream );

      for( i = 0; i < moduleDirectories->count; ++i ) {
         Journal_Printf( stream, "(path) %s\n", Stg_ObjectList_ObjectAt( moduleDirectories, i ) );
      }
      Stream_UnIndent( stream );
   }

   if( self->modules->count > 0 ) {
      Journal_Printf( stream, "Loaded modules:\n" );
      Stream_Indent( stream );

      for( i = 0; i < self->modules->count; ++i ) {
         Module* module = (Module*)Stg_ObjectList_At( self->modules, i );
         Journal_Printf( stream, "%s\n", module->name );
      }
      Stream_UnIndent( stream );
   }
}
示例#2
0
Bool File_Read( void* file, const char* const fileName ) {
	File* self = (File*)file;
	Bool result;
	
	if( !(result = self->_read( self, fileName )) ) {
		/* If the file failed to read, try prepending the search paths (if its not an absolute path) */
		if( strlen(fileName) >= 1 && fileName[0] != '/' ) {
			int i;

			for( i = 0; i < Stg_ObjectList_Count( _stgFilePaths ); i++ ) {
				char* path = (char*)Stg_ObjectAdaptor_Object( (Stg_ObjectAdaptor*)Stg_ObjectList_At( _stgFilePaths, i ) );
				char newFileName[FILENAME_MAX];

				strncpy( newFileName, path, FILENAME_MAX-1 );
				strncat( newFileName, "/", FILENAME_MAX-1 - 1 );
				strncat( newFileName, fileName, FILENAME_MAX-1 - 1 - strlen(path) );
				if( (result = self->_read( self, newFileName )) ) {
					break;
				}
			}
		}
	}
	
	if( result ) {
		/* File opened, set the name. */
		Stg_Object_SetName( self, (char*)fileName );
		self->_opened = True;
		self->_lastOpenedAs = 1;
	}
	
	return result;
}
void TimeIntegrator_Setup( void* timeIntegrator ) {
	TimeIntegrator*        self            = (TimeIntegrator*)timeIntegrator;
	EntryPoint*            entryPoint      = self->setupEP;
	Hook_Index             hookIndex;
	double wallTime,tmin,tmax;
	
	/* Shouldn't this be using a call to a run function of the entry point class ? */ 
	for( hookIndex = 0; hookIndex < entryPoint->hooks->count; hookIndex++ ) {
		wallTime = MPI_Wtime();
		
		((EntryPoint_2VoidPtr_Cast*)((Hook*)entryPoint->hooks->data[hookIndex])->funcPtr)(
			self, Stg_ObjectList_At( self->setupData, hookIndex ) );
	
			wallTime = MPI_Wtime()-wallTime;
        	MPI_Reduce( &wallTime, &tmin, 1, MPI_DOUBLE, MPI_MIN, 0, MPI_COMM_WORLD );
        	MPI_Reduce( &wallTime, &tmax, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD );
		Journal_RPrintf(self->info,"\t       EP: %35s - %9.4f [min] / %9.4f [max] (secs)\n",(entryPoint->hooks->data[hookIndex])->name,tmin,tmax);	
	}		
}
void _GeneralSwarm_Build( void* swarm, void* data )
{
   GeneralSwarm*	self = (GeneralSwarm*) swarm;
   int			commHandler_I;
   Bool                    movementCommHandlerFound = False;
   Stream*                 errorStream = Journal_Register( Error_Type, (Name)self->type  );
   int var_I;

   _Swarm_Build( self, data );

   if( self->escapedRoutine != NULL) Stg_Component_Build( self->escapedRoutine, data , False );

   /* Since this swarm is being set up to advect a PICellerator material, it should make sure
    * at least one ParticleMovementHandler-type ParticleCommHandler has been added to the base
    * Swarm. */
   for( commHandler_I=0; commHandler_I < self->commHandlerList->count; commHandler_I++ )
   {
      ParticleCommHandler *pComm = NULL;

      pComm = (ParticleCommHandler*)(Stg_ObjectList_At( self->commHandlerList, commHandler_I ));
      if( pComm->type == ParticleMovementHandler_Type )
      {
         movementCommHandlerFound = True;
         break;
      }
   }

   Journal_Firewall( (Stg_ObjectList_Count(self->commHandlerList) >= 1) && (movementCommHandlerFound == True),
                     errorStream, "Error: for GeneralSwarm Swarms, at least one ParticleMovementHandler"
                     " commHandler must be registered. Please rectify this in your XML / code.\n" );

   for( var_I = 0 ; var_I < self->nSwarmVars ; var_I++ )
   {
      Stg_Component_Build( self->swarmVars[var_I], data , False );
   }
}
void TimeIntegrator_Finalise( void* timeIntegrator ) {
	TimeIntegrator*	self = (TimeIntegrator*)timeIntegrator;
	EntryPoint*			entryPoint = self->finishEP;
	Hook_Index			hookIndex;
	double				wallTime,tmin,tmax;
	
	for( hookIndex = 0; hookIndex < entryPoint->hooks->count; hookIndex++ ) {
		wallTime = MPI_Wtime();
		
		((EntryPoint_2VoidPtr_Cast*)((Hook*)entryPoint->hooks->data[hookIndex])->funcPtr)( self, Stg_ObjectList_At( self->finishData, hookIndex ) );

   	wallTime = MPI_Wtime()-wallTime;
		MPI_Reduce( &wallTime, &tmin, 1, MPI_DOUBLE, MPI_MIN, 0, MPI_COMM_WORLD );
		MPI_Reduce( &wallTime, &tmax, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD );
		Journal_RPrintf(self->info,"\t       EP: %35s - %9.4f (secs)\n",(entryPoint->hooks->data[hookIndex])->name,tmin,tmax);	
	}
}
Stg_Component *LiveComponentRegister_At( void* liveComponentRegister, Index index ) {
   LiveComponentRegister* self = (LiveComponentRegister*)liveComponentRegister;
   assert( self );

   return ( Stg_Component* ) Stg_ObjectList_At( self->componentList, index );
}