gfxgfx
 
Please login or register.

Login with username, password and session length
 
gfx gfx
gfx
1617 Posts in 535 Topics by 779 Members - Latest Member: rhoronjeff@comcast.net December 01, 2022, 06:27:12 PM
*
gfx* Home | Help | Search | Login | Register | gfx
gfx
Absoft User Forum  |  Support  |  Windows  |  Some formatted I/O errors go undetected
gfx
gfxgfx
 

Author Topic: Some formatted I/O errors go undetected  (Read 619 times)

mecej4

  • Jr. Member
  • **
  • Posts: 76
Some formatted I/O errors go undetected
« on: March 14, 2022, 09:05:26 AM »
The test program given below contains four errors: format edit descriptors that are mismatched for the corresponding variables in the I/O list. Absoft Fortran catches only one of the four errors. Are there any obscure compiler options that can be specified to help catch such errors?


Code: [Select]
program mismatch
implicit none
integer i, ios
real r
character(2) :: iline = '1.', jline='12'
character(132) :: msg
!
print '(/,A,/)','Test-1'
read(iline,'(F2.1)',iostat=ios,iomsg=msg)i !reading real number into integer variable using F format
if(ios /= 0)then
   print *,'ios = ',ios,' for  READ 1, msg: ',trim(msg)
else
   print *,'Value of i: ',i
endif
write(*,'(ES10.3,4x,I10)',iostat=ios,iomsg=msg)i,i !printing integer using ES format
if(ios /= 0)print *,'ios = ',ios,' for WRITE 1, msg: ',trim(msg)


print '(/,A,/)','Test-2'
read(jline,'(I3)',iostat=ios,iomsg=msg)r  !reading integer data into real variable using I format
if(ios /= 0)print *,'ios = ',ios,' for  READ 2, msg: ',trim(msg)
write(*,'(ES10.3,4x,I10)',iostat=ios,iomsg=msg)r,r !printing real using I format
if(ios /= 0)print *,'ios = ',ios,' for WRITE 2, msg: ',trim(msg)


end program
The output from the same program when it is compiled and run using Gfortran:

Code: [Select]
Test-1


 ios =         5006  for  READ 1, msg: Expected REAL for item 1 in formatted transfer, got INTEGER
(F2.1)
 ^
 ios =         5006  for WRITE 1, msg: Expected REAL for item 1 in formatted transfer, got INTEGER
(ES10.3,4x,I10)
  ^


Test-2


 ios =         5006  for  READ 2, msg: Expected INTEGER for item 1 in formatted transfer, got REAL
(I3)
 ^
 1.401E-45     ios =         5006  for WRITE 2, msg: Expected INTEGER for item 2 in formatted transfer, got REAL
(ES10.3,4x,I10)
           ^
/code]

forumadmin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 333
Re: Some formatted I/O errors go undetected
« Reply #1 on: March 14, 2022, 03:01:07 PM »
There are no additional options available to enable the runtime I/O library to detect and report these errors. We have added this as a change request for a future release.

mecej4

  • Jr. Member
  • **
  • Posts: 76
Re: Some formatted I/O errors go undetected
« Reply #2 on: March 14, 2022, 06:33:34 PM »
There are no additional options available to enable the runtime I/O library to detect and report these errors. We have added this as a change request for a future release.
OK, thanks.

Absoft User Forum  |  Support  |  Windows  |  Some formatted I/O errors go undetected
 

gfxgfx
gfx gfx
Powered by MySQL Powered by PHP Valid XHTML 1.0! Valid CSS!