Difference between “character*10 :: a” and “character :: a(10)”

character*40 :: string is a character string of length 40

character :: string*40 is the same

character(len=40) :: string is also a character string of length 40

character :: string(40) is an array of 40 character strings of length 1

character*40 :: string(40) is an array of 40 character strings of length 40

character :: string(40)*40 is the same

character(len=40) :: string(40) is an array of 40 character strings of length 40

Your second internal writes fails, because it writes to the first string in the array string2. The first string string2(1) is just 1 character long and that is too short. For that reason you get the end of record error condition, the message is too long for the supplied string.

Internal writes treat array elements as separate records (similar to separate lines). One can utilize arrays of string in internal writes if one has more records (lines) to write into the array.

Leave a Comment