Skip to content

Commit

Permalink
Merge pull request #199 from geco-bern/patch-interface
Browse files Browse the repository at this point in the history
Patch for system specific compilation flags
  • Loading branch information
khufkens authored Dec 12, 2023
2 parents 8982c7f + d87aa94 commit 8eac0fa
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 3 deletions.
4 changes: 4 additions & 0 deletions cleanup
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

## a.out.dSYM may get created on OS X.
rm -rf src/Makevars a.out.dSYM
29 changes: 29 additions & 0 deletions configure
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

# System dependent config script to deal with
# CLANG / LLVM issues through custom compiler flags

# taken from Writing R Extensions, 1.2. Configure and cleanup
: ${R_HOME=`R RHOME`}
if test -z "${R_HOME}"; then
echo "could not determine R_HOME"
exit 1
fi

# determine the Fortran 9x compiler
FC="`"${R_HOME}/bin/R" CMD config FC`"

# grab system specific flags already set
SFLAGS="`"${R_HOME}/bin/R" CMD config FCFLAGS`"

# Use --version output to determine the compiler
# A different compiler will either accept --version and print something
# else or fail due to "unknown argument". In both cases the branch will
#
# use this routine to create the header / start of the Makevars file
if "$FC" --version 2>/dev/null | grep -q 'flang'; then
echo "PKG_FCFLAGS = $SFLAGS -fc-prototypes-external" > src/Makevars
fi

# Complete the Makevars file with known system agnostic settings
cat src/Makevars.in >> src/Makevars
3 changes: 0 additions & 3 deletions src/Makevars → src/Makevars.in
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ C_OBJS = wrappersc.o
# Fortran objects: refer to file names <name.o>, order reflects dependency structure
FT_OBJS = params_core.mod.o sofunutils.mod.o grid_siterun.mod.o params_siml_pmodel.mod.o params_siml_biomee.mod.o forcing_siterun_pmodel.mod.o forcing_siterun_biomee.mod.o params_soil_biomee.mod.o interface_biosphere_pmodel.mod.o interface_biosphere_biomee.mod.o tile_pmodel.mod.o plant_pmodel.mod.o soiltemp_sitch.mod.o waterbal_splash.mod.o vegdynamics_pmodel.mod.o gpp_pmodel.mod.o gpp_biomee.mod.o photosynth_pmodel.mod.o biosphere_pmodel.mod.o biosphere_biomee.mod.o vegetation_biomee.mod.o soil_biomee.mod.o sofun_r.o

# Flags for the Fortran compiler, suggested by Prof. Ligges
# PKG_FFLAGS = -fc-prototypes-external -fpic -g -O2 -mtune=native -Wall -pedantic -flto=10 -c

all: $(SHLIB) clean

$(SHLIB): $(FT_OBJS) $(C_OBJS)
Expand Down
68 changes: 68 additions & 0 deletions src/Makevars.win
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# PKG_FFLAGS = -ffree-line-length-0 -fbacktrace -ffpe-trap=invalid,zero,overflow -O1 -Wall -Wextra -pedantic -fbacktrace -fPIC -fmax-errors=1 -ggdb -fcheck=all

# C objects
C_OBJS = wrappersc.o

# Fortran objects: refer to file names <name.o>, order reflects dependency structure
FT_OBJS = params_core.mod.o sofunutils.mod.o grid_siterun.mod.o params_siml_pmodel.mod.o params_siml_biomee.mod.o forcing_siterun_pmodel.mod.o forcing_siterun_biomee.mod.o params_soil_biomee.mod.o interface_biosphere_pmodel.mod.o interface_biosphere_biomee.mod.o tile_pmodel.mod.o plant_pmodel.mod.o soiltemp_sitch.mod.o waterbal_splash.mod.o vegdynamics_pmodel.mod.o gpp_pmodel.mod.o gpp_biomee.mod.o photosynth_pmodel.mod.o biosphere_pmodel.mod.o biosphere_biomee.mod.o vegetation_biomee.mod.o soil_biomee.mod.o sofun_r.o

all: $(SHLIB) clean

$(SHLIB): $(FT_OBJS) $(C_OBJS)

