From: robert.corbett on
According to my understanding of Section 14.1.2.4.1 of the Fortran 95
standard and Section 12.4.4.1 of the Fortran 2003 standard, the
program

PROGRAM MAIN
INTERFACE COS
REAL FUNCTION MYCOS(X)
END FUNCTION
END INTERFACE
CALL SUBR
CONTAINS
SUBROUTINE SUBR
INTRINSIC COS
PRINT *, COS(0.0)
END SUBROUTINE
END

REAL FUNCTION MYCOS(X)
MYCOS = 2.0
END

should print

1.0

or something else like it. The third item in the lists in the cited
sections of
the cited standards says that the call of the generic function COS in
the
PRINT statement should call the intrinsic specific function COS, not
the
external procedure MYCOS. I am sorry to have to admit that Sun
Fortran
gets it wrong. I would like to know if other compilers get it right.

Bob Corbett
From: Arjen Markus on
On 10 apr, 10:21, robert.corb...(a)sun.com wrote:
> According to my understanding of Section 14.1.2.4.1 of the Fortran 95
> standard and Section 12.4.4.1 of the Fortran 2003 standard, the
> program
>
> PROGRAM MAIN
> INTERFACE COS
> REAL FUNCTION MYCOS(X)
> END FUNCTION
> END INTERFACE
> CALL SUBR
> CONTAINS
> SUBROUTINE SUBR
> INTRINSIC COS
> PRINT *, COS(0.0)
> END SUBROUTINE
> END
>
> REAL FUNCTION MYCOS(X)
> MYCOS = 2.0
> END
>
> should print
>
> 1.0
>
> or something else like it. The third item in the lists in the cited
> sections of
> the cited standards says that the call of the generic function COS in
> the
> PRINT statement should call the intrinsic specific function COS, not
> the
> external procedure MYCOS. I am sorry to have to admit that Sun
> Fortran
> gets it wrong. I would like to know if other compilers get it right.
>
> Bob Corbett

I tried this with gfortran (version 4.2.0 under Cygwin), g95 (version
4.0.3, under MinGW) and CVF (version 6.6C, under Windows XP):
gfortran and g95 gave as the answer 1.0, CVF however gave the answer
2.0.

Regards,

Arjen
From: Ian Bush on

g95:

Wot now ? g95 -v
Using built-in specs.
Target:
Configured with: ../configure --enable-languages=c
Thread model: posix
gcc version 4.0.3 (g95 0.90!) Jul 27 2006
Wot now ?
g95 -Wall -Wextra -fbounds-check -std=f95 -finteger=999999 -flogical=none -freal=NAN -fpointer=none -ftrace=full -g
inter.f90
In file inter.f90:3

REAL FUNCTION MYCOS(X)
1
Warning (163): Actual argument 'x' at (1) does not have an INTENT
In file inter.f90:14

REAL FUNCTION MYCOS(X)
1
Warning (163): Actual argument 'x' at (1) does not have an INTENT
Wot now ? ./a.out
1.

Intel:

Wot now ? /opt/intel/fc/10.0.025/bin/ifort -v
Version 10.0
Wot now ? /opt/intel/fc/10.0.025/bin/ifort inter.f90
Wot now ? ./a.out
2.000000

IBM version 10 ( on Power 5 )

Wot now ? xlf90 -qversion
IBM XL Fortran Enterprise Edition V10.1 for AIX
Version: 10.01.0000.0007
Wot now ? xlf90 -qlanglvl=95pure inter.f90
** main === End of Compilation 1 ===
** mycos === End of Compilation 2 ===
1501-510 Compilation successful for file inter.f90.
Wot now ? ./a.out
1.000000000

Portland Group on Cray XT4

ijb(a)nid15879:~> ftn -V
/opt/xt-pe/2.0.40/bin/snos64/ftn: INFO: linux target is being used

pgf90 7.0-4 64-bit target on x86-64 Linux
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2007, STMicroelectronics, Inc. All Rights Reserved.
/opt/pgi/7.0.4/linux86-64/7.0-4/lib/f90main.o(.text+0x3c): In function
`main':
: undefined reference to `MAIN_'
ijb(a)nid15879:~> ftn inter.f90
/opt/xt-pe/2.0.40/bin/snos64/ftn: INFO: linux target is being used
inter.f90:
PGF90-S-0126-Name cos is not an intrinsic function (inter.f90: 9)
ijb(a)nid15879:~>
(LOL!)

Pathscale on Cray XT4

ijb(a)nid15876:~> ftn -version
/opt/xt-pe/2.0.40/bin/snos64/ftn: INFO: linux target is being used

Copyright 2000, 2001 Silicon Graphics, Inc. All Rights Reserved.
Copyright 2002, 2003, 2004, 2005, 2006 PathScale, Inc. All Rights Reserved.
See complete copyright, patent and legal notices in the
/opt/pathscale/share/doc/pathscale-compilers-3.0/LEGAL.pdf file.
ijb(a)nid15876:~> ftn inter.f90
/opt/xt-pe/2.0.40/bin/snos64/ftn: INFO: linux target is being used
ijb(a)nid15876:~> ./a.out
2.

Hope this fairly sorry story helps,

Ian



From: robert.corbett on
On Apr 10, 1:55 am, Ian Bush <I.J.B...(a)ku.ca.ld> wrote:

> Hope this fairly sorry story helps,
>
> Ian

Yes, it does. Thank you.

I thought of the program as an example that compilers are
likely to get wrong while working on a request for
interpretation for a related matter. The RFI is likely
to be controversial. The program I gave should not be.

Bob Corbett
From: Charles Coldwell on
robert.corbett(a)sun.com writes:

> According to my understanding of Section 14.1.2.4.1 of the Fortran 95
> standard and Section 12.4.4.1 of the Fortran 2003 standard, the
> program
>
> PROGRAM MAIN
> INTERFACE COS
> REAL FUNCTION MYCOS(X)
> END FUNCTION
> END INTERFACE
> CALL SUBR
> CONTAINS
> SUBROUTINE SUBR
> INTRINSIC COS
> PRINT *, COS(0.0)
> END SUBROUTINE
> END
>
> REAL FUNCTION MYCOS(X)
> MYCOS = 2.0
> END
>
> should print
>
> 1.0
>
> or something else like it. The third item in the lists in the cited
> sections of
> the cited standards says that the call of the generic function COS in
> the
> PRINT statement should call the intrinsic specific function COS, not
> the
> external procedure MYCOS. I am sorry to have to admit that Sun
> Fortran
> gets it wrong. I would like to know if other compilers get it right.

$ ifort --version
ifort (IFORT) 10.1 20070913
Copyright (C) 1985-2007 Intel Corporation. All rights reserved.

gives 2.0 (wrong?)

$ gfortran --version
GNU Fortran (GCC) 4.1.2 20070925 (Red Hat 4.1.2-27)
Copyright (C) 2007 Free Software Foundation, Inc.

gives 1.0 (right?)

$ pgf90 -V

pgf90 6.0-5 32-bit target on x86 Linux
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2005, STMicroelectronics, Inc. All Rights Reserved.

won't compile it:

$ pgf95 -o test /tmp/test.f90
PGF90-S-0126-Name cos is not an intrinsic function (/tmp/test.f90: 9)

Chip

--
Charles M. "Chip" Coldwell
"Turn on, log in, tune out"
GPG Key ID: 852E052F
GPG Key Fingerprint: 77E5 2B51 4907 F08A 7E92 DE80 AFA9 9A8F 852E 052F
 |  Next  |  Last
Pages: 1 2 3 4
Prev: Good book on FORTRAN OT
Next: branch prediction?