Open chaukap opened 4 years ago
To elaborate on the externed variables issue, we will need to move the declaration of the following variables:
Technically we only need to move SuperGlobals and Globals, but while we're at it we might as well move the rest of them for the sake of clean code.
As a side effect of moving SXW to sxw.h the file sxw_vars.h will be rendered completely useless. It should probably be removed.
Re:
Unfortunately, the other change must be done on the SOILWAT2 side. There are 2 source files that are currently not compiled into the SOILWAT2 library: SW_Output_outtext.c and SW_Output_outarray.c. These must be added to the sources_lib variable in the SOILWAT2 makefile.
--> The SOILWAT2 makefile accounts for this issue because the output needs are so different for SOILWAT2-standalone, rSOILWAT2, and STEPWAT2: the makefile accepts sw_sources
to add additional source files to be compiled into the SOILWAT2 library. See the example in rSOILWAT2 https://github.com/DrylandEcology/rSOILWAT2/blob/master/src/Makevars
...
sw_sources = SW_Output_outarray.c
...
$(path_target)/$(lib_target):
@(cd $(path_target) && $(MAKE) $(lib_target) \
CC="$(CC)" CPPFLAGS="$(ALL_CPPFLAGS)" CFLAGS="$(ALL_CFLAGS)" AR="$(AR)" \
sw_sources="$(sw_sources)")
...
so for STEPWAT2, this could then be adjusted to something like
sw_sources = SW_Output_outtext.c SW_Output_outarray.c
@dschlaep Thanks for the help! This should make the implementation very easy for the person that implements it.
Currently the STEPWAT2 makefile is tightly coupled to the file structure of SOILWAT2. there are 23 points of contact:
If any one of these files is moved STEPWAT2 will not compile.
Solution
We can reduce the points of contact to 2:
SOILWAT2's makefile has a rule to create a library file. As long as we know where the makefile and the library file are located the rest of SOILWAT2 can be abstracted away.
However, there are a few caveats. Variables can no longer be externed across the two codebases. This means variables like
SXW
andSuperGlobals
must be declared in header files. This should be fairly easy to do.Unfortunately, the other change must be done on the SOILWAT2 side. There are 2 source files that are currently not compiled into the SOILWAT2 library:
SW_Output_outtext.c
andSW_Output_outarray.c
. These must be added to thesources_lib
variable in the SOILWAT2 makefile.