Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

This is now. Later is later.


devel / comp.lang.fortran / Error: VALUE attribute conflicts with DIMENSION attribute

SubjectAuthor
* Error: VALUE attribute conflicts with DIMENSION attributeDarrell Reich
+* Re: Error: VALUE attribute conflicts with DIMENSION attributegah4
|`- Re: Error: VALUE attribute conflicts with DIMENSION attributeeugene_...@yahoo.com
`* Re: Error: VALUE attribute conflicts with DIMENSION attributeThomas Koenig
 `* Re: Error: VALUE attribute conflicts with DIMENSION attributeSteve Lionel
  `* Re: Error: VALUE attribute conflicts with DIMENSION attributegah4
   `- Re: Error: VALUE attribute conflicts with DIMENSION attributeSteve Lionel

1
Error: VALUE attribute conflicts with DIMENSION attribute

<acfb28b8-e54f-4520-ba5f-4a4e9ce27f5cn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3409&group=comp.lang.fortran#3409

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:620a:178a:b0:757:9fb7:5317 with SMTP id ay10-20020a05620a178a00b007579fb75317mr2812217qkb.14.1684716377937;
Sun, 21 May 2023 17:46:17 -0700 (PDT)
X-Received: by 2002:ac8:5ac4:0:b0:3f4:b1bd:c30e with SMTP id
d4-20020ac85ac4000000b003f4b1bdc30emr3257121qtd.8.1684716377662; Sun, 21 May
2023 17:46:17 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Sun, 21 May 2023 17:46:17 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=2603:8001:5901:455f:0:0:0:7;
posting-account=wVQ8ZAoAAADxkSWK2RADAd96fr91TkIL
NNTP-Posting-Host: 2603:8001:5901:455f:0:0:0:7
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <acfb28b8-e54f-4520-ba5f-4a4e9ce27f5cn@googlegroups.com>
Subject: Error: VALUE attribute conflicts with DIMENSION attribute
From: dreich@yahoo.com (Darrell Reich)
Injection-Date: Mon, 22 May 2023 00:46:17 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 27
 by: Darrell Reich - Mon, 22 May 2023 00:46 UTC

Can anyone share an alternative syntax for the pass by value assumed shape array dimension below? Porting from Intel to Cygwin gfortran version 11.3.0
What is the current status of the gfortran standard compliance?
Are the results of the test suite posted?

Downloaded gfortran test suite. Found error message--see gfortran.dg-master\assumed_rank_11.f90
Does this test tell DejaGnu that the test passes if the compiler error occurs?

Here is my Minimal Reproducible Example (MRE). I found an alternative syntax for the import only command. I need to find a workaround to the assumed shape pass by value dimension in our ISO_C_BINDING code.

! Compare gfortran, flang, ifort classic, & Intel LLVM compilers
! Fortran 2008 extended Fortran 2003 ISO_C_BINDING standard
module foo
use, intrinsic :: ISO_C_BINDING, only : C_FLOAT
interface cbrt ! call C cube root
function cbrt(x) bind(C, name="cbrtf")
!import, only : C_FLOAT ! intel
import C_FLOAT ! gfortran
implicit none
real(KIND=C_FLOAT) :: cbrt
real(KIND=C_FLOAT), value :: x
end function cbrt
end interface
contains
subroutine val1(x)
integer, dimension(:), value :: x ! Error: VALUE attribute conflicts with DIMENSION attribute
end subroutine val1
end module foo

Re: Error: VALUE attribute conflicts with DIMENSION attribute

<d4cc12a7-0aea-4c57-8bb5-600e75c72b52n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3410&group=comp.lang.fortran#3410

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:622a:104a:b0:3f5:2006:50ee with SMTP id f10-20020a05622a104a00b003f5200650eemr2789016qte.2.1684717905605;
Sun, 21 May 2023 18:11:45 -0700 (PDT)
X-Received: by 2002:a05:620a:400b:b0:74a:dd04:6146 with SMTP id
h11-20020a05620a400b00b0074add046146mr2979201qko.3.1684717905433; Sun, 21 May
2023 18:11:45 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Sun, 21 May 2023 18:11:45 -0700 (PDT)
In-Reply-To: <acfb28b8-e54f-4520-ba5f-4a4e9ce27f5cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:a0a2:8e07:cc7:3ef8;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:a0a2:8e07:cc7:3ef8
References: <acfb28b8-e54f-4520-ba5f-4a4e9ce27f5cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d4cc12a7-0aea-4c57-8bb5-600e75c72b52n@googlegroups.com>
Subject: Re: Error: VALUE attribute conflicts with DIMENSION attribute
From: gah4@u.washington.edu (gah4)
Injection-Date: Mon, 22 May 2023 01:11:45 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1781
 by: gah4 - Mon, 22 May 2023 01:11 UTC

On Sunday, May 21, 2023 at 5:46:19 PM UTC-7, Darrell Reich wrote:
> Can anyone share an alternative syntax for the pass by value assumed shape array dimension below?
> Porting from Intel to Cygwin gfortran version 11.3.0
I presume you checked the standard to see if it is supposed to work.

In C, you can't pass arrays by value, but pointers to arrays are passed.
You can pass a struct with an array in it, but then the array has to be fixed dimension.
And you can pass a struct with a pointer to an array.

Re: Error: VALUE attribute conflicts with DIMENSION attribute

<e67d5408-696a-4b5e-aed9-081b6e6e1ea1n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3411&group=comp.lang.fortran#3411

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:622a:1307:b0:3f5:ef49:7215 with SMTP id v7-20020a05622a130700b003f5ef497215mr3568620qtk.2.1684757148438;
Mon, 22 May 2023 05:05:48 -0700 (PDT)
X-Received: by 2002:a05:620a:4694:b0:74d:33a7:1049 with SMTP id
bq20-20020a05620a469400b0074d33a71049mr3267441qkb.14.1684757148252; Mon, 22
May 2023 05:05:48 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Mon, 22 May 2023 05:05:47 -0700 (PDT)
In-Reply-To: <d4cc12a7-0aea-4c57-8bb5-600e75c72b52n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=192.55.54.49; posting-account=mg7VqQoAAAAi2CO4mRsFK-kGNNgIJxiC
NNTP-Posting-Host: 192.55.54.49
References: <acfb28b8-e54f-4520-ba5f-4a4e9ce27f5cn@googlegroups.com> <d4cc12a7-0aea-4c57-8bb5-600e75c72b52n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e67d5408-696a-4b5e-aed9-081b6e6e1ea1n@googlegroups.com>
Subject: Re: Error: VALUE attribute conflicts with DIMENSION attribute
From: eugene_epshteyn@yahoo.com (eugene_...@yahoo.com)
Injection-Date: Mon, 22 May 2023 12:05:48 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3230
 by: eugene_...@yahoo.com - Mon, 22 May 2023 12:05 UTC

ChatGPT prompt: Write a Fortran BIND_C function that accepts C array of float

ChagGTP answer:

You can define a Fortran subroutine that uses the `bind(C)` attribute to make it callable from C. This subroutine could accept a C-style array of floats. Here's an example of such a function:

```fortran
subroutine process_c_float_array(arr, size) bind(C)
use iso_c_binding, only: c_float, c_int
implicit none
integer(c_int), value :: size
real(c_float), dimension(*), intent(inout) :: arr
! here you can manipulate the array `arr`
! for demonstration purposes, let's just multiply every element by 2
arr = arr * 2.0_c_float
end subroutine process_c_float_array
```

This Fortran subroutine `process_c_float_array` accepts a one-dimensional array of `c_float` values (which correspond to `float` values in C) and its size, and modifies the array.

Note that the `value` attribute is used for `size` to ensure that it is passed by value, following the C convention, instead of by reference, which is the Fortran default. The `intent(inout)` attribute is used for `arr` to indicate that the subroutine can both read from and modify this array.

You could call this Fortran subroutine from a C program like this:

```c
extern void process_c_float_array(float* arr, int size);
```

Remember that `c_float` and `c_int` are Fortran types that are guaranteed to have the same size and representation as the C types `float` and `int`, respectively. This is important to ensure compatibility between Fortran and C.

Make sure your Fortran compiler supports the Fortran 2003 standard or later, which introduced the C interoperability features used here. Also, depending on the specifics of your Fortran and C compilers, you might need to apply compiler-specific options or use certain conventions for the names of the Fortran procedures when calling them from C.

Re: Error: VALUE attribute conflicts with DIMENSION attribute

<u4j75k$1tvmt$1@newsreader4.netcologne.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3412&group=comp.lang.fortran#3412

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd4-d83e-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoenig@netcologne.de (Thomas Koenig)
Newsgroups: comp.lang.fortran
Subject: Re: Error: VALUE attribute conflicts with DIMENSION attribute
Date: Tue, 23 May 2023 20:20:33 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <u4j75k$1tvmt$1@newsreader4.netcologne.de>
References: <acfb28b8-e54f-4520-ba5f-4a4e9ce27f5cn@googlegroups.com>
Injection-Date: Tue, 23 May 2023 20:20:33 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd4-d83e-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd4:d83e:0:7285:c2ff:fe6c:992d";
logging-data="2031325"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Tue, 23 May 2023 20:20 UTC

Darrell Reich <dreich@yahoo.com> schrieb:
> Can anyone share an alternative syntax for the pass by value assumed shape array dimension below? Porting from Intel to Cygwin gfortran version 11.3.0
> What is the current status of the gfortran standard compliance?
> Are the results of the test suite posted?
>
> Downloaded gfortran test suite. Found error message--see gfortran.dg-master\assumed_rank_11.f90
> Does this test tell DejaGnu that the test passes if the compiler error occurs?

The test case is about assumed rank, which is a strange beast.

Regarding arrays passed by value: Fortran 2003 has a constraint:

C527 (R501) If the VALUE attribute is specified, the PARAMETER,
EXTERNAL, POINTER, ALLOCATABLE, DIMENSION, VOLATILE, INTENT(INOUT),
or INTENT(OUT) attribute shall not be specified.

In contrast, F2008 has

(C558) An entity with the VALUE attribute shall not have the
ALLOCATABLE, INTENT (INOUT), INTENT (OUT), POINTER, or VOLATILE
attributes.

so this rule was relaxed for Fortran 2008.

gfortran simply has not yet implemented this particular feature.

> Here is my Minimal Reproducible Example (MRE). I found an alternative syntax for the import only command. I need to find a workaround to the assumed shape pass by value dimension in our ISO_C_BINDING code.

>
> ! Compare gfortran, flang, ifort classic, & Intel LLVM compilers
> ! Fortran 2008 extended Fortran 2003 ISO_C_BINDING standard
> module foo
> use, intrinsic :: ISO_C_BINDING, only : C_FLOAT
>
> interface cbrt ! call C cube root
> function cbrt(x) bind(C, name="cbrtf")
> !import, only : C_FLOAT ! intel
> import C_FLOAT ! gfortran
> implicit none
> real(KIND=C_FLOAT) :: cbrt
> real(KIND=C_FLOAT), value :: x
> end function cbrt
> end interface
> contains
> subroutine val1(x)
> integer, dimension(:), value :: x ! Error: VALUE attribute conflicts with DIMENSION attribute
> end subroutine val1
> end module foo

VALUE for arrays can be a bit tricky, the compiler would
have to copy the arry on procedure entry.

If your subroutine was called with an array bar, like

call bal1(bar)

the complier would, in effect, do

block
integer, dimension(size(bar)) :: bar_tmp
bar_tmp = bar
call val1(bar_tmp)
end block

val could then change the contents of its arguments without
affecting bar in the calling subprogram (which is what VALUE
is about).

Is that actually what you want?

Re: Error: VALUE attribute conflicts with DIMENSION attribute

<kd6s81Ft7gbU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3413&group=comp.lang.fortran#3413

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news-2.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: steve@seesignature.invalid (Steve Lionel)
Newsgroups: comp.lang.fortran
Subject: Re: Error: VALUE attribute conflicts with DIMENSION attribute
Date: Wed, 24 May 2023 12:27:44 -0400
Lines: 47
Message-ID: <kd6s81Ft7gbU1@mid.individual.net>
References: <acfb28b8-e54f-4520-ba5f-4a4e9ce27f5cn@googlegroups.com>
<u4j75k$1tvmt$1@newsreader4.netcologne.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net Hn3q/kcY/hB27ryHhNXo1gJwXaqrzeV7hO7uSREyxKJb9H9g/n
Cancel-Lock: sha1:XR+PkGSWto3gj1R2yIezpQGMaDc=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Content-Language: en-US
In-Reply-To: <u4j75k$1tvmt$1@newsreader4.netcologne.de>
 by: Steve Lionel - Wed, 24 May 2023 16:27 UTC

On 5/23/2023 4:20 PM, Thomas Koenig wrote:

> Regarding arrays passed by value: Fortran 2003 has a constraint:
>
> C527 (R501) If the VALUE attribute is specified, the PARAMETER,
> EXTERNAL, POINTER, ALLOCATABLE, DIMENSION, VOLATILE, INTENT(INOUT),
> or INTENT(OUT) attribute shall not be specified.
>
> In contrast, F2008 has
>
> (C558) An entity with the VALUE attribute shall not have the
> ALLOCATABLE, INTENT (INOUT), INTENT (OUT), POINTER, or VOLATILE
> attributes.
>
> so this rule was relaxed for Fortran 2008.
>

It is worth noting that VALUE has a very different meaning depending on
whether the procedure being called has BIND(C) or not. Without BIND(C),
a writable temporary copy is passed using the mechanism the particular
compiler would use without VALUE.

If the procedure does have BIND(C), then VALUE means "pass by value" as
in C. In this case, arrays are not permitted. As is often the case, the
words in the standard for this are not immediately obvious. In F2018,
18.3.6 says:

> (4) any scalar dummy argument with the VALUE attribute is interoperable with the corresponding formal parameter of the prototype,
> (5) any dummy argument without the VALUE attribute corresponds to a formal parameter of the prototype that is of a pointer type, and...

Note that (4) is restricted to "scalar dummy argument". Since the
standard does not describe the meaning of an array dummy argument with
VALUE, such a combination is not allowed by the standard.

The example in this case is not using VALUE for an argument in a
procedure with BIND(C), so that is allowed as of F2008 as noted.

--
Steve Lionel
ISO/IEC JTC1/SC22/WG5 (Fortran) Convenor
Retired Intel Fortran developer/support
Email: firstname at firstnamelastname dot com
Twitter: @DoctorFortran
LinkedIn: https://www.linkedin.com/in/stevelionel
Blog: https://stevelionel.com/drfortran
WG5: https://wg5-fortran.org

Re: Error: VALUE attribute conflicts with DIMENSION attribute

<887307c1-b226-46cb-88df-d7a8d64d13b8n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3414&group=comp.lang.fortran#3414

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:ac8:7dcc:0:b0:3f6:bb7b:b93e with SMTP id c12-20020ac87dcc000000b003f6bb7bb93emr1968588qte.4.1684947773696;
Wed, 24 May 2023 10:02:53 -0700 (PDT)
X-Received: by 2002:a05:620a:1994:b0:74e:1090:8906 with SMTP id
bm20-20020a05620a199400b0074e10908906mr5915713qkb.0.1684947773569; Wed, 24
May 2023 10:02:53 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 24 May 2023 10:02:53 -0700 (PDT)
In-Reply-To: <kd6s81Ft7gbU1@mid.individual.net>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:acfc:293:8ba3:36d2;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:acfc:293:8ba3:36d2
References: <acfb28b8-e54f-4520-ba5f-4a4e9ce27f5cn@googlegroups.com>
<u4j75k$1tvmt$1@newsreader4.netcologne.de> <kd6s81Ft7gbU1@mid.individual.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <887307c1-b226-46cb-88df-d7a8d64d13b8n@googlegroups.com>
Subject: Re: Error: VALUE attribute conflicts with DIMENSION attribute
From: gah4@u.washington.edu (gah4)
Injection-Date: Wed, 24 May 2023 17:02:53 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 21
 by: gah4 - Wed, 24 May 2023 17:02 UTC

On Wednesday, May 24, 2023 at 9:27:49 AM UTC-7, Steve Lionel wrote:

(snip)

> It is worth noting that VALUE has a very different meaning depending on
> whether the procedure being called has BIND(C) or not. Without BIND(C),
> a writable temporary copy is passed using the mechanism the particular
> compiler would use without VALUE.
> If the procedure does have BIND(C), then VALUE means "pass by value" as
> in C. In this case, arrays are not permitted. As is often the case, the
> words in the standard for this are not immediately obvious.

C does allow passing arrays inside a struct by value.

I presume Fortran knows how to do that?

Re: Error: VALUE attribute conflicts with DIMENSION attribute

<kd706hFt7gbU2@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3415&group=comp.lang.fortran#3415

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news-2.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: steve@seesignature.invalid (Steve Lionel)
Newsgroups: comp.lang.fortran
Subject: Re: Error: VALUE attribute conflicts with DIMENSION attribute
Date: Wed, 24 May 2023 13:35:12 -0400
Lines: 16
Message-ID: <kd706hFt7gbU2@mid.individual.net>
References: <acfb28b8-e54f-4520-ba5f-4a4e9ce27f5cn@googlegroups.com>
<u4j75k$1tvmt$1@newsreader4.netcologne.de> <kd6s81Ft7gbU1@mid.individual.net>
<887307c1-b226-46cb-88df-d7a8d64d13b8n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net 7VeJ86uJRTCTgZhe+6YDBQupLLH7xibd+lQ1h1t/GI1xO3WBSq
Cancel-Lock: sha1:Ch5pJF8drdz+0MaQ6SAqN8j6nYw=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Content-Language: en-US
In-Reply-To: <887307c1-b226-46cb-88df-d7a8d64d13b8n@googlegroups.com>
 by: Steve Lionel - Wed, 24 May 2023 17:35 UTC

On 5/24/2023 1:02 PM, gah4 wrote:
> C does allow passing arrays inside a struct by value.
>
> I presume Fortran knows how to do that?

That is allowed.
--
Steve Lionel
ISO/IEC JTC1/SC22/WG5 (Fortran) Convenor
Retired Intel Fortran developer/support
Email: firstname at firstnamelastname dot com
Twitter: @DoctorFortran
LinkedIn: https://www.linkedin.com/in/stevelionel
Blog: https://stevelionel.com/drfortran
WG5: https://wg5-fortran.org

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor