Fortran Coder

查看: 7140|回复: 2
打印 上一主题 下一主题

[求助] 错误 1 error LNK2019: Console3.obj

[复制链接]

5

帖子

2

主题

0

精华

新人

F 币
28 元
贡献
16 点
跳转到指定楼层
楼主
发表于 2019-11-5 22:33:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
[Fortran] 纯文本查看 复制代码
 !-------------!
 module system
!-------------!

 integer :: nn
 integer :: nst

 real(8), allocatable :: mat(:,:)
 real(8), allocatable :: vec(:,:)
 real(8), allocatable :: enr(:)
 real(8), allocatable :: spn(:)
 real(8), allocatable :: mag(:)

 end module system
!-----------------!

!================!
 program hchain_0
!================!
 use system; implicit none

 open(10,file='read.in',status='old')
 read(10,*)nn
 close(10)

 nst=2**nn
 allocate(mat(0:nst-1,0:nst-1))
 allocate(vec(0:nst-1,0:nst-1))
 allocate(enr(0:nst-1))
 allocate(spn(0:nst-1))
 allocate(mag(0:nst-1))

 call hamiltonian()
 call diagonalize(nst,mat,vec,enr)

 call spinsquared()
 call transform(nst,mat,vec,spn)
 spn(:)=0.5d0*abs(sqrt(1.d0+4.d0*spn(:))-1.d0)

 call magnetization()

 call writedata()

 deallocate(mat)
 deallocate(vec)
 deallocate(enr)
 deallocate(spn)
 deallocate(mag)

 end program hchain_0
!====================!

!----------------------!
 subroutine writedata()
!----------------------!
 use system; implicit none

 integer :: i

 open(10,file='eig.dat',status='unknown')
 do i=0,nst-1
    write(10,'(i5,3f18.10)')i,enr(i),spn(i),mag(i)
 enddo
 close(10)

 end subroutine writedata
!------------------------!

!------------------------!
 subroutine hamiltonian()
!------------------------!
 use system; implicit none

 integer :: i,j,a,b

 mat(:,:)=0.d0
 do a=0,nst-1
    do i=0,nn-1
       j=mod(i+1,nn)
       if (btest(a,i).eqv.btest(a,j)) then 
          mat(a,a)=mat(a,a)+0.25d0 
       else
          mat(a,a)=mat(a,a)-0.25d0                
          b=ieor(a,2**i+2**j)
          mat(a,b)=mat(a,b)+0.5d0    
       endif
    enddo
 enddo


 end subroutine hamiltonian
!--------------------------!

!------------------------!
 subroutine spinsquared()
!------------------------!
 use system; implicit none

 integer :: i,j,a,b,m

 mat(:,:)=0.d0
 do a=0,nst-1
    m=0
    do i=0,nn-1
       if (btest(a,i)) m=m+1
    enddo
    mat(a,a)=dfloat(m-nn/2)**2+0.5d0*dfloat(nn)
    do i=0,nn-1   
    do j=i+1,nn-1
       if (btest(a,i).neqv.btest(a,j)) then 
          b=ieor(a,2**i+2**j)
          mat(a,b)=mat(a,b)+1.d0    
       endif
    enddo
    enddo
 enddo

 end subroutine spinsquared
!--------------------------!

!--------------------------!
 subroutine magnetization()
!--------------------------!
 use system; implicit none

 integer :: i,j,a,b
 integer, allocatable :: mz(:)

 allocate(mz(0:nst-1))
 do a=0,nst-1
    mz(a)=0
    do i=0,nn-1
       if (btest(a,i)) mz(a)=mz(a)+1
    enddo
 enddo
 do a=0,nst-1
    mag(a)=0.d0
    do b=0,nst-1
       mag(a)=mag(a)+mz(b)*vec(b,a)**2
    enddo
 enddo
 mag(:)=(mag(:)-nn/2)*0.5d0
 deallocate(mz)

 end subroutine magnetization
!----------------------------!

!-------------------------------------!
 subroutine diagonalize(n,mat,vec,eig)
!-------------------------------------!
 implicit none

 integer :: n,info
 real(8) :: mat(n,n),vec(n,n),eig(n),work(n*(3+n/2))

 vec=mat
 call dsyev('V','U',n,vec,n,eig,work,n*(3+n/2),info)

 end subroutine diagonalize
!--------------------------!

!-----------------------------------!
 subroutine transform(n,mat,vec,dia)
!-----------------------------------!
 implicit none

 integer :: i,n
 real(8) :: mat(n,n),vec(n,n),dia(n)

 mat=matmul(mat,vec)
 mat=matmul(transpose(vec),mat)
 do i=1,n
    dia(i)=mat(i,i)
 enddo

 end subroutine transform
!------------------------!

分享到:  微信微信
收藏收藏 点赞点赞 点踩点踩

5

帖子

2

主题

0

精华

新人

F 币
28 元
贡献
16 点
沙发
 楼主| 发表于 2019-11-5 22:37:52 | 只看该作者
我是想问下面的代码调试时就会出现两个错误, error LNK2019

fatal error LNK1120: 1

想问为什么,       

954

帖子

0

主题

0

精华

大师

F 币
184 元
贡献
75 点

规矩勋章元老勋章新人勋章水王勋章热心勋章

QQ
板凳
发表于 2019-11-6 08:35:36 | 只看该作者
dsyev 函数没有给出。

如果是用的 lapack 的函数,需要在您的平台(windows或linux)上安装并合理配置 lapack 库
也可以用 intel 的 MKL,它包含了 lapack 库。

具体使用方法与你的操作系统和编译器有关。
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-4-26 06:41

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表