From fb9c95bd61c23888caf6becb55fcb0a3a146e94e Mon Sep 17 00:00:00 2001 From: q-posev Date: Fri, 8 Oct 2021 13:55:56 +0200 Subject: [PATCH] add version attributes to the Fortran module --- src/templates_front/build.sh | 15 +++++++++++++++ tests/test_f.f90 | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/src/templates_front/build.sh b/src/templates_front/build.sh index 4e78d8f..97e53a3 100644 --- a/src/templates_front/build.sh +++ b/src/templates_front/build.sh @@ -3,6 +3,7 @@ # prefixes cat prefix_front.c > trexio.c cat prefix_front.h > trexio.h + # grep some usefull constants from the config.h echo "" >> trexio.h grep "TREXIO_PACKAGE_VERSION" ../../include/config.h >> trexio.h @@ -11,10 +12,24 @@ grep "TREXIO_VERSION_MINOR" ../../include/config.h >> trexio.h grep "TREXIO_VERSION_PATCH" ../../include/config.h >> trexio.h echo "" >> trexio.h +# parse the config-defined version attributes to pass them to Fortran module file +VERSION_VAL=`grep "TREXIO_PACKAGE_VERSION" ../../include/config.h | cut -d " " -f 3` +VERSION_MAJOR_VAL=`grep "TREXIO_VERSION_MAJOR" ../../include/config.h | cut -d " " -f 3` +VERSION_MINOR_VAL=`grep "TREXIO_VERSION_MINOR" ../../include/config.h | cut -d " " -f 3` +VERSION_PATCH_VAL=`grep "TREXIO_VERSION_PATCH" ../../include/config.h | cut -d " " -f 3` + cat prefix_s_front.h > trexio_s.h cat prefix_fortran.f90 > trexio_f.f90 cat prefix_python.py > trexio.py +# append version string and attributes to the Fortran module file +echo "" >> trexio_f.f90 +echo "character(len = 12) :: TREXIO_PACKAGE_VERSION = ${VERSION_VAL}" >> trexio_f.f90 +echo "integer(4) :: TREXIO_VERSION_MAJOR = ${VERSION_MAJOR_VAL}" >> trexio_f.f90 +echo "integer(4) :: TREXIO_VERSION_MINOR = ${VERSION_MINOR_VAL}" >> trexio_f.f90 +echo "integer(4) :: TREXIO_VERSION_PATCH = ${VERSION_PATCH_VAL}" >> trexio_f.f90 +echo "" >> trexio_f.f90 + # c front end cat populated/pop_*.c >> trexio.c cat populated/pop_*.h >> trexio.h diff --git a/tests/test_f.f90 b/tests/test_f.f90 index 42f9387..0390756 100644 --- a/tests/test_f.f90 +++ b/tests/test_f.f90 @@ -2,6 +2,12 @@ program test_trexio use trexio implicit none + print * , "============================================" + print'(a,a)' , " TREXIO VERSION STRING : ", TREXIO_PACKAGE_VERSION + print'(a,i3)', " TREXIO MAJOR VERSION : ", TREXIO_VERSION_MAJOR + print'(a,i3)', " TREXIO MINOR VERSION : ", TREXIO_VERSION_MINOR + print * , "============================================" + call system('rm -rf test_write_f.dir') print *, 'call test_write(''test_write_f.dir'', TREXIO_TEXT)' call test_write('test_write_f.dir', TREXIO_TEXT)