|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Sun Jul 07, 2019 2:03 pm Post subject: Internal WRITE error goes undetected |
|
|
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.
Code: | 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.
Code: | 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'. |
|
Back to top |
|
|
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Sun Jul 07, 2019 5:54 pm Post subject: |
|
|
I agree this would be a useful additional run-time check. Though it is the programmer's responsibility to check such things.
The NAG and gfortran compilers also detect the error with the (I4) formatting at run-time. _________________ Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Mon Jul 08, 2019 7:28 am Post subject: |
|
|
Thank you for this. I have made a note that it needs fixing. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Mon Jul 08, 2019 10:08 am Post subject: |
|
|
This has now been fixed for the next release of the DLLs.
The iostat is 67 and the message is "Character buffer too small". |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|