Complex error

Matt Thompson thompsma@jilau1.colorado.edu
Wed Oct 26 23:12:00 GMT 2005


Tobias Schlüter wrote:
> Matt Thompson wrote:
>>In the first .f90 file the make finds, it exits out with:
>>
>>gfortran -c -O2 electronic_utils.f90
>> In file electronic_utils.f90:768
>>
>>    CWORK = CU .mult. (.dagger. CU)
>>                    1
>>Error: Operands of user operator 'mult' at (1) are COMPLEX(8)/COMPLEX(8)
>>
>>There are a few other COMPLEX(8)/COMPLEX(8) errors as well. 
>>
>>Any idea what is happening?
> 
> 
> Both operands are of type COMPLEX(8) and the interface of .mult. has no
> corresponding function?  Sorry, this is not enough information to tell if this
> is a bug in gfortran or in your program.

Sorry, thought it might be obvious (set this flag...).  To wit I'll post
from various modules looking for every bit that might help.  If you need
more, let me know; there are about 25 .f90 files and as many modules
that interlock in about 15000 lines of code...I'd rather not post all
that.  And, as I said, this has compiled before using ifc and ifort and
the DEC/Compaq/HP Fortran 90/95 compilers without complaint.  And if the
code is odd, it was written to be used on a DEC Alpha, but it has
compiled and worked on Xeons.

integer, parameter :: P=selected_real_kind(15,99)

COMPLEX(P), INTENT(IN) :: CU(NDIM,NDIM)
NDIM is an integer 6 or 12 say.

integer, parameter :: small_matrix_matrix = 1000

   public &
        operator(.mult.),&
        operator(.inner.),&
        operator(.cross.),&
        operator(.dagger.)

   ! matrix-matrix and matrix-vector multiplication
   interface operator (.mult.)
      ! matrix-matrix mult
      module procedure times_rm_rm
      module procedure times_cm_cm
      module procedure times_rm_cm
      module procedure times_cm_rm
      module procedure times_im_im
      ! matrix-vector mult and vector-matrix mult
      module procedure times_rm_rv
      module procedure times_rv_rm
      module procedure times_cm_cv
      module procedure times_cv_cm
      module procedure times_cm_rv
      module procedure times_rv_cm
      module procedure times_rm_cv
      module procedure times_cv_rm
      module procedure times_im_iv
      module procedure times_iv_im
   end interface

   ! Hermitian conjugation ie conj(transpose(x))
   interface operator (.dagger.)
      module procedure dagger_c
      module procedure dagger_r
   end interface

   function times_cm_cm ( m1, m2)
     use precision
     implicit none
     complex(p), intent(in) :: m1(:,:), m2(:,:)
     complex(p) :: times_cm_cm( size(m1,1), size(m2,2))
     integer :: i, j, m1_rows, m1_cols, m2_rows, m2_cols

     m1_rows= size(m1,1)
     m1_cols= size(m1,2)
     m2_rows= size(m2,1)
     m2_cols= size(m2,2)

     if (m1_cols /= m2_rows) then
        write(*,*) 'times_cm_cm: input matrices have incompatible
dimensions'
        write(*,*) 'm1 is ', m1_rows, 'x', m1_cols
        write(*,*) 'm2 is ', m2_rows, 'x', m2_cols
        stop
     end if

     if (m1_rows * m2_cols < small_matrix_matrix) then
        ! do explicit multiplication
        do i= 1, m1_rows
           do j= 1, m2_cols
              times_cm_cm(i,j)=dot_product( conjg(m1(i,:)), m2(:,j))
           enddo
        enddo
     else
        ! use f90 intrinsic
        times_cm_cm= matmul(m1,m2)
     end if
   end function times_cm_cm
and there are similar functions corresponding to the interface entry.  I
can't find any instance of a matmul function collision, so this matmul
does refer to the intrinsic.

   function dagger_c( m)
     use precision
     implicit none
     complex(p), intent(in) :: m(:,:)
     complex(p) :: dagger_c(size(m,2),size(m,1))

     dagger_c= conjg(transpose(m))
   end function dagger_c

Again, I apologize to Misters Maine and Schlüter and the list for not
including more code at the beginning.  I was hoping for an "Oh yeah, use
this flag!".

Matt
-- 
Learning just means you were wrong and they were right. - Aram
    Matt Thompson -- http://ucsub.colorado.edu/~thompsma/
    440 UCB, Boulder, CO  80309-0440
    JILA A510, 303-492-4662



More information about the Fortran mailing list