尝试重现旧代码

时间:2015-07-03 08:41:11

标签: fortran fortran77

我想问一下我的代码中的错误

Incompatible types in DATA statement at (1); attempted conversion of CHARACTER(1) to INTEGER(4)

发生在这一行:

      DATA TXT/6*'    '/

因为我对Fortran77缺乏经验,你能告诉我如何解决这个问题吗?

为了更清楚地澄清我的问题,我试图从一本书中复制旧代码(我也在这里附上),该书中的代码使用打字机键入(我想是这样)。我试图修复固定格式中的大部分错误,但仍然有3个部分我完全听不懂:

      DATA TXT/6*'    '/           (line 7)
        READ(1*IR) W,KX,KY,KZ       (line 105)

在书中,该行是

READ(1'IR) W,KX,KY,KZ

但我认为这是不同的角色,也是一个错误。请查看下面的附件 Book file 我还附上我的完整代码 Code

       PROGRAM DDNS
      IMPLICIT REAL*8 (A-H,O-Z)
       REAL*8 LNN,LNJ,LJJ
      INTEGER*4 TLAT(8)/' SC',' FCC',' BCC',' HCP',' ST',' BCT','AL-U'
     1 ,'TRIG'/
      INTEGER TXTS(15),TXTP(20,6),TXTC(15),TXT(6),POINT
      DATA TXT/6*'    '/
       COMMON/B1/ E(1000),EM(1001),CNT(1001),SNT(1001),DE,V,BOA,COA,NE,
     1 NPT,NL,NEMAX,NT,STS(1001,4),CTS(1001,4),STP(1001,4),CTP(1001,4),
     2 STD(1001,4),CTD(1001,4),STF(1001,4),CTF(1001,4),FTS(1000,4),
     3 FTP(1000,4),FTD(1000,4),FTF(1000,4),
     3 N1(1000),N2(1000),N3(1000),N4(1000),N5(1000),N6(1000),N7(1000)
       DIMENSION ENY(18),OMN(18),OMJ(18),FINSQ(18),FIJSQ(18),SWS(6),
     , SWSSQ(6),LNN(18),LNJ(18),LJJ(18)
   1  FORMAT(F10.6,I5)
   2  FORMAT(2F10.6,3I5,2X,3I1)
   3  FORMAT(11F7.6)
   4  FORMAT(1H,3X,F8.4,2F10.5,3X,2F10.5,3X,2F10.5,3X,2F10.5,
     1 3X,2F10.5)
   6  FORMAT(1H1,10X,'DENSITY OF STATES PROGRAMME FOR',A4,' LATTICE',/
     1 /11X,'BOA,COA,V,EB,EF,NE,NPT,NPX,NPY,NPZ,NB1,NB2',//,11X,5F10.6,
     1 2I5,5I3,//)
   7  FORMAT(1H,10X,I4,5X,2F10.6,2I5)
   8  FORMAT(1H,15F7.4)
   9  FORMAT(1H,10X,'ENERGY RANGE GENERATED AUTOMATICALLY,EB = ',
     1  F10.6,' EF =',F10.6,' DE=',F10.6,' NE=',I5,//)
  10    FORMAT(1H1,10X,'DENSITY OF STATES FOR ',A4,' IN',6A4,///,8X,'E',
     1  7X,'NOS',7X,'DOS',10X,'S-NOS',5X,'S-DOS',8X,'P-NOS',5X,'P-DOS',
     2  8X,'D-NOS',5X,'D-DOS',8X,'F-NOS',5X'F-DOS',//)
  11    FORMAT(1H1)
  12   FORMAT(1H,///,11X,20A4,//,11X,'SWS',F10.6,///,11X,'ENY',7X,'OMN',
     1 7X,'OMJ',6X,'FINSQ',5X,'FIJSQ',6X,'LNN',7X,'LNJ',7X,'LJJ',//)
  13    FORMAT(1H,5X,8F10.6)
  14    FORMAT(1H,10X,15A4,/)
  15    FORMAT(1H,10X,'BAND NO',6X,'EMIN',6X,'EMAX',5X,'N1',3X,'N2',//)
C
C        READ TEXTS /DENTIFYING STRUCTURE CONSTANTS AND CORRECTION
C        MATRICES USED IN BAND CALCULATION
C
        READ(1) TXTS(1),TXTS(2),TXTS(3),TXTS(4)
        READ(1) TXTS(5),TXTS(6),TXTS(7),TXTS(8)
        READ(1) TXTS(9),TXTS(10),TXTS(11),TXTS(12)
        READ(1) TXTS(13),TXTS(14),TXTS(15),NPOINT
        READ(1) TXTC(1),TXTC(2),TXTC(3),TXTC(4)
        READ(1) TXTC(5),TXTC(6),TXTC(7),TXTC(8)
        READ(1) TXTC(9),TXTC(10),TXTC(11),TXTC(12)
        READ(1) TXTC(13),TXTC(14),TXTC(15),NL
        READ(1) NQ,NLM,NLMQ,NT
        READ(1) NPX,NPY,NPZ,LAT
        READ(1) NPT1,BOA,COA,DUM1
C
        READ(5,2) EB,EF,NE,NB1,NB2,NOPRT,NOWRT,MODE
        DE=(EF-EB)/(NE-1)
        CALL TGEN(LAT,NPX,NPY,NPZ)
        WRITE(6,6) TLAT(LAT),BOA,COA,V,EB,EF,NE,NPT,NPX,NPY,NPZ,NB1,NB2
C
C        READ POTENTIAL PARAMETERS USED IN BAND CALCULATION
C
        INL=-NL
        DO 35 KT=1,NT
        INL=INL+NL
        READ(1) TXTP(1,KT),TXTP(2,KT),TXTP(3,KT),TXTP(4,KT)
        READ(1) TXTP(5,KT),TXTP(6,KT),TXTP(7,KT),TXTP(8,KT)
        READ(1) TXTP(9,KT),TXTP(10,KT),TXTP(11,KT),TXTP(12,KT)
        READ(1) TXTP(13,KT),TXTP(14,KT),TXTP(15,KT),TXTP(16,KT)
        READ(1) TXTP(17,KT),TXTP(18,KT),TXTP(19,KT),TXTP(20,KT)
        READ(1) SWO,SWS(KT),TXT(KT)
        DO 35 IL=1,NL
        I=INL+IL
        READ(1) ENY(I),OMN(I),OMJ(I),FINSQ(I)
        READ(1) FIJSQ(I),LNN(I),LNJ(I),LJJ(I)
  35    CONTINUE
C
        WRITE(6,14) TXTS
        WRITE(6,14) TXTC
C
C        WRITE INFORMATION FOR STATE DENSITY DATA SET
C
        WRITE(2) TXTS,TXTC,SWO,NL,NQ,NLM,NLMQ,NT
        WRITE(2) NPX,NPY,NPZ,LAT,NPT,BOA,COA,DUM1
        INL=-NL
        DO 26 KT=1,NT
        INL=INL+NL
        WRITE(6,12)(TXTP(I,KT),I=1,20),SWS(KT)
        WRITE(2)(TXTP(I,KT),L= 1,20),SWS(KT),TXT (KT)
        DO 26 IL=1,NL
        I=INL+IL
       WRITE(6,13) ENY(I),OMN(I),OMJ(I),FINSQ(I),FIJSQ(I),LNN(I),LNJ(I),
     1 LJJ(I)
        WRITE(2) ENY(I),OMN(I),OMJ(I),FINSQ(I),FIJSQ(I),LNN(I),LNJ(I),
     1   LJJ(I)
  26    CONTINUE
C
        WRITE(6,11)
        NLMQP=NLMQ+1
        IREC1=11+NT*6+NT*NL*2
C
C        CALCULATE STATE DENSITY BAND BY BAND
C
        DO 21 LB=NB1,NB2
        IR=IREC1+LB-NLMQP
        IF(NL.EQ.4) GO TO 30
        DO 25 IP=1,NPT
        IR=IR+NLMQP
        READ(1*IR) W,KX,KY,KZ
  25    READ(1) E(IP),(FTS(IP,KT),FTP(IP,KT),FTD(IP,KT),KT=1,NT)
        GO TO 31
  30    DO 32 IP=1,NPT
        IR=IR+NLMQP
        READ(1*IR) W,KX,KY,KZ
  32    READ(1) E(IP),(FTS(IP,KT),FTP(IP,KT),FTD(IP,KT),FTF(IP,KT),
     1 KT=1,NT)
C
C        FIND MAX AND MIN ENERGY OF BAND NUMBER LB
C
  31    EMAX=-100.D0
        EMIN=100.D0
        DO 22 LP=1,NPT
        ET=E(LP)
        IF(ET.GE.EMIN) GO TO 23
        EMIN=ET
  23    IF(ET.LE.EMAX) GO TO 22
        EMAX=ET
  22    CONTINUE
C
C        MODIFY ENERGY RANGE IF REQUESTED
C
        IF(LB.NE.NB1) GO TO 33
        IF(MODE.EQ.1) GO TO 41
        IEB=EMIN*10.D0
        IF(EMIN.LT.0.D0) IEB=IEB-1
        EBB=IEB/10.D0
        EF= (EF-EB)+ EBB
        EB=EBB
        WRITE(6,9) EB,EF,DE,NE
C
  41    WRITE(2) EB,EF,DE,NE,NB1,NB2
C
C        CONSTRUCT ENERGY MESH
C
        DO 20 LE = 1,NE
  20    EM(LE)=EB+(LE-1)*DE
        WRITE(6,15)
  33    IF(EMAX.LE.EB) GO TO 38
        IF(EMIN.GE.EF) GO TO 42
        EMAX=DMIN1(EMAX,EM(NE-1))
        NEMAX=(EMAX-EB)/DE
        NEMAX=NEMAX+2
        IF(NEMAX.GT.NE) NEMAX=NE
        NEMIN=(EMIN-EB)/DE
        IF(EMIN.LT.EB) NEMIN=-1
        NEMIN =NEMIN+2
        GO TO 39
  38    NEMIN=1
        NEMAX=1
C
  39    WRITE(6,7) LB,EMIN,EMAX,NEMIN,NEMAX
        IF(NOWRT.EQ.O) GO TO 40
        WRITE(6,8) (E(I),I=1,NPT)
        WRITE(6,11)
  40    CONTINUE
C
C        PERFORM K-SPACE SUMMATIONS
C
        IF(LAT.EQ.2) GO TO 34
        IF(LAT.EQ.4) GO TO 36
        IF(LAT.EQ.8) GO TO 36
        CALL DENS
        GO TO 37
  34    CALL FDENS
        GO TO 37
  36    CALL HDENS
C
  37    CONTINUE
        IF(NEMAX.GE.NE) GO TO 21
        NEP=NEMAX+1
        DO 28 LE=NEP,NE
        SNT(LE)=SNT(NEMAX)
        DO 28 KT=1,NT
        STS(LE,KT)=STS(NEMAX,KT)
        STP(LE,KT)=STP(NEMAX,KT)
        STD(LE,KT)=STD(NEMAX,KT)
        IF(NL.LT.4) GO TO 28
        STF(LE,KT)=STF(NEMAX,KT)
  28    CONTINUE
  21    CONTINUE
C
C       WRITE DENSITIES ON SYSOUT AND FILE 2
C
  42   IF(NOPRT.EQ.0) GO TO 43
       DO 27 KT= 1,NT
       WRITE(6,10) TXT(KT),TXT
  27   WRITE(6,4) (EM(LE),SNT(LE),CNT(LE),STS(LE,KT),CTS(LE,KT),
     1STP(LE,KT),CTP(LE,KT),STD(LE,KT),CTD(LE,KT),STF(LE,KT),CTF(LE,KT),
     2 LE=1,NE)
  43   WRITE(2) (SNT(LE),LE=1,NE)
       WRITE(2) (CNT(LE),LE=1,NE)
        DO 29 KT=1,NT
        WRITE(2) (STS(LE,KT),LE=1,NE)
        WRITE(2) (CTS(LE,KT),LE=1,NE)
        WRITE(2) (STP(LE,KT),LE=1,NE)
        WRITE(2) (CTP(LE,KT),LE=1,NE)
        WRITE(2) (STD(LE,KT),LE=1,NE)
        WRITE(2) (CTD(LE,KT),LE=1,NE)
        IF(NL.LT.4) GO TO 29
        WRITE(2) (STF(LE,KT),LE=1,NE)
        WRITE(2) (CTF(LE,KT),LE=1,NE)
  29    CONTINUE
        STOP
        END
        BLOCK DATA
C        •••••••• * ••••••••••••••••••••••• *.** •••• * •••••••• * •• * •••••• *.*****
C
C
C        SET ARRAYS TO ZERO
C        •• *.* •• **.*.**** ••• **** •• **** ••••• ** •••• ** •••• *******.******.***** *
        COMMON/B1/ E(1000),EM(1001),CNT(1001),SNT(1001),DE,V,BOA,COA,NE,
     1 NPT,NL,NEMAX,NT,STS(1001,4),CTS(1001,4),STP(1001,4),CTP(1001,4),
     2 STD(1001,4),CTD(1001,4),STF(1001,4),CTF(1001,4),FTS(1000,4),
     3 FTP(1000,4),FTD(1000,4),FTF(1000,4),
     3 N1(1000),N2(1000),N3(1000),N4(1000),N5(1000),N6(1000),N7(1000)
       DATA STS/4004*0.D0/,CTS/4004*0.D0/,STP/4004*0.D0/,CTP/4004* 0.D0/
        DATA STD/4004*0.D0/,CTD/4004*0.D0/,SNT/1001*0.D0/,CNT/1001*0.D0/
        DATA STF/4004*0.D0/,CTF/4004*0.D0/
        END

.........

感谢您对重复的一些评论,但我的问题包含另一个关于旧代码中的字符

的问题
     READ(1'IR) W,KX,KY,KZ. 

我不知道那个角色是什么,我希望有人可以帮助我。

0 个答案:

没有答案