From e5eeccbd1e602d8d54513b53a56614c234a6d244 Mon Sep 17 00:00:00 2001 From: Sam Hatchett Date: Thu, 31 Jan 2013 15:30:07 -0500 Subject: [PATCH] apple define, some cleanup - apple / *nix defines out the DLL[EX/IM]PORT directives - we should be using dox markup (see ENrunnexHQ for example) --- src/lemontiger.c | 75 ++++++++++++++++++++++++++---------------------- src/lemontiger.h | 8 ++++-- src/toolkit.h | 8 ++++-- 3 files changed, 51 insertions(+), 40 deletions(-) diff --git a/src/lemontiger.c b/src/lemontiger.c index 7d6d447..62f2022 100644 --- a/src/lemontiger.c +++ b/src/lemontiger.c @@ -47,48 +47,55 @@ int nexthydLT(long *tstep); void updateTanklevels(); //Prior to running hydraulic simulation, update the tank levels. -int DLLEXPORT ENrunnextHQ(long* pstime, /*Simulation time pointer*/ - long* ptstep /*next time step*/ ) { -/* The lemonTiger equivalent of ENnextQ, hydraulic solver is called on-demand*/ - long hydtime; /* Hydraulic solution time */ - long hydstep; /* Hydraulic time step */ - int errcode = 0; - - /* if needed, push forward hydraulic simulation, similar to runqual() */ - if (Qtime == Htime) - { - if ( (errcode = runhyd(&hydtime)) || - (errcode = nexthydLT(&hydstep)) - ) return errcode; - /* If simulating WQ: */ - if (Qualflag != NONE && Qtime < Dur) { +/*! + \fn int ENrunnexHQ( long* simTimePtr, long* timeStepPtr ) + \brief equivalent of ENnextQ, hydraulic solver is called on-demand + \param simTimePtr Simulation time (output variable). + \param timeStepPtr Time to next time step boundary (output variable). + \return on error, an error code + */ +int DLLEXPORT ENrunnextHQ(long* simTimePtr, long* timeStepPtr) { + /* The lemonTiger equivalent of ENnextQ, hydraulic solver is called on-demand*/ + long hydtime; /* Hydraulic solution time */ + long hydstep; /* Hydraulic time step */ + int errcode = 0; + + /* if needed, push forward hydraulic simulation, similar to runqual() */ + if (Qtime == Htime) + { + if ( (errcode = runhyd(&hydtime)) || (errcode = nexthydLT(&hydstep)) ) { + return errcode; + } + /* If simulating WQ: */ + if (Qualflag != NONE && Qtime < Dur) { + /* Compute reaction rate coeffs. */ if (Reactflag && Qualflag != AGE) ratecoeffs(); - + /* Initialize pipe segments (at time 0) or */ /* else re-orient segments if flow reverses.*/ if (Qtime == 0) initsegs(); else reorientsegs(); } - Htime = hydtime + hydstep; - } - *pstime = Htime; - hydstep = Htime - Qtime; - - /* Perform water quality routing over this time step */ - if (Qualflag != NONE && hydstep > 0) transport(hydstep); - - updateTanklevels(); - /* Update current time */ - if (OutOfMemory) errcode = 101; - if (!errcode) *ptstep = hydstep; - Qtime += hydstep; - - /* Save final output if no more time steps */ - if (!errcode && Saveflag && *ptstep == 0) errcode = savefinaloutput(); - return(errcode); - + Htime = hydtime + hydstep; + } + *simTimePtr = Htime; + hydstep = Htime - Qtime; + + /* Perform water quality routing over this time step */ + if (Qualflag != NONE && hydstep > 0) transport(hydstep); + + updateTanklevels(); + /* Update current time */ + if (OutOfMemory) errcode = 101; + if (!errcode) *timeStepPtr = hydstep; + Qtime += hydstep; + + /* Save final output if no more time steps */ + if (!errcode && Saveflag && *timeStepPtr == 0) errcode = savefinaloutput(); + return(errcode); + } int DLLEXPORT ENrunstepHQ(long* pstime /* Simulation time pointer */ diff --git a/src/lemontiger.h b/src/lemontiger.h index c4d8787..cdb6585 100644 --- a/src/lemontiger.h +++ b/src/lemontiger.h @@ -6,9 +6,11 @@ all original Epanet functions remain intact, and the new LT_functions are added. /*Note that this file is not used by the functions in the toolkit itself. Refer to toolkit.h for the internally used function declarations. */ - -#define DLLIMPORT __declspec(dllimport) - +#ifdef __APPLE__ + #define DLLIMPORT +#else + #define DLLIMPORT __declspec(dllimport) +#endif // --- Define the EPANET toolkit constants #define EN_ELEVATION 0 /* Node parameters */ diff --git a/src/toolkit.h b/src/toolkit.h index 87b0a9b..1abb018 100755 --- a/src/toolkit.h +++ b/src/toolkit.h @@ -25,9 +25,11 @@ AUTHOR: L. Rossman //#define CLE_LT /* LemonTiger test */ //Jinduan Chen #define DLL_LT /* Compile as a Windows DLL of LemonTiger */ - -#define DLLEXPORT __declspec(dllexport) - +#ifdef __APPLE__ + #define DLLEXPORT +#else + #define DLLEXPORT __declspec(dllexport) +#endif // --- Define the EPANET toolkit constants #define EN_ELEVATION 0 /* Node parameters */