[Fortran] 纯文本查看 复制代码
program shujv1
implicit none
integer::NxD,NyD,NzD
integer,allocatable::poro(:)
! Local Variables
integer::i,j,k,l ! Counter
integer::stat
character::line*160
character::key*12
NxD=20
NyD=30
NzD=1
!allocate(poro(NxD*NyD*NzD))
! Execution Part
k=0
open(unit=4,file='.\shujv2\poro.dat',iostat=stat)
if(stat==0)then
do
read(4,'(a)',iostat=stat)line
! if (stat/=0)exit
if ((line(1:2)/='--').and.(line/=' ').and.(line(1:6)/='poro'))then
k=k+1
end if
end do
!rewind(4)
allocate(poro(k))
! if(stat==0)
do i=1,k
read(4,*)poro(i)
end do
! end if
do i=1,k
write(*,*)poro(i)
end do
endif
end program
[Fortran] 纯文本查看 复制代码
open(unit=4,file='.\poro.dat')
allocate(poro(NxD*NyD))
read(4,*)line
if ((line(1:2)/='/').and.(line/=' ').and.(line(1:6)/='poro'))then
k=k+1
read(4,*)poro
end if
close(4)
write(*,*)line
write(*,*)poro
end
[Fortran] 纯文本查看 复制代码
program shujv1
implicit none
real,allocatable::poro(:)
integer::k,stat
character(len=160) :: line
open(unit=4,file='.\poro.dat',iostat=stat)
if(stat/=0) stop
k=0
Do
read(4,'(a)',iostat=stat) line
if (stat/=0)exit
if ((line(1:2)/='--').and.(line/=' ').and.(line(1:6)/='poro')) k=k+1
End Do
allocate(poro(k))
rewind(4)
k = 0
Do
read(4,'(a)',iostat=stat) line
if (stat/=0)exit
if ((line(1:2)/='--').and.(line/=' ').and.(line(1:6)/='poro')) then
k = k + 1
read(line,*,iostat=stat) poro(k)
end if
End Do
write(*,'(f10.4)') poro
end program shujv1