forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

FORMAT mismatch: F-Format with UNKNOWN item

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Sat Mar 12, 2022 3:03 pm    Post subject: FORMAT mismatch: F-Format with UNKNOWN item Reply with quote

The following program has format specifiers that are mismatched to the variables in the I/O list. FTN95 catches the errors, but the wording of the error message is a bit puzzling.

Code:
program mismatch
implicit none
integer i
real r
character(2) :: iline = '1.', jline='123'
read(iline,'(F2.1)')i !reading real number into integer variable using F format
print '(ES10.3,4x,I10)',i,i !printing integer using ES format
read(jline,'(I3)')r  !reading integer data into real variable using I format
print '(ES10.3,4x,I10)',r,r !printing real using I format
end program


The error message is:

Code:
FORMAT mismatch: F-Format with UNKNOWN item (at data position 1). at address 1a0093c9


Surely, the compiler knows the type of the variable as well as its name (if /debug is specified)? Running the same program with Gfortran gives

Code:
At line 6 of file mm.f90
Fortran runtime error: Expected REAL for item 1 in formatted transfer, got INTEGER
(F2.1)
 ^
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sat Mar 12, 2022 5:19 pm    Post subject: Reply with quote

mecej4

Thanks for the feedback. I will take a look at this.
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Sun Mar 13, 2022 9:08 am    Post subject: Reply with quote

When I ran the test program in 32 bit mode, I got a compilation warning as jline is CHARACTER*(2) and the data supplied is 3 chars long. This had a line number. Sure, there's not a line number with the runtime error, but 'format/data mismatch' is a hint as what to look for if not where to look.

Error messages aren't always diagnostic of where the problem lies in source code (or what it really is), unfortunately, certainly not at run time.

I'm presuming that the error message reported was a /debug message, because I didn't get it with a straightforward compile and run.

Eddie
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Sun Mar 13, 2022 1:41 pm    Post subject: Reply with quote

Eddie, there are many thing wrong with the program; it was intended to demonstrate the unexpected "UNKNOWN item" error message. As usual, the first run time error to be encountered causes the program to abort, so there can be any number of remaining errors that need fixing beyond the error that caused the abort.

You can change the character variable length from 2 to 3 in the fifth line of the program if you wish to remove the warning.
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Mon Mar 14, 2022 8:30 am    Post subject: Reply with quote

Mecej4, The point was that I didn't get the same message as you and I wondered why.

E
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Mon Mar 14, 2022 9:44 am    Post subject: Reply with quote

I also recently got an "UNKNOWN item" error report, which turned out to be an out of bounds subscript for an integer array.
This "UNKNOWN item" error report was a bit confusing at first, but found a logic error where a zero subscript was not identified.
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Mon Mar 14, 2022 1:26 pm    Post subject: Reply with quote

The "UNKNOWN item" runtime I/O error is shown for certain combinations of errors. The following version of the test program displays this behaviour:

Code:
program mismatch
implicit none
integer i
real r
character(2) :: iline = '1.', jline='12'
read(iline,'(F2.1)')i !reading real number into integer variable using F format
print '(ES10.3,4x,I10)',i,i !printing integer using ES format
read(jline,'(I3)')r  !reading integer data into real variable using I format
print '(ES10.3,4x,I10)',r,r !printing real using I format
end program


The expected output is something similar to what the NAG compiler gave:

Code:
Test-1

 ios =  135  for  READ 1, msg: Invalid edit descriptor for integer i/o-list item
 ios =  135  for WRITE 1, msg: Invalid edit descriptor for integer i/o-list item

Test-2

 ios =  134  for  READ 2, msg: Invalid edit descriptor for real i/o-list item
 ios =  134  for WRITE 2, msg: Invalid edit descriptor for real i/o-list item


FTN95 8.83, with or without /64 and with or without /debug gives:

Code:
Test-1

 ios =           51 for  READ 1, msg: FORMAT mismatch: F-Format with UNKNOWN item (at data position 1).
 ios =           51 for WRITE 1, msg: FORMAT mismatch: ES-Format with INTEGER item (at data position 1).

Test-2

 ios =           51 for WRITE 2, msg: FORMAT mismatch: I-Format with REAL item (at data position 2).


It may be noted that FTN95 does not detect the second READ error (reading data into a real variable using an I3 format).
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Mon Mar 21, 2022 8:21 am    Post subject: Reply with quote

This has now been corrected for the next release of the DLLs.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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