For Programmers: Free Programming Magazines  


Home > Archive > Fortran > December 2005 > please let me know what this program prints









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author please let me know what this program prints
robert.corbett@sun.com

2005-12-14, 4:00 am

I want to know what the following program prints using
various Fortran implementations:

PROGRAM MAIN
X = 0.0
Y = -X
PRINT '(F4.2)', X
PRINT '(F4.2)', Y
PRINT '(F5.2)', Y
END

Please run it and let me know the results. Please let me
know which implementation you used and the general class
of system on which it was run (PC, Mac, Sun workstation, etc.).

Using Sun f95 on a Sun Ultra 60, it prints

0.00
0.00
0.00

Bob Corbett

Jason Nielsen

2005-12-14, 4:00 am

On Tue, 13 Dec 2005, robert.corbett@sun.com wrote:

>
>
> I want to know what the following program prints using
> various Fortran implementations:
>
> PROGRAM MAIN
> X = 0.0
> Y = -X
> PRINT '(F4.2)', X
> PRINT '(F4.2)', Y
> PRINT '(F5.2)', Y
> END
>
> Please run it and let me know the results. Please let me
> know which implementation you used and the general class
> of system on which it was run (PC, Mac, Sun workstation, etc.).
>
> Using Sun f95 on a Sun Ultra 60, it prints
>
> 0.00
> 0.00
> 0.00
>
> Bob Corbett
>
>


ifort 9.0 Build 20051020Z
gfortran GNU Fortran 95 (GCC) 4.2.0 20051130 (experimental)
g95 G95 (GCC 4.0.1 (g95!) Dec 7 2005)

all print:

0.00
0.00
0.00

Cheers,
Jason
Jason Nielsen

2005-12-14, 4:00 am

>
> ifort 9.0 Build 20051020Z
> gfortran GNU Fortran 95 (GCC) 4.2.0 20051130 (experimental)
> g95 G95 (GCC 4.0.1 (g95!) Dec 7 2005)
>
> all print:
>
> 0.00
> 0.00
> 0.00
>
> Cheers,
> Jason
>


Oops! I'm running on a dual AMD Athlon(tm) MP 2600+ system.

Jason
FX

2005-12-14, 4:00 am

> PROGRAM MAIN
> X = 0.0
> Y = -X
> PRINT '(F4.2)', X
> PRINT '(F4.2)', Y
> PRINT '(F5.2)', Y
> END


Here is the results on a few interesting platforms (ppc-aix, ia64-hpux,
mips-irix and sx-superux):

$ uname -a
AIX regatta 3 5 00202C2A4C00 unknown unknown AIX
$ xlf -qversion
IBM XL Fortran Enterprise Edition V9.1
Version: 09.01.0000.0003
$ xlf a.f && ./a.out
** main === End of Compilation 1 ===
1501-510 Compilation successful for file a.f.
.00
.00
.00

> uname -a

HP-UX td176 B.11.23 U ia64 0391833941 unlimited-user license
> f90 +version

HP F90 v2.9.2
> f90 a.f && ./a.out

a.f
program MAIN

7 Lines Compiled
0.00
-.00
-0.00


$ f90 -v
MIPSpro Compilers: Version 7.4.2m
$ uname -a
IRIX64 rhodes 6.5 10060437 IP27 mips unknown Irix
$ f90 a.f && ./a.out
0.00
0.00
0.00


$ uname -a
SUPER-UX uqbar2 13.1 SX-5
$ f90 -V
FORTRAN90/SX Version 2.0 for SX-5
f90 driver (c) 1995,2005 NEC Corporation
Rev.313 2005/03/31
f90 compiler (c) 1995,2005 NEC Corporation
Rev.313 2005/03/31
$ f90 a.f && ./a.out
a.f:

f90: obsol(17): a.f, line 7: Fixed form source is used.
f90: a.f, main: There is 1 obsolescence.
0.00
-.00
-0.00

--
FX
Catherine Rees Lay

2005-12-14, 4:00 am

robert.corbett@sun.com wrote:
> I want to know what the following program prints using
> various Fortran implementations:
>
> PROGRAM MAIN
> X = 0.0
> Y = -X
> PRINT '(F4.2)', X
> PRINT '(F4.2)', Y
> PRINT '(F5.2)', Y
> END
>
> Please run it and let me know the results. Please let me
> know which implementation you used and the general class
> of system on which it was run (PC, Mac, Sun workstation, etc.).
>
> Using Sun f95 on a Sun Ultra 60, it prints
>
> 0.00
> 0.00
> 0.00
>
> Bob Corbett
>

