Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Compiler errors with parameterized types using defined assignment and - operator

$
0
0
module TestParamTypeMod
   integer, parameter :: DP =  SELECTED_REAL_KIND(13)

   type DoubleDif(n)
      integer, len :: n
      real(DP) :: v
      real(DP) :: d(n)
   end type

   interface assignment(=)
      module procedure ass_D_Dpdif, ass_Dpdif_Dpdif
   end interface

   interface operator(-)
      module procedure sub_Dpdif_Dpdif
   end interface

contains

pure elemental subroutine ass_D_Dpdif(b, a)
   real(DP), intent(in) :: a
   type(DoubleDif(*)), intent(inout) :: b
   b%v = a
   b%d = 0.0_DP
end subroutine

pure subroutine ass_Dpdif_Dpdif(b, a)
   type(DoubleDif(*)), intent(inout) :: b
   type(DoubleDif(*)), intent(in) :: a
   b%v = a%v
   b%d = a%d
end subroutine

pure function sub_Dpdif_Dpdif(a, b) result(c)
   type(DoubleDif(*)), intent(in) :: a
   type(DoubleDif(*)), intent(in) :: b
   type(DoubleDif(a%n)) c
   c%v = a%v - b%v
   c%d = a%d - b%d
end function

end module

program Test
   use TestParamTypeMod
   type(DoubleDif(1)) a, b, c

   a = 2.0_DP
   b = 1.0_DP
   b%d = 3.0_DP
   call ass_Dpdif_Dpdif(c, b - a)
   c = b - a
   print *, c%v, c%d
end program

This gives errors:

Compiling with Intel(R) Visual Fortran Compiler XE 15.0.3.208 [Intel(R) 64]...
TestParamType.f90
D:\dev\TestParamType.f90(51): error #6633: The type of the actual argument differs from the type of the dummy argument.
D:\dev\TestParamType.f90(52): error #6197: An assignment of different structure types is invalid.
ifort: error #10298: problem during post processing of parallel object compilation
compilation aborted for D:\dev\TestParamType.f90 (code 1)

Is my code f2008 compliant and / or is it compiler errors ?


Viewing all articles
Browse latest Browse all 3270


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