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

Working Git Hash for ADflow #214

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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 @@ -23,6 +23,7 @@ src/build/adflow_project.dep
src/build/libadflow-f2pywrappers2.f90
src/build/libadflowmodule.c
src/build/importTest.py
src/build/version.f90

# Regression test auxiliary files:
input_files.tar.gz
Expand Down
1 change: 1 addition & 0 deletions adflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
from .pyADflow_C import ADFLOW_C
from .oversetCheck import OversetCheck
from .checkZipper import checkZipper
from .fortranVersion import fortranVersion
15 changes: 15 additions & 0 deletions adflow/fortranVersion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from .libadflow import version


def fortranVersion():
"""
Return the version of the compiled Fortran code

Returns
-------
ver : str
the value of `git describe --dirty --always --tags` at compile time of the libadflow object.
"""

ver = version()
return ver.decode("utf-8").strip()
26 changes: 25 additions & 1 deletion src/build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ CC_ALL_FLAGS = $(C_FLAGS) -I../c_defines -I../metis-4.0 $(PETSC_CC_INCLUDE

LINKER_ALL_FLAGS = $(CGNS_LINKER_FLAGS) $(PETSC_LIB) $(LINKER_FLAGS)

GIT_VERSION = $(shell git describe --dirty --always --tags)

# Include the full filelist
include fileList

Expand Down Expand Up @@ -46,10 +48,32 @@ OFILES=$(f90Files:%.f90=%.o) $(F90Files:%.F90=%.o) $(cFilesNoDir:%.c=%.o) $(f77F
DEP_FILE=adflow_project.dep

# Not real targets are "phony"
.PHONY: sources lib
.PHONY: version sources lib

default: all

version: ../build/version.f90

../build/version.f90:
@echo "Making auto-generated version file"
@echo GIT_VERSION is $(GIT_VERSION)
# @echo "module fortranversion" > version.f90
# @echo " use constants, only : maxStringLen" >> version.f90
# @echo "contains" >> version.f90
@echo " subroutine version(ver)" > version.f90
@echo " ! Automatically generated version function" >> version.f90
@echo " !" >> version.f90
@echo " ! Desricption of Arguments" >> version.f90
@echo " ! Output" >> version.f90
@echo " ! ver - string, contains git tag and commit hash" >> version.f90
@echo " use precision" >> version.f90
@echo " implicit none" >> version.f90
@echo " character(len=256), intent(out) :: ver" >> version.f90
@echo " " >> version.f90
@echo " ver = '$(GIT_VERSION)'" >> version.f90
@echo " end subroutine version" >> version.f90
# @echo "end module fortranVersion" >> version.f90

# The 'source's makes all the .o files. It also depends on the dependence file "DEP_FILE".
sources: $(OFILES) $(DEP_FILE)

Expand Down
1 change: 1 addition & 0 deletions src/build/directoryList
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dirs:= adjoint\
adjoint/ADFirstAidKit\
ADT\
bcdata\
build\
initFlow\
inputParam\
NKSolver\
Expand Down
2 changes: 2 additions & 0 deletions src/build/fileList
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ fortranFiles= ADT/adtUtils.F90\
\
bcdata/BCData.F90\
\
build/version.f90\
\
initFlow/variableReading.F90\
initFlow/initializeFlow.F90\
\
Expand Down
3 changes: 3 additions & 0 deletions src/f2py/adflow.pyf
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,9 @@ python module libadflow
end subroutine getfam
end module surfacefamilies

subroutine version(ver) ! in :test:version.f90
character(len=256) intent(out) :: ver
end subroutine version

end interface

Expand Down