24小时热门版块排行榜    

Znn3bq.jpeg
查看: 2199  |  回复: 18
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

zhaohuxian

木虫 (正式写手)

[求助] 请大侠帮忙看一下下面的 程序

program angle

        !Define the parameters

      implicit real*8(a-h,o-z)
      parameter (x=10000)
      parameter (y=10000)
      parameter (radtodeg=57.29577951d0)

        integer i, j, atomkind, lower, upper
        integer iatom(x)


      dimension rv(3,3),temp(6)
      dimension dx(x,y), dy(x,y), dz(x,y)

      character(len=132) line, system
      character*4 lable(x), latom(x,y)

      double precision lattice

      logical eof, con, out

        eof=.false.
        con=.false.
        out=.false.

        ! Check the required files
       
        inquire(file='OUTCAR',exist=out)
        inquire(file='CONTCAR',exist=con)

        if (.not. out) then
        print *, "OUTCAR: file not exist."
        stop
        end if

        if (.not. con) then
        print *, "CONTCAR: file not exist."
        stop
        end if

        ! Read the species in OUTCAR

        open(unit=out,file='OUTCAR',status='OLD')
        atomkind=0
        do while(.not.eof)
          read(out,*,end=10) line
          if(index(line,'VRHFIN').ne.0) then
            atomkind=atomkind+1
            upper=index(line,':')-1
            lower=index(line,'=')+1
            lable(atomkind)=line(lower:upper)
          end if
        end do
        close(out)
10        continue

      ! Read POSCAR to process lattice information and amount of each kind

        open(unit=con,file='CONTCAR',status='OLD')
        read(con,*,end=20) system
        read(con,*,end=20) lattice
        read(con,*,end=20) rv(1,1), rv(2,1), rv(3,1)
        read(con,*,end=20) rv(1,2), rv(2,2), rv(3,2)
        read(con,*,end=20) rv(1,3), rv(2,3), rv(3,3)
        read(con,*,end=20), (iatom(i), i=1,atomkind)

        ! Process the label list
        do i=1,atomkind
          do j=1,iatom(i)
             latom(j,i)=lable(i)
          end do
        end do

        do i=1,3
          temp(i)=0.0
          do j=1,3
            temp(i)=temp(i)+rv(j,i)**2
          end do
          temp(i)=sqrt(temp(i))
        end do
        a=temp(1)
        b=temp(2)
        c=temp(3)

        do i=1,3
          temp(3+i)=0.0
        end do

        do j=1,3
          temp(4)=temp(4)+rv(j,2)*rv(j,3)
          temp(5)=temp(5)+rv(j,1)*rv(j,3)
          temp(6)=temp(6)+rv(j,1)*rv(j,2)
        end do
        temp(4)=temp(4)/(temp(2)*tem(3))
        temp(5)=temp(5)/(temp(1)*tem(3))
        temp(6)=temp(6)/(temp(1)*tem(2))

        alpha=radtodeg*acos(temp(4))
        beta=radtodeg*acos(temp(5))
        gamma=radtodeg*acos(temp(6))

20    continue
      
      ! Open file for record, and write

        open (11,file=opsition)
        write(11,300) system
        write(11,300) "lattice lengths: "
        write(11,300) "a=", a
        write(11,300) "b=", b
        write(11,300) "c=", c
        write(11,300) "lattice angles: "
        write(11,300) "alpha=", alpha
        write(11,300) "beta=", beta
        write(11,300) "gamma=", gamma

        close(con)


        ! Read OUTCAR to process the coordinates

        open(unit=out,file='OUTCAR',status='OLD')
        do while(.not.eof)
          read(out,*,end=30) line
          if (index(line,'POSITION').ne.0) then
          read(out,*,end=30) line
          
            do i=1,atomkind
              do j=1,iatom(i)
                read(out,*,end=30) dx(j,i), dy(j,i), dz(j,i)
                write(11,300) latom(j,i), dx(j,i), dy(j,i), dz(j,i)
              end do
            end do

          end if
        end do
        close(out)
30    continue
      
300        format(a4,1x,3f15.9,1x,a4,1x,i4,2(1x,a2),1x,f8.4,1x,i4)

        stop
      end

编译通过了,但是云心的时候报错:

--------------------Configuration: adf - Win32 Debug--------------------
Linking...
main.obj : error LNK2001: unresolved external symbol _TEM@4
Debug/adf.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

