24小时热门版块排行榜    

查看: 1729  |  回复: 1

rlafite

至尊木虫 (正式写手)

[交流] 脉冲信号的高斯展宽程序 已有1人参与

!---------------------------
program gaussianbroadening
!------------------------------------------------------------------------------------------------------------
! purpose: perform a gaussian broadening on a set of impulse signal data as input.
! usage:  ./command input_file sigma
!------------------------------------------------------------------------------------------------------------
!
implicit none

integer, parameter     :: dp = kind(1.0d0)
character(len=20)      :: arg, input, output
character(len=100)     :: temp
real(dp), allocatable  :: x0( : ), y0( : )  ! 0 - input, no 0 - output
integer,parameter      :: inputfile = 10, outputfile = 20
real(dp) ::  x, y, xmin, xmax, ysum, yavg, sigma, step, pi  ! sigma2 is sigmasquare
integer  :: i, j, nline, stat  ! nline: number of lines
logical  :: alive

call getarg(1, arg)
input = trim(arg)

inquire(file=input, exist=alive)
if( .not. alive) then
   write(*,*) input, "input_file does not exist! "
   write(*,*) input, "usage:  ./command input_file sigma"
   stop
end if

call getarg(2, arg)
read(arg, *) sigma
step = sigma/20

! open and count number of lines in input file
open( unit=inputfile, file=input, access="sequential", status="old" )

nline = 0
do
     read(unit=inputfile, fmt=*, end=100) temp
     nline = nline + 1
end do
100 continue

rewind(inputfile)

! allocate memory for arrays x0, y0
allocate(x0(1:nline), y0(1:nline))

! read in data from input file
do i = 1, nline
     read( unit=inputfile,fmt=*,iostat=stat ) x0( i ), y0( i )
end do

xmin = x0(1)
xmax = x0(nline)

open( unit=outputfile,file='gb.dat', status='replace',  action='write' )
write(outputfile,*) "./command input_file step sigma"
write(outputfile,*) " inputfile= ", input
write(outputfile,*) " step= ", step
write(outputfile,*) " sigma= ",sigma

pi = 2.0 * acos(0.0_dp)

xmin = xmin - 5.0*sigma
xmax = xmax + 5.0*sigma

x = xmin
do while(x .le. xmax)
     y = 0.0
     do i = 1, nline
       if( abs(x - x0(i)) .le. 3 * sigma ) then
         y = y + y0(i)/(sigma*sqrt(2*pi)) * exp(-1.0*(x - x0(i))**2.0 &
             /(2.0*sigma*sigma) )
       end if
     end do
    write( outputfile,fmt="(f9.2,1x,f15.8)" )  x,  y
    write( *,fmt="(f9.2,1x,f15.8)" ) x, y
     x = x + step
end do

! release memory
deallocate( x0, y0 )

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

wangyikeco

禁虫 (正式写手)

本帖内容被屏蔽

2楼2025-05-07 00:47:03
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 rlafite 的主题更新
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 为什么网上很多人说本周 12号出结果 +4 瞬息宇宙 2026-08-10 4/200 2026-08-11 02:02 by 旁观2020
[基金申请] 帮忙看看fileCode +4 wwncly 2026-08-10 8/400 2026-08-10 22:07 by demonstreets
[基金申请] 确定了,国自然21号放榜 +6 布布和一二 2026-08-10 7/350 2026-08-10 19:15 by 2000zf36392
[基金申请] 关于代码变化问题,想知道的进来 +17 且听虎啸 2026-08-07 24/1200 2026-08-10 18:35 by zhangduo2008
[基金申请] 应该是93bebmhtak前后十一个字符比较关键 +14 Lanmanbaby 2026-08-09 22/1100 2026-08-10 14:57 by wwncly
[基金申请] 8月时间戳变的,举个手。玩一下,释放压力 +11 archvillain 2026-08-04 13/650 2026-08-10 14:41 by seekfind
[基金申请] 好奇怪的filecode +4 布布和一二 2026-08-08 5/250 2026-08-10 14:20 by 冰心玉壶晴
[基金申请] 2026国自然放榜时间 +9 布布和一二 2026-08-08 9/450 2026-08-10 11:22 by xxxx2020
[基金申请] 这样的filecode谁见过 +11 布布和一二 2026-08-08 22/1100 2026-08-10 11:10 by wmfsnow
[基金申请] 面上项目filecode邪修 +5 西山十月 2026-08-09 7/350 2026-08-10 07:32 by 仁砚薪传
[基金申请] 关于filecode,很负责任的告诉大家 +6 爱看书的可乐 2026-08-08 7/350 2026-08-08 22:13 by a_niu
[基金申请] 国基金的申报应该改成非等额制,评价高的钱多评价低的钱少,但是增加资助率 +7 a089 2026-08-07 7/350 2026-08-08 18:05 by gltch
[基金申请] 关于filecode +4 布布和一二 2026-08-07 7/350 2026-08-07 22:55 by zhanghaozhu
[基金申请] 化学口download_prp&fileCode的固定段好像这几天一直没变,有变的大神么? +3 Tide man 2026-08-07 4/200 2026-08-07 22:39 by Tide man
[基金申请] filecode变化情况 +6 布布和一二 2026-08-07 22/1100 2026-08-07 14:45 by 且听虎啸
[基金申请] filecode +14 等待解的谜 2026-08-06 19/950 2026-08-07 12:20 by wlwhappy
[基金申请] 求各位大神看下 100+6 hpkpkpkp 2026-08-05 33/1650 2026-08-06 14:49 by zhiyanjiang
[基金申请] 影响面上的因素 +8 布布和一二 2026-08-05 11/550 2026-08-06 10:41 by 宝贝虫子
[基金申请] 好消息?这个有何含义??? +8 Tide man 2026-08-05 10/500 2026-08-05 16:14 by xmuxiaoyu
[基金申请] 纯娱乐,不喜欢勿喷 +7 Tide man 2026-08-04 10/500 2026-08-04 15:10 by loufangrui
信息提示
请填处理意见