分享

科学网

 Study_ZCY 2016-01-31
转自:
program main
implicit none
character(len=20) input
logical alive
integer,parameter::inputfile=11,outputfile=12
integer ::counter=0,lines
real x,y,w2
real,allocatable:: x0(,y0(
real left,right
real ::A=3.0,step=0.05,w !A为半高宽,step为x增加的间距
integer ::status

w2=A**2/2/LOG(2.0)
write(*,*)"input file name:"
read(*,*)input
inquire(file=input,exist=alive)
if(.not.alive)then
  write(*,*)input,"does not exist"
  stop
end if
open(unit=inputfile,file=input,access="sequential",status="old"
do while(.true.)
  read(unit=inputfile,fmt="(F6.2,1X,F8.6)",iostat=status)x,y
 
  if(status/=0)exit
  counter=counter+1
  write(*,*)counter,"line:",x,y
end do
lines=counter
rewind(inputfile)
allocate(x0(counter))
allocate(y0(counter))
do counter=1,lines
  read(unit=inputfile,fmt="(F6.2,1X,F8.6)",iostat=status)x0(counter),y0(counter)
  if(status/=0)exit
end do
write(*,*)"left:"
read(*,*)left
write(*,*)"right:"
read(*,*)right
open(unit=outputfile,file="data.dat"
x=left
do while(x<=right)
  y=0.0
  do counter=1,lines
    if(abs(x-x0(counter)<=3*A)) then
     y=y0(counter)/EXP(2*(x-x0(counter))**2/w2)+y
    end if
  end do
  write(unit=outputfile,fmt="(F6.2,1X,F8.6)"x,y
  x=x+step
end do

stop
end program


http://blog.sciencenet.cn/blog-588243-507686.html  此文来自科学网穆跃文博客,转载请注明出处。
上一篇:[转载]常见函数的半高宽
下一篇:[转载]VASP(计算前的)验证

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多