program RDMESH

      IMPLICIT   NONE
      INTEGER*4  NUMNP, NUMEL 
    integer*4, allocatable :: IEN(:,:), IN(:,:)
      INTEGER*4  I, IDUM, N, NDUM                     
      REAL*8, allocatable:: X(:,:)
C
      OPEN(21,FILE='mesh.dat')
C
      READ(21,*) NUMNP, NUMEL

      READ(21,*) (IDUM, X(1,I), X(2,I),I=1,NUMNP)
c   

      READ(21,*) (NDUM, (IEN(I, N), I = 1, 4), (IN(I, N), I = 1, 4),
     &    N=1,NUMEL)

      CLOSE(21)
      END

其中mesh.dat数据为
      7       5 numnp , numel
    1      0.00000E+00   0.00000E+00   1   node, x , y , ref. num. 
    2      0.00000E+00   0.35803E-03   1   node, x , y , ref. num. 
    3      0.00000E+00   0.70174E-03   1   node, x , y , ref. num. 
    4      0.00000E+00   0.10317E-02   1   node, x , y , ref. num. 
    5      0.00000E+00   0.13485E-02   1   node, x , y , ref. num. 
    6      0.00000E+00   0.16526E-02   1   node, x , y , ref. num. 
    7      0.00000E+00   0.19445E-02   1   node, x , y , ref. num. 
    1      1     32     33      2   2   0   0   1   elt , nodes, edges ref. num. 
    2      2     33     34      3   0   0   0   1   elt , nodes, edges ref. num. 
    3      3     34     35      4   0   0   0   1   elt , nodes, edges ref. num. 
    4      4     35     36      5   0   0   0   1   elt , nodes, edges ref. num. 
    5      5     36     37      6   0   0   0   1   elt , nodes, edges ref. num. 

编译没有问题,程序运行出现错误提示:forrtl: severe (161): Program Exception - array bounds exceeded,不知道什么原因,请大家多多指教,谢谢

PS:忘了没有对动态数组分配地址,所以我在 READ(21,*) NUMNP, NUMEL后面添加了语句
ALLOCATE (X(2,NUMNP),IEN(4,NUMEL),IN(4,NUMEL))
好像运行还会出错:
forrtl: severe<59>: list-directed I/O syntax error, unit 21