The following program does formatted writes of an integer to an internal file (i.e., a buffer) with three different variations. The second WRITE writes uses a field width of 4, which is adequate for the integer 123, but the resulting string is longer than the record length of the internal file, which is 3.
program asterisks
character(3) str
character(100) msg
n=123
print *,'Str Iostat Message'
str='xyz'; msg=' - '; write(str,'(i0)',iostat=i,iomsg=msg) n
write(*,10) str,i,trim(msg)
str='xyz'; msg=' - '; write(str,'(i4)',iostat=i,iomsg=msg) n
write(*,10) str,i,trim(msg)
str='xyz'; msg=' - '; write(str,'(i2)',iostat=i,iomsg=msg) n
write(*,10) str,i,trim(msg)
10 format(1x,A3,i5,4x,A)
end
I think that the second WRITE should yield a positive IOSTAT value, a suitable IOMSG, and leave the record unchanged. FTN95 8.51 (32 and 64-bit) returns IOSTAT = 0, instead, and the written record is incorrect.
Str Iostat Message
123 0
12 0
** 0
For the second case, Intel Fortran gives IOMSG='output statement overflows record, unit -5, file Internal Formatted Write'.