Skip to content

Commit

Permalink
Adjust script shebang to use Python interpreter
Browse files Browse the repository at this point in the history
Teach CMake how to find a Python interpreter and adjust the shebang in
the `convert-template` script to use that interpreter.

Co-Authored-By: Nicolas Bock <[email protected]>
Signed-off-by: Nicolas Bock <[email protected]>
  • Loading branch information
jeanlucf22 and nicolasbock committed Mar 24, 2020
1 parent d0a097c commit 5294d19
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 19 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,13 @@ else()
add_custom_target(dist)
endif()

include(FindPythonInterp)
if(NOT PYTHONINTERP_FOUND)
message(FATAL "Could not find Python interpreter")
endif()
configure_file(${CMAKE_SOURCE_DIR}/scripts/convert-template.in
${CMAKE_BINARY_DIR}/convert-template)

message(STATUS "When building executables with the bml library, please use the following link flags")

if(OPENMP_FOUND)
Expand Down
2 changes: 1 addition & 1 deletion scripts/convert-template → scripts/convert-template.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!${PYTHON_EXECUTABLE}

re_D = {}

Expand Down
2 changes: 1 addition & 1 deletion src/Fortran-interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ foreach(i RANGE ${NUMBER_TYPES_MAX})
get_filename_component(S_TYPED ${S_TYPED} NAME)
add_custom_command(OUTPUT ${S_TYPED}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${S}
COMMAND ${CMAKE_SOURCE_DIR}/scripts/convert-template
COMMAND ${CMAKE_BINARY_DIR}/convert-template
-DMATRIX_TYPE=${MATRIX_TYPE}
-DREAL_TYPE="${REAL_TYPE}"
-DREAL_KIND=${REAL_KIND}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fortran-tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ foreach(T ${TYPES})

add_custom_command(OUTPUT ${S_TYPED}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${S}
COMMAND ${CMAKE_SOURCE_DIR}/scripts/convert-template
COMMAND ${CMAKE_BINARY_DIR}/convert-template
-DDUMMY_KIND=${FORMATED_KIND}
-DDUMMY_PREC=${FORMATED_PREC}
-D_MP=${NUMBER_PREC}
Expand Down
35 changes: 19 additions & 16 deletions tests/Fortran-tests/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
FORTRAN TESTS
=============

The tests are driven by a general executable created when the code is compiled with
`BML_TESTING=yes`. This driver is called bml-testf compiled with the `testf.F90`
source.
The tests are driven by a general executable created when the code is
compiled with `BML_TESTING=yes`. This driver is called bml-testf
compiled with the `testf.F90` source.

Every low level source code of the type name_typed.F90 is preprocessed using
the `/scripts/convert-template` to chage to the particula element kind and presicion.
Two dummy varibles are used:
Every low level source code of the type name_typed.F90 is
pre-processed using the `/scripts/convert-template.in` to change to
the particular element kind and presicion. Two dummy varibles are
used:

- `DUMMY_KIND`: That gets replaced with either `real` or `complex`
- `DUMMY_PREC` or `_MP`: That gets replaced with `SP/_SP` of `DP/_DP` (defined in prec.F90)
There is are `exmple_template*` files that can be used as starting point to add
a particular test.

There is are `exmple_template*` files that can be used as starting
point to add a particular test.

# Conventions and rules

The general driver take four variables (this can be extended as needed).
These variables are:
The general driver take four variables (this can be extended as
needed). These variables are:

- `test_name`: The name of the test
- `matrix_type`: The matrix format (matrix format and matrix type are the same thing)
- `element_type`: The element "kind" and "precision". For example double_real, which gets
converted to real(8) at the lowest level.
- `test_name`: The name of the test
- `matrix_type`: The matrix format (matrix format and matrix type
are the same thing)
- `element_type`: The element "kind" and "precision". For example
double_real, which gets converted to real(8) at
the lowest level.

NOTE: Try to be as explicit as possible in naming the variables.
NOTE: Try to be as explicit as possible in naming the variables.

0 comments on commit 5294d19

Please sign in to comment.