Arrays fortran中数组引用的形式无效

Arrays fortran中数组引用的形式无效,arrays,forms,fortran,Arrays,Forms,Fortran,我正在用FORTRAN编写一个代码来读取STARCD格式的网格文件(has.cel、.vrt和.bnd)。我正在尝试使用计数器和指针数组来计算文件中的顶点数和单元格数,以便以后很容易定义单元格的邻域。请你看一下代码并纠正我,我在(1)处得到一个错误,数组引用的形式无效 此处显示了所有带有icounter的行的错误。为了给大家介绍正在做的事情,我刚刚声明了我使用的类型和变量,我正在读取.vrt(nov).cel(noc)和.bnd(bnd)三个文件,并定义数据结构,其中.vrt有4列,.cel有5

我正在用FORTRAN编写一个代码来读取STARCD格式的网格文件(has.cel、.vrt和.bnd)。我正在尝试使用计数器和指针数组来计算文件中的顶点数和单元格数,以便以后很容易定义单元格的邻域。请你看一下代码并纠正我,我在(1)处得到一个错误,数组引用的形式无效

此处显示了所有带有icounter的行的错误。为了给大家介绍正在做的事情,我刚刚声明了我使用的类型和变量,我正在读取.vrt(nov).cel(noc)和.bnd(bnd)三个文件,并定义数据结构,其中.vrt有4列,.cel有5列

program reader
implicit none

type::node
real,allocatable,dimension(:)::point1,icounter,vrt
end type 

type::elemtype
integer,allocatable,dimension(:)::quad,refback
integer,allocatable,dimension(:)::tri
end type 

type::cel
integer,allocatable,dimension(:)::cell,ishape,reffwd
end type 

type::boundnode
integer,allocatable,dimension(:)::bnode
end type 

type::boundarycell
integer,allocatable,dimension(:)::bcell
end type 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

type(node),allocatable,dimension(:)::ivrt 
type(elemtype),allocatable,dimension(:)::iquad
type(elemtype),allocatable,dimension(:)::itri 
type(cel),allocatable,dimension(:)::icell 
type(boundnode),allocatable,dimension(:)::ibnode 
type(boundarycell),allocatable,dimension(:)::ibcell 

integer::nov,noc,bnd,nbnd,i,j,k,count1,count2,numquad,flag,numtri
integer::usercell,tcell,cindex
integer::celltype,n,m

integer,allocatable,dimension(:,:)::qedg1,qedg2,qedg3,qedg4
integer,allocatable,dimension(:,:)::tedg1,tedg2,tedg3,tedg4
integer,allocatable,dimension(:)::ctype
integer,allocatable,dimension(:)::quadvert 
integer,allocatable,dimension(:)::trivert 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

CALL SYSTEM("wc  STAR.vrt > NO_V")
OPEN (UNIT=10,FILE='NO_V',STATUS="OLD",ACTION="READ")
READ (10,"(i6)")nov
close(10)

print *, nov

CALL SYSTEM("wc  STAR.cel > NO_C")
OPEN (UNIT=10,FILE='NO_C',STATUS="OLD",ACTION="READ")
READ (10,"(i6)")noc
close(10)

print *, noc 

CALL SYSTEM("wc  STAR.bnd > NO_B")
OPEN (UNIT=10,FILE='NO_B',STATUS="OLD",ACTION="READ")
READ (10,"(i6)")nbnd
close(10)

print *, nbnd

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

allocate(ivrt(nov))
do i=1,nov
  allocate(ivrt(i)%vrt(1:4))
  allocate(ivrt(i)%icounter(1))
end do

allocate(icell(noc))
do i=1,noc
  allocate(ivrt(i)%icounter(1)) 
  allocate(icell(i)%cell(1:5))
  allocate(icell(i)%ishape(1))
  allocate(icell(i)%reffwd(1))
end do

allocate(ibnode(nbnd))
do i=1,bnd
  allocate(ibnode(i)%bnode(1:3))
end do

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

