diff --git a/ST_defines.h b/ST_defines.h index af07b261..4b533348 100644 --- a/ST_defines.h +++ b/ST_defines.h @@ -17,7 +17,7 @@ #ifndef STEPPE_DEF_H #define STEPPE_DEF_H -#include "generic.h" +#include "sw_src/generic.h" /* see #include "ST_structs.h" below */ diff --git a/ST_environs.c b/ST_environs.c index e339718a..9ca1b185 100644 --- a/ST_environs.c +++ b/ST_environs.c @@ -19,7 +19,7 @@ #include "ST_steppe.h" #include "ST_globals.h" #include "sw_src/pcg/pcg_basic.h" -#include "rands.h" +#include "sw_src/rands.h" #include "sxw_funcs.h" #include "sw_src/filefuncs.h" #include "sw_src/Times.h" diff --git a/ST_grid.c b/ST_grid.c index 1149405f..53a326b9 100644 --- a/ST_grid.c +++ b/ST_grid.c @@ -31,14 +31,14 @@ #include #include #include +#include "sw_src/generic.h" +#include "sw_src/filefuncs.h" +#include "sw_src/myMemory.h" +#include "sw_src/rands.h" #include "ST_grid.h" #include "ST_steppe.h" -#include "generic.h" -#include "filefuncs.h" -#include "myMemory.h" #include "ST_globals.h" #include "ST_stats.h" -#include "rands.h" #include "sxw_funcs.h" #include "ST_initialization.h" #include "ST_progressBar.h" diff --git a/ST_grid.h b/ST_grid.h index 8157798a..5a5a5584 100644 --- a/ST_grid.h +++ b/ST_grid.h @@ -15,11 +15,11 @@ #include "ST_defines.h" #include "sw_src/pcg/pcg_basic.h" #include "sxw_vars.h" -#include "SW_Site.h" -#include "SW_SoilWater.h" -#include "SW_VegProd.h" -#include "SW_Model.h" -#include "SW_Weather.h" +#include "sw_src/SW_Site.h" +#include "sw_src/SW_SoilWater.h" +#include "sw_src/SW_VegProd.h" +#include "sw_src/SW_Model.h" +#include "sw_src/SW_Weather.h" #include "ST_seedDispersal.h" /*********************** Grid Structures ****************************/ diff --git a/ST_indivs.c b/ST_indivs.c index 45b2ee18..64464837 100644 --- a/ST_indivs.c +++ b/ST_indivs.c @@ -22,8 +22,8 @@ #include #include "ST_steppe.h" #include "ST_globals.h" -#include "filefuncs.h" -#include "myMemory.h" +#include "sw_src/filefuncs.h" +#include "sw_src/myMemory.h" /******** Modular External Function Declarations ***********/ diff --git a/ST_initialization.c b/ST_initialization.c index f70cb7c4..6789b3be 100644 --- a/ST_initialization.c +++ b/ST_initialization.c @@ -27,8 +27,8 @@ #include "sw_src/pcg/pcg_basic.h" #include "sw_src/rands.h" #include "sxw_funcs.h" -#include "myMemory.h" -#include "filefuncs.h" +#include "sw_src/myMemory.h" +#include "sw_src/filefuncs.h" #include "ST_progressBar.h" #include "ST_stats.h" diff --git a/ST_main.c b/ST_main.c index 670a3d7b..7b80acc5 100644 --- a/ST_main.c +++ b/ST_main.c @@ -20,11 +20,11 @@ #include #include #include "ST_steppe.h" -#include "generic.h" -#include "filefuncs.h" -#include "myMemory.h" -#include "SW_VegProd.h" -#include "SW_Control.h" +#include "sw_src/generic.h" +#include "sw_src/filefuncs.h" +#include "sw_src/myMemory.h" +#include "sw_src/SW_VegProd.h" +#include "sw_src/SW_Control.h" #include "sw_src/pcg/pcg_basic.h" #include "sxw_funcs.h" diff --git a/ST_mortality.c b/ST_mortality.c index 684e8603..cd811322 100644 --- a/ST_mortality.c +++ b/ST_mortality.c @@ -26,9 +26,9 @@ #include "ST_mortality.h" #include "sw_src/filefuncs.h" -#include "generic.h" -#include "rands.h" -#include "myMemory.h" +#include "sw_src/generic.h" +#include "sw_src/rands.h" +#include "sw_src/myMemory.h" #include "ST_steppe.h" #include "ST_globals.h" #include "sw_src/pcg/pcg_basic.h" diff --git a/ST_mortality.h b/ST_mortality.h index 5d047271..25acc3d4 100644 --- a/ST_mortality.h +++ b/ST_mortality.h @@ -10,7 +10,7 @@ #ifndef MORTALITY_H #define MORTALITY_H -#include "generic.h" +#include "sw_src/generic.h" #include "sw_src/pcg/pcg_basic.h" /* --------------------------- Exported Structs ---------------------------- */ diff --git a/ST_output.c b/ST_output.c index 37294473..4a2d03d8 100644 --- a/ST_output.c +++ b/ST_output.c @@ -16,14 +16,14 @@ #include #include "ST_steppe.h" #include "ST_globals.h" -#include "filefuncs.h" -#include "myMemory.h" +#include "sw_src/filefuncs.h" +#include "sw_src/myMemory.h" /******** Modular External Function Declarations ***********/ /* -- truly global functions are declared in functions.h --*/ /***********************************************************/ -#include "SW_Model.h" +#include "sw_src/SW_Model.h" extern SW_MODEL SW_Model; /*------------------------------------------------------*/ diff --git a/ST_params.c b/ST_params.c index 99bf96ab..9abbfab1 100644 --- a/ST_params.c +++ b/ST_params.c @@ -23,10 +23,10 @@ #include #include #include "ST_steppe.h" -#include "generic.h" -#include "filefuncs.h" -#include "myMemory.h" -#include "rands.h" +#include "sw_src/generic.h" +#include "sw_src/filefuncs.h" +#include "sw_src/myMemory.h" +#include "sw_src/rands.h" #include "sxw_funcs.h" @@ -1242,7 +1242,7 @@ void parm_free_memory( void ) { #ifdef DEBUG_MEM -#include "myMemory.h" +#include "sw_src/myMemory.h" /**************************************************************/ void Parm_SetMemoryRefs( void) { /*======================================================*/ diff --git a/ST_resgroups.c b/ST_resgroups.c index d824a451..098a7cf7 100644 --- a/ST_resgroups.c +++ b/ST_resgroups.c @@ -30,9 +30,9 @@ #include #include "ST_steppe.h" #include "ST_globals.h" -#include "myMemory.h" -#include "rands.h" -#include "generic.h" +#include "sw_src/myMemory.h" +#include "sw_src/rands.h" +#include "sw_src/generic.h" #include "sw_src/filefuncs.h" #include "ST_functions.h" #include "sxw_funcs.h" @@ -1254,7 +1254,7 @@ IndivType **RGroup_GetIndivs(GrpIndex rg, const char sort, IntS *num) } #ifdef DEBUG_MEM -#include "myMemory.h" +#include "sw_src/myMemory.h" /*======================================================*/ void RGroup_SetMemoryRefs( void) { diff --git a/ST_seedDispersal.c b/ST_seedDispersal.c index dd8c256b..e3474f70 100644 --- a/ST_seedDispersal.c +++ b/ST_seedDispersal.c @@ -8,8 +8,8 @@ #include "ST_defines.h" #include "ST_grid.h" #include "ST_seedDispersal.h" -#include "rands.h" -#include "myMemory.h" +#include "sw_src/rands.h" +#include "sw_src/myMemory.h" int _do_bulk_dispersal(SppIndex sp); void _do_precise_dispersal(int leftoverSeeds, SppIndex sp); diff --git a/ST_species.c b/ST_species.c index 9566e65a..15d61ae1 100644 --- a/ST_species.c +++ b/ST_species.c @@ -25,8 +25,8 @@ #include "ST_steppe.h" #include "ST_globals.h" #include "sw_src/filefuncs.h" -#include "myMemory.h" -#include "rands.h" +#include "sw_src/myMemory.h" +#include "sw_src/rands.h" #include "sw_src/pcg/pcg_basic.h" #include "ST_initialization.h" #include "ST_seedDispersal.h" @@ -628,7 +628,7 @@ void save_annual_species_relsize() { } #ifdef DEBUG_MEM -#include "myMemory.h" +#include "sw_src/myMemory.h" /*======================================================*/ void Species_SetMemoryRefs( void) { diff --git a/ST_stats.c b/ST_stats.c index 678134e9..35ccf3b6 100644 --- a/ST_stats.c +++ b/ST_stats.c @@ -35,8 +35,8 @@ #include #include #include "ST_steppe.h" -#include "filefuncs.h" -#include "myMemory.h" +#include "sw_src/filefuncs.h" +#include "sw_src/myMemory.h" #include "ST_structs.h" #include "ST_stats.h" // Contains most of the function declarations. #include "ST_seedDispersal.h" diff --git a/ST_steppe.h b/ST_steppe.h index 756a14db..9ff24a10 100644 --- a/ST_steppe.h +++ b/ST_steppe.h @@ -15,7 +15,7 @@ #include "ST_defines.h" #include "ST_functions.h" -#include "generic.h" +#include "sw_src/generic.h" #define DFLT_FIRSTFILE "files.in" diff --git a/ST_structs.h b/ST_structs.h index e405b480..944f77d7 100644 --- a/ST_structs.h +++ b/ST_structs.h @@ -23,7 +23,7 @@ #ifndef STEPPE_STRUCT_DEF #define STEPPE_STRUCT_DEF -#include "generic.h" +#include "sw_src/generic.h" #include "ST_mortality.h" /** diff --git a/makefile b/makefile index c4c17f66..3c4ab2f1 100644 --- a/makefile +++ b/makefile @@ -1,4 +1,5 @@ CC = gcc +CXX = g++ CFLAGS = \ -std=c99 \ @@ -17,16 +18,17 @@ CFLAGS = \ -Wstrict-prototypes \ -Wunused +sw2 = SOILWAT2 +lib_sw2 = lib$(sw2).a +path_sw2 = sw_src + INC_DIRS = \ -I. \ -Isqlite-amalgamation \ - -Isw_src \ - -Isw_src/googletest/googletest \ - -Isw_src/googletest/googletest/include \ + -I$(path_sw2)/googletest/googletest \ + -I$(path_sw2)/googletest/googletest/include \ -Itest -LIBS = -lm - sources_core = \ sqlite-amalgamation/sqlite3.c \ ST_environs.c \ @@ -40,29 +42,6 @@ sources_core = \ ST_species.c \ ST_sql.c \ ST_stats.c \ - sw_src/filefuncs.c \ - sw_src/generic.c \ - sw_src/mymemory.c \ - sw_src/pcg/pcg_basic.c \ - sw_src/rands.c \ - sw_src/SW_Carbon.c \ - sw_src/SW_Control.c \ - sw_src/SW_Files.c \ - sw_src/SW_Flow.c \ - sw_src/SW_Flow_lib.c \ - sw_src/SW_Markov.c \ - sw_src/SW_Model.c \ - sw_src/SW_Output.c \ - sw_src/SW_Output_get_functions.c \ - sw_src/SW_Output_outarray.c \ - sw_src/SW_Output_outtext.c \ - sw_src/SW_Site.c \ - sw_src/SW_Sky.c \ - sw_src/SW_SoilWater.c \ - sw_src/SW_VegEstab.c \ - sw_src/SW_VegProd.c \ - sw_src/SW_Weather.c \ - sw_src/Times.c \ sxw.c \ sxw_environs.c \ sxw_resource.c \ @@ -73,25 +52,39 @@ sources_core = \ ST_seedDispersal.c sources_test = \ - sw_src/googletest/googletest/src/gtest-all.cc \ - sw_src/googletest/googletest/src/gtest_main.cc \ + $(path_sw2)/googletest/googletest/src/gtest-all.cc \ + $(path_sw2)/googletest/googletest/src/gtest_main.cc \ test/test_ST_mortality.cc +sw2_sources = \ + SW_Output_outarray.c \ + SW_Output_outtext.c + + objects_core = $(sources_core:%.c=obj/%.o) objects_core_test = $(sources_core:%.c=obj/%_TEST.o) objects_test = $(sources_test:%.cc=obj/%.o) -all: stepwat stepwat_test -stepwat: $(objects_core) - $(CC) $(objects_core) $(CFLAGS) $(CPPFLAGS) $(LIBS) -o stepwat +sw_LDFLAGS = $(LDFLAGS) -L. -L$(path_sw2) +sw_LDLIBS = -l$(sw2) $(LDLIBS) -lm + + + +all: $(path_sw2)/$(lib_sw2) stepwat stepwat_test + +$(path_sw2)/$(lib_sw2): + @(cd $(path_sw2) && $(MAKE) $(lib_sw2) \ + CC="$(CC)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" AR="$(AR)" \ + sw_sources="$(sw2_sources)") + +stepwat: $(path_sw2)/$(lib_sw2) $(objects_core) + $(CC) $(objects_core) $(CFLAGS) $(CPPFLAGS) $(sw_LDLIBS) $(sw_LDFLAGS) -o stepwat -@cp stepwat testing.sagebrush.master -@cp stepwat testing.sagebrush.master/Stepwat_Inputs -stepwat_test: $(objects_core_test) $(objects_test) - $(CXX) $(objects_core_test) $(objects_test) $(CFLAGS) $(CPPFLAGS) $(LIBS) -o stepwat_test - -@cp stepwat_test testing.sagebrush.master - -@cp stepwat_test testing.sagebrush.master/Stepwat_Inputs +stepwat_test: $(path_sw2)/$(lib_sw2) $(objects_core_test) $(objects_test) + $(CXX) $(objects_core_test) $(objects_test) $(CFLAGS) $(CPPFLAGS) $(sw_LDLIBS) $(sw_LDFLAGS) -o stepwat_test obj/%.o: %.c $(CC) $(CFLAGS) $(CPPFLAGS) $(INC_DIRS) -c $< -o $@ @@ -102,12 +95,16 @@ obj/%.o: %.cc obj/%_TEST.o: %.c $(CC) $(CFLAGS) $(CPPFLAGS) $(INC_DIRS) -DSTDEBUG -c $< -o $@ +.PHONY: run_tests +run_tests: stepwat_test + ./stepwat_test + .PHONY: bint_testing_nongridded -bint_testing_nongridded: stepwat stepwat_test +bint_testing_nongridded: stepwat testing.sagebrush.master/Stepwat_Inputs/stepwat -d testing.sagebrush.master/Stepwat_Inputs -f files.in -o -i .PHONY: bint_testing_gridded -bint_testing_gridded: stepwat stepwat_test +bint_testing_gridded: stepwat testing.sagebrush.master/stepwat -d testing.sagebrush.master -f files.in -g .PHONY: cleanall @@ -119,15 +116,14 @@ clean: cleanobjs cleanbin documentation_clean .PHONY: cleanobjs cleanobjs: -@find . -type f -name '*.o' -delete + -@$(RM) -f $(path_sw2)/$(lib_sw2) .PHONY: cleanbin cleanbin: -@rm -f stepwat -@rm -f stepwat_test -@rm -f testing.sagebrush.master/stepwat - -@rm -f testing.sagebrush.master/stepwat_test -@rm -f testing.sagebrush.master/Stepwat_Inputs/stepwat - -@rm -f testing.sagebrush.master/Stepwat_Inputs/stepwat_test .PHONY: output_clean output_clean: @@ -135,11 +131,11 @@ output_clean: -@rm -rf testing.sagebrush.master/Stepwat_Inputs/Output/* .PHONY : documentation_clean -documentation_clean : +documentation_clean : @rm -rf Documentation/html .PHONY : documentation -documentation: +documentation: @doxygen doxyfile @if open Documentation/html/index.html; \ then echo "Success"; \ diff --git a/sxw.c b/sxw.c index 8ee79800..ea487a25 100644 --- a/sxw.c +++ b/sxw.c @@ -45,12 +45,12 @@ #include #include #include -#include "generic.h" -#include "filefuncs.h" -#include "myMemory.h" +#include "sw_src/generic.h" +#include "sw_src/filefuncs.h" +#include "sw_src/myMemory.h" #include "ST_steppe.h" #include "ST_globals.h" -#include "SW_Defines.h" +#include "sw_src/SW_Defines.h" #include "sxw.h" #include "sxw_funcs.h" #include "sxw_module.h" @@ -1111,7 +1111,7 @@ void _print_debuginfo(void) { #ifdef DEBUG_MEM -#include "myMemory.h" +#include "sw_src/myMemory.h" /*======================================================*/ void SXW_SetMemoryRefs( void) { /* when debugging memory problems, use the bookkeeping diff --git a/sxw.h b/sxw.h index 15ffb919..60996179 100644 --- a/sxw.h +++ b/sxw.h @@ -24,8 +24,8 @@ // The number of transpiration values retained by transp_data #define MAX_WINDOW 100 -#include "generic.h" -#include "SW_Times.h" +#include "sw_src/generic.h" +#include "sw_src/SW_Times.h" #include "ST_defines.h" #include "sw_src/SW_Defines.h" diff --git a/sxw_environs.c b/sxw_environs.c index b50483c5..71f27e97 100644 --- a/sxw_environs.c +++ b/sxw_environs.c @@ -17,16 +17,16 @@ /* --------------------------------------------------- */ #include -#include "generic.h" +#include "sw_src/generic.h" #include "ST_steppe.h" /*#include "ST_globals.h"*/ -#include "SW_Defines.h" +#include "sw_src/SW_Defines.h" #include "sxw.h" #include "sxw_module.h" -#include "SW_Model.h" -#include "SW_Site.h" -#include "SW_SoilWater.h" -#include "SW_Weather.h" +#include "sw_src/SW_Model.h" +#include "sw_src/SW_Site.h" +#include "sw_src/SW_SoilWater.h" +#include "sw_src/SW_Weather.h" /*************** Global Variable Declarations ***************/ /***********************************************************/ diff --git a/sxw_main.c b/sxw_main.c index 8743e258..de5ec62b 100644 --- a/sxw_main.c +++ b/sxw_main.c @@ -27,9 +27,9 @@ #include #include #include "ST_steppe.h" -#include "generic.h" -#include "filefuncs.h" -#include "myMemory.h" +#include "sw_src/generic.h" +#include "sw_src/filefuncs.h" +#include "sw_src/myMemory.h" #include "sxw_funcs.h" /* for the chdir function */ diff --git a/sxw_resource.c b/sxw_resource.c index f7641d20..b13f7667 100644 --- a/sxw_resource.c +++ b/sxw_resource.c @@ -21,22 +21,22 @@ /* --------------------------------------------------- */ #include -#include "generic.h" -#include "rands.h" -#include "filefuncs.h" -#include "myMemory.h" +#include "sw_src/generic.h" +#include "sw_src/rands.h" +#include "sw_src/filefuncs.h" +#include "sw_src/myMemory.h" #include "ST_steppe.h" #include "ST_globals.h" -#include "SW_Defines.h" +#include "sw_src/SW_Defines.h" #include "sxw.h" #include "sxw_module.h" #include "sxw_vars.h" -#include "SW_Control.h" -#include "SW_Site.h" -#include "SW_SoilWater.h" -#include "SW_VegProd.h" -#include "SW_Files.h" -#include "SW_Times.h" +#include "sw_src/SW_Control.h" +#include "sw_src/SW_Site.h" +#include "sw_src/SW_SoilWater.h" +#include "sw_src/SW_VegProd.h" +#include "sw_src/SW_Files.h" +#include "sw_src/SW_Times.h" #include "sw_src/pcg/pcg_basic.h" /*************** Global Variable Declarations ***************/ diff --git a/sxw_soilwat.c b/sxw_soilwat.c index 3a8451c5..371ec7b6 100644 --- a/sxw_soilwat.c +++ b/sxw_soilwat.c @@ -36,21 +36,21 @@ /* --------------------------------------------------- */ #include -#include "generic.h" -#include "filefuncs.h" -#include "myMemory.h" -#include "Times.h" +#include "sw_src/generic.h" +#include "sw_src/filefuncs.h" +#include "sw_src/myMemory.h" +#include "sw_src/Times.h" #include "ST_steppe.h" #include "ST_globals.h" -#include "SW_Defines.h" +#include "sw_src/SW_Defines.h" #include "sxw.h" #include "sxw_module.h" -#include "SW_Control.h" -#include "SW_Model.h" -#include "SW_Site.h" -#include "SW_SoilWater.h" -#include "SW_VegProd.h" -#include "SW_Files.h" +#include "sw_src/SW_Control.h" +#include "sw_src/SW_Model.h" +#include "sw_src/SW_Site.h" +#include "sw_src/SW_SoilWater.h" +#include "sw_src/SW_VegProd.h" +#include "sw_src/SW_Files.h" /*************** Global Variable Declarations ***************/ diff --git a/sxw_sql.c b/sxw_sql.c index ee9832dd..9f840c85 100644 --- a/sxw_sql.c +++ b/sxw_sql.c @@ -10,7 +10,7 @@ #include #include "ST_steppe.h" #include "ST_globals.h" -#include "SW_Defines.h" +#include "sw_src/SW_Defines.h" #include "sxw_module.h" #include "sxw.h" diff --git a/sxw_vars.h b/sxw_vars.h index 0896c1cb..0a27ebb5 100644 --- a/sxw_vars.h +++ b/sxw_vars.h @@ -16,7 +16,7 @@ #define SXW_VARS_DEF #include "sxw.h" -#include "generic.h" +#include "sw_src/generic.h" extern SXW_t* SXW; diff --git a/test/test_ST_mortality.h b/test/test_ST_mortality.h index 9ad0c8a9..ffefba22 100644 --- a/test/test_ST_mortality.h +++ b/test/test_ST_mortality.h @@ -1,8 +1,8 @@ #ifndef TEST_ST_MORTALITY_H #define TEST_ST_MORTALITY_H -#include "generic.h" -#include "myMemory.h" +#include "sw_src/generic.h" +#include "sw_src/myMemory.h" #include "ST_defines.h" #include "ST_globals.h"