24小时热门版块排行榜    

查看: 2423  |  回复: 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的回帖
回帖支持 ( 显示支持度最高的前 50 名 )

snoopyzhao

至尊木虫 (职业作家)

【答案】应助回帖

★ ★
感谢参与,应助指数 +1
jjdg(金币+2): 感谢应助 2012-03-08 01:56:40
引用回帖:
3楼: Originally posted by zhaohuxian at 2012-03-07 21:29:07:
不好意思,我也是第一次写程序,我是用CVF 6.5编译通过的
不知道哪里有问题,谢谢

你的 cvf 好强啊……

你看一下下面的编译错误提示:
CODE:
C:\Documents and Settings\Administrator\Desktop>gfortran -Wall -Wextra zf.f90
zf.f90:15.19:

      dimension dx(x,y), dy(x,y), dz(x,y)
                   1
Error: Expression at (1) must be of INTEGER type, found REAL
zf.f90:15.21:

      dimension dx(x,y), dy(x,y), dz(x,y)
                     1
Error: Expression at (1) must be of INTEGER type, found REAL
zf.f90:15.18:

      dimension dx(x,y), dy(x,y), dz(x,y)
                  1
Error: The module or main program array 'dx' at (1) must have constant shape
zf.f90:15.28:

      dimension dx(x,y), dy(x,y), dz(x,y)
                            1
Error: Expression at (1) must be of INTEGER type, found REAL
zf.f90:15.30:

      dimension dx(x,y), dy(x,y), dz(x,y)
                              1
Error: Expression at (1) must be of INTEGER type, found REAL
zf.f90:15.27:

      dimension dx(x,y), dy(x,y), dz(x,y)
                           1
Error: The module or main program array 'dy' at (1) must have constant shape
zf.f90:15.37:

      dimension dx(x,y), dy(x,y), dz(x,y)
                                     1
Error: Expression at (1) must be of INTEGER type, found REAL
zf.f90:15.39:

      dimension dx(x,y), dy(x,y), dz(x,y)
                                       1
Error: Expression at (1) must be of INTEGER type, found REAL
zf.f90:15.36:

      dimension dx(x,y), dy(x,y), dz(x,y)
                                    1
Error: The module or main program array 'dz' at (1) must have constant shape
zf.f90:11.22:

        integer iatom(x)
                      1
Error: Expression at (1) must be of INTEGER type, found REAL
zf.f90:11.24:

        integer iatom(x)
                        1
Error: The module or main program array 'iatom' at (1) must have constant shape
zf.f90:18.24:

      character*4 lable(x), latom(x,y)
                        1
Error: Expression at (1) must be of INTEGER type, found REAL
zf.f90:18.26:

      character*4 lable(x), latom(x,y)
                          1
Error: The module or main program array 'lable' at (1) must have constant shape
zf.f90:18.34:

      character*4 lable(x), latom(x,y)
                                  1
Error: Expression at (1) must be of INTEGER type, found REAL
zf.f90:18.36:

      character*4 lable(x), latom(x,y)
                                    1
Error: Expression at (1) must be of INTEGER type, found REAL
zf.f90:18.38:

      character*4 lable(x), latom(x,y)
                                      1
Error: The module or main program array 'latom' at (1) must have constant shape
zf.f90:45.18:

        open(unit=out,file='OUTCAR',status='OLD')
                  1
Error: UNIT tag at (1) must be of type INTEGER
zf.f90:48.15:

          read(out,*,end=10) line
               1
Error: UNIT specification at (1) must be an INTEGER expression or a CHARACTER va
riable
zf.f90:56.14:

        close(out)
              1
Error: UNIT tag at (1) must be of type INTEGER
zf.f90:61.18:

        open(unit=con,file='CONTCAR',status='OLD')
                  1
Error: UNIT tag at (1) must be of type INTEGER
zf.f90:62.13:

        read(con,*,end=20) system
             1
Error: UNIT specification at (1) must be an INTEGER expression or a CHARACTER va
riable
zf.f90:63.13:

        read(con,*,end=20) lattice
             1
Error: UNIT specification at (1) must be an INTEGER expression or a CHARACTER va
riable
zf.f90:64.13:

        read(con,*,end=20) rv(1,1), rv(2,1), rv(3,1)
             1
Error: UNIT specification at (1) must be an INTEGER expression or a CHARACTER va
riable
zf.f90:65.13:

        read(con,*,end=20) rv(1,2), rv(2,2), rv(3,2)
             1
Error: UNIT specification at (1) must be an INTEGER expression or a CHARACTER va
riable
zf.f90:66.13:

        read(con,*,end=20) rv(1,3), rv(2,3), rv(3,3)
             1
Error: UNIT specification at (1) must be an INTEGER expression or a CHARACTER va
riable
Fatal Error: Error count reached limit of 25.

» 本帖已获得的红花(最新10朵)

5楼2012-03-07 23:17:32
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
普通回帖

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的回帖

lwk205

至尊木虫 (著名写手)

【答案】应助回帖


感谢参与,应助指数 +1
jjdg(金币+1): 感谢应助 2012-03-08 01:56:44
没有定义tem为数组

» 本帖已获得的红花(最新10朵)

6楼2012-03-08 01:11:45
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

lurencyj

木虫 (著名写手)

引用回帖:
6楼: Originally posted by lwk205 at 2012-03-08 01:11:45:
没有定义tem为数组

记得去找房东

