打开文本文件中每行的读取列并执行(窗口)?

时间:2016-02-13 08:15:58

标签: arrays fortran multiple-columns

这是我修改过的Fortran代码。 问题是代码无法打开文本文件。

我收到以下错误:

The message is: RunCode: Fail to run.. At line 123 of file <unit = 90, file = 'cunnette_xyz.txt'> Fortran runtime error: End of file

文件低于4368行(三列的小数相同):

602340.440000,129706.190000,28.892939
602340.880000,129706.390000,28.955128
602884.500000,128780.700000,29.876873
602884.380000,128781.190000,29.875114
602884.250000,128781.660000,29.885448
602884.130000,128782.150000,29.895996
602883.940000,128782.630000,29.899380
602883.810000,128783.120000,29.903221
602883.690000,128783.590000,29.907070
602883.560000,128784.080000,29.910931
602883.440000,128784.560000,29.914803
602883.310000,128785.050000,29.918684
602883.190000,128785.520000,29.922575
602883.060000,128786.010000,29.926479
602882.940000,128786.490000,29.930393
602882.810000,128786.980000,29.934317
602882.630000,128787.450000,29.938253
602882.500000,128787.940000,29.942202
.
.
.

该计划是:      ----------------------------

  USE BIEF
  USE DECLARATIONS_TELEMAC2D
  IMPLICIT NONE
  INTEGER LNG,LU, K, ITRAC,I, NSOM,J, NLINE, NDOWN
  DOUBLE PRECISION, PARAMETER:: BATHY_RADIER_up= 29.84D0
  DOUBLE PRECISION, PARAMETER:: DEPTH_up = 2.15D0
  REAL A(5000),B(5000),C(5000)
  DOUBLE PRECISION XPOLYD(14), YPOLYD(14), INPOLYD(14)
  COMMON/INFO/LNG,LU
  DOUBLE PRECISION XPOLY(6), YPOLY(6),COTE_RADIER_up

   NSOM = 6
   XPOLY(1) = 602883.13
   XPOLY(2) = 602886.15
   XPOLY(3) = 602887.15
   XPOLY(4) = 602905.46
   XPOLY(5) = 602902.52
   XPOLY(6) = 602884.13


   YPOLY(1) = 128779.99
   YPOLY(2) = 128780.80
   YPOLY(3) = 128777.12
   YPOLY(4) = 128741.21
   YPOLY(5) = 128739.75
   YPOLY(6) = 128775.96


  AT = 0.D0


  CALL OS( 'X=0     ' , X=U )
  CALL OS( 'X=0     ' , X=V )



  IF(CDTINI(1:10).EQ.'COTE NULLE'.OR.
 *   CDTINI(1:14).EQ.'ZERO ELEVATION') THEN
    CALL OS( 'X=C     ' , H , H  , H , 0.D0 )
    CALL OS( 'X=X-Y   ' , H , ZF , H , 0.D0 )
  ELSEIF(CDTINI(1:14).EQ.'COTE CONSTANTE'.OR.
 *       CDTINI(1:18).EQ.'CONSTANT ELEVATION') THEN
    CALL OS( 'X=C     ' , H , H  , H , COTINI )
    CALL OS( 'X=X-Y   ' , H , ZF , H , 0.D0   )
  ELSEIF(CDTINI(1:13).EQ.'HAUTEUR NULLE'.OR.
 *       CDTINI(1:10).EQ.'ZERO DEPTH') THEN
    CALL OS( 'X=C     ' , H , H  , H , 0.D0  )
  ELSEIF(CDTINI(1:17).EQ.'HAUTEUR CONSTANTE'.OR.
 *       CDTINI(1:14).EQ.'CONSTANT DEPTH') THEN
    CALL OS( 'X=C     ' , H , H  , H , HAUTIN )
  ELSEIF(CDTINI(1:13).EQ.'PARTICULIERES'.OR.
 *       CDTINI(1:10).EQ.'PARTICULAR'.OR.
 *       CDTINI(1:07).EQ.'SPECIAL') THEN

  COTE_RADIER_up = BATHY_RADIER_up + DEPTH_up

   input for coordinates of the downstream
    NDOWN = 14

  XPOLYD(1) = 602883.13
  XPOLYD(2) = 602886.15
  XPOLYD(3) = 602864.47
  XPOLYD(4) = 602837.90
  XPOLYD(5) = 602821.91
  XPOLYD(6) = 602649.77
  XPOLYD(7) = 602634.35
  XPOLYD(8) = 602345.08
  XPOLYD(9) = 602326.07
  XPOLYD(10) = 602619.31
  XPOLYD(11) = 602638.33
  XPOLYD(12) = 602811.64
  XPOLYD(13) = 602831.52
  XPOLYD(14) = 602857.16


  YPOLYD(1) = 128779.99
  YPOLYD(2) = 128780.80
  YPOLYD(3) = 128867.74
  YPOLYD(4) = 128936.74
  YPOLYD(5) = 128953.95
  YPOLYD(6) = 129105.43  
  YPOLYD(7) = 129143.43
  YPOLYD(8) = 129713.38
  YPOLYD(9) = 129708.26
  YPOLYD(10) = 129136.41
  YPOLYD(11) = 129094.72 
  YPOLYD(12) = 128941.16      
  YPOLYD(13) = 128931.09
  YPOLYD(14) = 128865.81


   DO 10 J=1,NPOIN 
    IF(INPOLY(X(J),Y(J),XPOLY,YPOLY,NSOM)) THEN
          write(lu,*) 'upstream is recognized....'


          H%R(J)=MAX(0.D0,COTE_RADIER_up-ZF%R(J))
          U%R(J)=0.0D0
    ELSE
PRINT *, 'opening file'
  OPEN(unit =90, FILE = 'cunnette_xyz.txt', FORM ='FORMATTED')
  PRINT *, 'read now'
  READ (90, *)NLINE
  PRINT *, 'DO now'


     READ (90, *) A(K),B(K),C(K)
      IF(INPOLY(X(J),Y(J),XPOLYD,YPOLYD,NDOWN)) THEN
        DO K=1,NLINE
          H%R(K)=0.45D0
          U%R(K)=0.D0
        ENDDO
       ELSE
        H%R(J)=0.0D0
        U%R(J)=0.0D0
       ENDIF
    ENDIF
      write(lu,*) 'downstream ....',K,H%r(K)



10    CONTINUE

  ELSE
    IF(LNG.EQ.1) THEN
    WRITE(LU,*) 'CONDIN : CONDITION INITIALE NON PREVUE : ',CDTINI
    ENDIF
    IF(LNG.EQ.2) THEN
    WRITE(LU,*) 'CONDIN: INITIAL CONDITION UNKNOWN: ',CDTINI
    ENDIF
    STOP
  ENDIF


  IF(NTRAC.GT.0) THEN
    DO ITRAC=1,NTRAC
      CALL OS( 'X=C     ' , X=T%ADR(ITRAC)%P , C=TRAC0(ITRAC) )
    ENDDO
  ENDIF



  CALL OS( 'X=C     ' , VISC , VISC , VISC , PROPNU )



  RETURN
  END           

0 个答案:

没有答案