LNK2001 and LNK1120 errors.. newbie here please help 
Author Message
 LNK2001 and LNK1120 errors.. newbie here please help

hello. I am taking a numeric numbers class which involves some fortran
programming class and we had to "fix" this code. I moved some stuff
around, and it seems that it compiles well but when it has to link I
get the following error message:

Linking...
FVM Program Main.obj : error LNK2001: unresolved external symbol

Debug/FVM Program Main.exe : fatal error LNK1120: 1 unresolved
externals
Error executing link.exe.

FVM Program Main.exe - 2 error(s), 0 warning(s)

I will post my code next.. first the main program and then the module
I'm using.. Any help understanding these errors would be greatly
appreciated. Like I said, I am not a Fortran expert. I am using Compaq
Visual Fortran.

include "test_tridiagonal_class.f"
        include "Module_program.f"
        program FVM_1D_DIFF_MODEL
      !use input
        use tridiagonal_matrix_class
        use solver
        !use output

      !implicit none

        !character(20)::dir_in,dir_out,filename_in,filename_out
        !real(double):: cont_A(:)

        character (len=20) :: filename_in, filename_out,dir_in,dir_out
        type(node_1D),allocatable:: node(:)    ! domain node
      type(bd_conds) :: bd_value(2)
        type(tri_diag_matrix)::cont_a
        integer       ::nx,i
        !real(double)   ::dx
        real(double),allocatable:: soln(:)
        real(double),allocatable:: a(:,:),bb(:)

        !type(node_1D),allocatable::node(:)
        !type(bd_conds)::bd_value(2)

      ! define your input file directory and name
      write(*,*) 'input file directory and name'
        read(*,*) filename_in
        !dir_in=trim(dir_in)
        !filename_in=trim(filename_in)
      !filename_in=dir_in//'/'//filename_in

        ! define your output file name and directory
        write(*,*) 'output file directory and name'
        read(*,*) filename_out
        !dir_out=trim(dir_out)
        !filename_out=trim(filename_out)
        !filename_out=dir_out//'/'//filename_out

        ! process the input data
        call read_input(filename_in,node,bd_value)

        ! assemble linear equations
        call linear_eq(node,bd_value,a,bb,nx)

        ! solve the linear equations
        ! make a new type tri-diag_matrix
        cont_A%size=nx                                 ! cont_A is tri-
diagnal_matrix type

        do i=2,nx;cont_A%lower=a(i,i-1); enddo
        do i=1,nx-1;cont_A%upper=a(i,i+1); enddo
        do i=1,nx;cont_A%main=a(i,i); enddo

      soln= tri_diag_solve(cont_A,bb)

        ! write the output file
        call out(nx,soln,filename_out)

      end program FVM_1D_DIFF_MODEL

-----

Module Solver

        ! input data: constants, geometry, boundary conditions,
computtational information

      !implicit none

      integer, parameter :: double = selected_real_kind(10)

      ! geometrical information, connectivity
      type node_1D
        integer :: index
          integer :: w,e
          character :: ID
        real (double) :: x
          real(double)::source,area,cond
      end type

      ! boundary conditions

      type bd_conds
        character(10):: loc          !upstream, downstream,
          character(10):: name         ! Dirichlet,Neunman
        real (double):: value
      end type

      Contains

      subroutine read_input(input_filename, node, bd_value)
        implicit none
          character, intent(in) :: input_filename    !unknown length
character
        character :: project_title,BND_loc,BND_type
        integer       :: i,nx,error
          real(double)  ::q,k,area
          real(double)::domain_length,length_fvm,bnd_data
          type(node_1D), allocatable:: node (:)    ! domain node
        type(bd_conds) :: bd_value(2)

          open (unit=9, file='input_filename',iostat=error)

        read(9,*) project_title
        read(9,*) domain_length                          !domain
length
        read(9,*) nx                                      ! total
nodes

        allocate(node(nx), stat = error)
        if (error /= 0) then
            print *, "Failed to allocate the nodes array!"
            return ! exit the subroutine
        end if

        ! boundary values
          do i=1,2
                 read (9,*) BND_loc,BND_type,bnd_data
                 bd_value(i)%loc=BND_loc    ! upstream or downstream
                 bd_value(i)%name=BND_type   ! dirichlet or neunman
                 bd_value(i)%value=bnd_data       ! numerical number
          end do

        ! read source,conductivity, area
             read(9,*) q,k,area

      ! each FVM is length_fvm, and the upstream and downstream length
is length_fvm/2.0
          length_fvm=domain_length/nx
        do i= 1, nx
            node(i)%index = i              ! assign index

                        if(i.eq.1.or.i.eq.nx) then     ! assign node ID
                          node(i)%ID='BND'
                        else
                          node(i)%ID='Interior'
                        endif

              if(i.eq.1) then                ! assign West and East
Nodes
                          node(i)%w=0;node(i)%e=node(i)%index+1
                        elseif(i.le.nx) then
                          node(i)%w=node(i)%index-1;node(i)%e=node(i)%index+1
                        else
              node(i)%w=node(i)%index-1;node(i)%e=0
                        endif

                        if(i.eq.1) then
                         node(i)%x=0.5*length_fvm
                        elseif(i.le.nx) then
                         node(i)%x=node(i-1)%x+length_fvm
                        endif

                node(i)%source=q           ! where is q?
                node(i)%cond=k
                node(i)%area=area
        end do

        end subroutine read_input

        !end module input

        !module solve
        !use input
        !use tridiagonal_matrix_class

        !contains

      subroutine Linear_eqs(nx,node,bd_value,aa,b)

          implicit none
          integer,intent(in):: nx
          integer::i,j
          type(node_1D),intent(in)::node(nx)
          type(bd_conds), intent(in)::bd_value(2)
          !real(double), intent(out) :: soln(nx)
          real(double):: aa(nx,nx),b(nx),TA,TB         ! temporary
          real(double)::aw,ae,ap,su,sp,dx,A,K,q          ! temporary
variables

        ! initialize
           a=0.0;b=0.0
      do i=1,nx

            A=node(i)%area
            K=node(i)%cond
            q=node(i)%source
            dx=node(i+1)%x-node(i)%x
                !TA=bd_value(1)%value   !added
                !TB=bd_value(2)%value   !added
           if(i.EQ.1) then
             ! i=1  the first equation for the upstream node
             ! if upstream is dirichlet boundary condition
             if (bd_value(1)%name=='dirichlet') then
        ! the values for dirichlet upstream boundary conditions
                 TA=bd_value(1)%value
                 aw=0
                 ae=A*K/dx
                 sp=-2*K*A/dx
                 ap=aw+ae-sp
                 su=q*A*dx+2*K*TA/dx
             else
        ! the values for the Neunman type upstream boundary conditions
                 TA=bd_value(1)%value
                 aw=0
                 ae=K*A/dx
                 sp=0
                 ap=aw+ae-sp
                 su=q*A*dx-K*A*TA
             endif
                 aa(i,i+1)=-ae               ! assign the coefficients
                 aa(i,i)=ae+aw-sp
                 b(i)=su

       elseif(i.lt.nx) then  ! for internal nodes
             !1 < i < n  boundary conditions don't affect the coefficients
                 dx=node(i+1)%x-node(i)%x
                 aw=k*a/dx
                 ae=aw
                 sp=0
                 ap=aw+ae-sp
                 su=q*a*dx
                 aa(i,i)=ap
                 aa(i,i-1)=-aw
             aa(i,i+1)=-ae
                 b(i)=su

         else                  ! for the downstream node, i=nx
              TB=bd_value(2)%value
             if (bd_value(2)%name=='dirichlet') then
        ! the values for dirichlet downstream boundary conditions

                 aw=K*A/dx
                 ae=0
                 sp=-2*K*A/dx
                 ap=aw+ae-sp
                 su=q*A*dx+2*K*A/dx*TB
             else
        ! the values for the Neunman type downstream boundary conditions

                 aw=K*A/dx
                 ae=0
                 sp=0
                 ap=aw+ae-sp
                 su=K*A*TB+q*A*dx               !su=K*A*TB+Q*A*dx
             endif
                 aa(i,i)=ap
                 aa(i,i-1)=-aw
                 b(i)=su
           endif

        enddo
        return
      end subroutine Linear_eqs

        !use tridiagonal_matrix_class

        !soln= tri_diag_solve(a,b)

        !end module solve

        !module output
        !use input
           !implicit none

          ! integer::i,nx
           !real(double),intent(in)     ::soln(:)
           !character::output_file

           !contains

           subroutine out(nx,soln,output_file)
           integer,intent(in)::nx
           real(double),intent(in)      ::soln(:)

           character::output_file

           ! out put data into a given filename
           open(unit=10,file='output_file')
           do i=1,nx
           write(10,*) soln(i);end do

           end subroutine out

         ! end module output

        end Module Solver

