Fortran Coder

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

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

[复制链接]

5

帖子

2

主题

0

精华

新人

F 币
28 元
贡献
16 点
跳转到指定楼层
楼主
发表于 2019-11-5 22:33:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
[Fortran] 纯文本查看 复制代码
001!-------------!
002 module system
003!-------------!
004 
005 integer :: nn
006 integer :: nst
007 
008 real(8), allocatable :: mat(:,:)
009 real(8), allocatable :: vec(:,:)
010 real(8), allocatable :: enr(:)
011 real(8), allocatable :: spn(:)
012 real(8), allocatable :: mag(:)
013 
014 end module system
015!-----------------!
016 
017!================!
018 program hchain_0
019!================!
020 use system; implicit none
021 
022 open(10,file='read.in',status='old')
023 read(10,*)nn
024 close(10)
025 
026 nst=2**nn
027 allocate(mat(0:nst-1,0:nst-1))
028 allocate(vec(0:nst-1,0:nst-1))
029 allocate(enr(0:nst-1))
030 allocate(spn(0:nst-1))
031 allocate(mag(0:nst-1))
032 
033 call hamiltonian()
034 call diagonalize(nst,mat,vec,enr)
035 
036 call spinsquared()
037 call transform(nst,mat,vec,spn)
038 spn(:)=0.5d0*abs(sqrt(1.d0+4.d0*spn(:))-1.d0)
039 
040 call magnetization()
041 
042 call writedata()
043 
044 deallocate(mat)
045 deallocate(vec)
046 deallocate(enr)
047 deallocate(spn)
048 deallocate(mag)
049 
050 end program hchain_0
051!====================!
052 
053!----------------------!
054 subroutine writedata()
055!----------------------!
056 use system; implicit none
057 
058 integer :: i
059 
060 open(10,file='eig.dat',status='unknown')
061 do i=0,nst-1
062    write(10,'(i5,3f18.10)')i,enr(i),spn(i),mag(i)
063 enddo
064 close(10)
065 
066 end subroutine writedata
067!------------------------!
068 
069!------------------------!
070 subroutine hamiltonian()
071!------------------------!
072 use system; implicit none
073 
074 integer :: i,j,a,b
075 
076 mat(:,:)=0.d0
077 do a=0,nst-1
078    do i=0,nn-1
079       j=mod(i+1,nn)
080       if (btest(a,i).eqv.btest(a,j)) then
081          mat(a,a)=mat(a,a)+0.25d0
082       else
083          mat(a,a)=mat(a,a)-0.25d0               
084          b=ieor(a,2**i+2**j)
085          mat(a,b)=mat(a,b)+0.5d0   
086       endif
087    enddo
088 enddo
089 
090 
091 end subroutine hamiltonian
092!--------------------------!
093 
094!------------------------!
095 subroutine spinsquared()
096!------------------------!
097 use system; implicit none
098 
099 integer :: i,j,a,b,m
100 
101 mat(:,:)=0.d0
102 do a=0,nst-1
103    m=0
104    do i=0,nn-1
105       if (btest(a,i)) m=m+1
106    enddo
107    mat(a,a)=dfloat(m-nn/2)**2+0.5d0*dfloat(nn)
108    do i=0,nn-1  
109    do j=i+1,nn-1
110       if (btest(a,i).neqv.btest(a,j)) then
111          b=ieor(a,2**i+2**j)
112          mat(a,b)=mat(a,b)+1.d0   
113       endif
114    enddo
115    enddo
116 enddo
117 
118 end subroutine spinsquared
119!--------------------------!
120 
121!--------------------------!
122 subroutine magnetization()
123!--------------------------!
124 use system; implicit none
125 
126 integer :: i,j,a,b
127 integer, allocatable :: mz(:)
128 
129 allocate(mz(0:nst-1))
130 do a=0,nst-1
131    mz(a)=0
132    do i=0,nn-1
133       if (btest(a,i)) mz(a)=mz(a)+1
134    enddo
135 enddo
136 do a=0,nst-1
137    mag(a)=0.d0
138    do b=0,nst-1
139       mag(a)=mag(a)+mz(b)*vec(b,a)**2
140    enddo
141 enddo
142 mag(:)=(mag(:)-nn/2)*0.5d0
143 deallocate(mz)
144 
145 end subroutine magnetization
146!----------------------------!
147 
148!-------------------------------------!
149 subroutine diagonalize(n,mat,vec,eig)
150!-------------------------------------!
151 implicit none
152 
153 integer :: n,info
154 real(8) :: mat(n,n),vec(n,n),eig(n),work(n*(3+n/2))
155 
156 vec=mat
157 call dsyev('V','U',n,vec,n,eig,work,n*(3+n/2),info)
158 
159 end subroutine diagonalize
160!--------------------------!
161 
162!-----------------------------------!
163 subroutine transform(n,mat,vec,dia)
164!-----------------------------------!
165 implicit none
166 
167 integer :: i,n
168 real(8) :: mat(n,n),vec(n,n),dia(n)
169 
170 mat=matmul(mat,vec)
171 mat=matmul(transpose(vec),mat)
172 do i=1,n
173    dia(i)=mat(i,i)
174 enddo
175 
176 end subroutine transform
177!------------------------!

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

5

帖子

2

主题

0

精华

新人

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

fatal error LNK1120: 1

想问为什么,       

955

帖子

0

主题

0

精华

大师

F 币
188 元
贡献
77 点

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

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

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

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

本版积分规则

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

GMT+8, 2025-4-29 00:49

Powered by Discuz! X3.4

© 2013-2025 Comsenz Inc.

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