# Dependency of objects (?)
# <name.o>: <modulename.o>
sofun_r.o: interface_biosphere_pmodel.mod.o interface_biosphere_biomee.mod.o params_core.mod.o params_core.mod.o params_soil_biomee.mod.o params_siml_pmodel.mod.o params_siml_biomee.mod.o
interface_biosphere_pmodel.mod.o: forcing_siterun_pmodel.mod.o params_siml_pmodel.mod.o params_core.mod.o
interface_biosphere_biomee.mod.o: forcing_siterun_biomee.mod.o params_soil_biomee.mod.o params_siml_biomee.mod.o params_core.mod.o
forcing_siterun_pmodel.mod.o: params_core.mod.o params_siml_pmodel.mod.o grid_siterun.mod.o sofunutils.mod.o
forcing_siterun_biomee.mod.o: params_core.mod.o params_siml_biomee.mod.o grid_siterun.mod.o
params_soil_biomee.mod.o: params_core.mod.o
tile_pmodel.mod.o: params_core.mod.o interface_biosphere_pmodel.mod.o
waterbal_splash.mod.o: params_core.mod.o tile_pmodel.mod.o plant_pmodel.mod.o sofunutils.mod.o
gpp_pmodel.mod.o: params_core.mod.o sofunutils.mod.o plant_pmodel.mod.o tile_pmodel.mod.o interface_biosphere_pmodel.mod.o photosynth_pmodel.mod.o
gpp_biomee.mod.o: datatypes.mod.o soil_biomee.mod.o forcing_siterun_biomee.mod.o photosynth_pmodel.mod.o params_core.mod.o sofunutils.mod.o
photosynth_pmodel.mod.o: params_core.mod.o sofunutils.mod.o
soiltemp_sitch.mod.o: params_core.mod.o sofunutils.mod.o tile_pmodel.mod.o interface_biosphere_pmodel.mod.o
plant_pmodel.mod.o: params_core.mod.o sofunutils.mod.o interface_biosphere_pmodel.mod.o
vegdynamics_pmodel.mod.o: params_core.mod.o tile_pmodel.mod.o plant_pmodel.mod.o gpp_pmodel.mod.o waterbal_splash.mod.o
biosphere_pmodel.mod.o: params_core.mod.o classdefs.mod.o sofunutils.mod.o plant_pmodel.mod.o waterbal_splash.mod.o gpp_pmodel.mod.o vegdynamics_pmodel.mod.o tile_pmodel.mod.o interface_biosphere_pmodel.mod.o soiltemp_sitch.mod.o vegdynamics_pmodel.mod.o
biosphere_biomee.mod.o: params_core.mod.o interface_biosphere_biomee.mod.o datatypes.mod.o soil_biomee.mod.o vegetation_biomee.mod.o
soil_biomee.mod.o: datatypes.mod.o
vegetation_biomee.mod.o: datatypes.mod.o soil_biomee.mod.o gpp_biomee.mod.o
datatypes.mod.o: interface_biosphere_biomee.mod.o params_core.mod.o classdefs.mod.o
sofunutils.mod.o: params_core.mod.o

# Source (object) of Fortran modules
# <modulename.mod>: <filename.o>
sofun_r_mod.mod: sofun_r.o
md_params_core.mod: params_core.mod.o
md_params_siml_pmodel.mod: params_siml_pmodel.mod.o
md_params_siml_biomee.mod: params_siml_biomee.mod.o
md_forcing_pmodel.mod: forcing_siterun_pmodel.mod.o
md_forcing_biomee.mod: forcing_siterun_biomee.mod.o
md_params_soil_biomee.mod: params_soil_biomee.mod.o
md_interface_pmodel.mod: interface_biosphere_pmodel.mod.o
md_interface_biomee.mod: interface_biosphere_biomee.mod.o
md_grid.mod: grid_siterun.mod.o
md_biosphere_pmodel.mod: biosphere_pmodel.mod.o
md_biosphere_biomee.mod: biosphere_biomee.mod.o
md_classdefs.mod: classdefs.mod.o
md_plant_pmodel.mod: plant_pmodel.mod.o
md_waterbal.mod: waterbal_splash.mod.o
md_sofunutils.mod: sofunutils.mod.o
md_tile_pmodel.mod: tile_pmodel.mod.o
md_gpp_pmodel.mod: gpp_pmodel.mod.o
md_gpp_biomee.mod: gpp_biomee.mod.o
md_photosynth.mod: photosynth_pmodel.mod.o
md_soiltemp.mod: soiltemp_sitch.mod.o
md_vegdynamics_pmodel.mod: vegdynamics_pmodel.mod.o
datatypes.mod: datatypes.o
md_soil_biomee.mod: soil_biomee.o
md_vegetation_biomee.mod: vegetation_biomee.o

# Dependency of the C wrapper
wrappersc.o: sofun_r_mod.mod

clean:
@rm -rf *.mod *.o

0 comments on commit 8eac0fa

Please sign in to comment.