c:\TEST>ftn95 negzero.f90 /lgo
[FTN95/Win32 Ver. 4.8.0 Copyright (C) Salford Software Ltd 1993-2005]
Organisation: Polyhedron Software

NO ERRORS [<MAIN> FTN95/Win32 v4.8.0]
Creating executable: c:\TEST\lgotemp@.exe
Program entered
0.00
0.00
0.00

Athlon-based PC running WinXP.

Catherine.
Patrick Begou

2005-12-14, 7:57 am

These are some computer I can access for runing your test.

Patrick

intel-ifort8-8.1-019
Intel(R) Fortran Compiler for 32-bit applications, Version 8.1 Build
20040921Z Package ID: l_fc_pc_8.1.019
Linux 2.6.10-1.771_FC2 #1 Mon Mar 28 00:50:14 EST 2005 i686 athlon i386
GNU/Linux
./a.out
0.00
0.00
0.00

gcc-gfortran-4.0.1-4.fc4
version gcc 4.0.1 20050727 (Red Hat 4.0.1-5)./a.out
Linux 2.6.14-1.1637_FC4 #1 Wed Nov 9 18:19:37 EST 2005 i686
0.00
0.00
0.00

AIX 5.2 ML2 (IBM RS6000)
xlfcmp 8.1.1.4
../a.out
.00
.00
.00
(it prints an additionnal blank charater at the begining of each line in
comparison with linux compilers)


Linux 2.4.21-sgi302r24 #1 SMP Fri Oct 22 22:43:12 PDT 2004 ia64 ia64
ia64 GNU/Linux (Altix 350)
intel-ifort8-8.1-019
sgi-intel-compiler-runtimes-7.1.019-sgi302r25
Intel(R) Fortran Itanium(R) Compiler for Itanium(R)-based applications
Version 8.1 Build 20040922 Package ID: l_fc_pc_8.1.019
../a.out
0.00
0.00
0.00


IRIX64 6.5 10060437 IP27
MIPSpro Compilers: Version 7.4.2m
../a.out
0.00
0.00
0.00


SUPER-UX 13.1 SX-5 (NEC supercomputer)
FORTRAN90/SX Version 2.0 for SX-5
f90 driver (c) 1995,2005 NEC Corporation Rev.313 2005/03/31
../a.out
0.00
-.00
-0.00
Kelvin Hales

2005-12-14, 7:57 am

In article <1134537513.968643.311040@o13g2000cwo.googlegroups.com>,
wrote:
> PROGRAM MAIN
> X = 0.0
> Y = -X
> PRINT '(F4.2)', X
> PRINT '(F4.2)', Y
> PRINT '(F5.2)', Y
> END
>


Digital Visual Fortran 5.0D on Intel Pentium-4 under Windows-XP
(Command Prompt):

0.00
0.00
0.00

Kelvin B. Hales
Kelvin Hales Associates Limited
Consulting Process Control Engineers
Web: www.khace.com

FX

2005-12-14, 7:57 am

> IRIX64 6.5 10060437 IP27
> MIPSpro Compilers: Version 7.4.2m
>
> [...]
>
> SUPER-UX 13.1 SX-5 (NEC supercomputer)
> FORTRAN90/SX Version 2.0 for SX-5


Hey, someone who has access to the same supercomputing center as me!
(see my brother-post). Bonjour, Patrick! :)

--
FX
Patrick Begou

2005-12-14, 9:59 pm

FX wrote:
>
>
> Hey, someone who has access to the same supercomputing center as me!
> (see my brother-post). Bonjour, Patrick! :)
>


J'ai vu aussi.
Amicalement

Patrick
Reinhold Bader

2005-12-14, 9:59 pm

robert.corbett@sun.com wrote:
> I want to know what the following program prints using
> various Fortran implementations:
>
> PROGRAM MAIN
> X = 0.0
> Y = -X
> PRINT '(F4.2)', X
> PRINT '(F4.2)', Y
> PRINT '(F5.2)', Y
> END
>
> Please run it and let me know the results. Please let me
> know which implementation you used and the general class
> of system on which it was run (PC, Mac, Sun workstation, etc.).
>
> Using Sun f95 on a Sun Ultra 60, it prints
>
> 0.00
> 0.00
> 0.00
>
> Bob Corbett
>

f90 on Hitachi SR8000 (HI-UX/MPP sr8000.lrz-muenchen.de 03-07 0 SR8000)
../a.out -F'PORT(PRCNTL(1))'
0.0
0.0
0.0

The run time option ensures that the first column is not treated as a
print control character.

Regards
James Giles

2005-12-14, 9:59 pm

