我想定义一个块数组,每个块将包含一个不同大小的节点数组。所以我写了一个如下的程序,但它不起作用。我想知道我怎么能在 FORTRAN 中做到这一点?还有其他更好的方法吗?基本的困难是使它们可分配!
program Mesh
implicit none
integer::i
type node
double precision::x,y
end type node
type block
integer::NX,NY
integer::ENB,WNB,SNB,NNB
integer::BlockType
type(node),dimension(:,:),allocatable::nodes
end type block
type(block),dimension(:),allocatable::blocks !Error:Syntax Error in Data Declaration
allocate(blocks(1:9)) ! here using 9 just to simplify it,error: allocate-object is not a nonprocedure pointer or allocatable object
do i=1,sizeof(blocks)
blocks(i)%NX=i*2 !Here I want to read in some value, but just use i*2 to simplify
blocks(i)%NY=i*2 !Here I want to read in some value, but just use i*2 to simplify
allocate(blocks(i)%nodes(0:NX,0:NY)) !error: not allocatable object either
end do
end program