Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fortran: specification statement cannot appear in the executable section

  1. Sep 28, 2012 #1
    Hi guys,

    I am working on a Fortran code for a while. Might seem ridiculous but to better trace it, I split code into three separate parts and trying to compile both using the command 'ifort ss.f singpot.f SNGPOT.f -o ss'. With this command I receive the error

    singpot.f(22): error #6236: A specification statement cannot appear in the executable section.
    BLOCK DATA SPOT
    ------^
    compilation aborted for singpot.f (code 1). Does anyone has an idea why would that happen?

    By the way, since I still couldn't go further the compilation step, I am still not sure if the program works just in the way that I suppose.

    This is singpot.f


    COMMON/VSNGLT/RNODE(88),VNODE(88)
    COMMON/VSPLIN/BPAR(4),SPLC(87,3)

    C
    DO 1200 I=1,4
    1200 BPAR(I)=0.d0
    CONTINUE
    CALL ICSICU(RNODE,VNODE,88,BPAR,SPLC,87,IER)
    C



    BLOCK DATA SPOT
    C implicit real*8 (a-h,o-z)
    c
    C common/vsnglt/rnode(88),vnode(88)
    data(rnode(i),i=1,88)/0.d0,0.4d0,0.45d0,0.5d0,
    1 0.55d0,0.60d0,0.65d0,0.7d0,0.75d0,0.8d0,0.9d0,1.0d0,
    2 1.1d0,1.2d0,1.3d0,1.35d0,1.39d0,1.4d0,1.401d0,1.4011d0,
    31.41d0,1.45d0,1.5d0,1.6d0,1.7d0,1.8d0,1.9d0,2.0d0,
    42.1d0,2.2d0,2.3d0,2.4d0,2.5d0,2.6d0,2.7d0,2.8d0,2.9d0,3.0d0,
    53.1d0,3.2d0,3.3d0,3.4d0,3.5d0,3.6d0,3.7d0,3.8d0,3.9d0,4.0d0,
    64.1d0,4.2d0,4.3d0,4.4d0,4.5d0,4.6d0,4.7d0,4.8d0,4.9d0,5.0d0,
    75.1d0,5.2d0,5.3d0,5.4d0,5.5d0,5.6d0,5.7d0,5.8d0,5.9d0,6.0d0,
    86.1d0,6.2d0,6.3d0,6.4d0,6.5d0,6.6d0,6.7d0,6.8d0,6.9d0,7.0d0,
    97.2d0,7.4d0,7.6d0,7.8d0,8.d0,8.25d0,8.5d0,9.d0,9.5d0,10.d0/
    data(vnode(i),i=1,77)/2.5d0,
    10.8797972d0,0.6490718d0,0.4733730d0,0.3372293d0,
    20.2303659d0,0.1456386d0,0.0779739d0,0.0236643d0,
    3-0.0200556d0,-0.0836422d0,-0.1245385d0,-0.1500562d0,
    4-0.1649342d0,-0.1723459d0,-0.1739627d0,-0.1744517d0,
    5-0.1744744d0,-0.1744746d0,-0.1744746d0,-0.1744599d0,
    6-0.1740558d0,-0.1728537d0,-0.1685799d0,-0.1624570d0,
    7-0.1550670d0,-0.1468496d0,-0.1381312d0,-0.1291562d0,
    8-0.1201233d0,-0.1111725d0,-0.1024127d0,-0.0939273d0,
    9-0.0857810d0,-0.0780164d0,-0.0706700d0,-0.0637641d0,
    #-0.0573118d0,-0.0513185d0,-0.0457832d0,-0.0407003d0,
    #-0.0360578d0,-0.0318402d0,-0.0280272d0,-0.0245978d0,
    #-0.0215297d0,-0.0187967d0,-0.0163689d0,-0.0142247d0,
    #-0.0123371d0,-0.0106810d0,-0.0092303d0,-0.0079682d0,
    #-0.0068703d0,-0.0059178d0,-0.0050923d0,-0.0043782d0,
    #-0.0037626d0,-0.0032309d0,-0.0027740d0,-0.0023800d0,
    #-0.0020423d0,-0.0017521d0,-0.0015030d0,-0.0012899d0,
    #-0.0011069d0,-0.0009498d0,-0.0008150d0,-0.0007002d0,
    #-0.0006030d0,-0.0005162d0,-0.0004466d0,-0.0003864d0,
    #-0.0003328d0,-0.0002906d0,-0.0002466d0,-0.0002154d0/
    data (vnode(i),i=78,88)/-0.001889d0,-0.0001434d0,
    1-0.0001086d0,-0.0000868d0,-0.0000682d0,-0.0000528d0,
    2-0.0000404d0,-0.0000314d0,-0.0000185d0,-0.0000121d0,
    3-0.0000091d0/
    End

    subroutine ICSICU (X,Y,NX,BPAR,C,IC,IER)
    INTEGER NX,IC,IER
    real*8 X(NX),Y(NX),BPAR(4),C(IC,3)
    INTEGER I,J,NXM1
    real*8 DX,DXJ,DXJP1,DXP,DYJ,DYJP1,HALF,ONE,PJ,
    1 SIX,SIXI,TWO,YPPA,YPPB,ZERO
    EQUIVALENCE (DXJ,YPPB),(PJ,SIXI),(DXJP1,YPPA)
    DATA ZERO/0.0d0/,HALF/0.5d0/,ONE/1.0d0/,
    1 TWO/2.0d0/,SIX/6.0d0/
    C FIRST EXECUTABLE STATEMENT
    IER = 0
    C CHECK ERROR CONDITIONS
    NXM1 = NX-1
    IF (IC .LT. NXM1) GO TO 30
    IF (NX .LT. 2) GO TO 35
    IF (NX .EQ. 2) GO TO 10
    C COMPUTE COEFFICIENTS AND RIGHT
    C HAND SIDE OF THE TRIDIAGONAL
    C SYSTEM DEFINING THE SECOND
    C DERIVATIVES OF THE SPLINE
    C INTERPOLANT FOR (X,Y)
    C C(J,1) = LAMBDA(J)
    C C(J,2) = MU(J)
    C C(J,3) = D(J)
    DXJ = X(2)-X(1)
    IF (DXJ .LE. ZERO) GO TO 40
    DYJ = Y(2)-Y(1)
    DO 5 J=2,NXM1
    DXJP1 = X(J+1)-X(J)
    IF (DXJP1 .LE. ZERO) GO TO 40
    DYJP1 = Y(J+1)-Y(J)
    DXP = DXJ+DXJP1
    C(J,1) = DXJP1/DXP
    C(J,2) = ONE-C(J,1)
    C(J,3) = SIX*(DYJP1/DXJP1-DYJ/DXJ)/DXP
    DXJ = DXJP1
    DYJ = DYJP1
    5 CONTINUE
    C FACTOR THE TRIDIAGONAL MATRIX
    C AND SOLVE FOR U
    C C(J,2) = U(J)
    C C(J,1) = Q(J)
    C BPAR(1) = LAMBDA(1)
    C BPAR(2) = D(1)
    C BPAR(3) = MU(NX)
    C BPAR(4) = D(NX)
    10 C(1,1) = -BPAR(1)*HALF
    C(1,2) = BPAR(2)*HALF
    IF (NX .EQ. 2) GO TO 20
    DO 15 J=2,NXM1
    PJ = C(J,2)*C(J-1,1)+TWO
    C(J,1) = -C(J,1)/PJ
    C(J,2) = (C(J,3)-C(J,2)*C(J-1,2))/PJ
    15 CONTINUE
    C SOLVE FOR CUBIC COEFFICIENTS
    C OF SPLINE INTERPOLANT
    C C(J,1), C(J,2), AND C(J,3)
    20 YPPB = (BPAR(4)-BPAR(3)*C(NXM1,2))/(BPAR(3)*C(NXM1,1)+TWO)
    SIXI = ONE/SIX
    DO 25 I=1,NXM1
    J = NX-I
    YPPA = C(J,1)*YPPB+C(J,2)
    DX = X(J+1)-X(J)
    C(J,3) = SIXI*(YPPB-YPPA)/DX
    C(J,2) = HALF*YPPA
    C(J,1) = (Y(J+1)-Y(J))/DX-(C(J,2)+C(J,3)*DX)*DX
    YPPB = YPPA
    25 CONTINUE
    GO TO 9005
    30 IER = 129
    GO TO 9000
    35 IER = 130
    GO TO 9000
    40 IER = 131
    9000 CONTINUE
    write(6,29888) ier
    29888 format(1x,'imsl err.from ICSICU. ier=',i4)
    9005 RETURN
    END

    subroutine ICSEVU (X,Y,NX,C,IC,U,S,M,IER)
    INTEGER NX,IC,M,IER
    real*8 X(NX),Y(NX),C(IC,3),U(M),S(M)
    INTEGER I,JER,KER,NXM1,K
    real*8 D,DD,ZERO
    DATA I/1/,ZERO/0.0d0/
    C FIRST EXECUTABLE STATEMENT
    JER = 0
    KER = 0
    IF (M .LE. 0) GO TO 9005
    NXM1 = NX-1
    IF (I .GT. NXM1) I = 1
    C EVALUATE SPLINE AT M POINTS
    DO 40 K=1,M
    C FIND THE PROPER INTERVAL
    D = U(K)-X(I)
    IF (D) 5,25,15
    5 IF (I .EQ. 1) GO TO 30
    I = I-1
    D = U(K)-X(I)
    IF (D) 5,25,20
    10 I = I+1
    D = DD
    15 IF (I .GE. NX) GO TO 35
    DD = U(K)-X(I+1)
    IF (DD .GE. ZERO) GO TO 10
    IF (D .EQ. ZERO) GO TO 25
    C PERFORM EVALUATION
    20 S(K) = ((C(I,3)*D+C(I,2))*D+C(I,1))*D+Y(I)
    GO TO 40
    25 S(K) = Y(I)
    GO TO 40
    C WARNING - U(I) .LT. X(1)
    30 JER = 33
    GO TO 20
    C IF U(I) .GT. X(NX) - WARNING
    35 IF (DD .GT. ZERO) KER = 34
    D = U(K)-X(NXM1)
    I = NXM1
    GO TO 20
    40 CONTINUE
    IER = MAX0(JER,KER)
    9000 CONTINUE
    if(jer.gt.0) then
    write(6,29666) jer
    29666 format(1x,'err.mess. from ICSEVU jer=',i4)
    end if
    if(ker.gt.0) then
    write(6,29777) ker
    29777 format(1x,'err.mess. from ICSEVU ker=',i4)
    end if
    9005 RETURN
    END

    Here is ss.f

    C TRYING SNGPOT
    COMMON/VSNGLT/RNODE(88),VNODE(88)
    COMMON/VSPLIN/BPAR(4),SPLC(87,3)
    REAL B
    B=SNGPOT(1)
    PRINT *,B
    END

    and finally SNGPOT.f

    FUNCTION SNGPOT(X)
    IMPLICIT REAL*8 (a-h,o-z)
    c
    COMMON/VSNGLT/RNODE(88),VNODE(88)
    COMMON/VSPLIN/BPAR(4),SPLC(87,3)
    DIMENSION Y(1),VY(1)
    C
    Y(1)=X
    CALL ICSEVU(RNODE,VNODE,88,SPLC,87,Y,VY,1,IER)
    SNGPOT=VY(1)
    RETURN
    END

    Thank you in advance.
     
    Last edited: Sep 28, 2012
  2. jcsd
  3. Sep 28, 2012 #2
    SNGPOT.f starts with a line that starts with FUNCTION and ends with one that says END...that is fine; every file needs to start and end with that, or SUBROUTINE and END. Only one file, the one with the main program is to start with PROGRAM

    ...as it is, 2 of your files ( signpot.f and ss.f ) start with nothing at all, which implicitly means that it is the main procedure and equivalent to PROGRAM...in other words, you have two PROGRAMs and that cannot be...there should only one entry point to your program.
     
  4. Sep 29, 2012 #3
    Oh, and yes...the BLOCK needs to be at the beginning right after declarations...you cannot have it after executable statements like that DO loop.
     
  5. Sep 29, 2012 #4
    dear gsal, I have made several changes according to your advice. here is the final result;

    C SINGLET POTENTIAL OF H2
    C by spline interpolation of Kolos-Woniewicz data
    C
    C Before calling SNGPOT we have to
    C INITIALIZE FOR SPLINE INTERPOLATION (THIS IS USED
    C ONLY IF KOLOS-WOLNIEWICZ DATA IS USED)
    C calling program should have the following common blocks
    COMMON/VSNGLT/RNODE(88),VNODE(88)
    COMMON/VSPLIN/BPAR(4),SPLC(87,3)
    REAL SONUC,X
    BLOCK DATA SPOT
    c real*8 (a-h,o-z)
    c
    c common/vsnglt/rnode(88),vnode(88)
    data(rnode(i),i=1,88)/0.d0,0.4d0,0.45d0,0.5d0,
    1 0.55d0,0.60d0,0.65d0,0.7d0,0.75d0,0.8d0,0.9d0,1.0d0,
    2 1.1d0,1.2d0,1.3d0,1.35d0,1.39d0,1.4d0,1.401d0,1.4011d0,
    3 31.41d0,1.45d0,1.5d0,1.6d0,1.7d0,1.8d0,1.9d0,2.0d0,
    4 42.1d0,2.2d0,2.3d0,2.4d0,2.5d0,2.6d0,2.7d0,2.8d0,2.9d0,3.0d0,
    5 53.1d0,3.2d0,3.3d0,3.4d0,3.5d0,3.6d0,3.7d0,3.8d0,3.9d0,4.0d0,
    6 64.1d0,4.2d0,4.3d0,4.4d0,4.5d0,4.6d0,4.7d0,4.8d0,4.9d0,5.0d0,
    7 75.1d0,5.2d0,5.3d0,5.4d0,5.5d0,5.6d0,5.7d0,5.8d0,5.9d0,6.0d0,
    8 86.1d0,6.2d0,6.3d0,6.4d0,6.5d0,6.6d0,6.7d0,6.8d0,6.9d0,7.0d0,
    9 97.2d0,7.4d0,7.6d0,7.8d0,8.d0,8.25d0,8.5d0,9.d0,9.5d0,10.d0/
    data(vnode(i),i=1,77)/2.5d0,
    10.8797972d0,0.6490718d0,0.4733730d0,0.3372293d0,
    20.2303659d0,0.1456386d0,0.0779739d0,0.0236643d0,
    3-0.0200556d0,-0.0836422d0,-0.1245385d0,-0.1500562d0,
    4-0.1649342d0,-0.1723459d0,-0.1739627d0,-0.1744517d0,
    5-0.1744744d0,-0.1744746d0,-0.1744746d0,-0.1744599d0,
    6-0.1740558d0,-0.1728537d0,-0.1685799d0,-0.1624570d0,
    7-0.1550670d0,-0.1468496d0,-0.1381312d0,-0.1291562d0,
    8-0.1201233d0,-0.1111725d0,-0.1024127d0,-0.0939273d0,
    9-0.0857810d0,-0.0780164d0,-0.0706700d0,-0.0637641d0,
    #-0.0573118d0,-0.0513185d0,-0.0457832d0,-0.0407003d0,
    #-0.0360578d0,-0.0318402d0,-0.0280272d0,-0.0245978d0,
    #-0.0215297d0,-0.0187967d0,-0.0163689d0,-0.0142247d0,
    #-0.0123371d0,-0.0106810d0,-0.0092303d0,-0.0079682d0,
    #-0.0068703d0,-0.0059178d0,-0.0050923d0,-0.0043782d0,
    #-0.0037626d0,-0.0032309d0,-0.0027740d0,-0.0023800d0,
    #-0.0020423d0,-0.0017521d0,-0.0015030d0,-0.0012899d0,
    #-0.0011069d0,-0.0009498d0,-0.0008150d0,-0.0007002d0,
    #-0.0006030d0,-0.0005162d0,-0.0004466d0,-0.0003864d0,
    #-0.0003328d0,-0.0002906d0,-0.0002466d0,-0.0002154d0/
    data (vnode(i),i=78,88)/-0.001889d0,-0.0001434d0,
    1-0.0001086d0,-0.0000868d0,-0.0000682d0,-0.0000528d0,
    2-0.0000404d0,-0.0000314d0,-0.0000185d0,-0.0000121d0,
    3-0.0000091d0/
    End

    READ *, X


    C
    C DO 1200 I=1,4
    C 1200 BPAR(I)=0.d0
    CALL ICSICU(RNODE,VNODE,88,BPAR,SPLC,87,IER)
    C
    SONUC=SNGPOT(X)

    subroutine ICSICU (X,Y,NX,BPAR,C,IC,IER)
    INTEGER NX,IC,IER
    real*8 X(NX),Y(NX),BPAR(4),C(IC,3)
    INTEGER I,J,NXM1
    real*8 DX,DXJ,DXJP1,DXP,DYJ,DYJP1,HALF,ONE,PJ,
    1 SIX,SIXI,TWO,YPPA,YPPB,ZERO
    EQUIVALENCE (DXJ,YPPB),(PJ,SIXI),(DXJP1,YPPA)
    DATA ZERO/0.0d0/,HALF/0.5d0/,ONE/1.0d0/,
    1 TWO/2.0d0/,SIX/6.0d0/
    C FIRST EXECUTABLE STATEMENT
    IER = 0
    C CHECK ERROR CONDITIONS
    NXM1 = NX-1
    IF (IC .LT. NXM1) GO TO 30
    IF (NX .LT. 2) GO TO 35
    IF (NX .EQ. 2) GO TO 10
    C COMPUTE COEFFICIENTS AND RIGHT
    C HAND SIDE OF THE TRIDIAGONAL
    C SYSTEM DEFINING THE SECOND
    C DERIVATIVES OF THE SPLINE
    C INTERPOLANT FOR (X,Y)
    C C(J,1) = LAMBDA(J)
    C C(J,2) = MU(J)
    C C(J,3) = D(J)
    DXJ = X(2)-X(1)
    IF (DXJ .LE. ZERO) GO TO 40
    DYJ = Y(2)-Y(1)
    DO 5 J=2,NXM1
    DXJP1 = X(J+1)-X(J)
    IF (DXJP1 .LE. ZERO) GO TO 40
    DYJP1 = Y(J+1)-Y(J)
    DXP = DXJ+DXJP1
    C(J,1) = DXJP1/DXP
    C(J,2) = ONE-C(J,1)
    C(J,3) = SIX*(DYJP1/DXJP1-DYJ/DXJ)/DXP
    DXJ = DXJP1
    DYJ = DYJP1
    5 CONTINUE
    C FACTOR THE TRIDIAGONAL MATRIX
    C AND SOLVE FOR U
    C C(J,2) = U(J)
    C C(J,1) = Q(J)
    C BPAR(1) = LAMBDA(1)
    C BPAR(2) = D(1)
    C BPAR(3) = MU(NX)
    C BPAR(4) = D(NX)
    10 C(1,1) = -BPAR(1)*HALF
    C(1,2) = BPAR(2)*HALF
    IF (NX .EQ. 2) GO TO 20
    DO 15 J=2,NXM1
    PJ = C(J,2)*C(J-1,1)+TWO
    C(J,1) = -C(J,1)/PJ
    C(J,2) = (C(J,3)-C(J,2)*C(J-1,2))/PJ
    15 CONTINUE
    C SOLVE FOR CUBIC COEFFICIENTS
    C OF SPLINE INTERPOLANT
    C C(J,1), C(J,2), AND C(J,3)
    20 YPPB = (BPAR(4)-BPAR(3)*C(NXM1,2))/(BPAR(3)*C(NXM1,1)+TWO)
    SIXI = ONE/SIX
    DO 25 I=1,NXM1
    J = NX-I
    YPPA = C(J,1)*YPPB+C(J,2)
    DX = X(J+1)-X(J)
    C(J,3) = SIXI*(YPPB-YPPA)/DX
    C(J,2) = HALF*YPPA
    C(J,1) = (Y(J+1)-Y(J))/DX-(C(J,2)+C(J,3)*DX)*DX
    YPPB = YPPA
    25 CONTINUE
    GO TO 9005
    30 IER = 129
    GO TO 9000
    35 IER = 130
    GO TO 9000
    40 IER = 131
    9000 CONTINUE
    write(6,29888) ier
    29888 format(1x,'imsl err.from ICSICU. ier=',i4)
    9005 RETURN
    END

    subroutine ICSEVU (X,Y,NX,C,IC,U,S,M,IER)
    INTEGER NX,IC,M,IER
    real*8 X(NX),Y(NX),C(IC,3),U(M),S(M)
    INTEGER I,JER,KER,NXM1,K
    real*8 D,DD,ZERO
    DATA I/1/,ZERO/0.0d0/
    C FIRST EXECUTABLE STATEMENT
    JER = 0
    KER = 0
    IF (M .LE. 0) GO TO 9005
    NXM1 = NX-1
    IF (I .GT. NXM1) I = 1
    C EVALUATE SPLINE AT M POINTS
    DO 40 K=1,M
    C FIND THE PROPER INTERVAL
    D = U(K)-X(I)
    IF (D) 5,25,15
    5 IF (I .EQ. 1) GO TO 30
    I = I-1
    D = U(K)-X(I)
    IF (D) 5,25,20
    10 I = I+1
    D = DD
    15 IF (I .GE. NX) GO TO 35
    DD = U(K)-X(I+1)
    IF (DD .GE. ZERO) GO TO 10
    IF (D .EQ. ZERO) GO TO 25
    C PERFORM EVALUATION
    20 S(K) = ((C(I,3)*D+C(I,2))*D+C(I,1))*D+Y(I)
    GO TO 40
    25 S(K) = Y(I)
    GO TO 40
    C WARNING - U(I) .LT. X(1)
    30 JER = 33
    GO TO 20
    C IF U(I) .GT. X(NX) - WARNING
    35 IF (DD .GT. ZERO) KER = 34
    D = U(K)-X(NXM1)
    I = NXM1
    GO TO 20
    40 CONTINUE
    IER = MAX0(JER,KER)
    9000 CONTINUE
    if(jer.gt.0) then
    write(6,29666) jer
    29666 format(1x,'err.mess. from ICSEVU jer=',i4)
    end if
    if(ker.gt.0) then
    write(6,29777) ker
    29777 format(1x,'err.mess. from ICSEVU ker=',i4)
    end if
    9005 RETURN
    END

    and for the function SNGPOT.f

    FUNCTION SNGPOT(X)
    implicit real*8 (a-h,o-z)
    c
    COMMON/VSNGLT/RNODE(88),VNODE(88)
    COMMON/VSPLIN/BPAR(4),SPLC(87,3)
    DIMENSION Y(1),VY(1)
    C
    Y(1)=X
    CALL ICSEVU(RNODE,VNODE,88,SPLC,87,Y,VY,1,IER)
    SNGPOT=VY(1)
    RETURN
    END

    I placed block data right after the declarations, but I still I get the error;

    sngdeneme.f:8.72:

    COMMON/VSNGLT/RNODE(88),VNODE(88)
    1
    sngdeneme.f:50.72:

    REAL SONUC,X
    2
    Error: Two main PROGRAMs at (1) and (2)

    Moreover, 50th line is only an executable, so I don't understand why it stands for a new main program.
     
    Last edited: Sep 29, 2012
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Fortran: specification statement cannot appear in the executable section
Loading...