Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Dual Number Automatic Derivation using the DNAD package #2

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ __pycache__/
# Fortran extensions
*.o
*.mod
*.f

# Distribution / packaging
.Python
Expand Down
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "dnad"]
path = dnad
url = https://github.com/joddlehod/dnad
[submodule "fson"]
path = fson
url = https://github.com/josephalevin/fson
[submodule "json-fortran"]
path = json-fortran
url = https://github.com/jacobwilliams/json-fortran
43 changes: 34 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,58 @@ OPTIONDEFS = -DWRITEOUTFILE

DNAD_OBJ = dnad/dnad.o

# If using JSON output, compile with json-fortran library
ifeq ($(findstring USEJSONOUT,$(OPTIONDEFS)),USEJSONOUT)
JSON_DYL = -ljsonfortran -lgfortran
JSON_DIR = /Users/jml1/GitHub/microCOSM/json-fortran/jsonfortran-gnu-8.3.0/lib/
JSON_LIB = -L$(JSON_DIR)
JSON_INC = -I$(JSON_DIR)
FFLAGS += -Wl,-rpath,/opt/local/lib/gcc-devel -Wl,-rpath,$(JSON_DIR)
else
JSON_DYL =
JSON_LIB =
JSON_INC =
endif

MODULE_OBJ = mod_precision.o mod_dimensions.o \
mod_common.o mod_chemconst.o \
mod_chemspeciation.o mod_phsolvers.o \
mod_carbonchem.o mod_modelmain.o
mod_carbonchem.o mod_modelio.o \
mod_modelmain.o

MODEL_OBJ = microcosm_model.o

# C preprocessing
# C preprocessing and replacing the _d in constants:
ifeq ($(findstring USEDUALNUMAD,$(OPTIONDEFS)),USEDUALNUMAD)
CPPCMD = cat $< | sed -e "s/REAL(KIND=wp)/TYPE(DUAL)/g" \
-e "s/TYPE(DUAL), PARAMETER/REAL(KIND=wp), PARAMETER/g" \
| $(FC) $(OPTIONDEFS) -cpp -P -E $(FFLAGS)
MODULE_OBJ += $(DNAD_OBJ)
else
CPPCMD = cat $< | $(FC) $(OPTIONDEFS) -cpp -P -E $(FFLAGS)
endif

model: $(MODULE_OBJ) $(MODEL_OBJ)
$(FC) $(OPTIONDEFS) $(FFLAGS) $(MODULE_OBJ) $(MODEL_OBJ) -o microCOSM
model: $(DNAD_OBJ) $(MODULE_OBJ) $(MODEL_OBJ)
$(FC) $(JSON_LIB) $(JSON_INC) $(OPTIONDEFS) $(FFLAGS) $(MODULE_OBJ) $(MODEL_OBJ) -o microCOSM $(JSON_DYL)

# Requires seperate pre-processing for some reason
pymodel: $(MODULE_OBJ:.o=.f) $(MODEL_OBJ:.o=.f)
$(PC) $(OPTIONDEFS) --opt=$(FFLAGS) --f90flags=-ffree-form -m microCOSM -c $(MODULE_OBJ:.o=.f) $(MODEL_OBJ:.o=.f)
pymodel: $(DNAD_OBJ) $(MODULE_OBJ:.o=.f)
$(PC) $(OPTIONDEFS) --opt=$(FFLAGS) --f90flags=-ffree-form -m microCOSM -c $(MODULE_OBJ:.o=.f)

#%.o: %.F90
# $(FC) $(OPTIONDEFS) -c $(FFLAGS) $< -o $@

%.f: %.F90
$(CPPCMD) -o $@ -
$(CPPCMD) -o $@ $(JSON_DYL) -
%.o: %.f
$(FC) $(OPTIONDEFS) -c $(FFLAGS) -ffree-form $< -o $@
$(FC) $(JSON_LIB) $(JSON_INC) $(OPTIONDEFS) -c $(FFLAGS) -ffree-form -o $@ $< $(JSON_DYL)

.PHONY : dnadmod
dnadmod:
$(FC) $(OPTIONDEFS) -c $(FFLAGS) -ffree-form $(DNAD_OBJ:.o=.F90)

.PHONY : clean
clean:
$(RM) $(MODULE_OBJ) $(DNAD_OBJ) $(MODEL_OBJ)
$(RM) $(MODULE_OBJ:.o=.mod) $(DNAD_OBJ:.o=.mod) $(MODEL_OBJ:.o=.mod)
$(RM) $(MODULE_OBJ:.o=.mod) $(DNAD_OBJ:.o=.mod) $(MODEL_OBJ:.o=.mod) dnadmod.mod
$(RM) $(MODULE_OBJ:.o=.f) $(DNAD_OBJ:.o=.f) $(MODEL_OBJ:.o=.f)
1 change: 1 addition & 0 deletions dnad
Submodule dnad added at ca9327
1 change: 1 addition & 0 deletions fson
Submodule fson added at 16731d
1 change: 1 addition & 0 deletions json-fortran
Submodule json-fortran added at 280ae0
Loading