Hello,
I am new here and this is my first message in the forum, which already helped me when I was stuck in writing some Fortran lines and made me curious about this language, so I would like to thank the community.
I am writing a small library for an atomic potential to be used in a molecular dynamics code, which will probably be the object of other questions, but for now I restrict myself to the potential. Despite this being a small part of a larger project, I took it as an opportunity to learn about Fortran Package Manager and unit testing for the very first time.
The potential relies on importing some external coefficients stored in a huge text file; also, when I do the tests, I import few atomic configurations from an external modified .xyz file, which is just a plain text file.
Since I don’t know in principle where the code will be placed (well I know, either in my workstation or in some subpath of my $WORKDIR on some cluster, still, different ones), I pass the path to these files through the C preprocessor, using for example the following in the Makefile:
CPPFLAGS = -Ddata_path=‘“$(CURDIR)/tests/data/’ -cpp
I don’t know if this is the best solution, but it works. How can I achieve this using fpm?
In particular I have two problems:
- I tried different versions of what I found in the documentation:
[preprocess]
cpp.macros=[“data_path=‘tests/data/'"]
But I don’t get any substitution of the string data_path with “tests/data” in the code, instead I get an Error: Invalid character in name at (1) compilation terminated due to -fmax-errors=1.
What is the right way to substitute a word with a string through the preprocessor? Or, is there a better way this is achieved?
2. In the Makefile I am relying on the environment variable $CURDIR, but I can’t use it in the fpm. The relative path that I put as an example in the point 1 is relative to the fpm.toml file, but I’m still not sure if it would work when I call the executable from any place (for example, from a subpath of $SCRATCH in a cluster).
Thanks in advance for guidance!