robert.corbett@sun.com wrote:
> I want to know what the following program prints using
> various Fortran implementations:
>
> PROGRAM MAIN
> X = 0.0
> Y = -X
> PRINT '(F4.2)', X
> PRINT '(F4.2)', Y
> PRINT '(F5.2)', Y
> END


It may depend on compiler flags. CVF for example
writes:

0.00
-.00
-0.00

But is only does that if the /assume:minus0 compiler
directive is given.

(Also, I notice that one person posted a result that had only
one zero after the decimal points in each line. That's a
violation of the standard.)

--
J. Giles

"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare


Reinhold Bader

2005-12-14, 9:59 pm

James Giles wrote:
> robert.corbett@sun.com wrote:
>
> It may depend on compiler flags. CVF for example
> writes:
>
> 0.00
> -.00
> -0.00
>
> But is only does that if the /assume:minus0 compiler
> directive is given.
>
> (Also, I notice that one person posted a result that had only
> one zero after the decimal points in each line. That's a
> violation of the standard.)
>

I agree. We'll probably not have it fixed, since the machine will
be retired in a few months.
John Harper

2005-12-14, 9:59 pm

In article <1134537513.968643.311040@o13g2000cwo.googlegroups.com>,
<robert.corbett@sun.com> wrote:
>I want to know what the following program prints using
>various Fortran implementations:
>
> PROGRAM MAIN
> X = 0.0
> Y = -X
> PRINT '(F4.2)', X
> PRINT '(F4.2)', Y
> PRINT '(F5.2)', Y
> END
>
>Please run it and let me know the results. Please let me
>know which implementation you used and the general class
>of system on which it was run (PC, Mac, Sun workstation, etc.).
>
>Using Sun f95 on a Sun Ultra 60, it prints
>
>0.00
>0.00
> 0.00


Same with Sun Fortran 95 8.2 2005/10/13 on a Sun Solaris Sparcstation,
and Compaq Fortran Compiler V5.5-1877-48BBF on a DEC Alpha workstation.

But g95 version 4.0.1 (g95!) Dec 10 2005 (sparc-sun-solaris2.9) and
NAG f95 Release 4.2(542) on a DEC Alpha with OSTYPE=osf1 both print
0.00
-.00
-0.00

--
John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington, New Zealand
e-mail john.harper@vuw.ac.nz phone (+64)(4)463 5341 fax (+64)(4)463 5045
Ken Fairfield

2005-12-14, 9:59 pm

robert.corbett@sun.com wrote:
> I want to know what the following program prints using
> various Fortran implementations:
>
> PROGRAM MAIN
> X = 0.0
> Y = -X
> PRINT '(F4.2)', X
> PRINT '(F4.2)', Y
> PRINT '(F5.2)', Y
> END
>
> Please run it and let me know the results. Please let me
> know which implementation you used and the general class
> of system on which it was run (PC, Mac, Sun workstation, etc.).
>
> Using Sun f95 on a Sun Ultra 60, it prints
>
> 0.00
> 0.00
> 0.00
>
> Bob Corbett


On OpenVMS/Alpha V7.3-1 with both of the following compilers, and
on the F95 compiler, with and without IEEE floats and various
switches, all give the same output (last compile shown for
completeness):

========================================
==================
$ fort corbett/float=ieee/ieee_mode=denorm
$ link corbett
$ run corbett

..00

..00
0.00
$ fort/old/vers
HP Fortran 77 V7.6-198-48D52 on OpenVMS Alpha V7.3-1
$ fort/vers
HP Fortran V7.6-3276-48D52
$
========================================
===================

Note that Fortran output with PRINT on VMS is using Fortran
carriage-control conventions, gobbling up the initial
character, whether a "0" or a space character. If I change
the PRINT statements to "Write (*, '(1X,F4.2)') X", etc.,
the output is:

========================
$ run corbett
0.00
0.00
0.00
$
========================

Secondly, either the Alpha architecture, VMS on Alpha, and/or
the VMS Fortran on Alpha, doesn't seem to support a negative
zero. (This is an F95 compliant compiler so according to my
reading of the recent discussion, I would think the compiler
would be required NOT to print the minus sign, but what do I
know?)

Regards, Ken
--
I don't speak for Intel, Intel doesn't speak for me...

Ken Fairfield
D1C Automation VMS System Support
who: kenneth dot h dot fairfield
where: intel dot com
robert.corbett@sun.com

2005-12-15, 3:58 am

Thank you to all who responded. The information you have provided
will help me write a request for an official interpretation on how
Fortran
processors that can distinguish positive and negative zeros should
format negative zeros.

Bob Corbett

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com