Silverfrost Forums

Welcome to our forums

Q FOrMAT

3 Nov 2008 11:08 #3944

Hi,

I´m comparing a code writted in 77 FORTRAN Version with the PLato compiler. When I move this code from 77 to PLato, the code is not working.... . I found that my boss (which uses 77) defines Q in the format... I never heard about Q in the format....., maybe the error is here

Do you know what´s this Q? do you know if Plato supports it??

Any comment is really appreciated Thanks in advance and best regards

3 Nov 2008 1:02 #3945

The standard edit descriptors are listed in the help file under 'FORMAT edit descriptors'. Extensions are given under 'Business Editing'.

Q is not mentioned and I have not seen this before.

3 Nov 2008 1:24 #3946

Kingkastle,

Q format descriptor was never part of the Fortran 77 standard. Thus your source is non-standard and the chances are that there may well be more non-standard (compiler specific) extensions to the standard lurking within the code that ftn95 will object to.

3 Nov 2008 9:54 #3947

I'm not sure, but I recall that Q format was hex format in Prime or Vax fortran. The clue may be in the rest of format descriptor, say Q10. The solution is to replace it with a standard format that is consistent with the variable type being used. If it is used to write to a file, there is little to wory about. If it is being read then it may need more research.

John

6 Nov 2008 12:42 #3973

In Vax fortran77, the Q format allowed you to determine the number of characters on the line, i.e. record length on a formatted file with arbitary lengths for each line.

I used to use it to determine how many trailing spaces were actually on the line. For example if the input contained: hello there||||||[eol]

where i have used | to represent a space, & [eol] is end of line, then

character*100 text
open(unit=10,file='myfile.txt',status='old')
read(10,1000,end=999)ilen,text
1000 format(q,a)

would return ilen=17 in the above example.

In FTN95, the equivalent would be:

character*100 text
integer*2 attr,handle,error_code
attr=0
call OPENF@('myfile.txt',ATTR,HANDLE,ERROR_CODE)

call READFA@(text, HANDLE, ilen, ERROR_CODE)
if(ilen .eq. -1)goto 999
Please login to reply.