Can nvfortran handle large direct access I/O?

Hello,

We ran into a problem with the nvfortran compiler (version 21.7). It appears that nvfortran fails to handle Fortran direct access I/O when the record length (recl) exceeds the maximum value of a 32-bit integer. I created a mini reproducer here: GitHub - vyu16/test_direct_io

gfortran worked:

$ gfortran --version
GNU Fortran (GCC) 11.2.0
Copyright (C) 2021 Free Software Foundation, Inc.

$ gfortran -o test.x test.f90 
$ ./test.x 
  record length should be:          19110297600
  record length returned by inquire:          19110297600
  record length in file:          19110297600

nvfortran failed:

$ nvfortran --version
nvfortran 21.7-0 64-bit target on x86-64 Linux -tp zen 
NVIDIA Compilers and Tools
Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES.  All rights reserved.

$ nvfortran -o test.x test.f90
$ ./test.x 
  record length should be:              19110297600
  record length returned by inquire:                        3
  record length in file:                        3
  cannot write, error:          219

Am I missing a compiler flag or something? Or is this currently not supported by nvfortran?

Thank you for your help!

Victor

I suspect we don’t support record lengths > 2 GB. I will do a little more research and check with engineering.

I think another problem is with that form of the inquire statement. It should return a default integer, but even if I compile with -i8, it doesn’t seem to return a valid 8-byte value.

Thank you for investigating! Indeed, inquire doesn’t seem to return the correct value. We just replaced all “direct” with “stream” in our code we. Everything is working now. Would be great to have “direct” working in future releases of nvfortran!

Thanks,
Victor

I opened an RFE for this, FS#30769. It would have to be an opt-in, as the record length is a part of the file format, and changing that would break existing direct i/o to existing files. But, might be something to consider with Flang/F18. I know we have tried to be compatible with Intel; sounds like we are not with gfortran.