类似的另外一个程序运行没有问题
回复此楼

» 猜你喜欢

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zhaohuxian

木虫 (正式写手)

送鲜花一朵
引用回帖:
: Originally posted by snoopyzhao at 2012-03-09 10:04:21:
还有错误……


zf.f90:108.22:

        open (21,file=opsition)
                      1
Error: FILE tag at (1) must be of type CHARACTER
zf.f90:125.20:

      open (21,file=opsition)
    ...

program angle
      !Define the parameters

      integer,parameter :: x = 1000
      integer,parameter :: y = 1000

      parameter (radtodeg=57.29577951d0)

        integer i, j, atomkind, lower, upper
        integer iatom(x)


      dimension rv(3,3),temp(6)
      dimension dx(x,y), dy(x,y), dz(x,y)

      character(len=132) line, system, opsition
      character*4 lable(x), latom(x,y)

      double precision lattice

      logical eof, con_ex, out_ex

        eof=.false.
        con_ex=.false.
        out_ex=.false.

        ! Check the required files
        
        inquire(file='OUTCAR',exist=out_ex)
        inquire(file='CONTCAR',exist=con_ex)

        if (.not. out_ex) then
        print *, "OUTCAR: file not exist."
        stop
        end if

        if (.not. con_ex) then
        print *, "CONTCAR: file not exist."
        stop
        end if

        ! Read the species in OUTCAR

        open(unit=11,file='OUTCAR',status='OLD')
        atomkind=0
        do while(.not.eof)
          read(11,*,end=10) line
          if(index(line,'VRHFIN').ne.0) then
            atomkind=atomkind+1
            upper=index(line,':')-1
            lower=index(line,'=')+1
            lable(atomkind)=line(lower:upper)
          end if
        end do
        close(11)
10        continue

      ! Read POSCAR to process lattice information and amount of each kind

        open(unit=12,file='CONTCAR',status='OLD')
        read(12,*,end=20) system
        read(12,*,end=20) lattice
        read(12,*,end=20) rv(1,1), rv(2,1), rv(3,1)
        read(12,*,end=20) rv(1,2), rv(2,2), rv(3,2)
        read(12,*,end=20) rv(1,3), rv(2,3), rv(3,3)
        read(12,*,end=20), (iatom(i), i=1,atomkind)
        close(12)

        ! Process the label list
        do i=1,atomkind
          do j=1,iatom(i)
             latom(j,i)=lable(i)
          end do
        end do

        do i=1,3
          temp(i)=0.0
          do j=1,3
            temp(i)=temp(i)+rv(j,i)**2
          end do
          temp(i)=sqrt(temp(i))
        end do
        a=temp(1)
        b=temp(2)
        c=temp(3)

        do i=1,3
          temp(3+i)=0.0
        end do

        do j=1,3
          temp(4)=temp(4)+rv(j,2)*rv(j,3)
          temp(5)=temp(5)+rv(j,1)*rv(j,3)
          temp(6)=temp(6)+rv(j,1)*rv(j,2)
        end do
        temp(4)=temp(4)/(temp(2)*temp(3))
        temp(5)=temp(5)/(temp(1)*temp(3))
        temp(6)=temp(6)/(temp(1)*temp(2))

        alpha=radtodeg*acos(temp(4))
        beta=radtodeg*acos(temp(5))
        gamma=radtodeg*acos(temp(6))

20    continue
      
      ! Open file for record, and write

        open (21,file=opsition)
        write(21,300) system
        write(21,300) "lattice lengths: "
        write(21,300) "a=", a
        write(21,300) "b=", b
        write(21,300) "c=", c
        write(21,300) "lattice angles: "
        write(21,300) "alpha=", alpha
        write(21,300) "beta=", beta
        write(21,300) "gamma=", gamma

        close(21)


        ! Read OUTCAR to process the coordinates

        open(unit=11,file='OUTCAR',status='OLD')
      open (21,file=opsition)
        do while(.not.eof)
          read(11,*,end=30) line
          if (index(line,'POSITION').ne.0) then
          read(11,*,end=30) line
         
            do i=1,atomkind
              do j=1,iatom(i)
                read(11,*,end=30) dx(j,i), dy(j,i), dz(j,i)
                write(21,300) latom(j,i), dx(j,i), dy(j,i), dz(j,i)
              end do
            end do

          end if
        end do
        close(11)
        close(21)
30    continue
      
300        format(a4,1x,3f15.9,1x,a4,1x,i4,2(1x,a2),1x,f8.4,1x,i4)

      stop
      end

增加文件名的字符定义
谢谢
16楼2012-03-09 10:24:50
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 19 个回答

lurencyj

木虫 (著名写手)

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★
感谢参与,应助指数 +1
jjdg(金币+1): 感谢应助 2012-03-08 01:56:17
zhaohuxian(金币+30): 有帮助 2 2012-03-08 09:01:51
不知道楼主是怎么写的程序,gfortran编译,一大堆Error!
很女子很弓虽大
2楼2012-03-07 21:23:48
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zhaohuxian

木虫 (正式写手)

引用回帖:
: Originally posted by lurencyj at 2012-03-07 21:23:48:
不知道楼主是怎么写的程序,gfortran编译,一大堆Error!

不好意思,我也是第一次写程序,我是用CVF 6.5编译通过的
不知道哪里有问题,谢谢
3楼2012-03-07 21:29:07
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

uboat

银虫 (初入文坛)

【答案】应助回帖


感谢参与,应助指数 +1
jjdg(金币+1): 感谢应助 2012-03-08 01:56:28
temp(4)=temp(4)/(temp(2)*tem(3))
        temp(5)=temp(5)/(temp(1)*tem(3))
        temp(6)=temp(6)/(temp(1)*tem(2))

看最后的错误提示 应该是这里的错误
里面没有定义tem的变量
楼主好好的看看
4楼2012-03-07 22:25:17
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 296求调剂 +9 汪!?! 2026-04-10 10/500 2026-04-10 18:49 by HPUCZ
[考研] 272分材料子求调剂 +18 Loy0361 2026-04-10 24/1200 2026-04-10 18:31 by 1005715100
[考研] 284求调剂 +10 archer.. 2026-04-10 10/500 2026-04-10 18:26 by 1005715100
[考研] 337求调剂 +3 研s. 2026-04-10 3/150 2026-04-10 16:20 by 木子君1218
[考研] 085800 能源动力求调剂 +6 阿biu啊啊啊啊啊 2026-04-10 6/300 2026-04-10 15:03 by hemengdong
[考研] 材料专硕初试分332一志愿西北工业大学, +12 故人?? 2026-04-09 12/600 2026-04-09 18:34 by Ccclqqq
[考研] 367求调剂 +10 hffQAQ 2026-04-09 10/500 2026-04-09 18:06 by lijunpoly
[考研] 348求调剂 +3 candyyyi 2026-04-09 3/150 2026-04-09 17:20 by 段伟艳
[考研] 085501机械英二77总分294求调剂,接受跨专业学习 +6 守法公民亓纪 2026-04-08 6/300 2026-04-09 15:55 by wp06
[考研] 0703化学调剂 348分 +14 唉我超真没招了 2026-04-06 15/750 2026-04-08 19:16 by 我减肥1
[考研] 263分B区求调剂 +6 李nihao 2026-04-08 6/300 2026-04-08 09:38 by 南开小綦
[考研] 机械调剂 +3 zzzbcb 2026-04-07 3/150 2026-04-07 22:19 by hemengdong
[考研] 304求调剂(085602,过四级,一志愿985) +25 化工人999 2026-04-04 26/1300 2026-04-07 22:06 by hemengdong
[考研] 求调剂 +4 电气小神童 2026-04-04 6/300 2026-04-07 00:14 by guanxin1001
[考研] 一志愿北交大材料工程总分358求调剂 +10 cs0106 2026-04-05 12/600 2026-04-06 19:41 by 无际的草原
[考研] 考研调剂 +5 美丽的youth_ 2026-04-04 6/300 2026-04-06 06:57 by houyaoxu
[考研] 277求调剂 +5 考研调剂lxh 2026-04-05 5/250 2026-04-05 19:03 by chy09050039
[考研] 考研生物学考A区211,初试322,科目生化和生物综合,求调剂 +6 。。。54 2026-04-03 6/300 2026-04-05 14:54 by JOKER0401
[考研] 085400电子信息319求调剂(接受跨专业调剂) +5 星星不眨眼喽 2026-04-03 6/300 2026-04-04 21:50 by hemengdong
[考研] 求生物学专业调剂-332分 +5 云朵遛弯指南 2026-04-04 5/250 2026-04-04 10:05 by rzh123456
信息提示
请填处理意见