- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
while running executable cras.x i am getting -
"forrtl: severe (64): input conversion error"
this error is coming while reading crastat.in file -
while reading following line -
ABCD 20120625 2 309 33.901 22.521 20.000 28.048 79.924 -0.004 67.332******* 99.062 38.765
since while reading i have specified f7.3 format and in file crastat.in its ******* there .
Please help me as to how i can ignore this input conversion in ifort.
When i am compiling same program using xlf_r or f77 its ignoring input conversion and running fine.
Regards,
Shivali
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Before attempting to answer your question I should like to see the READ and Format statements concerned, and a copy of the actual input file as an attachment -- the last item is important because posting a few lines inside a post often changes whitespace and the success or failure of the READ statement may depend on the presence or absence of said whitespace, particularly tab (Z'09') characters.
In your position, I would want to track the problem down and fix it, not ignore it. It is possible to ignore the READ error and carry on blithely, but that would probably be an irresponsible thing to do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Shivali,
As pointed out by mecej4, you should try to figure out why the error happens rather than look for ways to get around it. Have you tried error handling your READ statements? An option is along the following lines:
.. use, intrinsic :: iso_fortran_env, only : iostat_end, iostat_eor .. character(len=255) :: errio !.. could be a string of any length integer :: istat read(unit=lun, fmt=my_format, iostat=istat, iomsg=errio) foo select case ( istat ) case ( 0 ) !.. normal operation case ( iostat_end ) print *, " end-of-file encountered during read: ", errio case ( iostat_eor ) print *, " end-of-record encountered during read: ", errio case default print *, " error encountered during read: error message is ", errio end select ..
As you indicate, there appears to be an issue with your format statement: perhaps, you can read the record in as a string and process it in chunks based on your expected values (use of internal file reads may come in handy) and skip over regions with asterisks, if that's what is appropriate.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have attached the input file crasinit.in as crasinit.in.h .
Below are the read and format statements used in the program.
++++++++++++++++++++++++
open(11,file='crastat.in')
open(66,file='shivali.pts')
200 format(a7,i4,2i2,2i6,5f7.3,7x,4f7.3,5(49x),35x,4f7.2,4(7x),f8.3,
>f7.2,7x,8f8.2)
read(11,200)model,iyr,mm,nn,icra,npts,ro,rf,t,xmea,rmseb,
>weto,romax,rfmax,wete,xdifcog,ydifcog,xdif,ydif,cca,rmsea,
>xlncgo,yltcgo,xlncge,yltcge,te,td,tv,tp
write(66,*) model,iyr,mm,nn,icra,npts,ro,rf,t,xmea,rmseb,
>weto,romax,rfmax,wete,xdifcog,ydifcog,xdif,ydif,cca,rmsea,
>xlncgo,yltcgo,xlncge,yltcge,te,td,tv,tp
end
++++++++++++++++++++++++
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I tried error handling in code , it ran absolutely fine and iostat specifier "istat value is coming 0 for all cases in my crastat.in.
Shivali istat -------------- 0
UKMO 2014 9 25 3 54
33.57900 17.47800 20.00000 26.53200 41.95700
57.64600 152.3070 36.68000 25.34500 0.7700000
2.000000 -1.000000 0.3300000 1.9200001E-02 0.6320000
60.38000 11.19000 7.380000 81.42000 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00
Thanks ,
Shivali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Line 75 of your data file has asterisks in one field which, when read with the format specification that you listed, will cause an error condition. If you use the IOSTAT= and/or ERR= clauses in the READ statement, you will receive more information about the error. With the short program below, the output was
Error reading line 75 , iostat = 64 Number of lines read = 1239
The program to read the file and note errors:
program shivali implicit none character*7 model real ro,rf,t,xmea,rmseb,weto,romax,rfmax,wete,xdifcog,ydifcog,xdif,ydif real cca,rmsea,xlncgo,yltcgo,xlncge,yltcge,te,td,tv,tp integer iyr,mm,nn,icra,npts,ist,lno open(unit=11,file='crastat.in',status='old') lno=0 do read(11,300,err=100,iostat=ist,end=200)model,iyr,mm,nn,icra,npts,ro, & rf,t,xmea,rmseb,weto,romax,rfmax,wete,xdifcog,ydifcog, & xdif,ydif,cca,rmsea,xlncgo,yltcgo,xlncge,yltcge,te,td,tv,tp lno=lno+1 cycle 100 write(*,*)'Error reading line ',lno+1,', iostat = ',ist lno=lno+1 end do 200 write(*,*)'Number of lines read = ',lno close(11) 300 format(a7,i4,2i2,2i6,5f7.3,7x,4f7.3,5(49x),35x,4f7.2,4(7x),f8.3, & f7.2,7x,8f8.2) end
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
mecej4 wrote:
Line 75 of your data file has asterisks in one field which, when read with the format specification that you listed, will cause an error condition. If you use the IOSTAT= and/or ERR= clauses in the READ statement, you will receive more information about the error. With the short program below..
@mecej4,
Hats off to you on the outstanding service you provide to Fortranners out there. If you could charge just a penny for each of your service instances, you could probably own a whole Mediterranean island for yourself! As a premier educator on the Intel site, may I please suggest to you to look into coding idioms from the latest Fortran standard for which Intel Fortran is offering more and more support? See below. If you see value is in these newer idioms (using intrinsic options, doing away with statement and format labels, hard-wired file unit numbers, string facilities, etc.) and if you adopt them in your own code samples and snippets that you use to educate and help others, then the whole Fortran world can start seeing the benefits as well:
program shivali !.. Use intrinsic facilities for numeric precision, I/O error handling, etc. use, intrinsic :: iso_fortran_env, only : i4 => int32, wp => real32, iostat_end implicit none !.. File processing variables character(len=*), parameter :: crafile = "crastat.in" integer(i4) :: craunit !.. Line format statement for crastat.in file character(len=*), parameter :: cra_line_fmt = & "(a7,i4,2i2,2i6,5f7.3,7x,4f7.3,5(49x),35x,4f7.2,4(7x),f8.3,f7.2,7x,8f8.2)" character(len=255) :: errio !.. Variables to be read from file character(len=7) :: model !.. character* syntax is depracted real(wp) :: ro,rf,t,xmea,rmseb,weto,romax,rfmax,wete,xdifcog,ydifcog,xdif,ydif real(wp) :: cca,rmsea,xlncgo,yltcgo,xlncge,yltcge,te,td,tv,tp integer(i4) :: iyr,mm,nn,icra,npts,ist,lno !.. Open the file; notice the newunit facility open(newunit=craunit, file=crafile, status='old', iostat=ist, iomsg=errio) if (ist /= 0) then write(*,*) " error opening file: " // crafile stop end if lno = 0 loop_read: do read (unit=craunit, fmt=cra_line_fmt, iostat=ist, iomsg=errio) & model,iyr,mm,nn,icra,npts,ro, & rf,t,xmea,rmseb,weto,romax,rfmax,wete,xdifcog,ydifcog, & xdif,ydif,cca,rmsea,xlncgo,yltcgo,xlncge,yltcge,te,td,tv,tp select case ( ist ) case ( 0 ) !.. successful; can introduce debug printing of read line here case ( iostat_end ) !.. End of file reached write(*,*)'Number of lines read = ',lno close(unit=craunit, iostat=ist, iomsg=errio) if (ist /= 0) then write(*,*) " error opening file: " // crafile end if exit loop_read case default !.. Error condition write(*,*)'Error reading line ',lno+1,', iostat = ',ist end select lno = lno + 1 end do loop_read stop end program shivali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
FortranFan: If I may paraphrase/steal from Molière's Le Malade imaginaire:
It may make the patient feel better to have the doctor describe his malady in mellifluous Latin, but he will not be cured as a result.
Many of the code snippets exchanged here have a short-lived, often immediate, purpose. Portable, standard and modern code may be a laudable goal, but insisting on adherence to coding standards is more appropriate in large projects than in a forum such as this. I must admit that I do not have the same evangelical urges as you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
mecej4 wrote:
FortranFan: If I may paraphrase/steal from Molière's Le Malade imaginaire:
It may make the patient feel better to have the doctor describe his malady in mellifluous Latin, but he will not be cured as a result. ..
Yes, Molière thinks it is better for the patient to instead receive the message in Old Latin!! :-))
(https://en.wikipedia.org/wiki/Old_Latin)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
![](/skins/images/7FC17B7B85029576C25F1E43CE255B51/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page