-
Notifications
You must be signed in to change notification settings - Fork 108
How to control the precision of dependency libraries in top-level projects? #950
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
Comments
@zoziha, do you think the current preprocessor macro feature is insufficient? I think that the current feature is project-based, while you’re asking for the ability to specify macros on a per-dependency basis. I think that if we do that, the two could clash. For example, if |
Currently > cd . \example_packages\preprocess_cpp_deps2
> cat . \fpm.toml
name = "preprocess_cpp_deps"
[dependencies]
utils = { path = "crate/utils" }
[preprocess]
[preprocess.cpp]
macros = ["REAL64"]
> fpm run
main.f90 failed.
[ 50%] Compiling...
app\main.f90:12:21.
12 | call say_hello(x)
| 1
Error: Type mismatch in argument 'x' at (1); passed REAL(8) to REAL(4)
<ERROR> Compilation failed for object " app_main.f90.o "
<ERROR> stopping due to failed compilation
STOP 1
For libraries like I understand #ifdef REAL64
use, intrinsic :: iso_fortran_env, only: rk => real64
#else
use, intrinsic :: iso_fortran_env, only: rk => real32
#endif But I won't define
@perazz Thanks for your reply. |
This issues comes back to one I opened previously: #122 |
Yep. using macros is not perfect, but one can have [dependencies]
slsqp = { git = 'https://github.com/jacobwilliams/slsqp', tag = '1.4.1', preprocess.cpp.macros = ['REAL32'] }
quadpack = { git = 'https://github.com/jacobwilliams/quadpack', preprocess.cpp.macros = ['REAL128'] } |
I don't see how to do chaining, say if |
There is no way to control the conflicts of course, because macros are just simple labels. [dependencies]
quadpack_dep = { git='blablah', preprocess.cpp.macros = ["QUADPACK_DEP_MACRO"]} |
Perhaps we could just ship a precision module with [dependencies]
fpm = { git = 'https://github.com/fortran-lang/fpm' } module mymod
use fpm_kinds, only: wp => fpm_wp In addition we could implement special preprocessing of the |
Closed by #952. |
Description
Fortran's default floating point precision is single precision, and the most used data type in scientific computing is floating point.
There are quite a few libraries (e.g. slsqp) that provide macro-based precision options, which seems very useful when developers don't want to write multiple precision versions of routines and polymorphic interfaces.
Is it possible to have macro definitions for dependency libraries in top-level projects, e.g.:
This also has a positive effect on the fpm library ecology.
Possible Solution
Style 1:
Style 2:
Style 3:
Additional Information
The text was updated successfully, but these errors were encountered: