24小时热门版块排行榜    

查看: 1811  |  回复: 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 的主题更新
普通表情 龙 兔 虎 猫 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 售SCI一区T0P文章,我:8.O.55.1.O.54,科目齐全,可+急 +4 CfXuS1rDhLYN 2026-09-28 4/200 2026-10-01 09:23 by Equinoxhua
[考博] 售SCI文章,我:8O.5.5.1O.54,科目全,可十急 (EPI+-1)(金币-50) +3 cqwQDCxMcL3I 2026-09-29 4/200 2026-09-30 16:52 by Z9YWQ5EAO3qp
[论文投稿] 售SCI一区T0P文章,我:8O.55.1.O.54,科目全,可伽急 +3 cqwQDCxMcL3I 2026-09-29 4/200 2026-09-30 16:45 by Z9YWQ5EAO3qp
[找工作] 售SCI一区T0P文章,我:8.O.55.1.O54,科目全,可伽急 +3 cqwQDCxMcL3I 2026-09-29 4/200 2026-09-30 16:33 by Z9YWQ5EAO3qp
[公派出国] 售SCI一区文章,我:8O5.5.1.O5.4,科目全,可伽急 +3 cqwQDCxMcL3I 2026-09-29 6/300 2026-09-30 16:26 by Z9YWQ5EAO3qp
[考研] 售SCI一区文章,我:8O5.5.1.O5.4,科目全,可伽急 +3 cqwQDCxMcL3I 2026-09-29 6/300 2026-09-30 16:14 by Z9YWQ5EAO3qp
[公派出国] 售一区SCI文章T0P,我:8O.551.O54,科目全,可十急 +3 cqwQDCxMcL3I 2026-09-29 4/200 2026-09-30 13:35 by C3vABopYbZJS
[有机交流] 同一个分子,一条来自文献,一条来自AI——不告诉你答案,你会选哪条? +4 tianxiaoxian 2026-09-28 7/350 2026-09-30 08:34 by 88817753
[考研] 售SCI一区T0P文章,我:8.O.55.1.O.54,科目齐全,可+急 +3 ZYXdhzDAy9ZX 2026-09-28 4/200 2026-09-29 16:37 by etmYJ6d2rquH
[博后之家] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +3 ZYXdhzDAy9ZX 2026-09-28 3/150 2026-09-29 16:30 by etmYJ6d2rquH
[硕博家园] 售SCI文章,我:8O.5.5.1O.54,科目全,可十急 +3 ZYXdhzDAy9ZX 2026-09-28 3/150 2026-09-29 16:03 by etmYJ6d2rquH
[论文投稿] 售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急 +4 tqUTOxClQUMF 2026-09-28 4/200 2026-09-29 15:15 by etmYJ6d2rquH
[博后之家] 售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急 +3 tqUTOxClQUMF 2026-09-28 3/150 2026-09-29 15:04 by etmYJ6d2rquH
[公派出国] 售SCI一区T0P文章,我:8.O.55.1.O54,科目全,可伽急 +3 tqUTOxClQUMF 2026-09-28 3/150 2026-09-29 14:58 by etmYJ6d2rquH
[公派出国] 售一区SCI文章T0P,我:8O.551.O54,科目全,可十急 +4 IDs3scOF0tjC 2026-09-28 5/250 2026-09-29 13:50 by etmYJ6d2rquH
[找工作] 售SCI一区文章,我:8.O.551.O.5.4,科目全,可伽急 +3 ZYXdhzDAy9ZX 2026-09-28 3/150 2026-09-29 06:28 by ZvyPK8n6Nfki
[硕博家园] 售SCI一区T0P文章,我:8.O.55.1.O.54,科目齐全,可+急 +3 tqUTOxClQUMF 2026-09-28 3/150 2026-09-28 23:46 by b8fCuTHqckEt
[硕博家园] 售SCI一区T0P文章,我:8.O.55.1.O.54,科目齐全,可+急 +3 CfXuS1rDhLYN 2026-09-28 4/200 2026-09-28 22:55 by ez6fGg9abYaj
[公派出国] 售SCI一区文章,我:8O5.5.1.O5.4,科目全,可伽急 +4 IDs3scOF0tjC 2026-09-28 4/200 2026-09-28 22:55 by ez6fGg9abYaj
[找工作] 售SCI文章,我:8O.5.5.1O.54,科目全,可十急 +3 IDs3scOF0tjC 2026-09-28 5/250 2026-09-28 22:32 by ez6fGg9abYaj
信息提示
请填处理意见