public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kamaraju at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/23889] New: non intuitive behaviour of gfortran
Date: Wed, 14 Sep 2005 22:27:00 -0000	[thread overview]
Message-ID: <20050914222751.23889.kamaraju@gmail.com> (raw)

consider the following program
program random
implicit none
 real :: x
 call random_seed();
 call random_number(x);
 write(*,*) x
end program random

When I run this program, I want to output different random numbers for
each run. This does not happen with gfortran.

$gfortran random.f90

$./a.out
 0.1264991

$./a.out
 0.1264991

$./a.out
 0.1264991

I agree that the current gfortran's behaviour is standard conforming. But it is
counter intuitive. Most of the other compilers (see below) do not exhibit this
behaviour. It would be nice if this functionality is provided by gfortran also.

I tried intel compiler (ifort 8.1). It does what I want to
do.

$ifort random.f90

$./a.out
 0.3770227

$./a.out
 0.7290102

$./a.out
 8.0997661E-02

$./a.out
 0.1369602

This is what I get with g95 (2005 Sep 13) build.

% ./a.out
 0.5556493
% ./a.out
 0.3600861
% ./a.out
 0.7311671
% ./a.out
 0.3920767

Absoft 8.0 exhibits this behaviour

% f90 random.f90
% ./a.out
   0.139087
% ./a.out
   0.139087
% ./a.out
   0.139087
% ./a.out
   0.139087


So absoft, intel, g95 compilers generate different sequences on subsequent runs.
 I hope gfortran also uses this methodology just to be consistent with the
common practice if not for anything else.

-- 
           Summary: non intuitive behaviour of gfortran
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kamaraju at gmail dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23889


             reply	other threads:[~2005-09-14 22:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-14 22:27 kamaraju at gmail dot com [this message]
2005-09-14 22:29 ` [Bug libfortran/23889] " pinskia at gcc dot gnu dot org
2005-09-15  0:16 ` kargl at gcc dot gnu dot org
2005-09-15  2:12 ` kamaraju at gmail dot com
2005-09-15  3:44 ` sgk at troutmask dot apl dot washington dot edu
2005-09-16 16:09 ` kargl at gcc dot gnu dot org
2005-09-17 18:23 ` fxcoudert at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050914222751.23889.kamaraju@gmail.com \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).