VBS_CS 发表于 2016-5-19 17:31:22

读写错误,请帮忙。

    PROGRAM TEST_WRNF
    IMPLICIT NONE
    Real, Dimension(9,62)::EPa
    CALL EllipseP(EPa)
    END

         Subroutine EllipseP(EPa)
         IMPLICIT NONE
         Real,    Intent(OUT), Dimension(9,62) :: EPa
         Integer :: I, J
         EPa=0.
         OPEN (103 ,FILE='CEP.txt', STATUS='UNKNOWN')
         Call Notes103
         Do I=1,62
             Read(103,*) (EPa(J,I), J=1,9)
         Enddo
         CLOSE(103)
         EndSubroutineEllipseP

      Subroutine Notes103
      CHARACTER*1 AX(80)
11    Read(103,'(80A1)')(AX(I),I=1,80)
      Do I=1,80
          If(AX(I)==']') Return
      Enddo
      GOTO 11
      END
以下为文本信息:
[ρ/Rwβ       m   n       mn   a/b    Ae      Be       AeBe]
   0.05   12.84   5.22   0.352   1.84   14.830.290   0.0195   5.66
   0.06   14.07   5.00   0.361   1.81   13.850.295   0.0213   6.27
   0.07   15.20   4.79   0.369   1.77   12.980.297   0.0229   6.81
   0.08   16.26   4.57   0.378   1.73   12.090.297   0.0245   7.27
   0.09   17.25   4.36   0.386   1.68   11.300.294   0.0261   7.67


fcode 发表于 2016-5-19 21:12:48

你把很多问题想复杂了。

Program test_wrnf
implicit none
real :: epa(9,5)
call EllipseP(epa)
contains
subroutine EllipseP(epa)
    implicit none
    real,intent(out) :: epa(:,:)
    integer :: i, j
    epa=0.
    open (103 ,file='cep.txt')
    call notes103()
    do i = 1 , size(epa,dim=2)
      read(103,*) epa(:,i)
    enddo
    close(103)
end subroutine EllipseP
subroutine notes103
    character(len=80) :: ax
    Do
      read(103,'(a80)') ax
      if ( index( ax , ']' ) > 0 ) return
    End Do
end subroutine notes103
End Program test_wrnf

左耳北上南 发表于 2016-6-13 17:28:44

第14行,你这里是有5行数据可以读入,不能写成62行。这里报错。
还有二楼的程序比你的简洁而且适用性广。
页: [1]
查看完整版本: 读写错误,请帮忙。