program takeminenergy
implicit none
integer i,j,num,num1,num2,lines,k,num4
integer,allocatable::x(:),y(:)
real,allocatable::z(:),minz(:),minumz(:)
open(12,file='result.txt')!输入文件
open(13,file='a.txt') !输出文件
open(14,file='b.txt') !输出文件
num1=1
num2=0
write(*,*) 'How many lines:' !读取文件有多少行
read(*,*) lines
allocate (x(lines))
allocate (y(lines))
allocate (minz(lines))
allocate (minumz(lines))
do i=1,lines
read(12,"(12x,I4,12x,I6)") x(i),y(i)
if (y(i)== num1) then
num2=num2+1
else if (y(i) /= num1) then
y(num1)=num2
num1=num1+1
num2=1
end if
end do
write(*,*) num1
do j=1,num1
write(13,"(I6)") y(j) !获取数字相同那一列有多少个,比如全是数字1的共有39个
end do
close(13)
close(12)
open(13,file='a.txt')
open(12,file='result.txt')
open(15,file='c.txt') !输出文件
do j=1,num1
read(13,"(I6)") num4
write(*,*) num4
do k=1,num4
read(12,"(38x,f16.9)") z(k)
write(15,*)z(k)
end do
minz=minval(z)
write(14,"(f16.9)") minz
deallocate(z)
end do
end
图片1.jpg (198.64 KB, 下载次数: 253)
546.88 KB, 下载次数: 2
Program www_fcode_cn
Implicit None
real(kind=kind(0.0d0)) :: rE , rMinE
integer :: ierr , iRepeat , iPoint , pointerlast , iMinRepeat
character(len=12) :: c(5)
Open( 12 , File = 'result.txt' )
Open( 13 , File = 'out.txt' )
pointerlast = 1
rMinE = 1.0e30
Do
Read( 12 , * , ioStat=ierr ) c(1) , c(2) , iRepeat , c(3) , c(4) , iPoint , c(5) , rE
if ( ( ierr== 0 ) .and. (iPoint == pointerlast) ) then !// 同一个Point
if( rE <= rMinE ) then
rMinE = rE
iMinRepeat = iRepeat
end if
else !//不同Point
write(13,'(a,1x,a,1x,i4,2x,a,1x,a,i6,2x,a,f16.9)') trim(c(1)) , trim(c(2)) , iMinRepeat , &
trim(c(3)) , trim(c(4)) , pointerlast , trim(c(5)) , rMinE
pointerlast = iPoint
iMinRepeat = iRepeat
rMinE = rE
end if
if ( ierr /= 0 ) Exit
End Do
Close( 12 )
Close( 13 )
End Program www_fcode_cn
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |