void _Geothermal_FieldMaps_AssignFromXML( void* component, Stg_ComponentFactory* cf, void* data ) { Geothermal_FieldMaps* self = (Geothermal_FieldMaps*)component; Dictionary* dict = Codelet_GetPluginDictionary( component, cf->rootDict ); Dictionary_Entry_Value* mapList; unsigned map_i; Stream* errorStream = Journal_Register( ErrorStream_Type, Geothermal_FieldMaps_Type ); Stream_SetPrintingRank( errorStream, 0 ); /* Plugin-wide stuff */ self->context = (AbstractContext*)Stg_ComponentFactory_ConstructByName( cf, "context", UnderworldContext, True, data ); /*self->swarm = Stg_ComponentFactory_ConstructByName( cf, Dictionary_GetString( dict, "Swarm" ), Swarm, True, data );*/ mapList = Dictionary_Get( dict, (Dictionary_Entry_Key)"maps" ); if( mapList ) { self->numMaps = Dictionary_Entry_Value_GetCount( mapList ); self->maps = malloc( self->numMaps * sizeof(Map*) ); } else { self->numMaps = 0; self->maps = NULL; } /* Per map stuff */ for( map_i = 0; map_i < self->numMaps; map_i++ ) { self->maps[map_i] = malloc( sizeof(Map) ); Dictionary* mapEntryDict = Dictionary_Entry_Value_AsDictionary( Dictionary_Entry_Value_GetElement( mapList, map_i ) ); char* tmpStr; #define SDEK Dictionary_Entry_Key #define SDGDWD Dictionary_GetDouble_WithDefault #define SDGSWD Dictionary_GetString_WithDefault #define SDGBWD Dictionary_GetBool_WithDefault #define SCFCBN Stg_ComponentFactory_ConstructByName strncpy( self->maps[map_i]->name, Dictionary_GetString( mapEntryDict, "name" ), FILENAME_MAX ); strncpy( self->maps[map_i]->outputPath, SDGSWD( mapEntryDict, (SDEK)"outputPath", self->context->outputPath ), FILENAME_MAX); self->maps[map_i]->field = SCFCBN( cf, Dictionary_GetString( mapEntryDict, "Field" ), FeVariable, True, data ); self->maps[map_i]->depth = SDGDWD( mapEntryDict, (SDEK)"depthFromSurface", 0.0 ); /* Type of map */ self->maps[map_i]->outputAllNodes = False; self->maps[map_i]->outputTopNodes = False; self->maps[map_i]->outputDepth = False; self->maps[map_i]->depth = 0.0; self->maps[map_i]->heightField = NULL; tmpStr = Dictionary_GetString( mapEntryDict, "of" ); if( strcmp( "surface", tmpStr ) == 0 ) { self->maps[map_i]->outputTopNodes = True; } else if( strcmp( "volume", tmpStr ) == 0 ) { self->maps[map_i]->outputAllNodes = True; } else if( strcmp( "depth", tmpStr ) == 0 ) { self->maps[map_i]->outputDepth = True; self->maps[map_i]->depth = SDGDWD( mapEntryDict, (SDEK)"depthFromSurface", 0.0 ); /* TODO: firewall if depth not given!!!*/ } else if( strcmp( "height", tmpStr ) == 0 ) { self->maps[map_i]->outputDepth = True; self->maps[map_i]->heightField = SCFCBN( cf, Dictionary_GetString( mapEntryDict, "HeightField" ), FieldVariable, True, data ); /* TODO: firewall if HeightField not given!!!*/ } Journal_Firewall( self->maps[map_i]->outputTopNodes || self->maps[map_i]->outputAllNodes || self->maps[map_i]->outputDepth, errorStream, "Error: On FieldMaps plugin entry %u (named: \"%s\"), the \"of\" parameter must be either \"surface\", \"volume\", " "\"depth\", or \"height\" (\"%s\" was given).\n", map_i, self->maps[map_i]->name, tmpStr ); /* Formats */ self->maps[map_i]->gocadOutput = SDGBWD( mapEntryDict, (SDEK)"GOCADOutput", True ); self->maps[map_i]->nodeValues = 0; self->maps[map_i]->nodeCoords = 0; self->maps[map_i]->topNodesCount = 0; } ContextEP_Append( self->context, AbstractContext_EP_Dump, Geothermal_FieldMaps_Dump ); }
void _VariableAllVC_ReadDictionary( void* variableCondition, void* dictionary ) { VariableAllVC* self = (VariableAllVC*)variableCondition; Dictionary_Entry_Value* vcDictVal; Dictionary_Entry_Value _vcDictVal; Dictionary_Entry_Value* varsVal; VariableAllVC_Entry_Index entry_I; /* Find dictionary entry */ if (self->_dictionaryEntryName) vcDictVal = Dictionary_Get( dictionary, self->_dictionaryEntryName ); else { vcDictVal = &_vcDictVal; Dictionary_Entry_Value_InitFromStruct( vcDictVal, dictionary ); } if (vcDictVal) { /* Obtain the variable entries */ self->_entryCount = Dictionary_Entry_Value_GetCount(Dictionary_Entry_Value_GetMember(vcDictVal, "variables")); self->_entryTbl = Memory_Alloc_Array( VariableAllVC_Entry, self->_entryCount, "VariableAllVC->_entryTbl" ); varsVal = Dictionary_Entry_Value_GetMember(vcDictVal, "variables"); for (entry_I = 0; entry_I < self->_entryCount; entry_I++) { char* valType; Dictionary_Entry_Value* valueEntry; Dictionary_Entry_Value* varDictListVal; varDictListVal = Dictionary_Entry_Value_GetElement(varsVal, entry_I); valueEntry = Dictionary_Entry_Value_GetMember(varDictListVal, "value"); self->_entryTbl[entry_I].varName = Dictionary_Entry_Value_AsString( Dictionary_Entry_Value_GetMember(varDictListVal, "name")); valType = Dictionary_Entry_Value_AsString(Dictionary_Entry_Value_GetMember(varDictListVal, "type")); if (!strcasecmp(valType, "func")) { char* funcName = Dictionary_Entry_Value_AsString(valueEntry); self->_entryTbl[entry_I].value.type = VC_ValueType_CFIndex; self->_entryTbl[entry_I].value.as.typeCFIndex = ConditionFunction_Register_GetIndex( self->conFunc_Register, funcName); } else if (!strcasecmp(valType, "array")) { Dictionary_Entry_Value* valueElement; Index i; self->_entryTbl[entry_I].value.type = VC_ValueType_DoubleArray; self->_entryTbl[entry_I].value.as.typeArray.size = Dictionary_Entry_Value_GetCount(valueEntry); self->_entryTbl[entry_I].value.as.typeArray.array = Memory_Alloc_Array( double, self->_entryTbl[entry_I].value.as.typeArray.size,"VariableAllVC->_entryTbl[].value.as.typeArray.array" ); for (i = 0; i < self->_entryTbl[entry_I].value.as.typeArray.size; i++) { valueElement = Dictionary_Entry_Value_GetElement(valueEntry, i); self->_entryTbl[entry_I].value.as.typeArray.array[i] = Dictionary_Entry_Value_AsDouble(valueElement); } } else if( !strcasecmp( valType, "double" ) || !strcasecmp( valType, "d" ) || !strcasecmp( valType, "float" ) || !strcasecmp( valType, "f" ) ) { self->_entryTbl[entry_I].value.type = VC_ValueType_Double; self->_entryTbl[entry_I].value.as.typeDouble = Dictionary_Entry_Value_AsDouble( valueEntry ); } else if( !strcasecmp( valType, "integer" ) || !strcasecmp( valType, "int" ) || !strcasecmp( valType, "i" ) ) { self->_entryTbl[entry_I].value.type = VC_ValueType_Int; self->_entryTbl[entry_I].value.as.typeInt = Dictionary_Entry_Value_AsUnsignedInt( valueEntry ); } else if( !strcasecmp( valType, "short" ) || !strcasecmp( valType, "s" ) ) { self->_entryTbl[entry_I].value.type = VC_ValueType_Short; self->_entryTbl[entry_I].value.as.typeShort = Dictionary_Entry_Value_AsUnsignedInt( valueEntry ); } else if( !strcasecmp( valType, "char" ) || !strcasecmp( valType, "c" ) ) { self->_entryTbl[entry_I].value.type = VC_ValueType_Char; self->_entryTbl[entry_I].value.as.typeChar = Dictionary_Entry_Value_AsUnsignedInt( valueEntry ); } else if( !strcasecmp( valType, "pointer" ) || !strcasecmp( valType, "ptr" ) || !strcasecmp( valType, "p" ) ) { self->_entryTbl[entry_I].value.type = VC_ValueType_Ptr; self->_entryTbl[entry_I].value.as.typePtr = (void*) ( (ArithPointer) Dictionary_Entry_Value_AsUnsignedInt( valueEntry )); } else { /* Assume double */ Journal_DPrintf( Journal_Register( InfoStream_Type, "myStream" ), "Type to variable on variable condition not given, assuming double\n" ); self->_entryTbl[entry_I].value.type = VC_ValueType_Double; self->_entryTbl[entry_I].value.as.typeDouble = Dictionary_Entry_Value_AsDouble( valueEntry ); } }
void ModulesManager_Load( void* modulesManager, void* _dictionary, Name contextName ) { ModulesManager* self = (ModulesManager*)modulesManager; Dictionary* dictionary = (Dictionary*)_dictionary; unsigned int entryCount; unsigned int entry_I; Dictionary_Entry_Value* modulesVal; /* * First add the directory list onto LD_LIBRARY_PATH so that it can potentially * resolve the unknown symbols */ #ifndef NOSHARED char* curEnvPath; char* newEnvPath; Index newEnvPathLength; Index dir_I; Index i, count; char* dir; newEnvPathLength = 0; if( dictionary ) { Dictionary_Entry_Value* localLibDirList = Dictionary_Get( dictionary, "LD_LIBRARY_PATH" ); if( localLibDirList ) { count = Dictionary_Entry_Value_GetCount( localLibDirList ); for( i = 0; i < count; ++i ) { dir = Dictionary_Entry_Value_AsString( Dictionary_Entry_Value_GetElement( localLibDirList, i ) ); ModulesManager_AddDirectory( "FromDictionary", dir ); } } } for( dir_I = 0; dir_I < moduleDirectories->count; ++dir_I ) { newEnvPathLength += strlen( (char*)Stg_ObjectList_ObjectAt( moduleDirectories, dir_I ) ); /* Add one make space for the ':' inbetween the directories */ newEnvPathLength += 1; } curEnvPath = getenv("LD_LIBRARY_PATH"); if( curEnvPath ) { newEnvPathLength += strlen( curEnvPath ); } if( newEnvPathLength > 0 ) { /* Add one to make space for the Null Terminator '\0' */ newEnvPathLength += 1; newEnvPath = Memory_Alloc_Array( char, newEnvPathLength, "LD_LIBRARY_PATH" ); newEnvPath[0] = '\0'; for( dir_I = 0; dir_I < moduleDirectories->count; ++dir_I ) { strcat( newEnvPath, (char*)Stg_ObjectList_ObjectAt( moduleDirectories, dir_I ) ); strcat( newEnvPath, ":" ); } if( curEnvPath ) { strcat( newEnvPath, curEnvPath ); } setenv( "LD_LIBRARY_PATH", newEnvPath, 1 ); Journal_Printf( Journal_Register( Debug_Type, self->type ), "Using LD_LIBRARY_PATH=%s\n", newEnvPath ); Memory_Free( newEnvPath ); }
void _FieldVariable_AssignFromXML( void* fieldVariable, Stg_ComponentFactory* cf, void* data ) { FieldVariable* self = (FieldVariable*)fieldVariable; FieldVariable_Register* fV_Register=NULL; Dimension_Index dim; Index fieldComponentCount; Bool isCheckpointedAndReloaded, isCheckpointedAndReloaded2; Dictionary_Entry_Value* feVarsList = NULL; char* o_units = NULL; DomainContext* context; Bool useCacheMaxMin; context = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"Context", DomainContext, False, data ); if( !context ) context = Stg_ComponentFactory_ConstructByName( cf, (Name)"context", DomainContext, False, data ); if (context) { fV_Register = context->fieldVariable_Register; assert( fV_Register ); } dim = Stg_ComponentFactory_GetRootDictUnsignedInt( cf, (Dictionary_Entry_Key)"dim", 0 ); /* allow this to be overwritten by the component dub dict */ dim = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, (Dictionary_Entry_Key)"dim", dim ); fieldComponentCount = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, (Dictionary_Entry_Key)"fieldComponentCount", 0 ); useCacheMaxMin = Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"useCacheMaxMin", False ); o_units = Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"outputUnits", NULL ); /* * Decide whether this FieldVariable will be checkpointed & reloaded, based on the dictionary list * "fieldVariableToCheckpoint". NB may want to put this in the XML component definintion of a * FieldVariable itself, but for now prefer list so it can be centrally set. * -- Pat, Jules, Kath - 29 November 2006 */ isCheckpointedAndReloaded2 = Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"isCheckpointedAndReloaded", False ); /* Case insensitive search */ feVarsList = Dictionary_Get( cf->rootDict, (Dictionary_Entry_Key)"fieldVariablesToCheckpoint" ); if( NULL == feVarsList ) { feVarsList = Dictionary_Get( cf->rootDict, (Dictionary_Entry_Key)"FieldVariablesToCheckpoint" ); } if( feVarsList != NULL ) { Index listLength = Dictionary_Entry_Value_GetCount( feVarsList ); Index var_I = 0; Dictionary_Entry_Value* feVarDictValue = NULL; char* fieldVariableName; /* if the 'fieldVariablesToCheckpoint' list is empty (but exists) * checkpoint every field * else selectively checkpoint based on list entries */ if( listLength == 0 ) { isCheckpointedAndReloaded = True; } else { isCheckpointedAndReloaded = False; for ( var_I = 0; var_I < listLength; var_I++ ) { feVarDictValue = Dictionary_Entry_Value_GetElement( feVarsList, var_I ); fieldVariableName = Dictionary_Entry_Value_AsString( feVarDictValue ); if ( 0 == strcmp( self->name, fieldVariableName ) ) { isCheckpointedAndReloaded = True; break; } } } } else { /* If there's no special list, just checkpoint/reload everything. */ isCheckpointedAndReloaded = True; } isCheckpointedAndReloaded = (isCheckpointedAndReloaded || isCheckpointedAndReloaded2 ); feVarsList = NULL; /* also include check to see if this fevariable should be saved for analysis purposes */ feVarsList = Dictionary_Get( cf->rootDict, (Dictionary_Entry_Key)"fieldVariablesToSave" ); if( NULL == feVarsList ) { feVarsList = Dictionary_Get( cf->rootDict, (Dictionary_Entry_Key)"FieldVariablesToSave" ); } if( feVarsList != NULL ) { Index listLength = Dictionary_Entry_Value_GetCount( feVarsList ); Index var_I = 0; Dictionary_Entry_Value* feVarDictValue = NULL; char* fieldVariableName; for( var_I = 0; var_I < listLength; var_I++ ) { feVarDictValue = Dictionary_Entry_Value_GetElement( feVarsList, var_I ); fieldVariableName = Dictionary_Entry_Value_AsString( feVarDictValue ); if( 0 == strcmp( self->name, fieldVariableName ) ) { self->isSavedData = True; break; } } } _FieldVariable_Init( self, context, fieldComponentCount, dim, isCheckpointedAndReloaded, o_units, MPI_COMM_WORLD, fV_Register, useCacheMaxMin ); }