| 查看: 3870 | 回复: 59 | ||
| 本帖产生 3 个 程序强帖 ,点击这里进行查看 | ||
| 当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖 | ||
Gina88木虫 (正式写手)
|
[求助]
写了一个fortran90的小程序,编译通不过,请大侠帮忙
|
|
|
program cell-POSCAR !announcement begin*********************************** implicit none real(8)::cellcon(3,3) !lattice constance real(8),allocatable::atomcoor(:, !direct coordinate of atoms integer,allocatable::type( ![]() integer i,j,k,m,n !m:atom number,n:type number character(len=1) nonsense !to contain something that will not be used character(len=2) position !to read % character(len=2) element1,element2 !End announcement************************************ !Begin reading data from "cell"**************************** open(unit=18,file="cell",status="old" ![]() read(18,*)nonsense do i=1,3 read(18,*)cellcon(i,1),cellcon(i,2),cellcon(i,3) end do read(18,*)position read(18,*)nonsense read(18,*)nonsense n=0;m=0 read(18,*)element2 do while(position/=element2) n=n+1 element1=element2 do while(element1==element2) m=m+1 read(18,*)element2 end do end do close(18) allocate(type(n)) allocate(atomcoor(m,3)) open(unit=28,file="cell",status="old" ![]() read(28,*)nonsense read(28,*)nonsense read(28,*)nonsense read(28,*)nonsense read(28,*)nonsense read(28,*)nonsense read(28,*)nonsense read(28,*)element2,atomcoor(1,1),atomcoor(1,2),atomcoor(1,3) i=1;k=1 element1=element2 if (m==1) then type(1)=1 else if do j=2,m read(28,*)element2,atomcoor(j,1),atomcoor(j,2),atomcoor(j,3) if(element1==element2) then k=k+1 if(m==j) type(i)=k else if type(i)=k i=i+1 element1=element2 k=1 if(m==j) type(i)=k end if end do end if close(28) !End reading data from "cell"**************************** !Begin writing to "POSCAR"****************************** open(unit=38,file="POSCAR",status="replace" ![]() write(38,10)System write(38,100)cellcon(1,1) do i=1,3 write(38,200)(cellcon(i,j)/cellcon(1,1),j=1,3) end do write(38,60)(type(i),i=1,n) write(38,20)Selective,dynamic write(38,30)Direct do i=1,m write(38,300)(atomcoor(i,j),j=1,3) end do 10 FORMAT(1X,A6) 20 FORMAT(1X,A9,1X,A7) 30 FORMAT(1X,A6) 60 FORMAT(1X,n(I3,2X)) 100 FORMAT(1X,F18.16) 200 FORMAT(1X,3(F18.16,3X)) 300 FORMAT(1X,F18.16,2X,F18.16,2X,F18.16,2X,'T',2X,'T',2X,'T') close(38) !End writing to "POSCAR"******************************** end |
» 猜你喜欢
职称评审没过,求安慰
已经有41人回复
回收溶剂求助
已经有7人回复
硝基苯如何除去
已经有3人回复
A期刊撤稿
已经有4人回复
垃圾破二本职称评审标准
已经有17人回复
投稿Elsevier的Neoplasia杂志,到最后选publishing options时页面空白,不能完成投稿
已经有22人回复
EST投稿状态问题
已经有7人回复
毕业后当辅导员了,天天各种学生超烦
已经有4人回复
求助文献
已经有3人回复
三无产品还有机会吗
已经有6人回复
Gina88
木虫 (正式写手)
- 应助: 9 (幼儿园)
- 金币: 3328.8
- 散金: 124
- 红花: 8
- 帖子: 395
- 在线: 113小时
- 虫号: 1047684
- 注册: 2010-06-26
- 专业: 理论和计算化学
43楼2011-05-09 15:13:26
Gina88
木虫 (正式写手)
- 应助: 9 (幼儿园)
- 金币: 3328.8
- 散金: 124
- 红花: 8
- 帖子: 395
- 在线: 113小时
- 虫号: 1047684
- 注册: 2010-06-26
- 专业: 理论和计算化学
|
这个是cell的内容 %BLOCK LATTICE_CART 12.782529349912258 -0.000000000000028 0.000000000000001 -0.000000000000000 13.529995000000000 0.000000000000001 0.000000000000000 0.000000000000000 10.000000000000000 %ENDBLOCK LATTICE_CART %BLOCK POSITIONS_FRAC H 0.0555000007152556 0.1666999995708470 0.5000000000000000 H 0.2221666673819220 0.0666999995708464 0.5000000000000000 H 0.1110555562708110 0.0666999995708466 0.5000000000000000 H 0.1110555562708110 0.0666999995708466 0.5000000000000000 C 0.2777222229374780 0.1666999995708470 0.5000000000000000 C 0.3888333340485890 0.1666999995708470 0.5000000000000000 C 0.5555000007152560 0.0666999995708465 0.5000000000000000 S 0.4443888896041450 0.0666999995708466 0.5000000000000000 S 0.6110555562708110 0.1666999995708470 0.5000000000000000 si 0.6110555562708110 0.1666999995708470 0.5000000000000000 %ENDBLOCK POSITIONS_FRAC |
2楼2011-05-04 17:52:59
Gina88
木虫 (正式写手)
- 应助: 9 (幼儿园)
- 金币: 3328.8
- 散金: 124
- 红花: 8
- 帖子: 395
- 在线: 113小时
- 虫号: 1047684
- 注册: 2010-06-26
- 专业: 理论和计算化学
3楼2011-05-04 17:56:30
Gina88
木虫 (正式写手)
- 应助: 9 (幼儿园)
- 金币: 3328.8
- 散金: 124
- 红花: 8
- 帖子: 395
- 在线: 113小时
- 虫号: 1047684
- 注册: 2010-06-26
- 专业: 理论和计算化学
|
program cell-POSCAR !announcement begin*********************************** implicit none real(8)::cellcon(3,3) !lattice constance real(8),allocatable::atomcoor(:, !direct coordinate of atoms integer,allocatable::type( ![]() integer i,j,k,m,n !m:atom number,n:type number character(len=1) nonsense !to contain something that will not be used character(len=2) position !to read % character(len=2) element1,element2 !End announcement************************************ !Begin reading data from "cell"**************************** open(unit=18,file="cell",status="old" ![]() read(18,*)nonsense do i=1,3 read(18,*)cellcon(i,1),cellcon(i,2),cellcon(i,3) end do read(18,*)position read(18,*)nonsense read(18,*)nonsense n=0;m=0 read(18,*)element2 do while(position/=element2) n=n+1 element1=element2 do while(element1==element2) m=m+1 read(18,*)element2 end do end do close(18) allocate(type(n)) allocate(atomcoor(m,3)) open(unit=28,file="cell",status="old" ![]() read(28,*)nonsense read(28,*)nonsense read(28,*)nonsense read(28,*)nonsense read(28,*)nonsense read(28,*)nonsense read(28,*)nonsense read(28,*)element2,atomcoor(1,1),atomcoor(1,2),atomcoor(1,3) i=1;k=1 element1=element2 if (m==1) then type(1)=1 else if do j=2,m read(28,*)element2,atomcoor(j,1),atomcoor(j,2),atomcoor(j,3) if(element1==element2) then k=k+1 if(m==j) type(i)=k else if type(i)=k i=i+1 element1=element2 k=1 if(m==j) type(i)=k end if end do end if close(28) !End reading data from "cell"**************************** !Begin writing to "POSCAR"****************************** open(unit=38,file="POSCAR",status="replace" ![]() write(38,10)System write(38,100)cellcon(1,1) do i=1,3 write(38,200)(cellcon(i,j)/cellcon(1,1),j=1,3) end do write(38,60)(type(i),i=1,n) write(38,20)Selective,dynamic write(38,30)Direct do i=1,m write(38,300)(atomcoor(i,j),j=1,3) end do 10 FORMAT(1X,A6) 20 FORMAT(1X,A9,1X,A7) 30 FORMAT(1X,A6) 60 FORMAT(1X,n(I3,2X)) 100 FORMAT(1X,F18.16) 200 FORMAT(1X,3(F18.16,3X)) 300 FORMAT(1X,F18.16,2X,F18.16,2X,F18.16,2X,'T',2X,'T',2X,'T') close(38) !End writing to "POSCAR"******************************** end |
4楼2011-05-04 17:58:28













!direct coordinate of atoms 
回复此楼