open(unit=10,file="STAR.vrt",status="old",action="read")
do i = 1,nov
  read(10,*)ivrt(i)%vrt(1), ivrt(i)%vrt(2), ivrt(i)%vrt(3), ivrt(i)%vrt(4) 
  !print *, ivrt(i)%vrt(1), ivrt(i)%vrt(2), ivrt(i)%vrt(3), ivrt(i)%vrt(4)
end do
close (10)

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

open(unit=10,file="STAR.cel",status="old",action="read")
do i=1,noc
  read(10,*)icell(i)%cell(1),icell(i)%cell(2),icell(i)%cell(3),icell(i)%cell(4),icell(i)%cell(5)
  ivrt(icell(i)%cell(2)%icounter(1)=ivrt(icell(i)%cell(2)%icounter(1)+1
  ivrt(icell(i)%cell(3)%icounter(1)=ivrt(icell(i)%cell(2)%icounter(1)+1
  ivrt(icell(i)%cell(4)%icounter(1)=ivrt(icell(i)%cell(2)%icounter(1)+1
    if (icell(i)%cell(4).ne.icell(i)%cell(5))then
    ivrt(icell(i)%cell(5)%icounter(1)=ivrt(icell(i)%cell(2)%icounter(1)+1
    end if
end do
close(10)

do i=1,nov
  allocate(ivrt(i)%point1(ivrt(i)%icounter(1)))
end do

ivrt(:)%icounter(:)=0

open(unit=10,file="STAR.cel",status="old",action="read")
do i=1,noc
  read(10,*)icell(i)%cell(1),icell(i)%cell(2),icell(i)%cell(3),icell(i)%cell(4),icell(i)%cell(5)
  ivrt(icell(i)%cell(2)%icounter(1)=ivrt(icell(i)%cell(2)%icounter(1)+1
  ivrt(icell(i)%cell(3)%icounter(1)=ivrt(icell(i)%cell(2)%icounter(1)+1
  ivrt(icell(i)%cell(4)%icounter(1)=ivrt(icell(i)%cell(2)%icounter(1)+1

  ivrt(icell(i)%cell(2))%point1(ivrt(icell(i)%cell(2))%icounter(1))=i
  ivrt(icell(i)%cell(3))%point1(ivrt(icell(i)%cell(2))%icounter(1))=i
  ivrt(icell(i)%cell(4))%point1(ivrt(icell(i)%cell(2))%icounter(1))=i
    if (icell(i)%cell(4).ne.icell(i)%cell(5))then
    ivrt(icell(i)%cell(5))%point1(ivrt(icell(i)%cell(2))%icounter(1))=i
    ivrt(icell(i)%cell(5))%icounter(1)=ivrt(icell(i)%cell(2))%icounter(1)+1
    end if
end do
close(10)

缺少两个括号。。。你是说:

ivrt( icell(i)%cell(2)%icounter(1) ) = ivrt( icell(i)%cell(2)%icounter(1)+1 )
                                   ^                                        ^
或:

这个错误在整个代码中重复了好几次

就像我同意缺少括号一样。然而,还有另一个问题

在类型
cel
的定义中,组件
cell
是一个整数数组:

type :: cel
  integer, allocatable, dimension(:) :: cell, ishape, reffwd
end type
type(cel), allocatable, dimension(:) :: icell
因此不能有一个引用
icell(i)%cell(2)%…

那么,
cel
的声明也许应该是

type :: cel
  type(node), allocatable, dimension(:) :: cell
  ! Also components ishape, reffwd of some type.
end type

end type

然后对括号进行额外更正。

不确定将代码粘贴到此站点是否出错,但
ivrt(icell(i)%cell(2)%icounter(1)
需要一个右括号。
type :: cel
  integer, allocatable, dimension(:) :: cell, ishape, reffwd
end type
type(cel), allocatable, dimension(:) :: icell
type :: cel
  type(node), allocatable, dimension(:) :: cell
  ! Also components ishape, reffwd of some type.
end type

end type