[ 发自手机版 http://muchong.com/3g ]
很女子很弓虽大
7楼2012-03-08 03:10:21
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zhaohuxian

木虫 (正式写手)

送鲜花一朵
引用回帖:
: Originally posted by lwk205 at 2012-03-08 01:11:45:
没有定义tem为数组

谢谢,但是我不知道为啥不能给金币了,sorry
8楼2012-03-08 09:15:35
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zhaohuxian

木虫 (正式写手)

送鲜花一朵
引用回帖:
: Originally posted by snoopyzhao at 2012-03-07 23:17:32:
你的 cvf 好强啊……

你看一下下面的编译错误提示:

C:\Documents and Settings\Administrator\Desktop>gfortran -Wall -Wextra zf.f90
zf.f90:15.19:

      dimension dx(x,y), dy(x,y), dz(x,y)
...

谢谢您的热心帮助,根据帖子里的错误信息,我改了程序:
        program angle
        !Define the parameters

      parameter (x=1000)
      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
      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=12,file='OUTCAR',status='OLD')
        atomkind=0
        do while(.not.eof)
          read(12,*,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(12)
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)

        ! 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 (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=16,file='OUTCAR',status='OLD')
        do while(.not.eof)
          read(16,*,end=30) line
          if (index(line,'POSITION').ne.0) then
          read(16,*,end=30) line
          
            do i=1,atomkind
              do j=1,iatom(i)
                read(1,*,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(16)
30    continue
      
300        format(a4,1x,3f15.9,1x,a4,1x,i4,2(1x,a2),1x,f8.4,1x,i4)

      stop
        end
9楼2012-03-08 10:54:37
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zhaohuxian

木虫 (正式写手)

送鲜花一朵
引用回帖:
: Originally posted by snoopyzhao at 2012-03-07 23:17:32:
你的 cvf 好强啊……

你看一下下面的编译错误提示:

C:\Documents and Settings\Administrator\Desktop>gfortran -Wall -Wextra zf.f90
zf.f90:15.19:

      dimension dx(x,y), dy(x,y), dz(x,y)
...

但是运行的时候debug出现了这样的信息,想问一下为什么,是第一次程序,谢谢热心帮助
Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\imagehlp.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\msvcrt.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\dbghelp.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\version.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\advapi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\rpcrt4.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\secur32.dll', no matching symbolic information found.
The program 'E:\SSC_date\temp\ADF\Debug\main.exe' has exited with code 0 (0x0).
10楼2012-03-08 10:55:39
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 zhaohuxian 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 听说今天filecode变了 +17 布布和一二 2026-08-06 31/1550 2026-08-06 22:34 by qusibaya
[基金申请] filecode +10 等待解的谜 2026-08-06 14/700 2026-08-06 21:16 by zhanghaozhu
[基金申请] 固定端突然变了,今天 +3 archvillain 2026-08-06 7/350 2026-08-06 21:05 by archvillain
[基金申请] filecode +8 布布和一二 2026-08-06 11/550 2026-08-06 20:41 by tangpu318
[基金申请] 大家散了吧,后缀研究没有意义,别浪费时间了,过好目前的每一天,不要焦虑 +5 Tide man 2026-08-06 6/300 2026-08-06 20:19 by 苏知砚
[基金申请] 基金中了 +4 laoda193707 2026-08-06 4/200 2026-08-06 18:56 by olivermiaoer
[有机交流] 一个有机合成实验室都需要哪些设备? 50+3 kf2781974 2026-07-31 12/600 2026-08-06 15:11 by eddyin
[基金申请] 求各位大神看下 100+6 hpkpkpkp 2026-08-05 33/1650 2026-08-06 14:49 by zhiyanjiang
[教师之家] 咨询面上基金 +4 李长云 2026-07-31 7/350 2026-08-06 11:20 by 李长云
[基金申请] 影响面上的因素 +8 布布和一二 2026-08-05 11/550 2026-08-06 10:41 by 宝贝虫子
[基金申请] 8月时间戳变的,举个手。玩一下,释放压力 +9 archvillain 2026-08-04 11/550 2026-08-05 20:06 by wlwhappy
[基金申请] 面上再次挂了,太难了,躺也躺不了,倦也卷不过,小学校之殇! +22 低垂的野花 2026-07-31 30/1500 2026-08-05 18:03 by 低垂的野花
[基金申请] 好消息?这个有何含义??? +8 Tide man 2026-08-05 10/500 2026-08-05 16:14 by xmuxiaoyu
[考博] 【2027博士申请】纳米药物递送方向 20+3 13586093586 2026-08-03 4/200 2026-08-05 09:59 by lfy8008
[基金申请] 有没有H口的?有收到消息的吗? +3 超级海虾 2026-08-04 3/150 2026-08-04 17:26 by 学教育滴
[论文投稿] 十年后又回来了,论文投稿求助 +3 哈哈114477 2026-08-01 3/150 2026-08-04 15:40 by tegsgjy20
[基金申请] 纯娱乐,不喜欢勿喷 +7 Tide man 2026-08-04 10/500 2026-08-04 15:10 by loufangrui
[基金申请] 面上提前没消息,有中的吗 +14 archvillain 2026-08-02 18/900 2026-08-04 14:42 by archvillain
[基金申请] 娱乐 +4 Tide man 2026-08-03 4/200 2026-08-04 11:51 by wgch518
[基金申请] 什么时候能放榜呀? +3 Jacob678 2026-08-03 3/150 2026-08-03 16:14 by gltch
信息提示
请填处理意见