Ejemplo n.º 1
0
int MDGrossRadDef () {
    int optID = MFUnset;
    const char *optStr, *optName = MDVarGrossRadiance;
    const char *options [] = { MDInputStr, "standard", "Otto", (char *) NULL };
    float par;

    if (_MDOutGrossRadID != MFUnset) return (_MDOutGrossRadID);

    MFDefEntering ("Gross Radiance");
    if ((optStr = MFOptionGet (optName)) != (char *) NULL) optID = CMoptLookup (options, optStr, true);

    switch (optID) {
    case MDinput:
        _MDOutGrossRadID = MFVarGetID (MDVarGrossRadiance, "MJ/m^2", MFInput,  MFFlux,  MFBoundary);
        break;
    case MDstandard:
        if (((optStr = MFOptionGet (MDParGrossRadTAU)) != (char *) NULL) && (sscanf (optStr,"%f",&par) == 1))
            _MDGrossRadStdTAU = par;
        if (((_MDOutGrossRadID    = MFVarGetID (MDVarGrossRadiance, "MJ/m^2", MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
                (MFModelAddFunction (_MDGrossRadianceStd)  == CMfailed)) return (CMfailed);
        break;
    case MDOtto:
        if (((_MDOutGrossRadID    = MFVarGetID (MDVarGrossRadiance, "MJ/m^2", MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
                (MFModelAddFunction (_MDGrossRadianceOtto) == CMfailed)) return (CMfailed);
        break;
    default:
        MFOptionMessage (optName, optStr, options);
        return (CMfailed);
    }
    MFDefLeaving ("Gross Radiance");
    return (_MDOutGrossRadID);
}
Ejemplo n.º 2
0
int MDBaseFlowDef () {
	float par;
	const char *optStr;
        // Test if the percolation pathway is active (if its not - PercolationBETA should not be in the Options)
        if ((optStr = MFOptionGet(MDParSoilPercolationBETA)) != (char *) NULL) {        
            if ((_MDInSoilPercolationID = MFVarGetID (MDVarSoilPercolation,     "mm", MFInput, MFFlux,   MFBoundary)) == CMfailed) return (CMfailed); // SZ 10212014
        }
        
        int  optID = MFUnset;                                                                                   // RJS 060214
	const char *optName = MDVarRunoff;                                                                      // RJS 060214
	const char *options [] = { "spatially", MDCalculateStr, MDPnETStr, (char *) NULL };                                // RJS 060214

	if (_MDOutBaseFlowID != MFUnset) return (_MDOutBaseFlowID);

	MFDefEntering ("Base flow");

	if ((optStr  = MFOptionGet (optName)) != (char *) NULL) optID = CMoptLookup (options, optStr, true);    // RJS 060214

        switch (optID) {
            case MDspatial:
                if ((_MDInGroundWatBETAID     = MFVarGetID(MDParGroundWatBETA,       "1/d", MFInput, MFState, MFBoundary)) == CMfailed) return (CMfailed);
             case MDcalculate: 	
                 if (_MDInGroundWatBETAID == MFUnset) {
                    if (((optStr = MFOptionGet (MDParGroundWatBETA))  != (char *) NULL) && (sscanf (optStr,"%f",&par) == 1)) _MDGroundWatBETA = par;
                 }
                if (((_MDInRechargeID       = MDRainInfiltrationDef ()) == CMfailed) ||
                    ((_MDInIrrGrossDemandID = MDIrrGrossDemandDef   ()) == CMfailed)) return (CMfailed);

                if ( _MDInIrrGrossDemandID != MFUnset) {
                        if (((_MDInSmallResReleaseID    = MDSmallReservoirReleaseDef ()) == CMfailed) ||
                            ((_MDInIrrAreaFracID        = MDIrrigatedAreaDef         ()) ==  CMfailed) ||
                            ((_MDInIrrReturnFlowID      = MFVarGetID (MDVarIrrReturnFlow,     "mm", MFInput,  MFFlux,  MFBoundary)) == CMfailed) ||
                            ((_MDOutIrrUptakeExternalID = MFVarGetID (MDVarIrrUptakeExternal, "mm", MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
                            ((_MDOutIrrUptakeGrdWaterID = MDIrrUptakeGrdWaterDef     ()) == CMfailed))
                            return CMfailed;
                 }
                if (((_MDOutGrdWatID                = MFVarGetID (MDVarGroundWater,         "mm", MFOutput, MFState, MFInitial))  == CMfailed) ||
                    ((_MDOutGrdWatChgID             = MFVarGetID (MDVarGroundWaterChange,   "mm", MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
                    ((_MDOutGrdWatRechargeID        = MFVarGetID (MDVarGroundWaterRecharge, "mm", MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
                    ((_MDOutGrdWatUptakeID          = MFVarGetID (MDVarGroundWaterUptake,   "mm", MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
                    ((_MDOutBaseFlowID              = MFVarGetID (MDVarBaseFlow,            "mm", MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
                     (MFModelAddFunction (_MDBaseFlow) == CMfailed)) return (CMfailed);
                break;
            case MDPnET:
                if (_MDInGroundWatBETAID == MFUnset) {
                    if (((optStr = MFOptionGet (MDParGroundWatBETA))  != (char *) NULL) && (sscanf (optStr,"%f",&par) == 1)) _MDGroundWatBETA = par;
                 }
                 if (((_MDInRechargeID               = MDRainInfiltrationDef ()) == CMfailed) ||
                     ((_MDOutGrdWatID                = MFVarGetID (MDVarGroundWater,         "mm", MFOutput, MFState, MFInitial))  == CMfailed) ||
                     ((_MDOutGrdWatChgID             = MFVarGetID (MDVarGroundWaterChange,   "mm", MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
                     ((_MDOutGrdWatRechargeID        = MFVarGetID (MDVarGroundWaterRecharge, "mm", MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
                     ((_MDOutGrdWatUptakeID          = MFVarGetID (MDVarGroundWaterUptake,   "mm", MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
                     ((_MDOutBaseFlowID              = MFVarGetID (MDVarBaseFlow,            "mm", MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
                     (MFModelAddFunction (_MDBaseFlow2) == CMfailed)) return (CMfailed);														// RJS 061312
                break;	      
        }
	MFDefLeaving ("Base flow ");
	return (_MDOutBaseFlowID);
}
Ejemplo n.º 3
0
int main (int argc,char *argv []) {
	int argNum;
	int  optID = MDbalance;
	const char *optStr, *optName = MDOptModel;
	const char *options [] = { "pet", "surplus", "infiltration", "runoff", "discharge",  "watertemp", "thermal", "thermal2", "thermal3", "balance", "geometry", "bgc", "bgc_DIN","bgc_DINPLUSBIOMASS", "bgc_DOC", "fecal", "DO2", (char *) NULL };

	argNum = MFOptionParse (argc,argv);

	if ((optStr = MFOptionGet (optName)) != (char *) NULL) optID = CMoptLookup (options, optStr, true);

	switch (optID) {
		case MDpet:          return (MFModelRun (argc,argv,argNum,MDRainPotETDef));
		case MDsurplus:      return (MFModelRun (argc,argv,argNum,MDRainWaterSurplusDef));
		case MDinfiltration: return (MFModelRun (argc,argv,argNum,MDRainInfiltrationDef));
		case MDrunoff:       return (MFModelRun (argc,argv,argNum,MDRunoffDef));
		case MDdischarge:    return (MFModelRun (argc,argv,argNum,MDDischargeDef));
		case MDbalance:      return (MFModelRun (argc,argv,argNum,MDWaterBalanceDef));
		case MDwatertemp:    return (MFModelRun (argc,argv,argNum,MDWTempRiverRouteDef));
		case MDthermal:		 return (MFModelRun (argc,argv,argNum,MDThermalInputsDef));		// RJS 013112
		case MDthermal2:	 return (MFModelRun (argc,argv,argNum,MDThermalInputs2Def));	// RJS 062012
		case MDthermal3:     return (MFModelRun (argc,argv,argNum,MDThermalInputs3Def));	// RJS 112712
		case MDgeometry:     return (MFModelRun (argc,argv,argNum,MDRiverWidthDef));
		case MDbgc:          return (MFModelRun (argc,argv,argNum,MDBgcRoutingDef));
		case MDbgc_DOC:      return (MFModelRun (argc,argv,argNum,MDBgcDOCRoutingDef));
		case MDbgc_DIN:      return (MFModelRun (argc,argv,argNum,MDBgcDINRoutingDef));
		case MDbgc_DINPLUSBIOMASS:    return (MFModelRun (argc,argv,argNum,MDBgcDINPlusBiomassRoutingDef));
		case MDDO2:			 return (MFModelRun (argc,argv,argNum,MDDO2Def));		// RJS 111612
		default: MFOptionMessage (optName, optStr, options); return (CMfailed);
	}
	return (CMfailed);
}
Ejemplo n.º 4
0
int MDBaseFlowDef () {
    float par;
    const char *optStr;

    if (_MDOutBaseFlowID != MFUnset) return (_MDOutBaseFlowID);

    MFDefEntering ("Base flow");
    if (((optStr = MFOptionGet (MDParGroundWatBETA))  != (char *) NULL) && (sscanf (optStr,"%f",&par) == 1)) _MDGroundWatBETA = par;

    if (((_MDInRechargeID       = MDRainInfiltrationDef ()) == CMfailed) ||
            ((_MDInIrrGrossDemandID = MDIrrGrossDemandDef   ()) == CMfailed)) return (CMfailed);

    if ( _MDInIrrGrossDemandID != MFUnset) {
        if (((_MDInSmallResReleaseID    = MDSmallReservoirReleaseDef ()) == CMfailed) ||
                ((_MDInIrrAreaFracID        = MDIrrigatedAreaDef         ()) ==  CMfailed) ||
                ((_MDInIrrReturnFlowID      = MFVarGetID (MDVarIrrReturnFlow,     "mm", MFInput,  MFFlux,  MFBoundary)) == CMfailed) ||
                ((_MDOutIrrUptakeExternalID = MFVarGetID (MDVarIrrUptakeExternal, "mm", MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
                ((_MDOutIrrUptakeGrdWaterID = MDIrrUptakeGrdWaterDef     ()) == CMfailed))
            return CMfailed;
    }
    if (((_MDOutGrdWatID                = MFVarGetID (MDVarGroundWater,         "mm", MFOutput, MFState, MFInitial))  == CMfailed) ||
            ((_MDOutGrdWatChgID             = MFVarGetID (MDVarGroundWaterChange,   "mm", MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
            ((_MDOutGrdWatRechargeID        = MFVarGetID (MDVarGroundWaterRecharge, "mm", MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
            ((_MDOutGrdWatUptakeID          = MFVarGetID (MDVarGroundWaterUptake,   "mm", MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
            ((_MDOutBaseFlowID              = MFVarGetID (MDVarBaseFlow,            "mm", MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
            (MFModelAddFunction (_MDBaseFlow) == CMfailed)) return (CMfailed);

    MFDefLeaving ("Base flow ");
    return (_MDOutBaseFlowID);
}
Ejemplo n.º 5
0
int MDRiverbedShapeExponentDef () {
	int  optID = MFUnset;
	const char *optStr, *optName = MDOptRiverbed;
	const char *options [] = { MDInputStr, "slope-independent", "slope-dependent", (char *) NULL };

	if (_MDOutRiverbedShapeExponentID != MFUnset) return (_MDOutRiverbedShapeExponentID);

	MFDefEntering ("Riverbed Geometry");
	if ((optStr = MFOptionGet (optName)) != (char *) NULL) optID = CMoptLookup (options,optStr,true);

	switch (optID) {
		case MDinput:
			if (((_MDOutRiverbedAvgDepthMeanID  = MFVarGetID (MDVarRiverbedAvgDepthMean,  "m",      MFInput,  MFState, MFBoundary)) == CMfailed) ||
			    ((_MDOutRiverbedWidthMeanID     = MFVarGetID (MDVarRiverbedWidthMean,     "m",      MFInput,  MFState, MFBoundary)) == CMfailed) ||
			    ((_MDOutRiverbedVelocityMeanID  = MFVarGetID (MDVarRiverbedVelocityMean,  "m/s",    MFInput,  MFState, MFBoundary)) == CMfailed) ||
			    ((_MDOutRiverbedShapeExponentID = MFVarGetID (MDVarRiverbedShapeExponent, MFNoUnit, MFInput,  MFState, MFBoundary)) == CMfailed))
				return (CMfailed);
			break;
		case MDdependent:
			if ((_MDInRiverbedSlopeID           = MFVarGetID (MDVarRiverbedSlope,         "m/km",   MFInput,  MFState, MFBoundary)) == CMfailed)
				return (CMfailed);
		case MDindependent:
			if (((_MDInDischMeanID = MDDischMeanDef ()) == CMfailed) ||
			    ((_MDOutRiverbedAvgDepthMeanID  = MFVarGetID (MDVarRiverbedAvgDepthMean,  "m",      MFOutput, MFState, MFBoundary)) == CMfailed) ||
			    ((_MDOutRiverbedWidthMeanID     = MFVarGetID (MDVarRiverbedWidthMean,     "m",      MFOutput, MFState, MFBoundary)) == CMfailed) ||
			    ((_MDOutRiverbedVelocityMeanID  = MFVarGetID (MDVarRiverbedVelocityMean,  "m/s",    MFOutput, MFState, MFBoundary)) == CMfailed) ||
			    ((_MDOutRiverbedShapeExponentID = MFVarGetID (MDVarRiverbedShapeExponent, MFNoUnit, MFOutput, MFState, MFBoundary)) == CMfailed) ||
			    (MFModelAddFunction (_MDRiverbedShapeExponent) == CMfailed)) return (CMfailed);
			break;
		default: MFOptionMessage (optName, optStr, options); return (CMfailed);
	}
	MFDefLeaving ("Riverbed Geometry");
	return (_MDOutRiverbedShapeExponentID);
}
Ejemplo n.º 6
0
int MDSmallReservoirCapacityDef () {

	int  optID = MFUnset;
	const char *optStr, *optName = MDVarSmallResCapacity;
	const char *options [] = { MDNoneStr, MDInputStr, MDCalculateStr, (char *) NULL };

	if ((optStr = MFOptionGet (optName)) != (char *) NULL) optID = CMoptLookup (options, optStr, true);
		
	if ((optID == MDnone) || (_MDOutSmallResCapacityID != MFUnset)) return (_MDOutSmallResCapacityID);

	MFDefEntering("SmallReservoirCapacity");
	if ((_MDInIrrGrossDemandID = MDIrrGrossDemandDef  ()) != MFUnset) {
		switch (optID) {
			case MDinput:
			    if ((_MDOutSmallResCapacityID       = MFVarGetID (MDVarSmallResCapacity,          "mm",   MFInput, MFState, MFBoundary))  == CMfailed)
			    	return (CMfailed);
			    break;
			case MDcalculate:
				if ((_MDInIrrGrossDemandID == CMfailed) ||
				    ((_MDInIrrAreaID                    = MDIrrigatedAreaDef ())==  CMfailed) ||
				    ((_MDInRainSurfRunoffID             = MFVarGetID (MDVarRainSurfRunoff,            "mm",  MFInput,  MFFlux,  MFBoundary)) == CMfailed) ||
				    ((_MDOutRainSurfRunoffAccumulatedID = MFVarGetID ("__SurfaceROAccumulated",       "mm",  MFOutput, MFState, MFInitial))  == CMfailed) ||
				    ((_MDOutIrrGrossDemandAccumulatedID = MFVarGetID ("__GrossDemandAccumulated",     "mm",  MFOutput, MFState, MFInitial))  == CMfailed) ||
				    ((_MDInSmallResStorageFractionID    = MFVarGetID (MDVarSmallReservoirStorageFrac, "-",   MFInput,MFState,MFBoundary))  == CMfailed) ||
				    ((_MDOutSmallResCapacityID          = MFVarGetID (MDVarSmallResCapacity,          "mm",  MFOutput, MFState, MFInitial))  == CMfailed) ||
				    (MFModelAddFunction (_MDSmallReservoirCapacity) == CMfailed)) return (CMfailed);
				break;
			default: MFOptionMessage (optName, optStr, options); return (CMfailed);
		}
	}
	MFDefLeaving("SmallReservoirCapacity");
	return (_MDOutSmallResCapacityID);
}
Ejemplo n.º 7
0
int MDWTempGrdWaterDef () {
	int  optID = MDinput;																												// RJS 061312
	const char *optStr, *optName = MDOptGrdWaterTemp;																					// RJS 061312
	const char *options [] = { MDCalculateStr, MDInputStr,  (char *) NULL };															// RJS 061312

	if ((optStr = MFOptionGet (optName)) != (char *) NULL) optID = CMoptLookup (options, optStr, true);									// RJS 061312

	if (_MDOutWTempGrdWaterID != MFUnset) return (_MDOutWTempGrdWaterID);

	MFDefEntering ("Groundwater temperature");

	switch (optID) {																													// RJS 061312

	case MDcalculate:																													// RJS 061312

	if (((_MDInWTempSurfRunoffID = MDWTempSurfRunoffDef  ()) == CMfailed) ||
	    ((_MDInRainRechargeID    = MDRainInfiltrationDef ()) == CMfailed) ||
	    ((_MDInIrrReturnFlowID   = MDIrrReturnFlowDef    ()) == CMfailed) ||
	    ((_MDOutGrdWaterID       = MDBaseFlowDef         ()) == CMfailed) ||
	    ((_MDInAirTempID         = MFVarGetID (MDVarAirTemperature,  "degC", MFInput,  MFState, MFBoundary))  == CMfailed) ||
	    ((_MDOutWTempGrdWaterID  = MFVarGetID (MDVarWTempGrdWater, "degC", MFOutput, MFState,  MFInitial)) == CMfailed) ||
	    (MFModelAddFunction (_MDWTempGrdWater) == CMfailed)) return (CMfailed);
	break;																																// RJS 061312

	case MDinput:	_MDOutWTempGrdWaterID = MFVarGetID (MDVarWTempGrdWater, "degC", MFInput,  MFState, MFBoundary); break;				// RJS 061312	MFInitial changed to MFBoundary in order to read in																													// RJS 061312

	default: MFOptionMessage (optName, optStr, options); return (CMfailed);																// RJS 061312
	}																																	// RJS 061312

	MFDefLeaving ("Groundwater temperature");
	return (_MDOutWTempGrdWaterID);
}
Ejemplo n.º 8
0
int MDRainInterceptDef () {
	int optID = MFUnset;
	const char *optStr, *optName = MDVarRainInterception;
	const char *options [] = { MDNoneStr, MDInputStr, MDCalculateStr, (char *) NULL };

	if ((optStr = MFOptionGet (optName)) != (char *) NULL) optID = CMoptLookup (options,optStr,true);

	if ((optID == MDnone) || (_MDOutInterceptID != MFUnset)) return (_MDOutInterceptID);

	MFDefEntering ("Rainfed Intercept");

	switch (optID) {
		case MDinput: _MDOutInterceptID = MFVarGetID (MDVarRainInterception,  "mm", MFInput, MFFlux, false); break;
		case MDcalc:
			if (((_MDInPrecipID        = MDPrecipitationDef ()) == CMfailed) ||
			    
	    	    ((_MDInSPackChgID      = MDSPackChgDef      ()) == CMfailed) ||
			    ((_MDInLeafAreaIndexID = MDLeafAreaIndexDef ()) == CMfailed) ||
			    ((_MDInStemAreaIndexID = MDStemAreaIndexDef ()) == CMfailed) ||
			    ((_MDInPetID           = MDRainPotETDef     ()) == CMfailed) ||
			    ((_MDOutInterceptID    = MFVarGetID (MDVarRainInterception,   "mm",     MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
			    (MFModelAddFunction (_MDRainIntercept) == CMfailed)) return (CMfailed);
			break;
		default: MFOptionMessage (optName, optStr, options); return (CMfailed);
	}
	MFDefLeaving ("Rainfed Intercept");
	return (_MDOutInterceptID); 
}
Ejemplo n.º 9
0
int MDReservoirDef () {
	int optID = MFUnset;
	const char *optStr, *optName = MDOptReservoirs;
	const char *options [] = { MDNoneStr, MDCalculateStr, (char *) NULL };
 
	if ((optStr = MFOptionGet (optName)) != (char *) NULL) optID = CMoptLookup (options, optStr, true);
 
	if ((optID == MDnone) || (_MDOutResReleaseID != MFUnset)) return (_MDOutResReleaseID);

	MFDefEntering ("Reservoirs");
	switch (optID) {
		case MDcalculate:
			if (((_MDInDischMeanID      = MDDischMeanDef ())   == CMfailed) ||
			    ((_MDInDischargeID      = MDDischLevel2Def ()) == CMfailed) ||
			    ((_MDInResCapacityID    = MFVarGetID (MDVarReservoirCapacity,      "km3",  MFInput,  MFState, MFBoundary)) == CMfailed) ||
			    ((_MDOutResStorageID    = MFVarGetID (MDVarReservoirStorage,       "km3",  MFOutput, MFState, MFInitial))  == CMfailed) ||
			    ((_MDOutResStorageChgID = MFVarGetID (MDVarReservoirStorageChange, "km3",  MFOutput, MFState, MFBoundary)) == CMfailed) ||
			    ((_MDOutResReleaseID    = MFVarGetID (MDVarReservoirRelease,       "m3/s", MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
			    (MFModelAddFunction (_MDReservoir) == CMfailed)) return (CMfailed);
			break;
		default: MFOptionMessage (optName, optStr, options); return (CMfailed);
	}
	MFDefLeaving ("Reservoirs");
	return (_MDOutResReleaseID); 
}
Ejemplo n.º 10
0
int MDRainPotETDef () {
	int optID = MFUnset;
	const char *optStr, *optName = MDVarRainPotEvapotrans;
	const char *options [] = { MDInputStr, "Hamon", "Jensen", "PsTaylor", "Pstd", "PMday", "PMdn", "SWGday", "SWGdn", "Turc", (char *) NULL };

	if (_MDPotETID != MFUnset) return (_MDPotETID);

	if ((optStr = MFOptionGet (optName)) != (char *) NULL) optID = CMoptLookup (options,optStr,true);
	MFDefEntering ("Rainfed Potential Evapotranspiration");

	switch (optID) {
		case MDinput:    _MDPotETID = MFVarGetID (MDVarRainPotEvapotrans, "mm", MFInput, MFFlux, false); break;
		case MDHamon:    _MDPotETID = MDRainPotETHamonDef    (); break;
		case MDJensen:   _MDPotETID = MDRainPotETJensenDef   (); break;
		case MDPsTaylor: _MDPotETID = MDRainPotETPsTaylorDef (); break;
		case MDPstd:     _MDPotETID = MDRainPotETPstdDef     (); break;
		case MDPMday:    _MDPotETID = MDRainPotETPMdayDef    (); break;
		case MDPMdn:     _MDPotETID = MDRainPotETPMdnDef     (); break;
		case MDSWGday:   _MDPotETID = MDRainPotETSWGdayDef   (); break;
		case MDSWGdn:    _MDPotETID = MDRainPotETSWGdnDef    (); break;
		case MDTurc:     _MDPotETID = MDRainPotETTurcDef     (); break;
		default: MFOptionMessage (optName, optStr, options); return (CMfailed);
	}
	MFDefLeaving ("Rainfed Potential Evapotranspiration");
	return (_MDPotETID);
}
int MDDischLevel3MuskingumCoeffDef () {
	int  optID = MFUnset;
	const char *optStr, *optName = MDOptMuskingum;
	const char *options [] = { MDInputStr, "static", (char *) NULL };

	if (_MDOutMuskingumC0ID != MFUnset) return (_MDOutMuskingumC0ID);

	MFDefEntering ("Muskingum Coefficients");
	if ((optStr = MFOptionGet (optName)) != (char *) NULL) optID = CMoptLookup (options, optStr, true);
	switch (optID) {
		case MDinput:
			if (((_MDOutMuskingumC0ID = MFVarGetID (MDVarMuskingumC0, MFNoUnit,   MFInput,  MFState,  MFBoundary)) == CMfailed) ||
			    ((_MDOutMuskingumC1ID = MFVarGetID (MDVarMuskingumC1, MFNoUnit,   MFInput,  MFState,  MFBoundary)) == CMfailed) ||
			    ((_MDOutMuskingumC2ID = MFVarGetID (MDVarMuskingumC2, MFNoUnit,   MFInput,  MFState,  MFBoundary)) == CMfailed))
				return (CMfailed);
			break;
		case MDstatic:
			if (((_MDInRiverbedShapeExponentID  = MDRiverbedShapeExponentDef ()) == CMfailed) ||
			    ((_MDInRiverbedWidthMeanID      = MFVarGetID (MDVarRiverbedWidthMean,    "m",      MFInput,  MFState, MFBoundary)) == CMfailed) ||
			    ((_MDInRiverbedAvgDepthMeanID   = MFVarGetID (MDVarRiverbedAvgDepthMean, "m",      MFInput,  MFState, MFBoundary)) == CMfailed) ||
			    ((_MDInRiverbedVelocityMeanID   = MFVarGetID (MDVarRiverbedVelocityMean, "m/s",    MFInput,  MFState, MFBoundary)) == CMfailed) ||
			    ((_MDInRiverbedSlopeID          = MFVarGetID (MDVarRiverbedSlope,        "m/km",   MFInput,  MFState, MFBoundary)) == CMfailed) ||
			    ((_MDOutMuskingumC0ID           = MFVarGetID (MDVarMuskingumC0,          MFNoUnit, MFOutput, MFState, MFBoundary)) == CMfailed) ||
			    ((_MDOutMuskingumC1ID           = MFVarGetID (MDVarMuskingumC1,          MFNoUnit, MFOutput, MFState, MFBoundary)) == CMfailed) ||
			    ((_MDOutMuskingumC2ID           = MFVarGetID (MDVarMuskingumC2,          MFNoUnit, MFOutput, MFState, MFBoundary)) == CMfailed) ||
			    ((_MDOutCourantID               = MFVarGetID ("Courant",                 MFNoUnit, MFOutput, MFState, MFBoundary)) == CMfailed) ||
			    (MFModelAddFunction (_MDDischRouteMuskingumCoeff) == CMfailed)) return (CMfailed);
			break;
		default: MFOptionMessage (optName, optStr, options); return (CMfailed);
	}
	MFDefLeaving ("Muskingum Coefficients");
	return (_MDOutMuskingumC0ID);
}
Ejemplo n.º 12
0
int MDWetlandAreaDef (){
	
	int  optID = MFUnset;
	const char *optStr, *optName = MDVarWetlandAreaFraction;
	const char *options [] = { MDNoneStr, MDInputStr, MDCalculateStr, (char *) NULL };
    if ((optStr = MFOptionGet (optName)) != (char *) NULL) optID = CMoptLookup (options, optStr, true);
	if ((optID == MDnone) || (_MDWetlandAreaFracID != MFUnset)) return (_MDWetlandAreaFracID);

	MFDefEntering ("WetlandArea");
//	printf ("Wetland Area optID  =%i  \n",optID);
	if (_MDWetlandAreaFracID != MFUnset) return (_MDWetlandAreaFracID);
	switch (optID) {
				case MDinput:
				    if ((_MDWetlandAreaFracID       = MFVarGetID (MDVarWetlandAreaFraction,          "[-]",   MFInput, MFState, MFBoundary))  == CMfailed)
				    	return (CMfailed);
				    break;
				case MDcalculate:
					
					if ((MFModelAddFunction (_MDWetlandAreaFraction) == CMfailed)) return (CMfailed);
					break;
				default: MFOptionMessage (optName, optStr, options); return (CMfailed);
	}
		MFDefLeaving("WetlandArea");
	return (_MDWetlandAreaFracID);
	
}
Ejemplo n.º 13
0
int MDWTempRiverRouteDef () {
   int optID = MFUnset, waterBalanceID;
   const char *optStr;
   const char *options [] = { "none", "calculate", (char *) NULL };
  
	if (_MDWTempRiverRouteID != MFUnset) return (_MDWTempRiverRouteID);

	MFDefEntering ("Route river temperature");
	
	if (((optStr = MFOptionGet (MDOptReservoirs))  == (char *) NULL) ||
       ((optID  = CMoptLookup ( options, optStr, true)) == CMfailed)) {
      CMmsgPrint(CMmsgUsrError,"Reservoir Option not specified! Option none or calculate");
		return CMfailed;
   }
   if (optID==1) {
      if ((( waterBalanceID             = MDWaterBalanceDef  ()) == CMfailed) ||
          ((_MDInResStorageChangeID     = MFVarGetID (MDVarReservoirStorageChange, "km3",     MFInput,  MFState, MFBoundary)) == CMfailed) ||	//RJS 071511
          ((_MDInResStorageID           = MFVarGetID (MDVarReservoirStorage,       "km3",     MFInput,  MFState, MFInitial))  == CMfailed) ||	//RJS 121311 changed from MFBoundary to MFInitial
          ((_MDInResCapacityID          = MFVarGetID (MDVarReservoirCapacity,      "km3",     MFInput,  MFState, MFBoundary)) == CMfailed))
         return (CMfailed);
    }
	//input
	if (((_MDInDischargeID            = MDDischargeDef     ()) == CMfailed) ||
       (( waterBalanceID             = MDWaterBalanceDef  ()) == CMfailed) ||
       ((_MDInSolarRadID             = MDSolarRadDef      ()) == CMfailed) ||
       ((_MDInWTempRiverID           = MDWTempRiverDef    ()) == CMfailed) ||
       ((_MDInRiverWidthID           = MDRiverWidthDef    ()) == CMfailed) ||
       ((_MDInRunoffVolumeID         = MDRunoffVolumeDef  ()) == CMfailed) ||
       ((_MDInWdl_QxTID	             = MDThermalInputsDef ()) == CMfailed) ||	//RJS 072011
       ((_MDInDischargeIncomingID    = MFVarGetID (MDVarDischarge0,             "m3/s",       MFInput,  MFFlux,  MFBoundary)) == CMfailed) ||
       ((_MDInWindSpeedID            = MFVarGetID (MDVarWindSpeed,              "m/s",        MFInput,  MFState, MFBoundary)) == CMfailed) ||
       ((_MDInAirTemperatureID       = MFVarGetID (MDVarAirTemperature,         "degC",       MFInput,  MFState, MFBoundary)) == CMfailed) ||
       ((_MDInCloudCoverID           = MFVarGetID (MDVarCloudCover,             "%",          MFInput,  MFState, MFBoundary)) == CMfailed) ||
       ((_MDInRiverStorageChgID      = MFVarGetID (MDVarRiverStorageChg,        "m3/s",       MFInput,  MFState, MFBoundary)) == CMfailed) ||
       ((_MDInRiverStorageID         = MFVarGetID (MDVarRiverStorage,           "m3",         MFInput,  MFState, MFInitial))  == CMfailed) ||
       ((_MDInSnowPackID             = MFVarGetID (MDVarSnowPack,               "mm",         MFInput,  MFState, MFBoundary)) == CMfailed) ||
       ((_MDInWarmingTempID	       = MFVarGetID (MDVarWarmingTemp,		        "degC",	    MFInput,  MFState, MFBoundary)) == CMfailed) ||	//RJS 072011
       ((_MDInThermalWdlID           = MFVarGetID (MDVarThermalWdl, 		        "-",          MFInput,  MFState, MFBoundary)) == CMfailed) ||	//RJS 072011
       // output
       ((_MDLocalIn_QxTID            = MFVarGetID (MDVarBgcLocalIn_QxT,         "m3*degC/d", MFOutput, MFFlux,  MFBoundary)) == CMfailed)   ||
       ((_MDRemoval_QxTID            = MFVarGetID (MDVarRemoval_QxT,            "m3*degC/d", MFOutput, MFFlux,  MFBoundary)) == CMfailed)   ||
       ((_MDFlux_QxTID               = MFVarGetID (MDVarFlux_QxT,               "m3*degC/d", MFRoute,  MFFlux,  MFBoundary)) == CMfailed)   ||
       ((_MDStorage_QxTID            = MFVarGetID (MDVarStorage_QxT,            "m3*degC",   MFOutput, MFState, MFInitial))  == CMfailed)   ||
       ((_MDDeltaStorage_QxTID       = MFVarGetID (MDVarDeltaStorage_QxT,       "m3*degC/d", MFOutput, MFFlux,  MFBoundary)) == CMfailed)   ||
       ((_MDWTemp_QxTID              = MFVarGetID (MDVarWTemp_QxT,              "degC",      MFOutput, MFState, MFBoundary)) == CMfailed)   ||
       ((_MDWTempDeltaT_QxTID        = MFVarGetID (MDVarWTempDeltaT_QxT,        "degC",      MFOutput, MFState, MFBoundary)) == CMfailed)   ||
       //output mixing
       ((_MDFluxMixing_QxTID         = MFVarGetID (MDVarFluxMixing_QxT,         "m3*degC/d", MFRoute,  MFFlux,  MFBoundary)) == CMfailed)   ||
       ((_MDStorageMixing_QxTID      = MFVarGetID (MDVarStorageMixing_QxT,      "m3*degC",   MFOutput, MFState, MFInitial))  == CMfailed)   ||
       ((_MDDeltaStorageMixing_QxTID = MFVarGetID (MDVarDeltaStorageMixing_QxT, "m3*degC/d", MFOutput, MFFlux,  MFBoundary)) == CMfailed)   ||
       ((_MDWTempMixing_QxTID        = MFVarGetID (MDVarWTempMixing_QxT,        "degC",      MFOutput, MFState, MFBoundary)) == CMfailed)   ||
       (MFModelAddFunction (_MDWTempRiverRoute) == CMfailed)) return (CMfailed);
      
	   MFDefLeaving ("Route river temperature");
	   return (_MDWTemp_QxTID);
}
Ejemplo n.º 14
0
int MDRunoffDef () {
	int  optID = MFUnset;
	const char *optStr, *optName = MDVarRunoff;
	const char *options [] = { MDInputStr, MDCalculateStr, "corrected", MDInput2Str, (char *) NULL };

	if (_MDOutRunoffID != MFUnset) return (_MDOutRunoffID);

	MFDefEntering ("Runoff");
	if ((optStr = MFOptionGet (optName)) != (char *) NULL) optID = CMoptLookup (options, optStr, true);
	switch (optID) {
//		case MDinput: _MDOutRunoffID = MFVarGetID (MDVarRunoff,         "mm",     MFInput,  MFFlux, MFBoundary); break;						// RJS commented out 061312
		case MDinput: 																										       			// RJS 061312
			if (((_MDInBaseFlowID          = MFVarGetID (MDVarBaseFlow,          "mm",    MFInput,  MFFlux, MFBoundary)) == CMfailed) ||	// RJS 061312
//				((_MDInRunoffPoolReleaseID = MFVarGetID (MDVarRunoffPoolRelease, "mm",    MFInput,  MFFlux, MFBoundary)) == CMfailed) ||	// RJS 061312, commented out 082812
				((_MDInTotalSurfRunoffID   = MFVarGetID (MDVarTotalSurfRunoff,   "mm",    MFInput,  MFFlux, MFBoundary)) == CMfailed) ||	// RJS 082812		
                                ((_MDOutPropROStormWaterID   = MFVarGetID (MDVarPropROStormWater,    "-",     MFOutput, MFState, MFBoundary)) == CMfailed) ||       // RJS 100313
                                ((_MDOutPropROSurfaceWaterID = MFVarGetID (MDVarPropROSurfaceWater,  "-",     MFOutput, MFState, MFBoundary)) == CMfailed) ||       // RJS 100313 
                                ((_MDOutPropROGroundWaterID  = MFVarGetID (MDVarPropROGroundWater,   "-",     MFOutput, MFState, MFBoundary)) == CMfailed) ||  
				((_MDOutTotalSurfRunoffID  = MFVarGetID (MDVarTotalSurfRunoff, "mm",     MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
				((_MDOutRunoffID           = MFVarGetID (MDVarRunoff,            "mm",    MFOutput, MFFlux, MFBoundary)) == CMfailed) ||	// RJS 061312
				(MFModelAddFunction (_MDRunoffInput) == CMfailed)) return (CMfailed);														// RJS 061312
			break;																															// RJS 061312
                case MDinput2:
                        if (((_MDInBaseFlowID   = MDBaseFlowDef   ()) == CMfailed) ||
                            ((_MDInRunoffPoolReleaseID = MDSurfRunoffPoolDef ()) == CMfailed) ||		// RJS 042612
                            ((_MDOutPropROStormWaterID   = MFVarGetID (MDVarPropROStormWater,    "-",     MFOutput, MFState, MFBoundary)) == CMfailed) ||       // RJS 100313
                            ((_MDOutPropROSurfaceWaterID = MFVarGetID (MDVarPropROSurfaceWater,  "-",     MFOutput, MFState, MFBoundary)) == CMfailed) ||       // RJS 100313 
                            ((_MDOutPropROGroundWaterID  = MFVarGetID (MDVarPropROGroundWater,   "-",     MFOutput, MFState, MFBoundary)) == CMfailed) ||  
			    ((_MDOutTotalSurfRunoffID  = MFVarGetID (MDVarTotalSurfRunoff, "mm",     MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
                            ((_MDOutRunoffID           = MFVarGetID (MDVarRunoff,            "mm",    MFOutput, MFFlux, MFBoundary)) == CMfailed) ||	// RJS 061312
                            (MFModelAddFunction (_MDRunoffInput2) == CMfailed)) return (CMfailed);														// RJS 061312
			break;	
                case MDcorrected:
			if ((_MDInRunoffCorrID  = MFVarGetID (MDVarRunoffCorretion, MFNoUnit, MFInput,  MFState, MFBoundary)) == CMfailed)
				return (CMfailed);
			break;	// RJS 082812
		case MDcalculate:		
			if (((_MDInBaseFlowID   = MDBaseFlowDef   ()) == CMfailed) ||
//			    ((_MDInSurfRunoffID = MDSurfRunoffDef ()) == CMfailed) ||				//commented out RJS 042612
				((_MDInRunoffPoolReleaseID = MDSurfRunoffPoolDef ()) == CMfailed) ||		// RJS 042612
//				((_MDInStormRunoffTotalID  = MDStormRunoffDef ()) == CMfailed) ||		// RJS 082812
				((_MDInStormRunoffTotalID  = MFVarGetID (MDVarStormRunoffTotal, "mm",    MFInput,  MFFlux,  MFBoundary)) == CMfailed) ||
                                ((_MDOutPropROStormWaterID   = MFVarGetID (MDVarPropROStormWater,    "-",     MFOutput, MFState, MFBoundary)) == CMfailed) ||       // RJS 100313
                                ((_MDOutPropROSurfaceWaterID = MFVarGetID (MDVarPropROSurfaceWater,  "-",     MFOutput, MFState, MFBoundary)) == CMfailed) ||       // RJS 100313 
                                ((_MDOutPropROGroundWaterID  = MFVarGetID (MDVarPropROGroundWater,   "-",     MFOutput, MFState, MFBoundary)) == CMfailed) ||  
				((_MDOutRunoffID           = MFVarGetID (MDVarRunoff,          "mm",     MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
				((_MDOutTotalSurfRunoffID  = MFVarGetID (MDVarTotalSurfRunoff, "mm",     MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
				(MFModelAddFunction (_MDRunoff) == CMfailed)) return (CMfailed);
			break;
		default: MFOptionMessage (optName, optStr, options); return (CMfailed);
	}
	MFDefLeaving  ("Runoff");
	return (_MDOutRunoffID);
}
Ejemplo n.º 15
0
int MDWTempRiverDef () {
	const char *optStr;
        
	if (_MDOutWTempRiverID != MFUnset) return (_MDOutWTempRiverID);

	MFDefEntering ("River temperature");
        
        int  optID = MFUnset;                                                                                   // RJS 060214
	const char *optName = MDVarRunoff;                                                                      // RJS 060214
	const char *options [] = { MDCalculateStr, MDInputStr, MDInput2Str, (char *) NULL };                    // RJS 060214
    
        if ((optStr  = MFOptionGet (optName)) != (char *) NULL) optID = CMoptLookup (options, optStr, true);    // RJS 060214

        
        switch (optID) {
        case MDcalculate: 	
            
	if (
            ((_MDInSurfRunoffID      = MDRainSurfRunoffDef ()) == CMfailed) ||
//	    ((_MDInBaseFlowID        = MDBaseFlowDef       ()) == CMfailed) ||          // commented out 051614 so that input BaseFlow isn't overwritten
            ((_MDInBaseFlowID        = MFVarGetID (MDVarBaseFlow,          "mm",    MFInput,  MFFlux, MFBoundary)) == CMfailed) ||     
//	    ((_MDInWTempSurfRunoffID = MDWTempSurfRunoffDef ()) == CMfailed) ||		// commented out RJS 060512
	    ((_MDInWTempSurfRunoffPoolID = MDWTempSurfRunoffPoolDef ()) == CMfailed) ||		// RJS 060512
	    ((_MDInWTempGrdWaterID   = MDWTempGrdWaterDef   ()) == CMfailed) ||
	    ((_MDInTotalSurfRunoffID = MFVarGetID (MDVarTotalSurfRunoff, "mm",  MFInput,  MFFlux, MFBoundary)) == CMfailed) ||	//RJS 082812
	    ((_MDOutWTempRiverID     = MFVarGetID (MDVarWTempRiver,    "degC", MFOutput, MFState, MFBoundary)) == CMfailed) ||	
	    (MFModelAddFunction (_MDWTempRiver) == CMfailed)) return (CMfailed);
                break;
       case MDinput:
        if (
            ((_MDInTotalSurfRunoffID   = MFVarGetID (MDVarTotalSurfRunoff, "mm",    MFInput,  MFFlux, MFBoundary)) == CMfailed) ||
            ((_MDInBaseFlowID        = MFVarGetID (MDVarBaseFlow,       "mm",    MFInput,  MFFlux, MFBoundary)) == CMfailed) ||     
	    ((_MDInWTempSurfRunoffPoolID = MDWTempSurfRunoffPoolDef ()) == CMfailed) ||		// RJS 060512
	    ((_MDInWTempGrdWaterID   = MDWTempGrdWaterDef   ()) == CMfailed) ||
//	    ((_MDInTotalSurfRunoffID = MFVarGetID (MDVarTotalSurfRunoff, "mm",  MFInput,  MFFlux, MFBoundary)) == CMfailed) ||	//RJS 082812
	    ((_MDOutWTempRiverID     = MFVarGetID (MDVarWTempRiver,    "degC", MFOutput, MFState, MFBoundary)) == CMfailed) ||	
	    (MFModelAddFunction (_MDWTempRiver) == CMfailed)) return (CMfailed);
                break;
         case MDinput2:
        if (
            ((_MDInSurfRunoffID      = MFVarGetID (MDVarRainSurfRunoff, "mm",    MFInput,  MFFlux, MFBoundary)) == CMfailed) ||
            ((_MDInBaseFlowID        = MFVarGetID (MDVarBaseFlow,       "mm",    MFInput,  MFFlux, MFBoundary)) == CMfailed) ||     
	    ((_MDInWTempSurfRunoffPoolID = MDWTempSurfRunoffPoolDef ()) == CMfailed) ||		// RJS 060512
	    ((_MDInWTempGrdWaterID   = MDWTempGrdWaterDef   ()) == CMfailed) ||
	    ((_MDInTotalSurfRunoffID = MFVarGetID (MDVarTotalSurfRunoff, "mm",  MFInput,  MFFlux, MFBoundary)) == CMfailed) ||	//RJS 082812
	    ((_MDOutWTempRiverID     = MFVarGetID (MDVarWTempRiver,    "degC", MFOutput, MFState, MFBoundary)) == CMfailed) ||	
	    (MFModelAddFunction (_MDWTempRiver) == CMfailed)) return (CMfailed);
                break;   
        }
	MFDefLeaving ("River temperature");
	return (_MDOutWTempRiverID);
}
Ejemplo n.º 16
0
int MDRainSMoistChgDef () {
	int ret = 0;
	float par;
	const char *optStr;
	if (_MDOutSMoistChgID != MFUnset) return (_MDOutSMoistChgID);
	const char *soilTemperatureOptions [] = { "none", "calculate", (char *) NULL };

	int soilTemperatureID;
	if (((optStr = MFOptionGet (MDOptSoilTemperature))  == (char *) NULL) ||
	    ((soilTemperatureID = CMoptLookup (soilTemperatureOptions, optStr, true)) == CMfailed)) {
		CMmsgPrint(CMmsgUsrError," Soil TemperatureOption not specifed! Options = 'none' or 'calculate'\n");
		return CMfailed;
	}
	if (((optStr = MFOptionGet (MDParSoilMoistALPHA))  != (char *) NULL) && (sscanf (optStr,"%f",&par) == 1)) _MDSoilMoistALPHA = par;
	
	MFDefEntering ("Rainfed Soil Moisture");
	if (soilTemperatureID == MFcalculate ) {
		if (((ret                        = MDPermafrostDef()) == CMfailed) ||
		    ((_MDInRelativeIceContent    = MFVarGetID ("SoilIceContent_01",     "mm",   MFOutput,  MFState, MFBoundary)) == CMfailed) ||
			((_MDOutLiquidSoilMoistureID = MFVarGetID (MDVarLiquidSoilMoisture, "-",    MFOutput,  MFState, MFBoundary)) == CMfailed)) return CMfailed;
	}

	if ((ret = MDIrrGrossDemandDef ()) == CMfailed) return (CMfailed);
	if ((ret != MFUnset) && ((_MDInIrrAreaFracID = MDIrrigatedAreaDef ())==  CMfailed) ) return (CMfailed);

	if (((_MDInPrecipID            = MDPrecipitationDef     ()) == CMfailed) ||
	    ((_MDInSPackChgID          = MDSPackChgDef          ()) == CMfailed) ||
	    ((_MDInPotETID             = MDRainPotETDef         ()) == CMfailed) ||
	    ((_MDInInterceptID         = MDRainInterceptDef     ()) == CMfailed) ||
	    ((_MDInSoilAvailWaterCapID = MDSoilAvailWaterCapDef ()) == CMfailed) ||
	    ((_MDInAirTMeanID          = MFVarGetID (MDVarAirTemperature,             "degC", MFInput,  MFState, MFBoundary)) == CMfailed) ||
 	    ((_MDOutEvaptrsID          = MFVarGetID (MDVarRainEvapotranspiration,     "mm",   MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
 	  	((_MDOutSoilMoistCellID    = MFVarGetID (MDVarRainSoilMoistureCell,       "mm",   MFOutput, MFState, MFInitial))  == CMfailed) ||
	    ((_MDOutSoilMoistID        = MFVarGetID (MDVarRainSoilMoisture,           "mm",   MFOutput, MFState, MFBoundary)) == CMfailed) ||
        ((_MDOutSMoistChgID        = MFVarGetID (MDVarRainSoilMoistChange,        "mm",   MFOutput, MFState, MFBoundary)) == CMfailed) ||
        (MFModelAddFunction (_MDRainSMoistChg) == CMfailed)) return (CMfailed);
	MFDefLeaving ("Rainfed Soil Moisture");
	return (_MDOutSMoistChgID);
}
Ejemplo n.º 17
0
int MDIrrSoilMoistChgDef() {
	int optID = MFUnset, ret;
	const char *optStr, *optName = MDOptIrrigation;
	const char *options [] = { MDNoneStr, MDInputStr, MDCalculateStr, (char *) NULL };

	if ((optStr = MFOptionGet (optName)) != (char *) NULL) optID = CMoptLookup (options, optStr, true);
		
	if ((optID == MDnone) || (optID == MDinput) || (_MDOutIrrSoilMoistChgID != MFUnset)) return (_MDOutIrrSoilMoistChgID);

	if ((ret = MDIrrGrossDemandDef ()) == CMfailed) return (CMfailed);
	if (ret == MFUnset) return (MFUnset);
	_MDOutIrrSoilMoistChgID = MFVarGetID (MDVarIrrSoilMoistChange,     "mm",   MFInput, MFFlux,  MFBoundary);
    return (_MDOutIrrSoilMoistChgID);
}
Ejemplo n.º 18
0
int MDSPackChgDef () {

	if (_MDOutSPackChgID != MFUnset) return (_MDOutSPackChgID);
	MFDefEntering ("Snow Pack Change");
	const char *optStr;
	const char *soilTemperatureOptions [] = { "none", "calculate", (char *) NULL };
	int soilTemperatureID;
	float par;
	if (((optStr = MFOptionGet (MDParSnowMeltThreshold))  != (char *) NULL) && (sscanf (optStr,"%f",&par) == 1))
		_MDSnowMeltThreshold = par;
	
	if (((optStr = MFOptionGet (MDParFallThreshold))  != (char *) NULL) && (sscanf (optStr,"%f",&par) == 1))
		_MDFallThreshold= par;

	if (((optStr = MFOptionGet (MDOptSoilTemperature))  == (char *) NULL) || ((soilTemperatureID = CMoptLookup (soilTemperatureOptions, optStr, true)) == CMfailed)) {
					CMmsgPrint(CMmsgUsrError," Soil TemperatureOption not specifed! Options = 'none' or 'calculate'\n");
					return CMfailed;
				}

	if (soilTemperatureID == 1 ){
		_MDCalculateSoilTempID=1;
		if ((_MDInWinterOnsetID    = MFVarGetID (MDVarWinterOnsetDoy, "DoY", MFInput,  MFState, MFBoundary)) == CMfailed) return CMfailed;
	}

	if (((_MDInPrecipID       = MDPrecipitationDef ()) == CMfailed) ||
	    ((_MDInAtMeanID       = MFVarGetID (MDVarAirTemperature, "degC", MFInput,  MFState, MFBoundary)) == CMfailed) ||
	    ((_MDOutSnowFallID    = MFVarGetID (MDVarSnowFall,       "mm",   MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
	    ((_MDOutSnowMeltID    = MFVarGetID (MDVarSnowMelt,       "mm",   MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
	    ((_MDOutSnowDensityID = MFVarGetID (MDVarSnowDensity,    "mm",   MFOutput, MFState, MFBoundary)) == CMfailed) ||
	    ((_MDOutSnowDepthID   = MFVarGetID (MDVarSnowDepth,      "mm",   MFOutput, MFState, MFBoundary)) == CMfailed) ||
	    ((_MDOutSnowPackID    = MFVarGetID (MDVarSnowPack,       "mm",   MFOutput, MFState, MFInitial))  == CMfailed) ||
	    ((_MDOutSPackChgID    = MFVarGetID (MDVarSnowPackChange, "mm",   MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
	    (MFModelAddFunction (_MDSPackChg) == CMfailed)) return (CMfailed);
	MFDefLeaving ("Snow Pack Change");
	return (_MDOutSPackChgID);
}
Ejemplo n.º 19
0
int MDStormRunoffDef () {

	if (_MDOutStormRunoffTotalID != MFUnset) return (_MDOutStormRunoffTotalID);

	MFDefEntering ("Storm Runoff");

	if (((_MDInPrecipID             = MDPrecipitationDef ()) == CMfailed) ||
            ((_MDInH2OFractionID        = MFVarGetID (MDVarH2OFracSpatial,  "-",   MFInput,  MFState, MFBoundary)) == CMfailed) ||		//commented out 082812
	    ((_MDInImpFractionID        = MFVarGetID (MDVarImpFracSpatial,  "-",    MFInput,  MFState, MFBoundary)) == CMfailed) ||
	    ((_MDInSPackChgID           = MFVarGetID (MDVarSnowPackChange,  "mm",   MFInput,  MFFlux, MFBoundary)) == CMfailed) ||
	    ((_MDInHCIAID               = MFVarGetID (MDVarHCIA,            "-",    MFInput,  MFState, MFBoundary)) == CMfailed) ||
	    ((_MDOutStormRunoffImpID    = MFVarGetID (MDVarStormRunoffImp,  "mm",   MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
	    ((_MDOutStormRunoffH2OID    = MFVarGetID (MDVarStormRunoffH2O,  "mm",   MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||		//commented out 082812
	    ((_MDOutPrecipPervID        = MFVarGetID (MDVarPrecipPerv,      "mm",   MFOutput, MFFlux, MFBoundary)) == CMfailed) ||
	    ((_MDOutStormRunoffTotalID  = MFVarGetID (MDVarStormRunoffTotal,"mm",   MFOutput, MFFlux, MFBoundary))  == CMfailed) ||
            ((_MDOutH2OFractionID       = MFVarGetID (MDVarH2OFracSpatial,  "-",    MFOutput,  MFState, MFBoundary)) == CMfailed) ||		// RJS 100113
	    ((_MDOutImpFractionID       = MFVarGetID (MDVarImpFracSpatial,  "-",    MFOutput,  MFState, MFBoundary)) == CMfailed) ||           // RJS 100113
            ((_MDOutRunofftoPervID      = MFVarGetID (MDVarRunofftoPerv,    "mm",   MFOutput, MFFlux, MFBoundary))  == CMfailed)
            ) return (CMfailed);

        // Add in check for development ... then read-in Impervious and HCIA ... then add model function
        enum { MFnone, MFcalculate };
        const char *optStr;
        const char *snowImpervMeltOptions [] = { MDNoneStr, MDCalculateStr,(char *) NULL };
        int impervSnowMeltCalcID;
        if ((optStr = MFOptionGet (MDOptImperviousMeltCalc) ) == (char *) NULL) {
            optStr = MDNoneStr;
            //CMmsgPrint(CMmsgWarning," Impervious Snow Fall runoff method not specified - defaulting to none (StormRunoff).\n");
        } 
        if ((impervSnowMeltCalcID = CMoptLookup (snowImpervMeltOptions,optStr,true)) == CMfailed) {
            CMmsgPrint(CMmsgUsrError," Impervious Snow Fall runoff method incorrectly specified. Options are 'none' or 'calculate'.\n");
            return (CMfailed);
        }
        switch (impervSnowMeltCalcID) {
            case MFnone:
                // Nothing to be done
                break;
            case MFcalculate:
                if (((_MDInImpSnowFallROID    = MFVarGetID ( MDVarImpSnowFallRunoff,"mm",   MFInput, MFFlux,  MFBoundary)) == CMfailed)
                    ) return (CMfailed);
                break;
            default: MFOptionMessage (MDOptImperviousMeltCalc, optStr, snowImpervMeltOptions); return (CMfailed);
        }
	// Include StormRunoff
        if ((MFModelAddFunction (_MDStormRunoff) == CMfailed)) return (CMfailed);
	MFDefLeaving ("Storm Runoff");
	return (_MDOutRunofftoPervID);
}
Ejemplo n.º 20
0
int MDBgcDINRoutingDef () {
	int optID = MFUnset;
	const char *optStr;
	const char *options [] = { "none", "calculate", (char *) NULL };
     //const char *options [] = { MDNoneStr, (char *) NULL };

	if (_MDFlux_DINID != MFUnset)	return (_MDFlux_DINID);

	MFDefEntering ("DIN Routing Calculation");
	if (((optStr = MFOptionGet (MDOptReservoirs))  == (char *) NULL) || ((optID = CMoptLookup ( options, optStr, true)) == CMfailed)) {
						CMmsgPrint(CMmsgUsrError,"Reservoir Option not specified! Option none or calculate \n");
						return CMfailed;
					}
		    if (optID==1){
		  //  	printf ("Resoption=%i\n",optID);
		    if (((_MDInResStorageID       = MFVarGetID (MDVarReservoirStorage,       "km3",   MFInput, MFState, MFInitial))  == CMfailed) ||
		        ((_MDInResStorageChangeID = MFVarGetID (MDVarReservoirStorageChange, "km3/s", MFInput, MFState, MFBoundary)) == CMfailed))
		    	return CMfailed;
		    }	
		    
   // Input
	if (((_MDInDischargeID            = MDDischargeDef    ()) == CMfailed) ||
        ((_MDInRiverWidthID           = MDRiverWidthDef   ()) == CMfailed) ||
	    ((_MDInRunoffVolumeID         = MDRunoffVolumeDef ()) == CMfailed) ||
	    ((_MDInRunoffID               = MDRunoffDef ()) == CMfailed) ||
	    ((_MDInWTempRiverRouteID      = MDWTempRiverRouteDef ()) == CMfailed) ||
	    ((_MDInRiverStorageChgID      = MFVarGetID (MDVarRiverStorageChg,         "m3/s",   MFInput,  MFState, MFBoundary)) == CMfailed) ||
	    ((_MDInRiverStorageID         = MFVarGetID (MDVarRiverStorage,            "m3",     MFInput,  MFState, MFInitial))  == CMfailed) ||
	    ((_MDInPointScenarioID        = MFVarGetID (MDVarPointScenario,           MFNoUnit, MFInput,  MFState, MFBoundary)) == CMfailed) ||
        ((_MDNonPoint_DINID           = MFVarGetID (MDVarBGCNonPoint_DIN,         "kg/m3",  MFInput,  MFState, MFBoundary)) == CMfailed) ||
	    ((_MDPointSources_DINID       = MFVarGetID (MDVarBGCPointSources_DIN,     "kg/day", MFInput,  MFState, MFBoundary)) == CMfailed) ||
	    	    
	    // Output
	    ((_MDLocalIn_DINID            = MFVarGetID (MDVarDINLocalIn,              "kg/d",   MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
	    ((_MDRemoval_DINID            = MFVarGetID (MDVarDINRemoval,              "kg/d",   MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
        ((_MDConc_DINID               = MFVarGetID (MDVarDINConcentration,        "kg/m3",  MFOutput, MFState, MFBoundary)) == CMfailed) ||
	    ((_MDStorage_DINID            = MFVarGetID (MDVarDINStorage,              "kg",     MFOutput, MFState, MFInitial))  == CMfailed) ||
	    ((_MDDeltaStorage_DINID       = MFVarGetID (MDVarDINDeltaStorage,         "kg/day", MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
        ((_MDFlux_DINID               = MFVarGetID (MDVarDINFlux  ,               "kg/day", MFRoute,  MFFlux,  MFBoundary)) == CMfailed) ||
        ((_MDConcMixing_DINID         = MFVarGetID (MDVarDINConcentration_Mixing, "kg/m3",  MFOutput, MFState, MFBoundary)) == CMfailed) ||
        ((_MDStorageMixing_DINID      = MFVarGetID (MDVarDINStorage_Mixing,       "kg",     MFOutput, MFState, MFInitial))  == CMfailed) ||
        ((_MDDeltaStorageMixing_DINID = MFVarGetID (MDVarDINDeltaStorage_Mixing,  "kg/day", MFOutput, MFFlux,  MFBoundary)) == CMfailed) ||
        ((_MDFluxMixing_DINID         = MFVarGetID (MDVarDINFlux_Mixing ,         "kg/day", MFRoute,  MFFlux,  MFBoundary)) == CMfailed) ||
        (MFModelAddFunction (_MDDINRouting) == CMfailed)) return (CMfailed); 

	MFDefLeaving ("DIN Routing Calculation");
	return (_MDFlux_DINID); 
}
Ejemplo n.º 21
0
int MDBgcRiverGPPDef () {
	int optID = MFUnset;
    const char *optStr;
		const char *options [] = { "none", "calculate", (char *) NULL };

	if (_MDRiverGPPID != MFUnset) return (_MDRiverGPPID);

	MFDefEntering ("Calculate river GPP");
	
	if (((optStr = MFOptionGet (MDOptReservoirs))  == (char *) NULL) || ((optID = CMoptLookup ( options, optStr, true)) == CMfailed)) {
				CMmsgPrint(CMmsgUsrError,"Reservoir Option not specified! Option none or calculate \n");
				return CMfailed;
			}
    if (optID==1){
//  	printf ("Resoption=%i\n",optID);
    if (((_MDInResStorageID           = MFVarGetID (MDVarReservoirStorage,       "km3",     MFInput, MFState, MFInitial))   == CMfailed) ||
        ((_MDInResStorageChangeID     = MFVarGetID (MDVarReservoirStorageChange, "km3/s",   MFInput, MFState, MFBoundary))  == CMfailed))
    	return CMfailed;
    }
	
//input
	if (//((_MDInDischargeID            = MDDischargeDef    ()) == CMfailed) ||
		 ((_MDInRiverLightID          = MDBgcRiverLightDef ()) == CMfailed) ||
         ((_MDInDischargeID           = MFVarGetID (MDVarDischarge,              "m3/s",    MFInput, MFState,  MFBoundary)) == CMfailed) ||
         ((_MDInRiverWidthID          = MFVarGetID (MDVarRiverWidth,             "m",       MFInput, MFState,  MFBoundary)) == CMfailed) ||
         ((_MDInPAR2BottomID          = MFVarGetID (MDVarPAR2Bottom,             "MJ/m2/d", MFInput,  MFState, MFBoundary)) == CMfailed) ||
// output
     	((_MDBenthicAlgaeCHLID        = MFVarGetID (MDVarBenthicAlgaeCHL,        "g/m2",    MFOutput, MFState, MFInitial))  == CMfailed) ||
        ((_MDBenthicAlgaeCID          = MFVarGetID (MDVarBenthicAlgaeC,          "g/m2",    MFOutput, MFState, MFInitial))  == CMfailed) ||
        ((_MDBenthicGPPID             = MFVarGetID (MDVarBenthicGPP,             "g/m2/d",  MFOutput, MFState, MFBoundary)) == CMfailed) ||
        ((_MDBenthicRaID              = MFVarGetID (MDVarBenthicRa,              "g/m2/d",  MFOutput, MFState, MFBoundary)) == CMfailed) ||
        ((_MDBenthicNPPID             = MFVarGetID (MDVarBenthicNPP,             "g/m2/d",  MFOutput, MFState, MFBoundary)) == CMfailed) ||
        ((_MDBenthicMortalityID       = MFVarGetID (MDVarBenthicMortality,       "g/m2/d",  MFOutput, MFState, MFBoundary)) == CMfailed) ||
        ((_MDBenthicAlgaeC_REACHID    = MFVarGetID (MDVarBenthicAlgaeC_REACH,    "g/m2",    MFOutput, MFState, MFInitial))  == CMfailed) ||
        ((_MDBenthicGPP_REACHID       = MFVarGetID (MDVarBenthicGPP_REACH,       "g/m2/d",  MFOutput, MFState, MFBoundary)) == CMfailed) ||
        ((_MDBenthicRa_REACHID        = MFVarGetID (MDVarBenthicRa_REACH,        "g/m2/d",  MFOutput, MFState, MFBoundary)) == CMfailed) ||
        ((_MDBenthicNPP_REACHID       = MFVarGetID (MDVarBenthicNPP_REACH,       "g/m2/d",  MFOutput, MFState, MFBoundary)) == CMfailed) ||
        ((_MDBenthicMortality_REACHID = MFVarGetID (MDVarBenthicMortality_REACH, "g/m2/d",  MFOutput, MFState, MFBoundary)) == CMfailed) ||


       (MFModelAddFunction (_MDRiverGPP) == CMfailed)) return (CMfailed);
      
	   MFDefLeaving ("Calculate river GPP");
	   return (_MDRiverGPPID);
}
Ejemplo n.º 22
0
int MDDischLevel1Def() {

   char *optStr;
   const char *options [] = { MDNoneStr, (char *) NULL };

   
	if (_MDOutDischLevel1ID != MFUnset) return (_MDOutDischLevel1ID);

	MFDefEntering ("Discharge Level 1");
	if ((_MDInDischLevel2ID = MDDischLevel2Def ()) == CMfailed) return (CMfailed);

	if (((optStr = MFOptionGet (MDOptReservoirs)) != (char *) NULL) && (CMoptLookup (options,optStr,true) == CMfailed)) {
		if ((_MDInDischReleasedID = MDReservoirDef ()) == CMfailed) return (CMfailed);
	}
	if (((_MDOutDischLevel1ID = MFVarGetID ("__DischLevel1", "m3/s",  MFOutput,  MFState, MFBoundary)) == CMfailed) ||
	    (MFModelAddFunction (_MDDischLevel1) == CMfailed)) return (CMfailed);
	MFDefLeaving ("Discharge Level 1");
	return (_MDOutDischLevel1ID);
}
Ejemplo n.º 23
0
int MDSpecCondDef () {

    int  optID = MFUnset;											//SZ 08212014
    const char *optStr, *optName = MDOptSpecConductance;								//SZ 08212014
    const char *options [] = { MDCalculateStr, MDInputStr, MDInput2Str, MDNoneStr, (char *) NULL };		//SZ 08212014

	MFDefEntering ("Specific Conductance Routing");
	
    if ((optStr = MFOptionGet (optName)) != (char *) NULL) optID = CMoptLookup (options, optStr, true);  //SZ 08212014

    switch (optID) {	//SZ 08212014

        case MDcalculate:
        if (
//            ((_MDInDischargeID                  = MDDischargeDef()) == CMfailed ) ||
            ((_MDInDINFluxID                    = MDDINDef ()) == CMfailed) ||     // Needed for merging with upstream
	    ((_MDInWTempRiverID                 = MFVarGetID (MDVarWTemp_QxT,              "degC",      MFInput, MFState, MFBoundary)) == CMfailed)   ||
            ((_MDInRiverWidthID                 = MDRiverWidthDef ())     == CMfailed) ||
//          ((_MDInLitterFall_POCID             = MDLitterFallDef ()) == CMfailed) ||
//          ((_MDInLocalLoad_DOCID              = MFVarGetID (MDVarLocalLoadDOC,                             "kg/d",    MFInput,  MFFlux,  MFBoundary))   == CMfailed) ||
            ((_MDInDischarge0ID                 = MFVarGetID (MDVarDischarge0,                               "m3/s",    MFInput,  MFState, MFBoundary))   == CMfailed) ||	
	    ((_MDInDischargeID                  = MFVarGetID (MDVarDischarge,                                "m3/s",    MFInput,  MFState, MFBoundary))   == CMfailed) ||
            ((_MDInRiverStorageID               = MFVarGetID (MDVarRiverStorage,                           "m3/day",    MFInput,  MFState, MFInitial))    == CMfailed) ||	
            ((_MDInBaseFlowID                   = MFVarGetID (MDVarBaseFlow,                                  "mm",    MFInput,  MFFlux,MFBoundary))    == CMfailed) ||
            ((_MDInStormRunoffTotalID           = MFVarGetID (MDVarStormRunoffTotal,                          "mm",   MFInput, MFFlux, MFBoundary))  == CMfailed) ||
            ((_MDInRunoffPoolReleaseID          = MFVarGetID (MDVarRunoffPoolRelease,                        "mm",  MFInput, MFFlux, MFBoundary))  == CMfailed) ||
            ((_MDInAirTemperatureID             = MFVarGetID (MDVarAirTemperature,         "degC",       MFInput,  MFState, MFBoundary)) == CMfailed) ||
            ((_MDInSubFractionID                = MFVarGetID (MDVarLandUseSpatialSub,                         "-",    MFInput,  MFState, MFBoundary))   == CMfailed) ||
            ((_MDOutLocalLoadSCID               = MFVarGetID (MDVarLocalLoadSC,               "ic/d",   MFOutput,  MFFlux,  MFBoundary))   == CMfailed) ||
             ((_MDOutPostConc_SCID               = MFVarGetID (MDVarPostSpecCond,    	      "uS/cm",   MFOutput,  MFFlux, MFBoundary))   == CMfailed) ||	               
            ((_MDOutStoreWater_SCID             = MFVarGetID (MDVarStoreWaterSC,              "ic/day",   MFOutput,  MFState, MFInitial))    == CMfailed) ||	
            ((_MDOutFlux_SCID                   = MFVarGetID (MDVarFluxSC,                    "ic/day",   MFRoute,   MFFlux,  MFBoundary))   == CMfailed) ||	  
            (MFModelAddFunction (_MDSpecCond) == CMfailed)) return (CMfailed);
            break;

        default: 
            MFOptionMessage (optName, optStr, options); return (CMfailed);
    }
    
	MFDefLeaving ("Specific Conductance Routing");
    return (_MDOutFlux_SCID);
}
Ejemplo n.º 24
0
int MDBgcRiverLightDef () {
	int optID = MFUnset;
    const char *optStr;
		const char *options [] = { "none", "calculate", (char *) NULL };

	if (_MDRiverLightID != MFUnset) return (_MDRiverLightID);

	MFDefEntering ("Calculate river light");
	
	if (((optStr = MFOptionGet (MDOptReservoirs))  == (char *) NULL) || ((optID = CMoptLookup ( options, optStr, true)) == CMfailed)) {
				CMmsgPrint(CMmsgUsrError,"Reservoir Option not specified! Option none or calculate \n");
				return CMfailed;
			}
    if (optID==1){
  //  	printf ("Resoption=%i\n",optID);
    if (((_MDInResStorageID        = MFVarGetID (MDVarReservoirStorage,       "km3",   MFInput, MFState, MFInitial))  == CMfailed) ||
        ((_MDInResStorageChangeID  = MFVarGetID (MDVarReservoirStorageChange, "km3/s", MFInput, MFState, MFBoundary)) == CMfailed))
    	return CMfailed;
    }
	
		//input
	if (//((_MDInDischargeID          = MDDischargeDef    ()) == CMfailed) ||
         // ((_MDInSolarRadID         = MDSolarRadDef     ()) == CMfailed) ||
         ((_MDInFluxDOCID           = MDBgcDOCRoutingDef   ()) == CMfailed) ||
         ((_MDInSolarRadID          = MFVarGetID (MDVarSolarRadiation,     "MJ/m2/d", MFInput,  MFFlux,  MFBoundary)) == CMfailed) ||
         ((_MDInDischargeID         = MFVarGetID (MDVarDischarge,          "m3/s",    MFInput,  MFState, MFBoundary)) == CMfailed) ||
         ((_MDInConcDOCID           = MFVarGetID (MDVarDOCConcentration,   "kg/m3",   MFInput,  MFState, MFBoundary)) == CMfailed) ||
         ((_MDInRiverWidthID        = MFVarGetID (MDVarRiverWidth,         "m",       MFInput,  MFState, MFBoundary)) == CMfailed) ||
         ((_MDInRiverbedWidthMeanID = MFVarGetID (MDVarRiverbedWidthMean,  "m",       MFInput,  MFState, MFBoundary)) == CMfailed) ||
 	     ((_MDInRiverDepthID        = MFVarGetID (MDVarRiverDepth,         "m",       MFInput,  MFState, MFBoundary)) == CMfailed) ||
 	     ((_MDInKoppenID            = MFVarGetID (MDVarKoppen,             MFNoUnit,  MFInput,  MFState, MFBoundary)) == CMfailed) ||

        // output
        ((_MDPAR2BottomID           = MFVarGetID (MDVarPAR2Bottom,         "MJ/m2/d", MFOutput, MFState, MFBoundary))  == CMfailed) ||
        ((_MDPAR2ReachID            = MFVarGetID (MDVarPAR2Reach,          "MJ/d",    MFOutput, MFState, MFBoundary))  == CMfailed) ||

       (MFModelAddFunction (_MDRiverLight) == CMfailed)) return (CMfailed);
      
	   MFDefLeaving ("Calculate river light");
	   return (_MDRiverLightID);
}
Ejemplo n.º 25
0
int MDCParamZ0gDef () {
	int optID = MFUnset;
	const char *optStr, *optName = MDVarCParamZ0g;
	const char *options [] = { MDInputStr, MDLookupStr, (char *) NULL };

	if (_MDOutCParamZ0gID != MFUnset) return (_MDOutCParamZ0gID);

	if ((optStr = MFOptionGet (optName)) != (char *) NULL) optID = CMoptLookup (options,optStr,true);

	MFDefEntering ("Z0g");
	switch (optID) {
		case MDinput: _MDOutCParamZ0gID = MFVarGetID (MDVarCParamZ0g,  "m", MFInput, MFState, false); break;
		case MDlookup:
			if (((_MDInCoverID = MDLandCoverDef ()) == CMfailed) ||
	    		 ((_MDOutCParamZ0gID = MFVarGetID (MDVarCParamZ0g, "m", MFOutput, MFState, false)) == CMfailed) ||
	    		 (MFModelAddFunction (_MDCParamZ0g) == CMfailed)) return (CMfailed);
			break;
		default: MFOptionMessage (optName, optStr, options); return (CMfailed);
	}
	MFDefLeaving ("Z0g");
	return (_MDOutCParamZ0gID); 
}
Ejemplo n.º 26
0
int MDRunoffVolumeDef () {
	int optID = MFUnset;
	const char *optStr, *optName = MDVarRunoffVolume;
	const char *options [] = { MDInputStr, MDCalculateStr, (char *) NULL };

	if (_MDOutRunoffVolumeID != MFUnset) return (_MDOutRunoffVolumeID);

	MFDefEntering ("Runoff Volume");
	if ((optStr = MFOptionGet (optName)) != (char *) NULL) optID = CMoptLookup (options, optStr, true);
	switch (optID) {
		case MDinput:
			_MDOutRunoffVolumeID = MFVarGetID (MDVarRunoffVolume, "m3/s", MFInput, MFState, MFBoundary);
			break;
		case MDcalculate:
			if (((_MDInRunoffID        = MDRunoffDef ()) == CMfailed) ||
			    ((_MDOutRunoffVolumeID = MFVarGetID (MDVarRunoffVolume, "m3/s", MFOutput, MFState, MFBoundary)) == CMfailed) ||
			    (MFModelAddFunction (_MDRunoffVolume) == CMfailed)) return (CMfailed);
			break;
		default: MFOptionMessage (optName, optStr, options); return (CMfailed);
	}
	MFDefLeaving  ("Runoff Volume");
	return (_MDOutRunoffVolumeID);
}
Ejemplo n.º 27
0
int MDCParamAlbedoDef () {
	int optID = MFUnset;
	const char *optStr, *optName = MDVarCParamAlbedo;
	const char *options [] = { MDInputStr, MDLookupStr, (char *) NULL };

	if (_MDOutCParamAlbedoID != MFUnset) return (_MDOutCParamAlbedoID);

	MFDefEntering ("Albedo");
	if ((optStr = MFOptionGet (optName)) != (char *) NULL) optID = CMoptLookup (options,optStr,true);

	switch (optID) {
		case MDinput:  _MDOutCParamAlbedoID = MFVarGetID (MDVarCParamAlbedo,  MFNoUnit, MFInput, MFState, MFBoundary); break;
		case MDlookup:
			if (((_MDInCoverID    = MDLandCoverDef ()) == CMfailed) ||
			    ((_MDInSnowPackID = MDSPackChgDef  ()) == CMfailed) ||
			    ((_MDOutCParamAlbedoID = MFVarGetID (MDVarCParamAlbedo, MFNoUnit, MFOutput, MFState, MFBoundary)) == CMfailed) ||
			    (MFModelAddFunction (_MDCParamAlbedo) == CMfailed)) return (CMfailed);
			break;
		default: MFOptionMessage (optName, optStr, options); return (CMfailed);
	}
	MFDefLeaving ("Albedo");
	return (_MDOutCParamAlbedoID); 
}
Ejemplo n.º 28
0
int MDDischMeanDef () {
	int  optID = MFUnset;
	const char *optStr, *optName = MDVarDischMean;
	const char *options [] = { MDInputStr, MDCalculateStr, (char *) NULL };

	if (_MDOutDischMeanID != MFUnset) return (_MDOutDischMeanID);
	MFDefEntering ("Discharge Mean");

	if ((optStr = MFOptionGet (optName)) != (char *) NULL) optID = CMoptLookup (options, optStr, true);

	switch (optID) {
		case MDinput: _MDOutDischMeanID  = MFVarGetID (MDVarDischMean, "m3/s", MFInput,  MFState, MFBoundary); break;
		case MDcalculate:
			if (((_MDInAvgNStepsID       = MDAvgNStepsDef ())   == CMfailed) ||
			    ((_MDInAccumDischargeID  = MDAccumRunoffDef ()) == CMfailed) ||
			    ((_MDOutDischMeanID      = MFVarGetID (MDVarDischMean, "m3/s", MFOutput, MFState, MFInitial))  == CMfailed) ||
			    (MFModelAddFunction (_MDDischMean) == CMfailed)) return (CMfailed);
			break;
		default: MFOptionMessage (optName, optStr, options); return (CMfailed);
	}
	MFDefLeaving ("Discharge Mean");
	return (_MDOutDischMeanID);
}
Ejemplo n.º 29
0
int main (int argc,char *argv []) {
	//printf("at start of main\n");
	int argNum;
	//int DELAY=10;
	//int i;
	int  optID = MDbankfullQcalc; //CHANGED may2011
	const char *optStr, *optName = MDOptModel;
	const char *options [] = { "pet", "surplus", "infiltration", "runoff", "discharge",  "watertemp", "balance", "geometry", "bgc", "bgc_DIN","bgc_DINPLUSBIOMASS", "bgc_DOC", "fecal", "sedimentflux","bedloadflux", "BQARTinputs" , "BQARTpreprocess","bankfullQcalc","riverbedshape",(char *) NULL };

	argNum = MFOptionParse (argc,argv);
		
	if ((optStr = MFOptionGet (optName)) != (char *) NULL) optID = CMoptLookup (options, optStr, true);

	//printf("before switch\n");
	switch (optID) {
		case MDpet:          return (MFModelRun (argc,argv,argNum,MDRainPotETDef));
		case MDsurplus:      return (MFModelRun (argc,argv,argNum,MDRainWaterSurplusDef));
		case MDinfiltration: return (MFModelRun (argc,argv,argNum,MDRainInfiltrationDef));
		case MDrunoff:       return (MFModelRun (argc,argv,argNum,MDRunoffDef));
		case MDdischarge:    return (MFModelRun (argc,argv,argNum,MDDischargeDef));
		case MDwatertemp:    return (MFModelRun (argc,argv,argNum,MDWTempRiverRouteDef));
		case MDbalance:      return (MFModelRun (argc,argv,argNum,MDWaterBalanceDef));
		case MDgeometry:     return (MFModelRun (argc,argv,argNum,MDRiverWidthDef));
		case MDbgc:          return (MFModelRun (argc,argv,argNum,MDBgcRoutingDef));
		case MDbgc_DOC:      return (MFModelRun (argc,argv,argNum,MDBgcDOCRoutingDef));
		case MDbgc_DIN:      return (MFModelRun (argc,argv,argNum,MDBgcDINRoutingDef));
		case MDbgc_DINPLUSBIOMASS: return (MFModelRun (argc,argv,argNum,MDBgcDINPlusBiomassRoutingDef));
		case MDsedimentflux:    return (MFModelRun (argc,argv,argNum,MDSedimentFluxDef));
		case MDbedloadflux:    return (MFModelRun (argc,argv,argNum,MDBedloadFluxDef));	
		case MDBQARTpreprocess:    return (MFModelRun (argc,argv,argNum,MDBQARTpreprocessDef));	
		case MDbankfullQcalc:    return (MFModelRun (argc,argv,argNum,MDBankfullQcalcDef));	
		case MDRiverbedShapeExponent:    return (MFModelRun (argc,argv,argNum,MDRiverbedShapeExponentDef));
		default: MFOptionMessage (optName, optStr, options); return (CMfailed);
	}
	return (CMfailed);
}
Ejemplo n.º 30
0
int MDWTempSurfRunoffPoolDef () {
	int  optID = MDnone;	// was MFUnset
	const char *optStr, *optName = MDOptSurfRunoffPool;
	const char *options [] = { MDNoneStr, MDCalculateStr, MDInputStr, (char *) NULL };											// RJS 061312 added MDInputStr

	if ((optStr = MFOptionGet (optName)) != (char *) NULL) optID = CMoptLookup (options, optStr, true);

	MFDefEntering ("Surface Runoff Pool Temperature");

	switch (optID) {

	case MDcalculate:

	if (((_MDInWTempSurfRunoffID       = MDWTempSurfRunoffDef ()) == CMfailed) ||
		((_MDInRainSurfRunoffID        = MDRainSurfRunoffDef  ()) == CMfailed) ||
		((_MDInRunoffPoolID            = MFVarGetID (MDVarRunoffPool,            "mm", MFInput,  MFState, MFBoundary))  == CMfailed) ||
//		((_MDInRainSurfRunoffID        = MFVarGetID (MDVarRainSurfRunoff,        "mm", MFInput,   MFFlux, MFBoundary)) == CMfailed) ||
	    ((_MDOutWTempSurfRunoffPoolID  = MFVarGetID (MDVarWTempSurfRunoffPool, "degC", MFOutput, MFState, MFInitial)) == CMfailed) ||
	    (MFModelAddFunction (_MDWTempSurfRunoffPool) == CMfailed)) return (CMfailed);
		break;

	case MDnone:

	if (((_MDInWTempSurfRunoffID       = MDWTempSurfRunoffDef ()) == CMfailed) ||
		((_MDOutWTempSurfRunoffPoolID  = MFVarGetID (MDVarWTempSurfRunoffPool, "degC", MFOutput, MFState, MFInitial)) == CMfailed) ||
		(MFModelAddFunction (_MDWTempNoSurfRunoffPool) == CMfailed)) return (CMfailed);
		break;

	case MDinput:	_MDOutWTempSurfRunoffPoolID = MFVarGetID (MDVarWTempSurfRunoffPool, "degC", MFInput,  MFState, MFBoundary); break;		// RJS 061312	MFInitial changed to MFBoundary in order to read in																														// RJS 061312

	default: MFOptionMessage (optName, optStr, options); return (CMfailed);
	}

	MFDefLeaving ("Surface Runoff Pool Temperature");
	return (_MDOutWTempSurfRunoffPoolID);
}