Fortran OOP Operator (+) -
I am coding the operator (+) used in a vector module, and I am getting the following error inside I Calling the operator it raises another function in error.
gfortran -o build / lib / vectors.o -c -ffree-form -g -J./build/lib lib / vectors.f lib /vectors.f: 804.7: vd = Ud + scald 1 error: Operation of binary numerical operator '+' (1) class (vector) / real (4) scone: *** [build / lib / vector. ] 1 scone error: ended due to building errors
Here is the code. I am unsure if the problem is that how binding is due to declaration.
Module vectors are not any type: Vector Real: X Real: y Real: z process is included: Vecp = & gt; Vector_add process :: vecpscal = & gt; Vector_plus_integer, & amp; Vector_plus_real process, pass (ub) :: integer_plus_vector process, pass (ud) :: real_plus_vector generic :: operator (+) = & gt; Vecp, Vecascal, & amp; Integer_plus_vector, & amp; Real_plus_vector end type vector function includes vector_add & amp; (& Amp; u, v & amp; nbsp; & amp; Result (W) !! $ In orbit (vector), intent (in) :: u, v !! $ Out Type (vector) :: w w% x = u% x + v% xw% y = y% z + v% z termination function vector_add function vector_plus_real & amp; (& Amp; u, Scale & amp;) & amp; Results (V) !! $ IN orbit (vector), intent (in) :: u real, intent (in) :: scale !! $ Out Type (vector) :: VV% x = U% x + Scale V% y = Y% Y + Scale v% z = u% z + Scale end function vector_plus_real function vector_plus_integer & amp; (& Amp; ub, Scalab & amp;) & amp; Results (VB) !! $ In class (vector), intent (in) :: UI integer, intent (in) :: Scalab !! $ Out Type (vector) :: VB vb% x = ub% x + scalb vb% y = ub% y + scalb vb% z = ub% z + scalb closing function vector_plus_integer function real_plus_vector & amp; (And Scale, UK) & amp; Result (VC) !! $ In real, intent (in) :: scale class (vector), intent (in) :: UK !! $ Out Type (Vector) :: VC VC = UK + Scalec End Function real_plus_vector function integer_plus_vector & amp; (And scale, ud & amp;) & amp; Result (VD) !! $ IN integer, intent (in) :: scale orbit (vector), intent (in) :: fly! $ Out Type (Vector) :: VDVD = UD + Scaled and Function integer_plus_vector and module vector
There is a syntax error in the declaration of the vecpscal
binding in your type of announcement - you list two processes in the form of binding enforcement. I expect the compiler to diagnose it.
The error you list is due to the lack of a particular binding which corresponds to the vector plus the actual case (which is the second process in the wrong type of bound process details).
Comments
Post a Comment