From owner-sc22wg5@open-std.org  Wed Sep 22 20:12:27 2004
Return-Path: <owner-sc22wg5@open-std.org>
X-Original-To: sc22wg5-domo
Delivered-To: sc22wg5-domo@ghz.klid.dk
Received: by ghz.klid.dk (Postfix, from userid 521)
	id D158137607; Wed, 22 Sep 2004 20:12:27 +0200 (CET DST)
X-Original-To: sc22wg5@open-std.org
Delivered-To: sc22wg5@open-std.org
Received: from dkuug.dk (ptah.dkuug.dk [195.215.30.66])
	by ghz.klid.dk (Postfix) with ESMTP id 0A29337605
	for <sc22wg5@open-std.org>; Wed, 22 Sep 2004 20:12:26 +0200 (CET DST)
Received: from purcell.obs-nice.fr (purcell.obs-nice.fr [192.54.174.72])
	by dkuug.dk (8.12.10/8.9.2) with ESMTP id i8MI9ajH068139
	for <sc22wg5@dkuug.dk>; Wed, 22 Sep 2004 20:09:44 +0200 (CEST)
	(envelope-from Bernard.Pichon@obs-nice.fr)
Received: from pcpichon (pcpichon.obs-nice.fr [192.54.175.45])
          by purcell.obs-nice.fr (8.12.9/jtpda-5.4) with SMTP id i8MIAZgi295088
          ; Wed, 22 Sep 2004 20:10:35 +0200 (CEST)
Message-ID: <003c01c4a0cf$952f0e60$2daf36c0@pcpichon>
From: "Bernard PICHON" <Bernard.Pichon@obs-nice.fr>
To: <sc22wg5@dkuug.dk>
Cc: "NOULLEZ, Alain" <anz@obs-nice.fr>, <Steve.Lionel@intel.com>
Subject: Why (standard conforming OR platform implementation)
Date: Wed, 22 Sep 2004 20:11:29 +0200
MIME-Version: 1.0
Content-Type: multipart/mixed;
	boundary="----=_NextPart_000_0039_01C4A0E0.58964CA0"
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
X-Spam-Score: 0 () 
Sender: owner-sc22wg5@open-std.org
Precedence: bulk

This is a multi-part message in MIME format.

------=_NextPart_000_0039_01C4A0E0.58964CA0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

Dear Fortran !
(expands in : Dear WG5 members, dear Lionel)

This program seems to me standard conforming.
But I don't understand its (different) behavior
  between Alpha platforms (with True64) for
      which the result is OK (for me)
  and Windows/Intel platforms (with CVF V6.6B)
      with a (very) strange result (in my opinion).

----------------------------------------------------------
----------------------------------------------------------

Program ANZBUG
  Integer, Parameter :: SP = KIND(1.) , DP = KIND(1.D0)
  Real(SP) :: sx, sy
  Real(DP) :: dres, dres1
  !
  Write(*,*)
  Write(*,*) " ==================== "
  Write(*,*)
  !
  dres = 12345.0_SP + 0.123456_SP
  Write(*,"(G30.20)") dres
  dres1 = DBLE(12345.0_SP) + DBLE(0.123456_SP)
  Write(*,"(G30.20)") dres1
  Write(*,*) dres - dres1       ! must be non zero and it is OK ....
  !
  Write(*,*)
  Write(*,*) " ==================== "
  Write(*,*)
  !
  sx = 12345.0_SP
  sy = 0.123456_SP
  dres = sx + sy
  Write(*,"(G30.20)") dres
  dres1 = DBLE(sx) + DBLE(sy)
  Write(*,"(G30.20)") dres1
  Write(*,*) dres - dres1       ! must be ALSO non zero
                                ! BUT  it is  OK on True64 & Alpha,
                                ! AND NOT OK on Win & Intel (CVF 6.6B)
  !
  Write(*,*)
  Write(*,*) " ==================== "
  Write(*,*)
  !
End Program ANZBUG

----------------------------------------------------------
----------------------------------------------------------

Also attached, the program.

Question 1 :
   What does the Standard really say about operations
   with litteral constants :  dres = 12345.0_SP + 0.123456_SP
              OR variables :  dres = sx + sy     ?????

Question 2 :
   If it is (only) a platform Windows/Intel/CVF problem,
            how to fix it ?

Rmq: In fact, switching between SP and DP is very useful
           to test/improve accuracies in numerical algorithms.

PS: For WG5 members only, a great thanks to
      Mike Metcalf for his Fortran resources
      over past years !

Bernard

-- 
Dr. Bernard PICHON
Département Cassiopée (UMR 6202 du CNRS)
Observatoire de la Côte d'Azur (OCA) à Nice
BP 4229                     06304 Nice Cedex 04
Telephone : 04 92 00 31 83
Telecopie : 04 92 00 31 21
Sur la toile : http://www.obs-nice.fr/pichon/


------=_NextPart_000_0039_01C4A0E0.58964CA0
Content-Type: application/octet-stream;
	name="anzbug.f90"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="anzbug.f90"

Program ANZBUG
  Integer, Parameter :: SP = KIND(1.) , DP = KIND(1.D0)
  Real(SP) :: sx, sy
  Real(DP) :: dres, dres1
  !
  Write(*,*)
  Write(*,*) " ==================== "
  Write(*,*)
  !  
  dres = 12345.0_SP + 0.123456_SP 
  Write(*,"(G30.20)") dres
  dres1 = DBLE(12345.0_SP) + DBLE(0.123456_SP)
  Write(*,"(G30.20)") dres1
  Write(*,*) dres - dres1       ! must be non zero and it is OK ....
  !
  Write(*,*)
  Write(*,*) " ==================== "
  Write(*,*)
  !
  sx = 12345.0_SP
  sy = 0.123456_SP
  dres = sx + sy
  Write(*,"(G30.20)") dres
  dres1 = DBLE(sx) + DBLE(sy)
  Write(*,"(G30.20)") dres1
  Write(*,*) dres - dres1       ! must be ALSO non zero 
                                ! BUT  it is  OK on True64 & Alpha, 
                                ! AND NOT OK on Win & Intel (CVF 6.6B)
  !
  Write(*,*)
  Write(*,*) " ==================== "
  Write(*,*)
  !
End Program ANZBUG

------=_NextPart_000_0039_01C4A0E0.58964CA0--

