⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 huad.for

📁 此程序用Fortran语言编写
💻 FOR
字号:
      program main
	  integer m,n,rx,ry
        real xmax,xmin,ymax,ymin
	  character*(40) infile,outfile,cmdfile
	  real,allocatable::dg(:,:),dgmean(:,:)
	  write(*,*)'input the name of cmdfilename'
	  read(*,*)cmdfile
	  call readcmd(cmdfile,infile,outfile,rx,ry)
	  call readmn(m,n,infile)
	  allocate(dg(m,n),dgmean(m,n))
	  call readin(infile,m,n,dg,xmax,xmin,ymax,ymin)
	  call hp(dg,m,n,rx,ry,dgmean)
	  call out(outfile,dgmean,m,n,xmax,xmin,ymax,ymin)
	  deallocate(dg,dgmean)
	end program
      
      subroutine readcmd(cmdfile,infile,outfile,rx,ry)
        character*(*) cmdfile,infile,outfile
        integer rx,ry
         open(unit=11,file=cmdfile,status='old')
	    read(11,*) rx,ry
	    read(11,*) infile
          read(11,*) outfile
        close(11)
	end subroutine

      subroutine readmn(m,n,infile)
	  character *(*)infile
	  integer m,n
	  open(12,file=infile)
	  read(12,*)
	  read(12,*)m,n
	  close(12)
	end subroutine


      subroutine readin(infile,m,n,dg,xmax,xmin,ymax,ymin)
	  integer m,n
	  real xmax,xmin,ymax,ymin
	  character*(*)infile
	  real dg(1:m,1:n)
	  open(15,file=infile)
        read(15,*)
        read(15,*)
	  read(15,*)xmin,xmax
	  read(15,*)ymin,ymax
        read(15,*)
	  read(15,*)((dg(i,j),i=1,m),j=1,n)
	  close(15)
	end subroutine

	subroutine hp(dg,m,n,rx,ry,dgmean)
	  integer m,n,rx,ry,s,t
	  real dg(1:m,1:n),dgmean(1:m,1:n)
	  do k=1,4
	    do j=1,n,1
	      do i=1,m,1
	       number=0
	       sum=0.0
	        do s=max(1,i-rx),min(m,i+rx)
	          do t=max(1,j-ry),min(n,j+ry)
	            sum=sum+dg(s,t)
	            number=number+1
	          end do
	        end do
	       dgmean(i,j)=sum/number
	      end do
	    end do
	    dg=dgmean
	  end do
	end subroutine
	  
      subroutine out(outfile,dgmean,m,n,xmax,xmin,ymax,ymin)
	  integer m,n
	  real xmax,xmin,ymax,ymin,dmax,dmin
	  character *(*)outfile
	  real dgmean(1:m,1:n)
	  dmax=-huge(dmax)
	  dmin=huge(dmin)
	  do i=1,m
	    do j=1,n
	      dmax=max(dmax,dgmean(i,j))
	      dmin=min(dmin,dgmean(i,j))
	    end do
	  end do
	  open(20,file=outfile)
	  close(20,status='delete')
	  open(20,file=outfile)
	  write(20,'(a)') 'DSAA'
	  write(20,*)m,n
	  write(20,*) xmin,xmax
	  write(20,*) ymin,ymax
	  write(20,*) dmin,dmax
        write(20,*)((dgmean(i,j),i=1,m),j=1,n)
	  close(20)
	end subroutine



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -