[Fortran] 纯文本查看 复制代码 Program Fcode
Implicit None
Character(len=512) :: cStr
integer :: k
Open(12,File="Shielding Material Handbook.dat")
Open(21,File="文档1")
Open(22,File="文档2")
Open(23,File="文档3")
Do
Read(12,"(a512)",ioStat=k) cStr
if(k/=0) exit
If( cStr(1:7) == "Density" ) then
k = index(cStr,"=")
if(k>3) write(21,*) trim(adjustl(cStr(k+1:)))
ElseIf( cStr(1:8) == "Neutrons" ) then
call PutRows(12,22)
ElseIf( cStr(1:7) == "Photons" ) then
call PutRows(12,23)
End If
End Do
Close(12)
Close(21)
Close(22)
Close(23)
contains
Subroutine PutRows(fuIn,fuOut)
integer :: fuIn , fuOut , j , k
real :: r
Do
read(fuIn,*,ioStat=k) j , r
if(k/=0) then
backspace(fuIn)
return
end if
write(fuOut,*) j , r
End Do
End Subroutine PutRows
End Program Fcode |