-------

module tridiagonal_matrix_class

                type :: tri_diag_matrix                                                 !tridiagonal matrix
                        integer                               :: size                           !dimension
                        double precision, pointer :: lower (:)                  !lower diagonal
                        double precision, pointer :: main  (:)                  !main diagonal
                        double precision, pointer :: upper (:)                  !upper diagonal

        end type tri_diag_matrix

        interface transpose                                             !interface for transpose function
                module procedure tri_diag_trans
      end interface

        interface tri_diag_maker                                         !genetic constructor
                module procedure tri_diag_alloc                  !null matrix
                module procedure tri_diag_scalars                !build from scalars
                module procedure tri_diag_vectors                !build from vectors
        end interface

        interface operator (*)                                   !matrix times vector
                module procedure tri_diag_by_vector
        end interface

        interface operator (.solve.)                             !by factorization
                module procedure tri_diag_solve
        end interface

        contains

        function tri_diag_trans (S) result (T)            ! T = transpose (s)
                type (tri_diag_matrix), intent(in) :: s
                type (tri_diag_matrix)                     :: t   !intent (out)
                        T = tri_diag_alloc (S % size)         !allocate T
                        T % upper = s % lower                 !lower --> upper
                        t % main = s % main                                       !same main diagonal
                        T % lower = s % upper                             !upper --> lower
        end function tri_diag_trans

        function tri_diag_alloc (n) result (t)            !allocate tri_diag_matrix
                integer, intent(in)        :: n                           !desire size
                type (tri_diag_matrix) :: t                               !intent(out)
                        t % size = n                                              ! (consider all size n)
                        allocate ( t % lower (n-1), t % main (n), t % upper (n-1))
        end function tri_diag_alloc

        subroutine tri_diag_print (T)                                   !print tri_diag_matrix
                type (tri_diag_matrix), intent (in) :: t        !matrix
                integer                                                         :: n, j !work
                        n = t % size                                                    !size
                        print *, 1, 0.d0, t % main (1), t % upper (1)
                        if ( n > 2 ) then                                            !more rows
                                do j = 2, n-1                                           !row loop
                print *, j, t % lower (j-1), t % main (j), t % upper (j)
                                end do
                        end if                                                                  !add last row
                        print *, n, t % lower (n-1), t % main (n), 0.d0
        end subroutine tri_diag_print

        subroutine tri_diag_free (A)                            !deallocate tri_diag_matrix
                type (tri_diag_matrix), intent(inout) :: a      !destroy
                        a % size = 0
                deallocate (A % lower, a % main, a % upper)
        end subroutine tri_diag_free

        function tri_diag_scalars (n, s1, sm, su) result (t)
                integer,                  intent(in) :: n                        !size from scalars
                double
...

read more »



Sun, 03 Apr 2011 10:29:55 GMT  
 LNK2001 and LNK1120 errors.. newbie here please help

Quote:

> hello. I am taking a numeric numbers class which involves some Fortran
> programming class and we had to "fix" this code. I moved some stuff
> around, and it seems that it compiles well but when it has to link I
> get the following error message:

> Linking...
> FVM Program Main.obj : error LNK2001: unresolved external symbol

> Debug/FVM Program Main.exe : fatal error LNK1120: 1 unresolved
> externals
> Error executing link.exe.

> FVM Program Main.exe - 2 error(s), 0 warning(s)

You defined subroutine    LINEAR_EQS
and you called subroutine LINEAR_EQ

The linker then could not find the called subroutine LINEAR_EQ, which
generated the errors.

...

--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



Sun, 03 Apr 2011 10:55:04 GMT  
 LNK2001 and LNK1120 errors.. newbie here please help

Quote:

> > hello. I am taking a numeric numbers class which involves some Fortran
> > programming class and we had to "fix" this code. I moved some stuff
> > around, and it seems that it compiles well but when it has to link I
> > get the following error message:

> > Linking...
> > FVM Program Main.obj : error LNK2001: unresolved external symbol

