Trying to update my Fortran 90 knowledge for a project, I encountered some weirdness when using internal files. Consider a code example:
! ---- internal_file_confusion.f90 ----
program internal_file_confusion
implicit none
character*40 :: string1
character :: string2(40)
write(string1, *) "Hello World 1"
write(*,*) "string1 = ", string1
write(string2, *) "Hello World 2"
write(*,*) "string2 = ", string2
end program
which when compiling with gfortran
crashes, writing to STDOUT
string1 = Hello World 1
At line 10 of file e:/Daten/tmp/fortran-training/internal_file_confusion.f90
Fortran runtime error: End of record
When declaring with a notation, an *length
array of characters can be used for internal notation, but not when declaring with a note name(length)
. In addition, I noticed that the designation is *length
apparently only allowed for character arrays, while this is forbidden with an error message, e.g.
Error: Old-style type declaration INTEGER*40 not supported at (1)
for other data types.
What is the difference between these designations and why does this affect the use as internal files?