- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have the following code
integer :: iostat
logical :: exist = .false.
character(*), parameter :: path = repeat("A", 10000)
!character(:), allocatable :: path; path = repeat("A", 10000)
inquire(file = path, exist = exist)
print *, exist
end
which yields the following error:
error #6258: The CHARACTER string result is greater than 7198 characters.
Is this error reflecting the standard Fortran programming language limitation, or is it an ifort / ifx limit? If it is a compiler limitation, then why?
In any case, the error can be resolved by letting `path` be allocatable. But even then, we hit another compiler warning (which used to be an error in my older tests).
forrtl: warning (785): File-path is longer than Intel(r) Fortran limit of 4096
Again why?
If I supply the `iostat` as an argument to `inquire()`, then I get a non-zero error code `785` which indicates the occurrence of an error. Then again, why is it a warning (which, as far as I remember, used to be an actual runtime error not long ago, perhaps with older ifort compilers) with the status code but turns into an error with the error code supplied? Isn't it a dangerous behavior by the compiler?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Intel Fortran has a 7198 character limit for character constants - see Compiler Limits
I'm not sure where the 4096 character limit on a file specification comes from, though Windows tends to limit file paths to 260 characters, with some exceptions. I do see this warning documented, but am uncertain why it is a warning and where the number comes from.
What are you trying to accomplish here?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Intel Fortran has a 7198 character limit for character constants - see Compiler Limits
I'm not sure where the 4096 character limit on a file specification comes from, though Windows tends to limit file paths to 260 characters, with some exceptions. I do see this warning documented, but am uncertain why it is a warning and where the number comes from.
What are you trying to accomplish here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, Steve; I had documented this behavior as an oddity in the codebase.
I noticed this issue when the program passed a long string to `inquire(..., iostat = iostat)`.
Because Intel ifort/ifx returns a non-zero `iostat` for this warning, the program stops with an error message.
It seems like this is a compiler limitation. To bypass it, we have now wrapped `inquire()` with another function that first checks for the string length to be less than 256/4096 on Windows/Linux.
However, ifort/ifx's flagging of this behavior as an error when `iostat` is passed is a significant problem. It must be either a warning or an error, not both, depending on the presence of `iostat`. This makes reliable capturing of other errors more complex, as in the solution above.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
IOSTAT doesn't have the concept of "warning". My view is that it is a bug to call it a warning. If it still works, let it succeed; if it fails, call it an error. I'd love to see an explanation from Intel development on this topic.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page