Fortran (f90)

From: Padiyath Kumar (Kumar.Padiyath@psi.ch)
Date: Mon Mar 10 2003 - 10:16:31 EST


  Hello,
   To-day I have received the following program from a user.
    The program produces different results for dufferent formats.
   The question is whether this is a compiler error or not.
   On the VMS systems the program was producing correct
results(unfortunately we donot have
   any more VMS systems).

    regards,
    Kumar

                        Programme DEMO
! **************
!
! Programme showing that we must avoid to use
! the FORMAT * , with the quadruple precision !!
!
        Integer , Parameter :: qd = Kind(0.q0)
!
        Real(qd) :: Pi,Qi
!
        Character(80) :: c,d,e
!---------------------------------------------------------------------------

----
        Pi = 4.q0*Atan(1.q0)
!
        write(29,*) Pi                          ! Here ~ 2.7E-32
        rewind(29)
        read(29,*) Qi
        write(c,*) Pi-Qi
        rewind(29)
!
        write(29,1) Pi                          ! Here ~ -0.4E-33 
        rewind(29)
        read(29,1) Qi
        write(d,1) Pi-Qi
        rewind(29)
!
        write(29,2) Pi                          ! Here 0 as it should !!
        rewind(29)
        read(29,2) Qi
        write(e,2) Pi-Qi
!
        write(*,'(//)')
        write(*,'(a)') Trim(Adjustl(c))
        write(*,'(a)') Trim(Adjustl(d))
        write(*,'(a)') Trim(Adjustl(e))
        write(*,'(//)')
!
1       format(g60.34)
2       format(g60.35)                          ! Good format
!
        end programme DEMO
Output from Program:
===============
2.696301922142130194278369119618898E-0033
-0.3851859888774471706111955885169855E-33
0.0000000000000000000000000000000000


This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 10:49:10 EDT