> > Debug/FVM Program Main.exe : fatal error LNK1120: 1 unresolved
> > externals
> > Error executing link.exe.

> > FVM Program Main.exe - 2 error(s), 0 warning(s)

> You defined subroutine ? ?LINEAR_EQS
> and you called subroutine LINEAR_EQ

> The linker then could not find the called subroutine LINEAR_EQ, which
> generated the errors.

> ...

> --
> Bob Walton
> Email:http://bwalton.com/cgi-bin/emailbob.pl

Thank you sir, I realize now what I was doing. It's so hard to look
through the code for mistakes, I was just looking at my modules
instead of the main program. I also changed the order of the variables
and now I get a 100% working code.
Thanks again.


Sun, 03 Apr 2011 13:24:36 GMT  
 LNK2001 and LNK1120 errors.. newbie here please help

Quote:


> > > hello. I am taking a numeric numbers class which involves some Fortran
> > > programming class and we had to "fix" this code. I moved some stuff
> > > around, and it seems that it compiles well but when it has to link I
> > > get the following error message:

> > > Linking...
> > > FVM Program Main.obj : error LNK2001: unresolved external symbol

> > > Debug/FVM Program Main.exe : fatal error LNK1120: 1 unresolved
> > > externals
> > > Error executing link.exe.

> > > FVM Program Main.exe - 2 error(s), 0 warning(s)

> > You defined subroutine ? ?LINEAR_EQS
> > and you called subroutine LINEAR_EQ

> > The linker then could not find the called subroutine LINEAR_EQ, which
> > generated the errors.

> > ...

> > --
> > Bob Walton
> > Email:http://bwalton.com/cgi-bin/emailbob.pl

> Thank you sir, I realize now what I was doing. It's so hard to look
> through the code for mistakes, I was just looking at my modules
> instead of the main program. I also changed the order of the variables
> and now I get a 100% working code.
> Thanks again.

seems I keep getting problems, this time it's this:

forrt1: severe (29): file not found, unit 9.

here's what the input file looks like:  input.txt

project
0.05, 5
upstream, neuman, 100
downstream, neuman, 200
1000
.5
1

I don't know what's going on.
Any help?



Sun, 03 Apr 2011 15:24:55 GMT  
 LNK2001 and LNK1120 errors.. newbie here please help



Quote:
> seems I keep getting problems, this time it's this:
> forrt1: severe (29): file not found, unit 9.

        That means exactly what it says -- the file it tried to open as
UNIT=9 does not exist.

Quote:
> here's what the input file looks like:  input.txt

        I suggest you add a temporary print statement to your read
subprogram to print out what the _programme_ thinks the filename is, to
see if this matches up with _your_ expectations.

--
Ivan Reid, School of Engineering & Design, _____________  CMS Collaboration,

        KotPT -- "for stupidity above and beyond the call of duty".



Sun, 03 Apr 2011 15:47:00 GMT  
 LNK2001 and LNK1120 errors.. newbie here please help

Quote:

>seems I keep getting problems, this time it's this:

>forrt1: severe (29): file not found, unit 9.

>here's what the input file looks like:  input.txt

If you are running the program from within Microsoft Visual Studio, input
files will be assumed to be in the project folder and not the folder
containing the executable.
--
Steve Lionel
Developer Products Division
Intel Corporation
Nashua, NH

For email address, replace "invalid" with "com"

User communities for Intel Software Development Products
  http://software.intel.com/en-us/forums/
Intel Fortran Support
  http://support.intel.com/support/performancetools/fortran
My Fortran blog
  http://www.intel.com/software/drfortran



Sun, 03 Apr 2011 22:04:41 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. LNK1120 error and libraries

2. LNK2001 Error with EasyDLL.zip

3. error LNK2001: unresolved external symbol *******

4. Visual C++ calling Fortran / DVF 6.1: error LNK2001

5. error LNK2001: unresolved external symbol

6. Linking error under CDF: LNK2001

7. Link Error LNK2001 with DVF5.0D

8. Linker Tools Error LNK2001

9. _____ MSFPS4.0 Problem: Use of EXTERNAL in MODULE generates LNK2001 error ____

10. error LNK2001: unresolved external symbol __imp__Tcl_CreateInterp

11. LNK2001 error

12. Graphics help by newbie, please help

 

 
Powered by phpBB® Forum Software