Darrell Reich <
dre...@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?