Quantcast
Channel: Intel® Software - Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2746

Wrong error when the actual argument of a procedure is a coarray component

$
0
0

The following code generates a compile-time error but I think the code is correct.

Here is the code:

Program Main

  implicit none

  Type :: MyType
    real(8) ,allocatable ,codimension[:] :: CoVar
  End Type

  type(MyType)  ::      Object

! The following line cause a compile-time error with ifort version 15.0.4
  Object%CoVar       =       CoMinVal( Object%CoVar )   ! main.f90(12): error #8396: If the dummy argument is a coarray, the corresponding actual argument must be a coarray and must have the VOLATILE attribute if and only if the dummy argument has the VOLATILE attribute.   [COVAR]

  associate( CoVar => Object%CoVar )
   CoVar        =       CoMinVal( CoVar )
  end associate

  contains

  Pure Function CoMinVal( CoVar ) result(VarMin)
    real(8) ,codimension[*]   ,intent(in)     ::      CoVar
    real(8)                                   ::      VarMin
    integer                                     ::      iImg
    VarMin        =       CoVar
    do iImg = This_image()+1,Num_images()
      VarMin      =       min( VarMin, CoVar[iImg] )
    end do
    do iImg = 1,This_image()-1
      VarMin      =       min( VarMin, CoVar[iImg] )
    end do
  End Function

End Program

and the compilation output is:

$ ifort -v && ifort -coarray main.f90
ifort version 15.0.4
main.f90(12): error #8396: If the dummy argument is a coarray, the corresponding actual argument must be a coarray and must have the VOLATILE attribute if and only if the dummy argument has the VOLATILE attribute.   [COVAR]
  Object%CoVar       =       CoMinVal( Object%CoVar )   ! main.f90(12): error #8396: If the dummy argument is a coarray, the corresponding actual argument must be a coarray and must have the VOLATILE attribute if and only if the dummy argument has the VOLATILE attribute.   [COVAR]
----------------------------------------------^
compilation aborted for main.f90 (code 1)

Note that a workaround consists of using an associate block


Viewing all articles
Browse latest Browse all 2746

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>