本帖最后由 愤怒的三炮 于 2023-3-26 02:04 编辑
我想用这个派生类型数组去读取SEGY文件,但是提示错误
[Fortran] 纯文本查看 复制代码 type trace
sequence
type(segy_trace_head):: header
real(4),dimension(:),allocatable:: idata
end type
type(segy_reel_head):: reel_head
type(trace),dimension(:),allocatable:: traces
integer:: fp,fid_segy,fid_traces
integer:: i
open(newunit=fid_segy,file='D:/Example.SEGY',form='unformatted',access='stream',convert='big_endian')
allocate(traces(500))
do i = 1,500
allocate(traces(i)%idata(6000))
end do
read(fid_segy) reel_head
do i = 1, 500
read(fid_segy) traces(i) ! 读取前500道
end do
Error: Data transfer element at (1) cannot have ALLOCATABLE components unless it is processed by a defined input/output procedure
出错位置在第23行,该怎么处理呢?
|