Example #1
0
CMreturn NFparseObjAliasFinalize(NFobject_p parent, NFobject_p object) {
    NFobjList_p list;

    if (object->Type != NFobjAlias) {
        CMmsgPrint(CMmsgAppError, "This shouldn't have happened in %s%d.\n", __FILE__, __LINE__);
        goto Abort;
    }
    switch (parent->Type) {
        case NFcompRegion:
            list = ((NFcompRegion_p) parent)->Aliases;
            break;
        case NFmodEquation:
            list = ((NFmodEquation_p) parent)->Aliases;
            break;
        case NFmodProcess:
            list = ((NFmodProcess_p) parent)->Aliases;
            break;
        default:
            CMmsgPrint(CMmsgAppError, "This shouldn't have happened in %s%d.\n", __FILE__, __LINE__);
            goto Abort;
    }
    if (NFobjListAddItem(list, object) == CMfailed) {
        CMmsgPrint(CMmsgAppError, "Error adding alias to %s in %s:%d\n", NFobjTypeName(object->Parent->Type), __FILE__,
                   __LINE__);
        goto Abort;
    }
    return (CMsucceeded);
    Abort:
    NFobjectFree(object);
    return (CMfailed);
}
Example #2
0
CMreturn NFparseCompContainerFinalize(NFobject_p parent, NFobject_p object) {
    ;
    NFcompModel_p model;

    if (object->Type != NFcompContainer) {
        CMmsgPrint(CMmsgAppError, "This shouldn't have happened in %s:%d!\n", __FILE__, __LINE__);
        return (CMfailed);
        goto Abort;
    }
    switch (parent->Type) {
        case NFcompContainer:
            if (NFobjListAddItem(((NFcompContainer_p) parent)->Components, object) != CMsucceeded) {
                CMmsgPrint(CMmsgAppError, "Error adding component to model in %s:%d\n", __FILE__, __LINE__);
                goto Abort;
            }
        case NFcompModel:
            model = (NFcompModel_p) NFobjectRoot(parent);
            if (NFobjListAddItem(model->Components, object) != CMsucceeded) {
                CMmsgPrint(CMmsgAppError, "Error adding component to model in %s:%d\n", __FILE__, __LINE__);
                goto Abort;
            }
            break;
        default:
            CMmsgPrint(CMmsgAppError, "This shouldn't have happened in %s:%d!\n", __FILE__, __LINE__);
            goto Abort;
    }
    return (CMsucceeded);
    Abort:
    NFobjectFree(object);
    return (CMfailed);
}
Example #3
0
NFobject_p NFparseObjAliasCreate(XML_Parser parser, NFobject_p parent, const char *name, const char **attr) {
    const char *attrib;
    NFobjAlias_p alias = (NFobjAlias_p) NULL;

    if ((parent->Type != NFcompRegion) && (parent->Type != NFmodEquation) && (parent->Type != NFmodProcess)) {
        CMmsgPrint(CMmsgAppError, "This shouldn't have happened in %s%d.\n", __FILE__, __LINE__);
        goto Abort;
    }
    if ((alias = (NFobjAlias_p) NFobjectCreate(name, NFobjAlias)) == (NFobjAlias_p) NULL) {
        CMmsgPrint(CMmsgAppError, "Alias creation error in %s:%d.\n", __FILE__, __LINE__);
        goto Abort;
    }
    attrib = NFparseGetAttribute(attr, NFattrValueStr, NFkeyVariableStr);
    if ((strcmp(attrib, NFkeyVariableStr) != 0) && (strcmp(attrib, NFkeyParameterStr) != 0)) {
        CMmsgPrint(CMmsgUsrError, "Invalid alias type in line %d!\n", XML_GetCurrentLineNumber(parser));
        goto Abort;
    }
    alias->AliasType = strcmp(attrib, NFkeyVariableStr) == 0 ? NFaliasVariable : NFaliasParameter;
    if ((attrib = NFparseGetAttribute(attr, NFobjAliasStr, (char *) NULL)) == (char *) NULL) {
        CMmsgPrint(CMmsgUsrError, "Missing alias attribute URL in line %d!\n", XML_GetCurrentLineNumber(parser));
        goto Abort;
    }
    alias->Alias = CMstrDuplicate(attrib);

    alias->Parent = parent;
    return ((NFobject_p) alias);
    Abort:
    if (alias != (NFobjAlias_p) NULL) NFobjectFree((NFobject_p) alias);
    return ((NFobject_p) NULL);
}
Example #4
0
NFobject_p NFparseCompRegionCreate(XML_Parser parser, NFobject_p parent, const char *name, const char **attr) {
    NFcompRegion_p component = (NFcompRegion_p) NULL;

    if (parent->Type != NFcompContainer) {
        CMmsgPrint(CMmsgAppError, "This shouldn't have happened in %s%d\n", __FILE__, __LINE__);
        goto Abort;
    }
    if ((component = (NFcompRegion_p) NFobjectCreate(name, NFcompRegion)) == (NFcompRegion_p) NULL) {
        CMmsgPrint(CMmsgAppError, "Region component creation error in %s:%d\n", __FILE__, __LINE__);
        goto Abort;
    }
    if (parent->Type != NFcompContainer) {
        CMmsgPrint(CMmsgAppError, "This shouldn't have happened in %s%d\n", __FILE__, __LINE__);
        goto Abort;
    }

//    variable CDATA #REQUIRED
//   condition (&lt|&le|&eq|&ne|&ge|&gt) #REQUIRED
//       value CDATA #REQUIRED>
    component->TimeStep = ((NFcomponent_p) parent)->TimeStep;
    component->Parent = parent;
    return ((NFobject_p) component);
    Abort:
    if (component != (NFcompRegion_p) NULL) NFobjectFree((NFobject_p) component);
    return ((NFobject_p) NULL);
}
Example #5
0
CMreturn NFparseModInterfaceFinalize(NFobject_p parent, NFobject_p object) {
    NFmodInterface_p interface = (NFmodInterface_p) object;

    if ((object->Type != NFmodInterface) || (parent->Type != NFcompContainer)) {
        CMmsgPrint(CMmsgAppError, "Wrong object in %s:%d\n", __FILE__, __LINE__);
        goto Abort;
    }
    if (NFobjListAddItem(((NFcompContainer_p) parent)->Modules, object) != CMsucceeded) {
        CMmsgPrint(CMmsgAppError, "Error adding interface to container in %s:%d\n", __FILE__, __LINE__);
        goto Abort;
    }
    if (NFobjListAddItem(((NFcompContainer_p) parent)->Variables, (NFobject_p) ((NFmodInterface_p) object)->Variable) !=
            CMsucceeded) {
        CMmsgPrint(CMmsgAppError, "Error adding variable to container in %s:%d\n", __FILE__, __LINE__);
        goto Abort;
    }
    if ((interface->Coupler = NFcouplerGet(interface->Component, (NFcomponent_p) (interface->Parent),
                                           interface->CouplerType)) == (NFcoupler_p) NULL) {
        CMmsgPrint(CMmsgAppError, "Interface error in %s:%d\n", __FILE__, __LINE__);
        goto Abort;
    }
    return (CMsucceeded);
Abort:
    NFobjectFree(object);
    return (CMfailed);
}
Example #6
0
static void _NFmodEquationFree(NFobject_p object) {
    NFmodEquation_p module = (NFmodEquation_p) object;

    if (module->Variable != (NFnumVariable_p) NULL) NFobjectFree((NFobject_p) module->Variable);
    NFobjListFree(module->InputVars);
    NFobjListFree(module->Aliases);
    NFobjListFree(module->Parameters);
}
Example #7
0
/****************************************************************************************************************
 * Object List free
*****************************************************************************************************************/
void NFobjListFree(NFobjList_p list) {
    size_t i;

    for (i = 0; i < list->Num; ++i)
        if (list->Parent == (list->List[i])->Parent) NFobjectFree(list->List[i]);
    if (list->List != (NFobject_p *) NULL) free(list->List);
    free(list);
    return;
}
Example #8
0
CMreturn NFparseCompModelFinalize(NFobject_p object) {

    if (object->Type != NFcompModel) {
        CMmsgPrint(CMmsgAppError, "This shouldn't have happened in %s%d.\n", __FILE__, __LINE__);
        goto Abort;
    }
    return (CMsucceeded);
    Abort:
    NFobjectFree(object);
    return (CMfailed);
}
Example #9
0
NFobject_p NFparseModProcessCreate (XML_Parser parser,NFobject_p parent,const char *name, const char **attr) {
	const char *attrib;

	NFmodProcess_p module = (NFmodProcess_p) NULL;
	NFcompModel_p  model;
	NFobjPlugin_p  plugin = (NFobjPlugin_p)  NULL;

	if (parent->Type != NFcompContainer) {
		CMmsgPrint (CMmsgAppError, "This shouldn't have happened in %s%d.\n",__FILE__,__LINE__);
		goto Abort;
	}

	if ((module = (NFmodProcess_p) NFobjectCreate (name,NFmodProcess)) == (NFmodProcess_p) NULL) {
		CMmsgPrint (CMmsgAppError, "Process module creation error in %s:%d\n",__FILE__,__LINE__);
		goto Abort;
	}
	if ((attrib = NFparseGetAttribute (attr, NFobjPluginStr, (char *) NULL)) == (char *) NULL) {
		CMmsgPrint (CMmsgUsrError, "Missing process [%s] plugi in line %d!\n",name, XML_GetCurrentLineNumber (parser));
		goto Abort;
	}
	model = (NFcompModel_p) NFobjectRoot (parent);
	if ((plugin = NFpluginGet (model->ModPlugins,attrib)) == (NFobjPlugin_p) NULL) {
		CMmsgPrint (CMmsgUsrError, "Modules plugin [%s] loading error in line %d!\n",attrib, XML_GetCurrentLineNumber (parser));
		goto Abort;
	}
	if ((attrib = NFparseGetAttribute (attr, NFattrMethodStr, (char *) NULL)) == (char *) NULL) {
		CMmsgPrint (CMmsgUsrError, "Missing plugin [%s] method in line %d!\n",plugin->Name, XML_GetCurrentLineNumber (parser));
		goto Abort;
	}
	if ((module->Initialize = (NFinitializeFunc) NFpluginFunction (plugin, NFfuncInitializeStr, attrib)) == (NFinitializeFunc) NULL) {
		CMmsgPrint (CMmsgUsrError, "Error loding plugin [%s] function [%s] in line %d!\n",plugin->Name, attrib, XML_GetCurrentLineNumber (parser));
		goto Abort;
	}
	if ((module->Execute    = (NFexecuteFunc)    NFpluginFunction (plugin, NFfuncExecuteStr,   attrib)) == (NFexecuteFunc)    NULL) {
		CMmsgPrint (CMmsgUsrError, "Error loding plugin [%s] function [%s] in line %d!\n",plugin->Name, attrib, XML_GetCurrentLineNumber (parser));
		goto Abort;
	}
	if ((module->Finalize   = (NFfinalizeFunc)   NFpluginFunction (plugin, NFfuncFinalizeStr,  attrib)) == (NFfinalizeFunc)   NULL) {
		CMmsgPrint (CMmsgUsrError, "Error loading plugin [%s] function [%s] in line %d!\n",plugin->Name, attrib, XML_GetCurrentLineNumber (parser));
		goto Abort;
	}
	module->Initialize (module->Context);
	if ((module->Context->UserData = (void *) malloc (module->Context->UserDataSize)) == (void *) NULL) {
		CMmsgPrint (CMmsgSysError, "Memory allocation errord in %s:%d\n",__FILE__,__LINE__);
		goto Abort;
	}
	module->Parent = parent;
	CMmsgPrint (CMmsgInfo,"Parameter num: %d Variable num: %d\n", module->Context->ParameterNum, module->Context->VariableNum);
	return ((NFobject_p) module);
Abort:
	if (module != (NFmodProcess_p) NULL) NFobjectFree ((NFobject_p) module);
	return ((NFobject_p) NULL);	
}
Example #10
0
/****************************************************************************************************************
 * Parse configuration
*****************************************************************************************************************/
NFcompModel_p NFmodelParse (FILE *inFile, bool report)
{
	char *doc;

	NFdata_t      data;
	XML_Parser parser;

	data.SkipName   = "root";
	data.Abort      = false;
	data.Buffer     = (char *) NULL;
	data.BufferLen  = 0;
	data.Skip       = false;
	data.Stack      =
	data.StackSize  =
	data.SkipLevel  = 0;
	data.Model      = (NFcompModel_p) NULL;
	data.Objects    = (NFobject_p *)  NULL;

	if ((doc = _NFreadDoc (inFile)) == (char *) NULL) {
		CMmsgPrint (CMmsgAppError, "Document reading error in %s:%d\n",__FILE__,__LINE__);
		return ((NFcompModel_p) NULL);
	}

	if ((parser = XML_ParserCreate(NULL)) == (XML_Parser) NULL) {
		CMmsgPrint (CMmsgSysError, "Memory allocation in %s:%d\n",__FILE__,__LINE__);
		return ((NFcompModel_p) NULL);
	}

	XML_SetUserData             (parser, &data);
	XML_SetElementHandler       (parser, _NFentryStart, _NFentryEnd);
	XML_SetCharacterDataHandler (parser, _NFentryText);
	XML_UseParserAsHandlerArg   (parser);

	if (XML_Parse(parser, doc, strlen (doc), true) == XML_STATUS_ERROR) {
		CMmsgPrint (CMmsgAppError,"Parse error at line %d\n", XML_GetCurrentLineNumber(parser));
		return ((NFcompModel_p) NULL);
	}
	XML_ParserFree (parser);
	if (data.Objects != (NFobject_p *) NULL) free (data.Objects);
	if ((data.Abort) && (data.Model != (NFcompModel_p) NULL)) {
		NFobjectFree ((NFobject_p) data.Model);
		return ((NFcompModel_p) NULL);
	}
	if (report) NFobjectPrint ((NFobject_p) (data.Model));
	return (data.Model);
}
Example #11
0
CMreturn NFparseModProcessFinalize (NFobject_p parent, NFobject_p object) {
	size_t i, j;
	NFmodProcess_p module = (NFmodProcess_p) object;

	if ((object->Type != NFmodProcess) || (parent->Type != NFcompContainer)) {
		CMmsgPrint (CMmsgUsrError, "This shouldn't have happend in %s:%d.\n",__FILE__,__LINE__);
		goto Abort;
	}
	if (NFobjListAddItem (((NFcompContainer_p) parent)->Modules, object) != CMsucceeded) {
		CMmsgPrint (CMmsgAppError, "Error adding process module to container in %s:%d\n",__FILE__,__LINE__);
		goto Abort;
	}
	for (i = 0;i < module->Context->ParameterNum; ++i) {
	
	}
	for (i = 0;i < module->Context->VariableNum;  ++i) {
		if ((module->Context->Variables [i].Role == NFinput) ||
			(module->Context->Variables [i].Role == NFmodified)) {
			for (j = 0; j < module->Aliases->Num; ++j) {
				if ((((NFobjAlias_p) module->Aliases->List [j])->AliasType == NFaliasVariable) &&
					(strcmp (module->Context->Variables [i].Name, (((NFobjAlias_p) module->Aliases->List [j])->Alias)) == 0))
					break;
			}
			if (j == module->Aliases->Num) {
				CMmsgPrint (CMmsgAppError,"Process [%s] variable [%s] is not found!\n", module->Name, module->Context->Variables [i].Name);
				goto Abort;
			}
		}
		else {
			
		}
	}

	module->Execute    (module->Context->UserData);
	module->Finalize   (module->Context->UserData);

	return (CMsucceeded);
Abort:
	NFobjectFree (object);
	return (CMfailed);
}
Example #12
0
NFobject_p NFparseCompModelCreate(XML_Parser parser, const char *name, const char **attr) {
    NFcompModel_p model = (NFcompModel_p) NULL;

    if ((model = (NFcompModel_p) NFobjectCreate(name, NFcompModel)) == (NFcompModel_p) NULL) {
        CMmsgPrint(CMmsgAppError, "Creating model in %s:%d\n", __FILE__, __LINE__);
        goto Abort;
    }
    if (NFtimeSetFromString(model->Begin, NFparseGetAttribute(attr, NFattrBeginStr, "0000-01-01")) == false) {
        CMmsgPrint(CMmsgAppError, "Begin time setting error in %s:%d!\n", __FILE__, __LINE__);
        goto Abort;
    }
    if (NFtimeSetFromString(model->End, NFparseGetAttribute(attr, NFattrEndStr, "0000-12-31")) == false) {
        CMmsgPrint(CMmsgAppError, "End time setting error in %s:%d!\n", __FILE__, __LINE__);
        goto Abort;

    }
    model->Version = CMstrDuplicate(NFparseGetAttribute(attr, NFattrVersionStr, "noversion"));
    return ((NFobject_p) model);
    Abort:
    if (model != (NFcompModel_p) NULL) NFobjectFree((NFobject_p) model);
    return ((NFobject_p) NULL);
}
Example #13
0
NFobject_p NFparseCompContainerCreate(XML_Parser parser, NFobject_p parent, const char *name, const char **attr) {
    const char *attrib;
    NFcompContainer_p component = (NFcompContainer_p) NULL;
    NFcompModel_p model;
    NFcomponent_p sibling;
    NFobjList_p componentList;
    NFtimeStep_p timeStep;

    if ((parent->Type != NFcompModel) && (parent->Type != NFcompContainer)) {
        CMmsgPrint(CMmsgAppError, "This shouldn't have happened in %s%d\n", __FILE__, __LINE__);
        goto Abort;
    }
    if ((component = (NFcompContainer_p) NFobjectCreate(name, NFcompContainer)) == (NFcompContainer_p) NULL) {
        CMmsgPrint(CMmsgAppError, "Component creation error in %s:%d\n", __FILE__, __LINE__);
        goto Abort;
    }
    attrib = NFparseGetAttribute(attr, NFcompLayoutStr, NFkeyInheritStr);
    if (strcmp(attrib, NFkeyInheritStr) == 0) {
        if (parent->Type == NFcompContainer)
            component->Domain = ((NFcomponent_p) parent)->Domain;
        else {
            CMmsgPrint(CMmsgUsrError, "Container [%s] in model can't inherit layout in line %d!\n", name,
                       XML_GetCurrentLineNumber(parser));
            goto Abort;
        }
    }
    else {
        switch (parent->Type) {
            case NFcompContainer:
                componentList = ((NFcompContainer_p) parent)->Components;
                break;
            case NFcompModel:
                componentList = ((NFcompModel_p) parent)->Components;
                break;
            default:
                CMmsgPrint(CMmsgUsrError, "This shouldn't have happened in %s,%d!\n", __FILE__, __LINE__);
                goto Abort;
        }
        if ((sibling = (NFcomponent_p) NFobjListFindItemByName(componentList, attrib)) == (NFcomponent_p) NULL) {
            CMmsgPrint(CMmsgUsrError, "Invalid container [%s] layout [%s] in line %d.\n", name, attrib,
                       XML_GetCurrentLineNumber(parser));
            goto Abort;
        }
        component->Domain = sibling->Domain;
    }
    model = (NFcompModel_p) NFobjectRoot(parent);
    attrib = NFparseGetAttribute(attr, NFattrTimeStepStr, "inherit");
    if (strcmp(attrib, NFkeyInheritStr) == 0) {
        switch (parent->Type) {
            case NFcompContainer:
            case NFcompModel:
                component->TimeStep = ((NFcomponent_p) parent)->TimeStep;
                break;
            default:
                CMmsgPrint(CMmsgAppError, "This shouldn't have happened in %s%d!\n", __FILE__, __LINE__);
                goto Abort;
        }
    }
    else {
        if (NFtimeStepSetFromString(component->TimeStep, attrib) == false) {
            CMmsgPrint(CMmsgAppError, "Time step [%s] error in %d!\n", attrib, XML_GetCurrentLineNumber(parser));
            goto Abort;
        }
        if ((timeStep = NFmodelAddTimeStep(model, component->TimeStep)) != component->TimeStep) {
            NFtimeStepFree(component->TimeStep);
            component->TimeStep = timeStep;
        }
    }
    if ((attrib = NFparseGetAttribute(attr, NFattrStatesStr, (char *) NULL)) == (char *) NULL) {
        CMmsgPrint(CMmsgUsrError, "Missing container state in line %d\n", XML_GetCurrentLineNumber(parser));
        goto Abort;
    }
    component->States = CMstrDuplicate(attrib);

    component->Parent = parent;
    return ((NFobject_p) component);
    Abort:
    if (component != (NFcompContainer_p) NULL) NFobjectFree((NFobject_p) component);
    return ((NFobject_p) NULL);
}
Example #14
0
NFobject_p NFparseModInterfaceCreate (XML_Parser parser,NFobject_p parent,const char *name, const char **attr) {
	const char *attrib;
	NFmodInterface_p module   = (NFmodInterface_p) NULL;
	NFnumVariable_p  inputVar;
	NFobject_p       component;
	NFobjList_p list;

	if ((parent->Type != NFcompContainer) || (parent->Parent == (NFobject_p) NULL))  {
		CMmsgPrint (CMmsgAppError, "This shouldn't have happened in %s%d.\n",__FILE__,__LINE__);
		goto Abort;
	}
	if ((attrib = NFparseGetAttribute (attr, NFattrRelationStr, (char *) NULL)) == (char *) NULL) {
		CMmsgPrint (CMmsgUsrError, "Missing interface [%s] relation in %d!\n",name, XML_GetCurrentLineNumber (parser));
		goto Abort;
	}
	if      (strcmp (attrib,NFkeyRootStr)   == 0) {
		component = NFobjectRoot (parent);
		if (component->Type == NFcompModel) list = ((NFcompModel_p) component)->Components;
		else {
			CMmsgPrint (CMmsgAppError, "This shouldn't have happened in %s%d.\n",__FILE__,__LINE__);
			goto Abort;
		}
	}
	else if (strcmp (attrib,NFkeyParentStr) == 0) {
		component = parent->Parent;
		switch (component->Type) {
		case NFcompModel:     list = ((NFcompModel_p)     component)->Components; break;
		case NFcompContainer: list = ((NFcompContainer_p) component)->Components; break;
		default:
			CMmsgPrint (CMmsgAppError, "This shouldn't have happened in %s%d.\n",__FILE__,__LINE__);
			goto Abort;
		}
	}
	else if (strcmp (attrib,NFkeyOwnStr)    == 0) list = ((NFcompModel_p) parent)->Components;

	if ((attrib = NFparseGetAttribute (attr, NFcomponentStr, (char *) NULL)) == (char *) NULL) {
		CMmsgPrint (CMmsgUsrError, "Missing interface [%s] component in %d!\n",name, XML_GetCurrentLineNumber (parser));
		goto Abort;
	}
	if ((component = NFobjListFindItemByName (list,attrib)) == (NFobject_p) NULL) {
		CMmsgPrint (CMmsgUsrError, "Invalid interface [%s] component [%s] in line %d!\n",name, attrib, XML_GetCurrentLineNumber (parser));
		goto Abort;
	}
	if ((attrib = NFparseGetAttribute (attr, NFcomponentStr, (char *) NULL)) == (char *) NULL) {
		CMmsgPrint (CMmsgUsrError, "Missing interface [%s] component in %d!\n",name, XML_GetCurrentLineNumber (parser));
		goto Abort;
	}
	if ((component = NFobjListFindItemByName (list,attrib)) == (NFobject_p) NULL) {
		CMmsgPrint (CMmsgUsrError, "Invalid interface [%s] component [%s] in line %d!\n",name, attrib, XML_GetCurrentLineNumber (parser));
		goto Abort;
	}
	if ((attrib = NFparseGetAttribute (attr, NFnumVariableStr, (char *) NULL)) == (char *) NULL) {
		CMmsgPrint (CMmsgUsrError, "Missing interface [%s] variable in line %d!\n",name,XML_GetCurrentLineNumber (parser));
		goto Abort;
	}
	switch (component->Type) {
	case NFcompAggregate: inputVar = (NFnumVariable_p) NFobjListFindItemByName (((NFcompAggregate_p) component)->Variables,attrib); break;
	case NFcompInput:     inputVar = (NFnumVariable_p) NFobjListFindItemByName (((NFcompInput_p    ) component)->Variables,attrib); break;
	case NFcompContainer: inputVar = (NFnumVariable_p) NFobjListFindItemByName (((NFcompContainer_p) component)->Variables,attrib); break;
	default:
		CMmsgPrint (CMmsgAppError, "This shouldn't have happened in %s%d.\n",__FILE__,__LINE__);
		goto Abort;
	}
	if (inputVar == (NFnumVariable_p) NULL) {
		CMmsgPrint (CMmsgUsrError, "Missing interface [%s] variable [%s] in line %d!\n",name, attrib, XML_GetCurrentLineNumber (parser));
		goto Abort;
	}
	if ((module    = (NFmodInterface_p) NFobjectCreate (name,NFmodInterface)) == (NFmodInterface_p) NULL) {
		CMmsgPrint (CMmsgAppError, "Interface module creation error in %s:%d.\n",__FILE__,__LINE__);
		goto Abort;
	}
	if ((module->Variable = (NFnumVariable_p) NFobjectCreate (name,NFnumVariable))  == (NFnumVariable_p) NULL) {
		CMmsgPrint (CMmsgAppError, "Derivative variable creation error in %s:%d.\n",__FILE__,__LINE__);
		goto Abort;
	}
	if ((attrib = NFparseGetAttribute (attr, NFattrCouplerStr, (char *) NULL)) != (char *) NULL) {
		if      (strcmp (attrib,NFkeyCouplerFluxStr)  == 0) module->CouplerType = NFcouplerFlux;
		else if (strcmp (attrib,NFkeyCouplerPointStr) == 0) module->CouplerType = NFcouplerPoint;
		else if (strcmp (attrib,NFkeyCouplerSurfStr)  == 0) module->CouplerType = NFcouplerSurface;
		// TODO set interface weight when the coupler type is point!
	}
	module->Component = (NFcomponent_p) component;
	module->Variable->Parent  = (NFobject_p) module;
	module->Variable->StandardName = CMstrDuplicate (inputVar->StandardName);
	module->Variable->UnitString   = CMstrDuplicate (inputVar->UnitString);

	module->InputVar   = inputVar;

	module->Parent = parent;
	return ((NFobject_p) module);
Abort:
	if (module           != (NFmodInterface_p) NULL) {
		if (module->Variable != (NFnumVariable_p) NULL)
			NFobjectFree ((NFobject_p) module->Variable);
		NFobjectFree ((NFobject_p) module);
	}
	return ((NFobject_p) NULL);
}
Example #15
0
static void _NFobjCategoryFree(NFobject_p object) {
    NFobjCategory_p category = (NFobjCategory_p) object;

    if (category->Values != (char *) NULL) free(category->Values);
    if (category->Variable != (NFnumVariable_p) NULL) NFobjectFree((NFobject_p) category->Variable);
}
Example #16
0
static void _NFmodRouteFree(NFobject_p object) {
    NFmodRoute_p module = (NFmodRoute_p) object;

    if (module->Variable != (NFnumVariable_p) NULL) NFobjectFree((NFobject_p) module->Variable);
}