-
Couldn't load subscription status.
- Fork 196
Description
Description
An example of stdlib_io, example_loadnpy, terminated with an error when built using NAG Fortran with the release profile.
>fpm run --compiler nagfor --profile release --example example_loadnpy
Project is up to date
Failed to read array from file 'example.npy'
ERROR STOPExpected Behaviour
I expected the example to run and finish as successfully as it did under the following configurations:
- gfortran with the
debugandreleaseprofiles - Intel Fortran with the
debugandreleaseprofiles - NAG Fortran with the
debugprofile
>fpm run --compiler gfortran --profile debug --example example_loadnpy
Project is up to date
>fpm run --compiler gfortran --profile release --example example_loadnpy
Project is up to date
>fpm run --compiler ifort --profile debug --example example_loadnpy
Project is up to date
>fpm run --compiler ifort --profile release --example example_loadnpy
Project is up to date
>fpm run --compiler nagfor --profile debug --example example_loadnpy
Project is up to date
Version of stdlib
Platform and Architecture
Windows 10 22H2 64bit, gfortran 11.2 bundled with quickstart Fortran on Windows, Intel Fortran 2021.5.0, NAG Fortran 7.1 Build 7117, fpm 0.7.0 alpha
Additional Information
I print-debugged to determine the cause of this error, and I found that parse_header called in get_descriptor is considered a failure because stat is 1.
No error occurred in parse_header; stat is always 0. However, stat becomes 1 when returned to get_descriptor.
Several print statements reveal this strange behavior.
- in
get_descriptor
print *,"before calling perse_header", stat
call parse_header(header, major, stat, msg)
print *,"after calling perse_header",stat
if (stat /= 0) return- in
parse_header
integer :: minor
print *,"at the top of perse_header", stat
...
print *,"at the end of perse_header", stat
end subroutine parse_header>fpm run --compiler nagfor --profile debug --example example_loadnpy
Project is up to date
before calling perse_header 0
at the top of perse_header 0
at the end of perse_header 0
after calling perse_header 0
>fpm run --compiler nagfor --profile release --example example_loadnpy
Project is up to date
before calling perse_header 0
at the top of perse_header 0
at the end of perse_header 0
after calling perse_header 1
Failed to read array from file 'example.npy'
ERROR STOPIn parse_header, stat is not assigned any value if no error occurs. stat having the intent(out) attribute may become undefined according to the Fortran standard:
The INTENT (OUT) attribute for a nonpointer dummy argument specifies that the dummy argument becomes undefined on invocation of the procedure, except for any subcomponents that are default-initialized (7.5.4.6).
I cannot say whether this behavior is a NAG Fortran's bug, but adding a statement stat = 0 to specify that no error occurred in parse_header avoids this spurious failure.
+ stat = 0
end subroutine parse_header