title: Undefined reference to main fortran program
body: <p>I am writing a fortran code for benchmarking three loop kernels:</p>
  
  <pre><code>       program Kernel_benchmark
  
         implicit none
  
         double precision,dimension (:),save,allocatable:: a,b,c,d,x,y
         double precision s
         double precision,dimension (:,:),save,allocatable:: mat
         double precision wcs,wce,ct,runtime, total
         integer k,iter,r,i,j,N
  
  
         do k = 3, 20
            N = INT(2.5**k)
            allocate (a(N),b(N),c(N),d(N))
            do i=1,N
               a(i) = 1.2
               b(i) = 1.2
               c(i) = 1.2
               d(i) = 1.2
            end do
            iter = 1
            runtime = 0.0
            do while(runtime &lt; 0.2)
              call timing(wcs,ct)
              do r =0, iter
                      do i=1,N
                              a(i) = b(i) + c(i) * d(i)
                      end do
                      if(a(ISHFT(N,-1)) &lt; 0.0) then
                               call dummy(a)
                      end if
              end do
              call timing(wce,ct)
              runtime = wce - wcs
              iter = iter * 2
          end do
          iter = iter / 2
          open(unit=1, file = 'vector_triad.dat',status = 'unknown')
          write(1,*) N, (N * iter* 2) / (runtime * 1e-6)
          close(1)
          deallocate(a,b,c,d)
       end do
  
       do k = 3, 20
         N = INT(2.5**k)
         allocate(a(N))
         do i = 1, N
              a(i) = 1.2
         end do
         s = 2.2
         iter = 1
         runtime = 0.0
      do while(runtime &lt; 0.2)
              call timing(wcs,ct)
              do r = 0, iter
                      do i = 1, N
                              a(i) = s * a(i)
                      end do
                      if(a(ISHFT(N,-1)) &lt; 0.0) then
                               call dummy(a)
                      end if
              end do
              call timing(wce,ct)
              runtime = wce - wcs
              iter = iter * 2
      end do
      iter = iter / 2
      open (unit = 2, file = 'vector_update.txt', status = 'unknown' )
      write(2,*) N, (N * iter) / (runtime * 1e-6)
      close(2)
      deallocate(a)
    end do
  
    do k = 10, 22
        N = INT(1.5**k)
        allocate (mat(N,N),x(N),y(N))
        do i = 1, N
              do j = 1, N
                      mat(i,j) = 1.2
              end do
              y(i) = 1.2
              x(i) = 1.2
        end do
        iter = 1
        runtime = 0.0
        do while(runtime &lt; 0.2)
              call timing(wcs,ct)
              do r = 0, iter
                      do i = 1, N
                              y(i) = 0.0      
                              do j = 1, N
                                      y(i)     = y(i) + (mat(i,j) * x(i))
                              end do
                      end do
                      if(y(ISHFT(N,-1))&lt; 0.0) then
                              call  dummy(y)
                      end if
              end do
              call timing(wce,ct)
              runtime = wce - wcs
              iter = iter * 2
        end do
        iter = iter / 2
        open (unit = 3, file = 'matrix_vector.txt', status ='unknown')
        write(3,*) N, (2 * N * N * iter) / (runtime * 1e-6)
        close(3)
        deallocate(mat,x,y)
      end do
  
  end program Kernel_benchmark
  </code></pre>
  
  <p>The dummy function I have written inside a C source file as follows</p>
  
  <pre><code>#include "dummy.h"
  
  void  dummy(double *array){
      printf ("Well if its printing this then you're pretty much screwed.");
  }
  </code></pre>
  
  <p>and dummy.h simply contains the function prototype.</p>
  
  <p>I made an dummy.o object file and I'm trying to link it with my fortran source code using an intel ifort compiler. Unfortunately, I'm getting an error 
            In function <code>MAIN__':bench.f90:(.text+0x8ca): undefined reference to</code>dummy_' </p>
  
  <p>every time the dummy function is called. Any suggestion? Thanks in advance.</p>