Skip to content

Commit

Permalink
MacOS/Unix compilation with lp_solve, updated makefile
Browse files Browse the repository at this point in the history
MacOS/Unix compilation with lp_solve, updated makefile

bug fixes:
-fix to CCustomTable constructor (CustomTable.cpp)
  • Loading branch information
James Craig authored and James Craig committed Jul 16, 2024
1 parent 4dfdcae commit d53e46c
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/CustomTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ CCustomTable::CCustomTable(string filename, int pp, const CModel* pMod)
_aForcings=NULL;
_aSVtypes=NULL;
_aLayers=NULL;
_nCols=NULL;

_nCols=0;
_pModel=pMod;
}
CCustomTable::~CCustomTable()
{
Expand Down
4 changes: 4 additions & 0 deletions src/DemandOptimization.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

#ifdef _LPSOLVE_
namespace lp_lib {
#ifdef _WIN32
#include "../lib/lp_solve/lp_lib.h"
#else
#include "../lib/lp_solve_unix/lp_lib.h"
#endif
}
#endif

Expand Down
31 changes: 21 additions & 10 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,37 @@
# Modified Feb 2017 Juliane Mai - add NetCDF support
# Mar 2017 Juliane Mai - increase stack size to 256 MB from standard 64MB
# Jan 2019 Alan J. Barton - added OS name to created exe name
# Dec 2023 David Huard - support for python binding
# Dec 2023 David Huard - support for python binding
# Jul 2024 James Craig and Bohao Tang - support for lp_solve
###
# appname := raven_rev$(shell svnversion -n . | sed -e 's/:/-/g')_$(shell uname -o).exe
appname := Raven.exe

CXX := g++
CXXFLAGS := -Wno-deprecated
# some compilers require the c++11 flag, some may not
LDLIBS :=
LDFLAGS :=

# OPTION 0) some compilers require the c++11 flag, some may not
CXXFLAGS += -std=c++11 -fPIC

srcfiles := $(shell ls *.cpp)
objects := $(patsubst %.cpp, %.o, $(srcfiles))
# OPTION 1) include netcdf - uncomment following two commands (assumes netCDF path = /usr/local):
#CXXFLAGS += -Dnetcdf
#LDLIBS += -L/usr/local -lnetcdf

# OPTION 2) include lp_solve - uncomment following two commands (assumes liblpsolve55.a in ../lib/lp_solve_unix/ folder):
CXXFLAGS += -D_LPSOLVE_
LDLIBS += -L../lib/lp_solve_unix -llpsolve55

# include netcdf
CXXFLAGS += -Dnetcdf # if netcdf is installed use "CXXFLAGS += -Dnetcdf", else "CXXFLAGS += "
LDLIBS := -L/usr/local -lnetcdf # if netcdf is installed give first path "-L<PATH>"and then "-lnetcdf", else "LDLIBS := "
# OPTION 3) if you use a OSX/BSD system, uncomment the LDFLAGS line below
# this is to allow for use a 1Gb stack, see http://linuxtoosx.blogspot.ca/2010/10/stack-overflow-increasing-stack-limit.html
# LDFLAGS += -Wl,-stack_size,0x80000000,-stack_addr,0xf0000000

# if you use a OSX/BSD system, uncomment the LDFLAGS line below
# this is to allow for use a 1Gb, see http://linuxtoosx.blogspot.ca/2010/10/stack-overflow-increasing-stack-limit.html
# LDFLAGS := -Wl,-stack_size,0x80000000,-stack_addr,0xf0000000
# OPTION 4) uncomment for M1 and newer MacOS
#CXXFLAGS := -Dfinite=isfinite

srcfiles := $(shell ls *.cpp)
objects := $(patsubst %.cpp, %.o, $(srcfiles))

all: $(appname)

Expand Down
2 changes: 2 additions & 0 deletions src/RavenInclude.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

//#define _MODFLOW_USG_ // uncomment if compiling MODFLOW-USG coupled version of Raven
//#define _STRICTCHECK_ // uncomment if strict checking should be enabled (slows down model)
#ifndef _LPSOLVE_
//#define _LPSOLVE_ // uncomment if compiling lpsolve Demand Optimization version of Raven
#endif
#define STANDALONE
#ifdef netcdf
#define _RVNETCDF_ // if Makefile is used this will be automatically be uncommented if netCDF library is available
Expand Down
9 changes: 8 additions & 1 deletion src/TimeSeries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,13 +648,20 @@ CTimeSeries *CTimeSeries::Sum(CTimeSeries *pTS1, CTimeSeries *pTS2, string name
// OR
// :AnnualCycle J F M A M J J A S O N D
// OR
// :AnnualEvents [STEP or INTERPOLATE]
// :AnnualEvents
// mm-dd v1 (or J v1, where J is julian day)
// mm-dd v2
// mm-dd v3
// ...
// :EndAnnualEvents
// OR
// :AnnualPattern [STEP or INTERPOLATE]
// mm-dd v1 (or J v1, where J is julian day)
// mm-dd v2
// mm-dd v3
// ...
// :EndAnnualPattern
// OR
// :ReadFromNetCDF
// :FileNameNC ./input/input.nc
// :VarNameNC Qobs
Expand Down
2 changes: 1 addition & 1 deletion src/UnitTesting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ void BarycentricWeights() {
TEST.open("BarycentricWeights.csv");
for(int m=0; m<10000;m++) {
sum=0;
for(int i=0;i<4;i++) { aVals[i]=rand()/(double)(RAND_MAX+1); }
for(int i=0;i<4;i++) { aVals[i]=rand()/(double)(RAND_MAX); }
for(int q=0; q<N-1;q++) {
_aWeights[q]=(1.0-sum)*(1.0-pow(1.0-aVals[q],1.0/(N-q)));
sum+=_aWeights[q];
Expand Down

0 comments on commit d53e46c

Please sign in to comment.