From owner-sc22wg5@open-std.org  Wed Dec  3 17:27:12 2008
Return-Path: <owner-sc22wg5@open-std.org>
X-Original-To: sc22wg5-dom7
Delivered-To: sc22wg5-dom7@www2.open-std.org
Received: by www2.open-std.org (Postfix, from userid 521)
	id 04A9AC56CF8; Wed,  3 Dec 2008 17:27:12 +0100 (CET)
X-Original-To: sc22wg5@open-std.org
Delivered-To: sc22wg5@open-std.org
Received: from mail1.cray.com (mail1.cray.com [136.162.0.111])
	by www2.open-std.org (Postfix) with ESMTP id 29370C4596D
	for <sc22wg5@open-std.org>; Wed,  3 Dec 2008 17:27:09 +0100 (CET)
Received: from beaver.us.cray.com (beaver.us.cray.com [172.30.74.51])
	by mail1.cray.com (8.13.6/8.13.3/gw-5323) with ESMTP id mB3GR5Mb000400
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);
	Wed, 3 Dec 2008 10:27:05 -0600 (CST)
Received: from CFEXFE01.us.cray.com (cfexfe01.us.cray.com [172.30.74.93])
	by beaver.us.cray.com (8.13.8/8.13.3/hub-5273) with ESMTP id mB3GR4Qb028375;
	Wed, 3 Dec 2008 10:27:04 -0600
Received: from mh-dhcp-172-31-16-160.us.cray.com ([172.31.16.160]) by CFEXFE01.us.cray.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959);
	 Wed, 3 Dec 2008 10:27:04 -0600
Message-ID: <4936B3D3.9060500@cray.com>
Date: Wed, 03 Dec 2008 10:29:07 -0600
From: Bill Long <longb@cray.com>
Reply-To: longb@cray.com
Organization: Cray Inc.
User-Agent: Thunderbird 2.0.0.9 (Macintosh/20071031)
MIME-Version: 1.0
To: fortran standards email list for J3 <j3@j3-fortran.org>
Cc: sc22wg5@open-std.org
Subject: Re: (j3.2006) (SC22WG5.3708)   Comment on N1761
References: <20081127195627.3CEA7C178D6@www2.open-std.org>	<200812011440.22725.donev1@llnl.gov>	<20081202134612.5BECAC178E1@www2.open-std.org>	<200812021000.58528.donev1@llnl.gov> <20081203132148.DA084C178E0@www2.open-std.org>
In-Reply-To: <20081203132148.DA084C178E0@www2.open-std.org>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-OriginalArrivalTime: 03 Dec 2008 16:27:04.0209 (UTC) FILETIME=[FA0DA010:01C95563]
X-Cray-VirusStatus: clean
Sender: owner-sc22wg5@open-std.org
Precedence: bulk



Reinhold Bader wrote:
>
> before taking this offline, I'd like to understand something about BIND(C)
> which other people might know ...
>
> Take the following example program:
>
> module mod_label_interf
>   use, intrinsic :: iso_c_binding
>   implicit none
>   interface foo
>     subroutine foo_1(x, n, i) bind(c, name='Foo')
>       import :: c_float, c_int
>       real(c_float) :: x
>       integer(c_int), value :: n, i
>     end subroutine
>     subroutine foo_2(x, n, i) bind(c, name='Foo')
>       import :: c_float, c_int
>       real(c_float) :: x(*)
>       integer(c_int), value :: n, i
>     end subroutine
>   end interface
> end module
> program label_interf
>   use mod_label_interf
>   implicit none
>   integer(c_int) :: i
>   real(c_float) :: xx, xxx(3)
>   i = 2
>   call foo(xx, 1, i)
>   call foo(xxx, 3, i)
>   write(*, *) xx
>   write(*, *) xxx
> end program
>
> together with the C implementation
>
> #include <math.h>
>
> void Foo(float *x, int n, int i) {
>   int j;
>   for (j=0; j<n; j++) {
>     *(x+j)  = (float) (i + j) + 0.1;
>   }
> }
>
> This code is accepted by various processors and executes in accordance with my
> personal expectations (for what that is worth :-)).
> It is not accepted by NAG's compiler, and also not by IBM xlf. NAG's error message is
>
> Error: label_interf.f90: Duplicate binding label 'Foo' for external procedure FOO_2 and external procedure FOO_1
>   


This error message is consistent with the Fortran 2003 rules.  An 
(non-abstract) interface declares the procedure name to be external.  
However, in the case of a separate binding label, that rule is being 
changed in Fortran 2008 to be the way you want it. If there is a 
separate binding label then the procedure's name becomes a local name, 
not external.

Cheers,
Bill

-- 
Bill Long                                   longb@cray.com
Fortran Technical Support    &              voice: 651-605-9024
Bioinformatics Software Development         fax:   651-605-9142
Cray Inc., 1340 Mendota Heights Rd., Mendota Heights, MN, 55120

            

