-
Notifications
You must be signed in to change notification settings - Fork 192
Description
Description
When I use stdlib_io_npy via FPM, i.e. with
[dependencies]
stdlib = { git="https://github.com/fortran-lang/stdlib", branch="stdlib-fpm" }
the FPM defaults to building with maximum rank of 4 for array procedures. While I can see that there are instructions for building with cmake to set this higher (up to 15), I'm running in a cluster environment where I'm having a few issues with cmake suddenly while FPM basically just works.
Except that I need rank 7. Is there a way in the FPM toml or environment variable to set -DCMAKE_MAXIMUM_RANK
to 7 instead?
Expected Behaviour
The preprocessor generates array procedures with up to rank 7 when using the FPM.
Version of stdlib
Platform and Architecture
SUSE Linux Enterprise Server 15 SP4
Additional Information
I have some binary data U which is naturally rank 7, double precision complex. I need to convert this to a different format for use in other code but the code to do this is in python. I have reader code in Fortran that I know gives me the correct ordering. I was going to use this fortran code to read the data, dump it to numpy so I can read it into python and then output it again there. This way, I could be assured that I had not messed up the ordering of the data.
The stdlib function I was to use was save_npy
and so hence a MWE would be
program example_savenpy
use stdlib_io_npy, only: save_npy
implicit none
real :: x(3, 2, 4, 4, 4, 4, 4) = 1
call save_npy('example.npy', x)
end program example_savenpy
but of course the difficulty is in the FPM build.
Activity
jvdp1 commentedon Apr 12, 2024
You can build locally a version of stdlib with up to rank 7 as described here. This would need to first modify the variable
maxrank
infpm-deployment.sh
.@jalvesz is working on an alternative Python script (see #791 for more details). Unfortunately I didn't get a chance to test it. Don't hesitate to provide feedback in #791 too.
RJaBi commentedon Apr 15, 2024
Thanks! I'll have a look and see how I get on.
Unfortunately the computer I want to use is down for a few days, so it'll take a little time.
RJaBi commentedon Apr 25, 2024
I was able to use #791 to generate a pre-processed version with the approriate max rank and add that dependency as
which seems to work (it compiles at least which I suspect will do the trick as I'm not asking for anything complicated).
I did however stumble across something else that may have been appropriate, but can't find it now. In the fpm.toml of stdlib on the stdlib-fpm branch there is
and FPM documentation suggests that this could be modified in the dependencies of another project, i.e.
At some point, I saw the maxrank in there for the stdlib preprocess, but I can't find the exact form for it now. Clearly being able to do
Would be a neat way to do what I need. Like I say, I can't find that now though (the above line does not work).
jalvesz commentedon Apr 27, 2024
@RJaBi glad to know the script was useful to you! as this an early stage proposal your feedback is highly useful to consider before pushing further with it.
In your comment #791 (comment) you mention not being able to use Cray compilers, I have personally never worked with them (and have no means to). So I was wondering if on your system are you able to set the environment variables
FPM_FC
,FPM_CC
andFPM_CXX
to point to the Cray compilers before building?This is an interesting use case which I did not think about when working out the script, as the main target was to preprocess stdlib in-place. I think that to enable what you want to do,
fpm
should be able of handling fypp on its own to recursively apply fypp preprocessing to a project and any dependencies within.RJaBi commentedon Apr 29, 2024
Yes I can set these. If I do, than the script crashes at the line:
flags = preprocessor[FPM_FC]
as there is no
crayftn
entry in the preprocessor variable. I think that the appropriate flag is just '-c', but I'm not 100% sure. This still doesn't make it compile, but that's cause the cray compiler is very picky (I think the error might be related to a variable calledmodule
) and not a problem with your script.Yes, that's clearly a FPM thing.