Fortran Troubleshooting - Get Help with Codeblocks Issues

  • Fortran
  • Thread starter felipearcaro
  • Start date
  • Tags
    Fortran
In summary, the conversation is about a person asking for help with their Fortran code that is not working. They provide a link to the code and a list of error messages they are receiving. Another person suggests that the errors could be due to a lack of a PROGRAM statement in the code. The first person also mentions inputting the energy and mass of the incident particle in the code.
  • #1
felipearcaro
20
0
Hello everyone, I'm new here and i have a question:
I did this fortran code and isn't work, but i think the problem is my codeblocks
Someone can execute the code and if they presents some errors help me also?
 
Technology news on Phys.org
  • #2
The code: http://codepaste.net/s23byg
 
  • #3
How about you tell us the error messages that you get (copy and paste them), and which lines of code they refer to?
 
  • #4
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|74|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 74 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|78|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 78 .73:|
||Error: Letter A already has an IMPLICIT type |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|79|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 79 .29:|
||Error: Letter C already has an IMPLICIT type |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|80|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 80 .19:|
||Error: VARIABLE attribute of 'x' conflicts with PARAMETER attribute |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|81|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 81 .17:|
||Error: Duplicate DIMENSION attribute specified |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|82|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 82 .29:|
||Error: Symbol 'cw' already has basic type of COMPLEX|
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|90|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 90 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|91|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 91 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|92|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 92 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|93|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 93 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|95|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 95 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|96|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 96 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|97|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 97 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|98|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 98 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|103|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 103 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|105|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 105 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|112|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 112 .9:|
||Error: Expecting END PROGRAM statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|116|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 116 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|120|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 120 .32:|
||Error: Letter A already has an IMPLICIT type |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|121|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 121 .23:|
||Error: PARAMETER attribute of 'nz' conflicts with PARAMETER attribute |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|122|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 122 .21:|
||Error: Unexpected attribute declaration statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|125|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 125 .29:|
||Error: Unexpected STATEMENT FUNCTION statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|129|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 129 .9:|
||Error: Expecting END PROGRAM statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|133|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 133 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|137|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 137 .32:|
||Error: Letter A already has an IMPLICIT type |
||Fatal Error: Error count reached limit of 25.|
||=== Build finished: 26 errors, 0 warnings (0 minutes, 1 seconds) ===|

I think the program doesn't recognize the subrotines as subrotines..
||Error: Letter C already has an IMPLICIT type|| suggest this
 
  • #5
Btw, you must see the code to understand what i mean
 
  • #6
Here's your code. Why didn't you just post it here?

I believe that the errors are due to your lack of a PROGRAM statement (and an END statement for it.

Code:
!
      IMPLICIT REAL (8) (A-B,D-H, O-Z) !Define numeros reais e imaginarios
      IMPLICIT COMPLEX (8)(C)
      PARAMETER(NZ=501,L=2) !Define parametros
!
      DIMENSION D1(L,L) , P(L,L) , D(L,L) , X(NZ) , Y(NZ)
      DIMENSION V(NZ), Q(L,L)
      COMPLEX (8) CW(NZ), CKP(X,X), CTRANSM(L,L), CT(L,L)
      !OPEN(UNIT=12,FILE='ENERGY.DAT',FORM='FORMATTED')
      !OPEN(UNIT=13,FILE='PSI0.DAT',FORM='FORMATTED')
      !OPEN(UNIT=14,FILE='PSI.DAT',FORM='FORMATTED')
 
!
!
!307   FORMAT(86(2X,E14.7))
!308   FORMAT(I5,86(2X,E14.7))
       AM = 0.067D0 !Massa efetiva do e- (GaAs)
       EPS = 12.5D0 !Constante dielétrica (GaAs)
       RY = 13.6058D3 * AM / EPS / EPS
       A0 = 0.5292D0 * EPS / AM
       PI = 4.D0 * DATAN(1.D0)
       CZ = (0.D0,1.D0)
 
      WRITE(*,*)'INSIRA ENERGIA DA PARTICULA INCIDENTE (meV)=' !Insere variável
      READ(*,*) E1
      E = E1/RY
 
 
!      WRITE(*,*)'INSIRA A MASSA DA PARTICULA INCIDENTE=' !Insere variável
!      READ(*,*) MASSA
 
      WRITE(*,*)'INSIRA O COMPRIMENTO=' !Insere variável
      READ(*,*) ALF
      AL = ALF/A0
 
 
 
      DZ = AL/NZ-1
 
 
      CALL MESH (DZ,Z)
 
      CALL POTE(A0,RY,AL,Z,V)
      K2 = DSQRT(E-V(NZ))
 
      DO M=NZ,2
      KB = DSQRT(E-V(M-1))
      DM = K2/KB
      C = CDEXP(CZ*K2*DZ)
 
      CW(M) = C
      X(M) = (1 + DM)/2
      Y(M) = (1 - DM)/2
      K2 = KB
      ENDDO
 
 
     D1 (1,1) = X(1)
     D1 (2,1) = Y(1)
     D1 (1,2) = Y(1)
     D1 (2,2) = X(1)
 
     CALL CALCM(X,Y,CW,KW)
     CT = D1*KW
 
     CT(2,1) = T1
     CT(1,2) = T2
 
     CTRANSM = 1 - (DABS(T1)**2)/DABS(T2)**2
 
 
!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
      SUBROUTINE CALCM(X,Y,CW,KW)
 
!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
!
      IMPLICIT REAL (8) (A-B,D-H,O-Z) !Define numeros reais e imaginarios
      IMPLICIT COMPLEX (8)(C)
      PARAMETER(X=2, NZ=501)
      DIMENSION D(X,X), P(X,X), C(X,X)
      COMPLEX (8) CP(X,X), CW(NZ),  CQ(X,X) , CKP(X,X), CK3(X,X), CDP(X,X)
      DO M = NZ,2
 
      D (1,1) = X(M)
      D (2,1) = Y(M)
      D (1,2) = Y(M)
      D (2,2) = X(M)
 
      CP (1,1) = CW(M)
      CP (2,1) = (0.D0,0.D0)
      CP (1,2) = (0.D0,0.D0)
      CP (2,2) = DCONJG(CW(M))
 
      KY(1,1) = D(1,1)*P(1,1)+D(1,2)*P(2,1)
      KY(1,2) = D(1,1)*P(1,2)+D(1,2)*P(2,2)
      KY(2,1) = D(2,1)*P(1,1)+D(2,2)*P(2,1)
      KY(2,2) = D(2,1)*P(1,2)+D(2,2)*P(2,2)
 
      ENDDO
 
 
      KY(NZ-1)*KY(NZ)=KW
      DO M=NZ,2
      KY(NZ-2)*KW=KX
      KW=KX
 
      ENDDO
 
 
      RETURN
      END  SUBROUTINE CALCM
 
!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
!
      SUBROUTINE MESH(DZ,Z)
 
!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
!
      IMPLICIT REAL(8) (A-H,O-Z)
      PARAMETER (NZ=501)
      DIMENSION Z(NZ)
!
      DO I=1,NZ
      Z(I) = DFLOAT(I-1) * DZ
      ENDDO
 !
      RETURN
      END  SUBROUTINE MESH
 
!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
      SUBROUTINE POTE(A0,RY,AL,Z,POTF) !**********
 
!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
      IMPLICIT REAL(8) (A-H,O-Z)
      PARAMETER (NZ=501)
      DIMENSION Z(NZ), POTF(NZ)
 
        ALH = 0.5D0 * AL  !MEIO DO SISTEMA
        DQW = 20.D0 / A0   ! DISTANCIA ENTRE POCOS
        DQWH = 0.5D0 * DQW
        QW = 100.D0 / A0   ! LARGURA DOS POCOS
        QWH = 0.5D0 * QW
        AT = DQWH + QW
 
        DO IZ=1,NZ
        ZW = Z(IZ) - ALH
        POTF(IZ) = 0.D0
        IF(DABS(ZW).GT.DQWH.AND.DABS(ZW).LT.AT)  POTF(IZ) = 400.D0/RY
        ENDDO
 !
      RETURN
      END  SUBROUTINE POTE
 
  • #7
But where? i searched for this erros so many times and found nothing
 
  • #8
You need to separate the main program from its subroutines.
Code:
[color="red"]PROGRAM XYZ[/color]
      IMPLICIT REAL (8) (A-B,D-H, O-Z) !Define numeros reais e imaginarios
      IMPLICIT COMPLEX (8)(C)
      PARAMETER(NZ=501,L=2) !Define parametros
!
      DIMENSION D1(L,L) , P(L,L) , D(L,L) , X(NZ) , Y(NZ)
      DIMENSION V(NZ), Q(L,L)
      COMPLEX (8) CW(NZ), CKP(X,X), CTRANSM(L,L), CT(L,L)
      !OPEN(UNIT=12,FILE='ENERGY.DAT',FORM='FORMATTED')
      !OPEN(UNIT=13,FILE='PSI0.DAT',FORM='FORMATTED')
      !OPEN(UNIT=14,FILE='PSI.DAT',FORM='FORMATTED')
 
!
!
!307   FORMAT(86(2X,E14.7))
!308   FORMAT(I5,86(2X,E14.7))
       AM = 0.067D0 !Massa efetiva do e- (GaAs)
       EPS = 12.5D0 !Constante dielétrica (GaAs)
       RY = 13.6058D3 * AM / EPS / EPS
       A0 = 0.5292D0 * EPS / AM
       PI = 4.D0 * DATAN(1.D0)
       CZ = (0.D0,1.D0)
 
      WRITE(*,*)'INSIRA ENERGIA DA PARTICULA INCIDENTE (meV)=' !Insere variável
      READ(*,*) E1
      E = E1/RY
 
 
!      WRITE(*,*)'INSIRA A MASSA DA PARTICULA INCIDENTE=' !Insere variável
!      READ(*,*) MASSA
 
      WRITE(*,*)'INSIRA O COMPRIMENTO=' !Insere variável
      READ(*,*) ALF
      AL = ALF/A0
 
 
 
      DZ = AL/NZ-1
 
 
      CALL MESH (DZ,Z)
 
      CALL POTE(A0,RY,AL,Z,V)
      K2 = DSQRT(E-V(NZ))
 
      DO M=NZ,2
      KB = DSQRT(E-V(M-1))
      DM = K2/KB
      C = CDEXP(CZ*K2*DZ)
 
      CW(M) = C
      X(M) = (1 + DM)/2
      Y(M) = (1 - DM)/2
      K2 = KB
      ENDDO
 
 
     D1 (1,1) = X(1)
     D1 (2,1) = Y(1)
     D1 (1,2) = Y(1)
     D1 (2,2) = X(1)
 
     CALL CALCM(X,Y,CW,KW)
     CT = D1*KW
 
     CT(2,1) = T1
     CT(1,2) = T2
 
     CTRANSM = 1 - (DABS(T1)**2)/DABS(T2)**2
[color="red"]END PROGRAM XYZ[/color]
 
  • #9
I did but don't work :(

Code:

PROGRAM ABCDE


IMPLICIT REAL (8) (A-B,D-H, O-Z) !Define numeros reais e imaginarios
IMPLICIT COMPLEX (8)(C)
PARAMETER(NZ=501,L=2) !Define parametros
!
DIMENSION D1(L,L) , P(L,L) , D(L,L) , X(NZ) , Y(NZ)
DIMENSION V(NZ), Q(L,L)
COMPLEX (8) CW(NZ), CKP(X,X), CTRANSM(L,L), CT(L,L)
!OPEN(UNIT=12,FILE='ENERGY.DAT',FORM='FORMATTED')
!OPEN(UNIT=13,FILE='PSI0.DAT',FORM='FORMATTED')
!OPEN(UNIT=14,FILE='PSI.DAT',FORM='FORMATTED')

!
!
!307 FORMAT(86(2X,E14.7))
!308 FORMAT(I5,86(2X,E14.7))
AM = 0.067D0 !Massa efetiva do e- (GaAs)
EPS = 12.5D0 !Constante dielétrica (GaAs)
RY = 13.6058D3 * AM / EPS / EPS
A0 = 0.5292D0 * EPS / AM
PI = 4.D0 * DATAN(1.D0)
CZ = (0.D0,1.D0)

WRITE(*,*)'INSIRA ENERGIA DA PARTICULA INCIDENTE (meV)=' !Insere variável
READ(*,*) E1
E = E1/RY


! WRITE(*,*)'INSIRA A MASSA DA PARTICULA INCIDENTE=' !Insere variável
! READ(*,*) MASSA

WRITE(*,*)'INSIRA O COMPRIMENTO=' !Insere variável
READ(*,*) ALF
AL = ALF/A0



DZ = AL/NZ-1


CALL MESH (DZ,Z)

CALL POTE(A0,RY,AL,Z,V)
K2 = DSQRT(E-V(NZ))

DO M=NZ,2
KB = DSQRT(E-V(M-1))
DM = K2/KB
C = CDEXP(CZ*K2*DZ)

CW(M) = C
X(M) = (1 + DM)/2
Y(M) = (1 - DM)/2
K2 = KB
ENDDO


D1 (1,1) = X(1)
D1 (2,1) = Y(1)
D1 (1,2) = Y(1)
D1 (2,2) = X(1)

CALL CALCM(X,Y,CW,KW)
CT = D1*KW

CT(2,1) = T1
CT(1,2) = T2

CTRANSM = 1 - (DABS(T1)**2)/DABS(T2)**2

END PROGRAM ABCDE




!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

SUBROUTINE CALCM(X,Y,CW,KW)

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
!
IMPLICIT REAL (8) (A-B,D-H,O-Z) !Define numeros reais e imaginarios
IMPLICIT COMPLEX (8)(C)
PARAMETER(X=2, NZ=501)
DIMENSION D(X,X), P(X,X), C(X,X)
COMPLEX (8) CP(X,X), CW(NZ), CQ(X,X) , CKP(X,X), CK3(X,X), CDP(X,X)
DO M = NZ,2

D (1,1) = X(M)
D (2,1) = Y(M)
D (1,2) = Y(M)
D (2,2) = X(M)

CP (1,1) = CW(M)
CP (2,1) = (0.D0,0.D0)
CP (1,2) = (0.D0,0.D0)
CP (2,2) = DCONJG(CW(M))

KY(1,1) = D(1,1)*P(1,1)+D(1,2)*P(2,1)
KY(1,2) = D(1,1)*P(1,2)+D(1,2)*P(2,2)
KY(2,1) = D(2,1)*P(1,1)+D(2,2)*P(2,1)
KY(2,2) = D(2,1)*P(1,2)+D(2,2)*P(2,2)

ENDDO


KY(NZ-1)*KY(NZ)=KW
DO M=NZ,2
KY(NZ-2)*KW=KX
KW=KX

ENDDO


RETURN
END SUBROUTINE CALCM

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
!
SUBROUTINE MESH(DZ,Z)

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
!
IMPLICIT REAL(8) (A-H,O-Z)
PARAMETER (NZ=501)
DIMENSION Z(NZ)
!
DO I=1,NZ
Z(I) = DFLOAT(I-1) * DZ
ENDDO
!
RETURN
END SUBROUTINE MESH

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

SUBROUTINE POTE(A0,RY,AL,Z,POTF) !**********

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

IMPLICIT REAL(8) (A-H,O-Z)
PARAMETER (NZ=501)
DIMENSION Z(NZ), POTF(NZ)

ALH = 0.5D0 * AL !MEIO DO SISTEMA
DQW = 20.D0 / A0 ! DISTANCIA ENTRE POCOS
DQWH = 0.5D0 * DQW
QW = 100.D0 / A0 ! LARGURA DOS POCOS
QWH = 0.5D0 * QW
AT = DQWH + QW

DO IZ=1,NZ
ZW = Z(IZ) - ALH
POTF(IZ) = 0.D0
IF(DABS(ZW).GT.DQWH.AND.DABS(ZW).LT.AT) POTF(IZ) = 400.D0/RY
ENDDO
!
RETURN
END SUBROUTINE POTE


Errors:

fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|76|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 76 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|80|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 80 .73:|
||Error: Letter A already has an IMPLICIT type |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|81|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 81 .29:|
||Error: Letter C already has an IMPLICIT type |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|82|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 82 .19:|
||Error: VARIABLE attribute of 'x' conflicts with PARAMETER attribute |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|83|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 83 .17:|
||Error: Duplicate DIMENSION attribute specified |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|84|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 84 .29:|
||Error: Symbol 'cw' already has basic type of COMPLEX|
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|92|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 92 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|93|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 93 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|94|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 94 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|95|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 95 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|97|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 97 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|98|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 98 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|99|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 99 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|100|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 100 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|105|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 105 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|107|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 107 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|114|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 114 .9:|
||Error: Expecting END PROGRAM statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|118|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 118 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|122|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 122 .32:|
||Error: Letter A already has an IMPLICIT type |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|123|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 123 .23:|
||Error: PARAMETER attribute of 'nz' conflicts with PARAMETER attribute |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|124|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 124 .21:|
||Error: Unexpected attribute declaration statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|127|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 127 .29:|
||Error: Unexpected STATEMENT FUNCTION statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|131|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 131 .9:|
||Error: Expecting END PROGRAM statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|135|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 135 .6:|
||Error: Unclassifiable statement |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|139|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 139 .32:|
||Error: Letter A already has an IMPLICIT type |
||Fatal Error: Error count reached limit of 25.|
||=== Build finished: 26 errors, 0 warnings (0 minutes, 1 seconds) ===|


I'm sorry but i don't know how i put the code in a box like you, if you tell me i edit my post, thanks.
 
  • #10
Put "[noparse]
Code:
[/noparse]" before your code and "[noparse]
[/noparse]" after it.
 
  • #11
I'm not an expert in Fortran 90, but I believe one of your problems is that you aren't declaring your arrays and other variables correctly.

For example, here's how you should be declaring a two-dimension array of reals:
REAL, DIMENSION(4,20) :: F

Also, you are using statements such as IMPLICIT REAL (8) (A-B,D-H,O-Z) and I think this is causing problems with arrays that start with one of these letters (such as D, which you later use as an array).

In the CALCM subroutine, you have this code:
KY(NZ-1)*KY(NZ)=KW
I don't know what you're trying to do in that line of code. There's a similar problem two lines down from that one.

Also in CALCM, X is one of the formal parameters, but you declare it as a PARAMETER (that is, a constant) inside this subroutine. Later you use it as an array, as in this code
D (1,1) = X(M).
I'm sure it's confusing, but a subroutine or function parameter is not the same thing as a PARAMETER, which is a constant. A subroutine parameter is a placeholder for a value that is passed to the subroutine.
Also, you have some statement

BTW, put a [noparse]
Code:
 tag at the top of your code and a
tag[/noparse] at the bottom.
 
  • #12
Mark44 said:
I'm not an expert in Fortran 90, but I believe one of your problems is that you aren't declaring your arrays and other variables correctly.

For example, here's how you should be declaring a two-dimension array of reals:
REAL, DIMENSION(4,20) :: F

Also, you are using statements such as IMPLICIT REAL (8) (A-B,D-H,O-Z) and I think this is causing problems with arrays that start with one of these letters (such as D, which you later use as an array).

In the CALCM subroutine, you have this code:
KY(NZ-1)*KY(NZ)=KW
I don't know what you're trying to do in that line of code. There's a similar problem two lines down from that one.

Also in CALCM, X is one of the formal parameters, but you declare it as a PARAMETER (that is, a constant) inside this subroutine. Later you use it as an array, as in this code
D (1,1) = X(M).
I'm sure it's confusing, but a subroutine or function parameter is not the same thing as a PARAMETER, which is a constant. A subroutine parameter is a placeholder for a value that is passed to the subroutine.
Also, you have some statement

BTW, put a [noparse]
Code:
 tag at the top of your code and a
tag[/noparse] at the bottom.

1) I used: COMPLEX, DIMENSION(L) :: and REAL, DIMENSION(L) :: and i think it works

2) I need remove this line? IMPLICIT REAL (8) (A-B,D-H,O-Z)

3) In this part i try calculate KY, and after to do:
KY(500)*KY(501)=KW
KY(NZ-2)*KW=KX
KW=KX where renew KW

I have a matrix[L,L] with D e P, where D depends on the X,Y and P depends on the CW.
I believe that i can use a matrix in a "DO" using just one variable, like KW(NZ).. I don't know if i was clear..
But if I'm wrong, how i fix it?

Code:
      KY(1,1) = D(1,1)*P(1,1)+D(1,2)*P(2,1)
      KY(1,2) = D(1,1)*P(1,2)+D(1,2)*P(2,2)
      KY(2,1) = D(2,1)*P(1,1)+D(2,2)*P(2,1)
      KY(2,2) = D(2,1)*P(1,2)+D(2,2)*P(2,2)

      ENDDO      KY(NZ-1)*KY(NZ)=KW
      DO M=NZ,2
      KY(NZ-2)*KW=KX
      KW=KX

4) X was conflicting, you are right, i fixed.

Code:
Code:
      PROGRAM ABCDE      IMPLICIT REAL (8) (A-B,D-H, O-Z) !Define numeros reais e imaginarios
      IMPLICIT COMPLEX (8)(C)
      PARAMETER(NZ=501,L=2) !Define parametros
!
      REAL, DIMENSION(L,L) :: D1
      REAL, DIMENSION(L,L) :: P
      REAL, DIMENSION(L,L) :: D
      REAL, DIMENSION(L,L) :: Q
      REAL, DIMENSION(NZ) :: X
      REAL, DIMENSION(NZ) :: Y
      REAL, DIMENSION(NZ) :: V
      COMPLEX, DIMENSION(NZ) :: CW
      COMPLEX, DIMENSION(L,L) :: CKP
      COMPLEX, DIMENSION(L,L) :: CTRANSM
      COMPLEX, DIMENSION(L,L) :: CT

      !OPEN(UNIT=12,FILE='ENERGY.DAT',FORM='FORMATTED')
      !OPEN(UNIT=13,FILE='PSI0.DAT',FORM='FORMATTED')
      !OPEN(UNIT=14,FILE='PSI.DAT',FORM='FORMATTED')

!
!
!307   FORMAT(86(2X,E14.7))
!308   FORMAT(I5,86(2X,E14.7))
       AM = 0.067D0 !Massa efetiva do e- (GaAs)
       EPS = 12.5D0 !Constante dielétrica (GaAs)
       RY = 13.6058D3 * AM / EPS / EPS
       A0 = 0.5292D0 * EPS / AM
       PI = 4.D0 * DATAN(1.D0)
       CZ = (0.D0,1.D0)

      WRITE(*,*)'INSIRA ENERGIA DA PARTICULA INCIDENTE (meV)=' !Insere variável
      READ(*,*) E1
      E = E1/RY!      WRITE(*,*)'INSIRA A MASSA DA PARTICULA INCIDENTE=' !Insere variável
!      READ(*,*) MASSA

      WRITE(*,*)'INSIRA O COMPRIMENTO=' !Insere variável
      READ(*,*) ALF
      AL = ALF/A0
      DZ = AL/NZ-1      CALL MESH (DZ,Z)

      CALL POTE(A0,RY,AL,Z,V)
      K2 = DSQRT(E-V(NZ))

      DO M=NZ,2
      KB = DSQRT(E-V(M-1))
      DM = K2/KB
      C = CDEXP(CZ*K2*DZ)

      CW(M) = C
      X(M) = (1 + DM)/2
      Y(M) = (1 - DM)/2
      K2 = KB
      ENDDO     D1 (1,1) = X(1)
     D1 (2,1) = Y(1)
     D1 (1,2) = Y(1)
     D1 (2,2) = X(1)

     CALL CALCM(X,Y,CW,KW)
     CT = D1*KW

     CT(2,1) = T1
     CT(1,2) = T2

     CTRANSM = 1 - (DABS(T1)**2)/DABS(T2)**2

     END PROGRAM ABCDE

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

      SUBROUTINE CALCM(X,Y,CW,KW)

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
!
      IMPLICIT REAL (8) (A-B,D-H,O-Z) !Define numeros reais e imaginarios
      IMPLICIT COMPLEX (8)(C)
      PARAMETER(L=2, NZ=501)
      DIMENSION D(L,L), P(L,L), C(L,L)
      COMPLEX (8) CP(L,L), CW(NZ),  CQ(L,L) , CKP(L,L), CK3(L,L), CDP(L,L)
      DO M = NZ,2

      D (1,1) = X(M)
      D (2,1) = Y(M)
      D (1,2) = Y(M)
      D (2,2) = X(M)

      CP (1,1) = CW(M)
      CP (2,1) = (0.D0,0.D0)
      CP (1,2) = (0.D0,0.D0)
      CP (2,2) = DCONJG(CW(M))

      KY(1,1) = D(1,1)*P(1,1)+D(1,2)*P(2,1)
      KY(1,2) = D(1,1)*P(1,2)+D(1,2)*P(2,2)
      KY(2,1) = D(2,1)*P(1,1)+D(2,2)*P(2,1)
      KY(2,2) = D(2,1)*P(1,2)+D(2,2)*P(2,2)

      ENDDO      KY(NZ-1)*KY(NZ)=KW
      DO M=NZ,2
      KY(NZ-2)*KW=KX
      KW=KX

      ENDDO      RETURN
      END  SUBROUTINE CALCM

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
!
      SUBROUTINE MESH(DZ,Z)

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
!
      IMPLICIT REAL(8) (A-H,O-Z)
      PARAMETER (NZ=501)
      DIMENSION Z(NZ)
!
      DO I=1,NZ
      Z(I) = DFLOAT(I-1) * DZ
      ENDDO
 !
      RETURN
      END  SUBROUTINE MESH

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

      SUBROUTINE POTE(A0,RY,AL,Z,POTF) !**********

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

      IMPLICIT REAL(8) (A-H,O-Z)
      PARAMETER (NZ=501)
      DIMENSION Z(NZ), POTF(NZ)

        ALH = 0.5D0 * AL  !MEIO DO SISTEMA
        DQW = 20.D0 / A0   ! DISTANCIA ENTRE POCOS
        DQWH = 0.5D0 * DQW
        QW = 100.D0 / A0   ! LARGURA DOS POCOS
        QWH = 0.5D0 * QW
        AT = DQWH + QW

        DO IZ=1,NZ
        ZW = Z(IZ) - ALH
        POTF(IZ) = 0.D0
        IF(DABS(ZW).GT.DQWH.AND.DABS(ZW).LT.AT)  POTF(IZ) = 400.D0/RY
        ENDDO
 !
      RETURN
      END  SUBROUTINE POTE

Errors:
Code:
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90|110|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90 110 .6:|
||Error: Unclassifiable statement  |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90|111|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90 111 .6:|
||Error: Unclassifiable statement  |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90|112|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90 112 .6:|
||Error: Unclassifiable statement  |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90|113|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90 113 .6:|
||Error: Unclassifiable statement  |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90|118|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90 118 .6:|
||Error: Unclassifiable statement  |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90|120|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90 120 .6:|
||Error: Unclassifiable statement  |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90|52|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90 52 .20:|
||Warning: Rank mismatch in argument 'z'  (rank-1 and scalar)|
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90|54|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90 54 .25:|
||Warning: Rank mismatch in argument 'z'  (rank-1 and scalar)|
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90|57|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90 57 .15:|
||Warning: DO loop  will be executed zero times|
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90|98|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90 98 .17:|
||Warning: DO loop  will be executed zero times|
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90|119|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90 119 .15:|
||Warning: DO loop  will be executed zero times|
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90|74|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira 2.f90 74 .16:|
||Warning: Type mismatch in argument 'x'  ; passed REAL(4) to REAL(8)|
||=== Build finished: 6 errors, 6 warnings (0 minutes, 0 seconds) ===|

Errors decreased significantly, thanks for now.
 
  • #13
jtbell said:
Put "[noparse]
Code:
[/noparse]" before your code and "[noparse]
[/noparse]" after it.

Thanks, help me a lot.
 
  • #14
felipearcaro said:
2) I need remove this line? IMPLICIT REAL (8) (A-B,D-H,O-Z)
I would recommend that you remove all of these statements, and replace them with just the declarations of the variables you are using. I believe this statement is causing problems with array variables that start with the letters you list in this statement. I'll say more about this later.

felipearcaro said:
3) In this part i try calculate KY, and after to do:
KY(500)*KY(501)=KW
KY(NZ-2)*KW=KX
KW=KX where renew KW
Those statements are illegal. An assignment statement must have a variable on the left side of =, and the value to be stored on the right side of =.
You can do this:
KW = KY(500) * KY(501)
Here I multiply the two array elements and store the result in KW.

felipearcaro said:
I have a matrix[L,L] with D e P, where D depends on the X,Y and P depends on the CW.
I believe that i can use a matrix in a "DO" using just one variable, like KW(NZ).. I don't know if i was clear..
No comprendo (sorry, no hablo portugueso, pero yo hablo poquito español...)
You have a two-dimension matrix. What does "D e P" mean?
You can operate on a matrix in a DO loop. If the matrix has two indexes, both must be present, although there is a shortcut you can use to operate only on the rows or the columns, something like KW(I, :). When I wrote Fortran code, that wasn't part of the language.

The comments below apply to your CALCM subroutine.
felipearcaro said:
Code:
    SUBROUTINE CALCM(X,Y,CW,KW)
!
      IMPLICIT REAL (8) (A-B,D-H,O-Z) !Define numeros reais e imaginarios
      IMPLICIT COMPLEX (8)(C)
      PARAMETER(L=2, NZ=501)
      DIMENSION D(L,L), P(L,L), C(L,L)
      COMPLEX (8) CP(L,L), CW(NZ),  CQ(L,L) , CKP(L,L), CK3(L,L), CDP(L,L)
Again, I would advise you to get rid of the IMPLICIT REAL and IMPLICIT COMPLEX lines. They are definitely causing errors for you.
For example, the second IMPLICIT line says that any variable whose name begins with 'C' is a complex number. I believe this conflicts with your declaration a few lines later of CP, CW, and so on, all of which are arrays.

The subroutine formal parameters are X, Y, CW, and KW. You should have explicit declarations for each of these, as well as the explicit declarations of the other variables that you are using in this subroutine.

Your array declarations are still wrong. They should look like this:
Code:
REAL, DIMENSION(L,L) :: KW
REAL, DIMENSION(NZ) :: X
COMPLEX, DIMENSION(NZ) :: CW

If you want the arrays to hold double-precision numbers, you can do this:
Code:
REAL*8, DIMENSION(L,L) :: KW
REAL*8, DIMENSION(NZ) :: X
COMPLEX*16, DIMENSION(NZ) :: CW


The same comments apply to your MESH and POTE subroutines.

Finally, you should clean up your main PROGRAM.
As I said before, get rid of the two IMPLICIT statements at the top, and explicitly declare each variable that you use in the PROGRAM part of your code, but only those variables. Make sure that you declare array variables as arrays. It looks to me like you are declaring every variable in the PROGRAM section, including the ones used in the subroutines. Declare only the variables that are used in the main program.
 
  • #15
I forgot to mention that there is some information in the error messages that can be useful. In post #9 you gave a long list of errors such as this one:

fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|76|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 76 .6:|

The last two numbers at the end indicate (I believe) the line where the error occurred, and possibly the position in the line.

One thing that makes me nervous is that your directory name and file name have lots of spaces in them. I don't know the requirements of your compiler and linker, but many will complain if there are spaces in the file name.
 
  • #16
Mark44 said:
I forgot to mention that there is some information in the error messages that can be useful. In post #9 you gave a long list of errors such as this one:

fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90|76|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira.f90 76 .6:|

The last two numbers at the end indicate (I believe) the line where the error occurred, and possibly the position in the line.

One thing that makes me nervous is that your directory name and file name have lots of spaces in them. I don't know the requirements of your compiler and linker, but many will complain if there are spaces in the file name.

You're right, i will check this.
 
  • #17
In the subrotine, if i want do a loop with matrix, how i define the matrix?
I try this but didnt work, i believe that the logica is right (i did in a paper before)
The lines with "!" i left just like a base for me

Code:
!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

      SUBROUTINE CALCM(X,Y,CW,KW)

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
!
      IMPLICIT REAL (8) (A-B,D-H,O-Z) !Define numeros reais e imaginarios
      IMPLICIT COMPLEX (8)(C)
      PARAMETER(L=2, NZ=501)
      DIMENSION KY(L,L)
      COMPLEX (8) CKY(L,L), CKW(L,L,NZ), CKJ (L,L,NZ)

!faz o D*P para todos as barreiras D2*P2, D3*P3..
      DO M = NZ,2

      CKY(1,1) = X(M)*CW(M)
      CKY(1,2) = Y(M)*DCONJG(CW(M)
      CKY(2,1) = Y(M)*CW(M)
      CKY(2,2) = X(M)*DCONJG(CW(M)

      ENDDO
!faz a primeira multiplicação de trás pra frente (D500*P500)*(D501*P501)
      CKW(1,1,NZ) = CKY(1,1,NZ-1)*CKY(1,1,NZ) + CKY(1,2,NZ-1)*CKY(2,1,NZ)
      CKW(1,2,NZ) = CKY(1,1,NZ-1)*CKY(1,2,NZ) + CKY(1,2,NZ-1)*CKY(2,2,NZ)
      CKW(2,1,NZ) = CKY(2,1,NZ-1)*CKY(1,1,NZ) + CKY(2,2,NZ-1)*CKY(2,1,NZ)
      CKW(2,2,NZ) = CKY(2,1,NZ-1)*CKY(1,2,NZ) + CKY(2,2,NZ-1)*CKY(2,2,NZ)

      DO M = NZ-2,2

      !CKJ = CKY(M)*CKW
      CKJ(1,1,M) = CKY(1,1,M)*CKY(1,1,NZ) + CKY(1,2,M)*CKY(2,1,NZ)
      CKJ(1,2,M) = CKY(1,1,M)*CKY(1,2,NZ) + CKY(1,2,M)*CKY(2,2,NZ)
      CKJ(2,1,M) = CKY(2,1,M)*CKY(1,1,NZ) + CKY(2,2,M)*CKY(2,1,NZ)
      CKJ(2,2,M) = CKY(2,1,M)*CKY(1,2,NZ) + CKY(2,2,M)*CKY(2,2,NZ)
      !CKW = CKJ

      CKW(1,1,NZ) = CKJ(1,1,M)
      CKW(1,2,NZ) = CKJ(1,1,M)
      CKW(2,1,NZ) = CKY(2,1,M)
      CKW(2,2,NZ) = CKY(2,1,M)      !D(1,1) = X(M)
      !D(2,1) = Y(M)
      !D(1,2) = Y(M)
      !D(2,2) = X(M)

      !CP(1,1) = CW(M)
      !CP(2,1) = (0.D0,0.D0)
      !CP(1,2) = (0.D0,0.D0)
      !CP(2,2) = DCONJG(CW(M))

      !CKY(1,1,M) = D(1,1)*CP(1,1)+D(1,2)*P(2,1)
      !KY(1,2,M) = D(1,1)*P(1,2)+D(1,2)*P(2,2)
      !KY(2,1,M) = D(2,1)*P(1,1)+D(2,2)*P(2,1)
      !KY(2,2,M) = D(2,1)*P(1,2)+D(2,2)*P(2,2)    

      ENDDO      RETURN
      END  SUBROUTINE CALCM
 
  • #18
I found the problem.
 
  • #20
I don't know why but i changed just the first lines (DIMENSION) and the program worked.
Then i did some little changes like "DO M = NZ, 2" to "DO M = 2,NZ"

The complete code:
Code:
      PROGRAM ABCDE


      IMPLICIT REAL (8) (A-B,D-H,O-Z) !Define numeros reais e imaginarios
      IMPLICIT COMPLEX (8)(C)
      PARAMETER(NZ=501,L=2) !Define parametros
!

      REAL, DIMENSION(L,L) :: D1
      REAL, DIMENSION(L,L) :: P
      REAL, DIMENSION(L,L) :: D
      REAL, DIMENSION(L,L) :: Q
      REAL, DIMENSION(NZ) :: X
      REAL, DIMENSION(NZ) :: Y
      REAL, DIMENSION(NZ) :: V
      COMPLEX, DIMENSION(NZ) :: CW
      COMPLEX, DIMENSION(L,L) :: CKP
      COMPLEX, DIMENSION(L,L) :: CTRANSM
      COMPLEX, DIMENSION(L,L) :: CT
      COMPLEX, DIMENSION(2,2) :: CKJ
      COMPLEX, DIMENSION(2,2) :: CKT



      !OPEN(UNIT=12,FILE='ENERGY.DAT',FORM='FORMATTED')
      !OPEN(UNIT=13,FILE='PSI0.DAT',FORM='FORMATTED')
      !OPEN(UNIT=14,FILE='PSI.DAT',FORM='FORMATTED')

!
!
!307   FORMAT(86(2X,E14.7))
!308   FORMAT(I5,86(2X,E14.7))
       AM = 0.067D0 !Massa efetiva do e- (GaAs)
       EPS = 12.5D0 !Constante dielétrica (GaAs)
       RY = 13.6058D3 * AM / EPS / EPS
       A0 = 0.5292D0 * EPS / AM
       PI = 4.D0 * DATAN(1.D0)
       CZ = (0.D0,1.D0)

      WRITE(*,*)'INSIRA ENERGIA DA PARTICULA INCIDENTE (meV)=' !Insere variável
      READ(*,*) E1
      E = E1/RY


!      WRITE(*,*)'INSIRA A MASSA DA PARTICULA INCIDENTE=' !Insere variável
!      READ(*,*) MASSA

      WRITE(*,*)'INSIRA O COMPRIMENTO=' !Insere variável
      READ(*,*) ALF
      AL = ALF/A0


      CALL MESH (DZ,Z)

      CALL POTE(A0,RY,AL,Z,V)
      KB = DSQRT(E-V(2)) !COMEÇA NO 3 OU NO 2?

      DO M=3,NZ
      K2 = DSQRT(E-V(M))
      DM = K2/KB
      C = CDEXP(CZ*K2*DZ)

      CW(M) = C
      X(M) = (1 + DM)/2
      Y(M) = (1 - DM)/2
      KB = K2
      ENDDO


     D1 (1,1) = X(1)
     D1 (2,1) = Y(1)
     D1 (1,2) = Y(1)
     D1 (2,2) = X(1)

     CALL CALCM(X,Y,CW,CKJ)

    CKT(1,1)= D(1,1)*CKJ(1,1)+D(1,2)*CKJ(2,1)
    !CKT(1,2)
    CKT(2,1) = D(2,1)*CKJ(1,1)+D(2,2)*CKJ(2,1)
    !CKT(2,2)
     !CKY(1,1,M) = D(1,1)*CP(1,1)+D(1,2)*P(2,1)
      !KY(1,2,M) = D(1,1)*P(1,2)+D(1,2)*P(2,2)
      !KY(2,1,M) = D(2,1)*P(1,1)+D(2,2)*P(2,1)
      !KY(2,2,M) = D(2,1)*P(1,2)+D(2,2)*P(2,2)


    !CKT(2,1) = CT1
     !CKT(1,1) = CT2

!ESCREVER DESSE JEITO DA CERTO?

    CEFICIENCIA = 1 - (DABS(CKT(2,1))**2)/DABS(CKT(1,1))**2

    WRITE(*,*) CEFICIENCIA



     END PROGRAM ABCDE




!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

      SUBROUTINE CALCM(X,Y,CW,CKJ)

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
!
      IMPLICIT REAL (8) (A-B,D-H,O-Z) !Define numeros reais e imaginarios
      IMPLICIT COMPLEX (8)(C)
      PARAMETER(NZ=501)
      !DIMENSION
      !COMPLEX (8) CKY(2,2), CKW(L,L,NZ), CKJ (L,L,NZ)
      COMPLEX, DIMENSION(2,2,NZ) :: CKY
      COMPLEX, DIMENSION(2,2) :: CKW
      COMPLEX, DIMENSION(2,2) :: CKJ

!faz o D*P para todos as barreiras D2*P2, D3*P3..
      DO M = 2,NZ

      CKY(1,1,M) = X(M)*CW(M)
      CKY(1,2,M) = Y(M)*DCONJG(CW(M))
      CKY(2,1,M) = Y(M)*CW(M)
      CKY(2,2,M) = X(M)*DCONJG(CW(M))

      ENDDO
!faz a primeira multiplicação de trás pra frente (D500*P500)*(D501*P501)
      CKW(1,1) = CKY(1,1,2)*CKY(1,1,3) + CKY(1,2,2)*CKY(2,1,3)
      CKW(1,2) = CKY(1,1,2)*CKY(1,2,3) + CKY(1,2,2)*CKY(2,2,3)
      CKW(2,1) = CKY(2,1,2)*CKY(1,1,3) + CKY(2,2,2)*CKY(2,1,3)
      CKW(2,2) = CKY(2,1,2)*CKY(1,2,3) + CKY(2,2,2)*CKY(2,2,3)

      DO M = 4,NZ

      !CKJ = CKY(M)*CKW
      CKJ(1,1) = CKW(1,1)*CKY(1,1,M) + CKW(1,2)*CKY(2,1,M)
      CKJ(1,2) = CKW(1,1)*CKY(1,2,M) + CKW(1,2)*CKY(2,2,M)
      CKJ(2,1) = CKW(2,1)*CKY(1,1,M) + CKW(2,2)*CKY(2,1,M)
      CKJ(2,2) = CKW(2,1)*CKY(1,2,M) + CKW(2,2)*CKY(2,2,M)
      !CKW = CKJ

      CKW(1,1) = CKJ(1,1)
      CKW(1,2) = CKJ(1,2)
      CKW(2,1) = CKJ(2,1)
      CKW(2,2) = CKJ(2,2)


      !D(1,1) = X(M)
      !D(2,1) = Y(M)
      !D(1,2) = Y(M)
      !D(2,2) = X(M)

      !CP(1,1) = CW(M)
      !CP(2,1) = (0.D0,0.D0)
      !CP(1,2) = (0.D0,0.D0)
      !CP(2,2) = DCONJG(CW(M))

      !CKY(1,1,M) = D(1,1)*CP(1,1)+D(1,2)*P(2,1)
      !KY(1,2,M) = D(1,1)*P(1,2)+D(1,2)*P(2,2)
      !KY(2,1,M) = D(2,1)*P(1,1)+D(2,2)*P(2,1)
      !KY(2,2,M) = D(2,1)*P(1,2)+D(2,2)*P(2,2)




      ENDDO


      RETURN
      END  SUBROUTINE CALCM

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
!
      SUBROUTINE MESH(AL,Z)

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
!
      IMPLICIT REAL(8) (A-H,O-Z)
      PARAMETER (NZ=501)
      DIMENSION Z(NZ)
!
      DZ = AL/(NZ-1)
      DO I=1,NZ
      Z(I) = DFLOAT(I-1) * DZ
      ENDDO
 !
      RETURN
      END  SUBROUTINE MESH

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

      SUBROUTINE POTE(A0,RY,AL,Z,POTF) !**********

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

      IMPLICIT REAL(8) (A-H,O-Z)
      PARAMETER (NZ=501)
      DIMENSION Z(NZ), POTF(NZ)

        ALH = 0.5D0 * AL  !MEIO DO SISTEMA
        DQW = 20.D0 / A0   ! DISTANCIA ENTRE POCOS
        DQWH = 0.5D0 * DQW
        QW = 100.D0 / A0   ! LARGURA DOS POCOS
        QWH = 0.5D0 * QW
        AT = DQWH + QW

        DO IZ=1,NZ
        ZW = Z(IZ) - ALH
        POTF(IZ) = 0.D0
        IF(DABS(ZW).GT.DQWH.AND.DABS(ZW).LT.AT)  POTF(IZ) = 400.D0/RY
        ENDDO
 !
      RETURN
      END  SUBROUTINE POTE

There's some "warnings" but i will fix tomorrow with my teacher, i think isn't a big problem.
 
  • #21
There is no errors anymore but when i run the program asking for print CEF appears NaN (not a number), i don't know what to do

Code:
      PROGRAM ABCDE


      IMPLICIT REAL (8) (A-B,D-H,O-Z) !Define numeros reais e imaginarios
      IMPLICIT COMPLEX (8)(C)
      PARAMETER(NZ=501,L=2) !Define parametros
      DIMENSION Z(NZ), X(NZ), Y(NZ), V(NZ), D1(L,L), P(L,L), D(L,L)
      DIMENSION Q(L,L)
      COMPLEX (8) CW(NZ), CKP(L,L), CKJ (L,L)
!
      !OPEN(UNIT=12,FILE='ENERGY.DAT',FORM='FORMATTED')
      !OPEN(UNIT=13,FILE='PSI0.DAT',FORM='FORMATTED')
      OPEN(UNIT=14,FILE='POT.DAT',FORM='FORMATTED')
!
!
!307   FORMAT(86(2X,E14.7))
!308   FORMAT(I5,86(2X,E14.7))
       AM = 0.067D0 !Massa efetiva do e- (GaAs)
       EPS = 12.5D0 !Constante dielétrica (GaAs)
       RY = 13.6058D3 * AM / EPS / EPS
       A0 = 0.5292D0 * EPS / AM
       PI = 4.D0 * DATAN(1.D0)
       CZ = (0.D0,1.D0)

      WRITE(*,*)'INSIRA ENERGIA DA PARTICULA INCIDENTE (meV)=' !Insere variável
      READ(*,*) E1
      E = E1/RY

!      WRITE(*,*)'INSIRA A MASSA DA PARTICULA INCIDENTE=' !Insere variável
!      READ(*,*) MASSA

      WRITE(*,*)'INSIRA O COMPRIMENTO=' !Insere variável
      READ(*,*) ALF
      AL = ALF/A0

      CALL MESH(AL,Z)

      CALL POTE(A0,RY,AL,Z,V)
      KB = DSQRT(E-V(2)) !COMEÇA NO 3 OU NO 2?

      DO M=3,NZ
       K2 = DSQRT(E-V(M))
       DM = K2/KB
       C = CDEXP(CZ*K2*DZ)

       CW(M) = C
       X(M) = (1.D0 + DM)/2.D0
       Y(M) = (1.D0 - DM)/2.D0
       KB = K2
      ENDDO

      D1 (1,1) = X(1)
      D1 (2,1) = Y(1)
      D1 (1,2) = Y(1)
      D1 (2,2) = X(1)

      CALL CALCM(X,Y,CW,CKJ)

      CKT11= D1(1,1)*CKJ(1,1)+D1(1,2)*CKJ(2,1)
      !CKT(1,2)
      CKT21 = D1(2,1)*CKJ(1,1)+D1(2,2)*CKJ(2,1)
      !CKT(2,2)

      !CKY(1,1,M) = D(1,1)*CP(1,1)+D(1,2)*P(2,1)
      !KY(1,2,M) = D(1,1)*P(1,2)+D(1,2)*P(2,2)
      !KY(2,1,M) = D(2,1)*P(1,1)+D(2,2)*P(2,1)
      !KY(2,2,M) = D(2,1)*P(1,2)+D(2,2)*P(2,2)

      !CKT(2,1) = CT1
      !CKT(1,1) = CT2

!ESCREVER DESSE JEITO DA CERTO?

      CEF = 1.D0 - (CDABS(CKT21))**2/(CDABS(CKT11))**2

      WRITE(*,*) CEF

      END PROGRAM ABCDE


!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

      SUBROUTINE CALCM(X,Y,CW,CKJ)

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
!
      IMPLICIT REAL (8) (A-B,D-H,O-Z) !Define numeros reais e imaginarios
      IMPLICIT COMPLEX (8)(C)
      PARAMETER(NZ=501, L=2)
      DIMENSION Z(NZ), X(NZ), Y(NZ), V(NZ)
      !DIMENSION
      COMPLEX (8) CW(NZ), CKW(L,L), CKJ (L,L), CKY(L,L,NZ)


!faz o D*P para todos as barreiras D2*P2, D3*P3..
      DO M = 2,NZ
       CKY(1,1,M) = X(M)*CW(M)
       CKY(1,2,M) = Y(M)*DCONJG(CW(M))
       CKY(2,1,M) = Y(M)*CW(M)
       CKY(2,2,M) = X(M)*DCONJG(CW(M))
      ENDDO
!faz a primeira multiplicação de trás pra frente (D500*P500)*(D501*P501)
      CKW(1,1) = CKY(1,1,2)*CKY(1,1,3) + CKY(1,2,2)*CKY(2,1,3)
      CKW(1,2) = CKY(1,1,2)*CKY(1,2,3) + CKY(1,2,2)*CKY(2,2,3)
      CKW(2,1) = CKY(2,1,2)*CKY(1,1,3) + CKY(2,2,2)*CKY(2,1,3)
      CKW(2,2) = CKY(2,1,2)*CKY(1,2,3) + CKY(2,2,2)*CKY(2,2,3)

      DO M = 4,NZ
      !CKJ = CKY(M)*CKW
       CKJ(1,1) = CKW(1,1)*CKY(1,1,M) + CKW(1,2)*CKY(2,1,M)
       CKJ(1,2) = CKW(1,1)*CKY(1,2,M) + CKW(1,2)*CKY(2,2,M)
       CKJ(2,1) = CKW(2,1)*CKY(1,1,M) + CKW(2,2)*CKY(2,1,M)
       CKJ(2,2) = CKW(2,1)*CKY(1,2,M) + CKW(2,2)*CKY(2,2,M)
      !CKW = CKJ

      CKW(1,1) = CKJ(1,1)
      CKW(1,2) = CKJ(1,2)
      CKW(2,1) = CKJ(2,1)
      CKW(2,2) = CKJ(2,2)

      !D(1,1) = X(M)
      !D(2,1) = Y(M)
      !D(1,2) = Y(M)
      !D(2,2) = X(M)

      !CP(1,1) = CW(M)
      !CP(2,1) = (0.D0,0.D0)
      !CP(1,2) = (0.D0,0.D0)
      !CP(2,2) = DCONJG(CW(M))

      !CKY(1,1,M) = D(1,1)*CP(1,1)+D(1,2)*P(2,1)
      !KY(1,2,M) = D(1,1)*P(1,2)+D(1,2)*P(2,2)
      !KY(2,1,M) = D(2,1)*P(1,1)+D(2,2)*P(2,1)
      !KY(2,2,M) = D(2,1)*P(1,2)+D(2,2)*P(2,2)

      ENDDO


      RETURN
      END  SUBROUTINE CALCM

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
!
      SUBROUTINE MESH(AL,Z)

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
!
      IMPLICIT REAL(8) (A-H,O-Z)
      PARAMETER (NZ=501)
      DIMENSION Z(NZ)
!
      DZ = AL/(NZ-1)
      DO I=1,NZ
      Z(I) = DFLOAT(I-1) * DZ
      ENDDO
 !
      RETURN
      END  SUBROUTINE MESH

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

      SUBROUTINE POTE(A0,RY,AL,Z,V) !**********

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

      IMPLICIT REAL(8) (A-H,O-Z)
      PARAMETER (NZ=501)
      DIMENSION Z(NZ), V(NZ)

        ALH = 0.5D0 * AL  !MEIO DO SISTEMA
        DQW = 50.D0 / A0   ! DISTANCIA ENTRE POCOS
        DQWH = 0.5D0 * DQW
        QW = 50.D0 / A0   ! LARGURA DOS POCOS
        QWH = 0.5D0 * QW
        AT = DQWH + QW

        DO IZ=1,NZ
        ZW = Z(IZ) - ALH
        V(IZ) = 0.D0
        IF(DABS(ZW).GT.DQWH.AND.DABS(ZW).LT.AT)  V(IZ) = 200.D0/RY
        WRITE(14,*) Z(IZ)*A0, V(IZ)*RY
        ENDDO
 !
      RETURN
      END  SUBROUTINE POTE
 
  • #22
I would add write statements for the variables usedto compute cef and continue to backtrack from there. It may be that you forgot to initialize one of them properly. Also I would add write stmts to print the subroutine arguments as well I case they are not initialized as expected.

Its hard to diagnose a problem like this with only the program and not the input data nor compiler, system... used. Only you can do the diagnostics and figure this out. Backtrack thru your variables to see what's going on.
 
Last edited:
  • #23
Yes, i did this and found the problem, i think.
It was some problems with complex numbers and definitions
I tried to fix with this IF, but wasn't work..
Code:
      CKB = DSQRT(E-V(2))

      !WRITE(*,*) CKB, V(2)*RY, E

      DO M=3,NZ
      IF (E.GT.V(M)) THEN
      K2 = DSQRT(E-V(M))
      CK2 = (DSQRT(E-V(M)),0.D0)
      END IF      IF (V(M).GT.E) THEN
      K2 = DSQRT(V(M)-E)
      CK2 = (0.D0, DSQRT(V(M)-E)
      END IF      CDM = CK2/CKB
      C = CDEXP(CZ*AK2*DZ)

      CW(M) = C !>>>> CW ESTA DANDO 1 SEMPRE / DZ NAO TERIA QUE TROCAR POR Z(IZ)?<<<<
        !WRITE(*,*)CW(M)
      X(M) = (1.D0 + CDM)/2.D0 !>>>>DA SEMPRE 1<<<<
        !WRITE(*,*) X(M)
      Y(M) = (1.D0 - CDM)/2.D0 !>>>>DA SEMPRE 0<<<<
        CKB = CK2

      ENDDO

This part "CKB = DSQRT(E-V(2))" will be a real number, so don't need a IF.

Code:
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira FINAL.f90|47|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira FINAL.f90 47 .26:|
||Error: Expected a right parenthesis in expression  |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira FINAL.f90|53|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira FINAL.f90 53 .24:|
||Error: Expected PARAMETER symbol in complex constant  |
||=== Build finished: 2 errors, 0 warnings (0 minutes, 0 seconds) ===|
 
  • #24
Dont you need to use ENDIF and not END IF for your IF stmts?

also you should use and ELSE clause instead of the second IF stmt since you're not covering the possiblity of E.eq.V(M) or you need to change one of the IF stmts with .ge. or .le. to cover the equals condition.
 
  • #25
i trade to ENDIF and the erros keep on..
i use IF and ELSE now, when E.eq.V(M), K2 = 0 so i can use in the complex part (CK2 = 0.D0,K2 = 0.D0,0.D0)

I indicate the line with error in the code
Code:
      DO M=3,NZ

      IF (E.GT.V(M)) THEN
      K2 = DSQRT(E-V(M))
      CK2 = (K2,0.D0) !LINE 48

      ELSE
      K2 = DSQRT(V(M)-E)
      CK2 = (0.D0, K2) !LINE 52
      ENDIF      CDM = CK2/CKB
      C = CDEXP(CZ*AK2*DZ)

      CW(M) = C
      !WRITE(*,*)CW(M)
      X(M) = (1.D0 + CDM)/2.D0
      !WRITE(*,*) X(M)
      Y(M) = (1.D0 - CDM)/2.D0
      CKB = CK2

      ENDDO

Code:
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira FINAL.f90|47|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira FINAL.f90 47 .15:|
||Error: Expected PARAMETER symbol in complex constant  |
fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira FINAL.f90|51|fica\Programa Computacional\FORTRAN\Particula incidente em uma barreira\particula incidente em uma barreira FINAL.f90 51 .21:|
||Error: Expected PARAMETER symbol in complex constant  |
||=== Build finished: 2 errors, 0 warnings (0 minutes, 0 seconds) ===|
 
  • #26
the only thing I can think of is that it wants K2 to be a constant meaning that it thinks CK2 is defined as a constant but I couldn't see that in your code.

I found a bugzilla report where it said if your lines of code are too long then you'll get this error and the fix was to set a compile flag.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31594
 
  • #27
I think you need to change CK2 = (K2,0.D0) to CK2 = CMPLX(K2,0.D0)

Also, what type of variable is K2? In your code it seems to be an integer, which is probably wrong.
 
  • #28
AlephZero said:
I think you need to change CK2 = (K2,0.D0) to CK2 = CMPLX(K2,0.D0)

Also, what type of variable is K2? In your code it seems to be an integer, which is probably wrong.

I trade K2 to AK2, because this line says that K is actually INTEGER:
IMPLICIT REAL (8) (A-B,D-H,O-Z)

And I add CMPLX and it works.
But why i need this?
In other line, I write: CZ = (0.D0,1.D0) for define complex number and it works fine..
 
  • #29
felipearcaro said:
And I add CMPLX and it works.
But why i need this?
In other line, I write: CZ = (0.D0,1.D0) for define complex number and it works fine..

The form ( ... , ... ) is a complex constant. The only things you can put in a constant are values that the complier can figure when it compiles the priogram, not when the program is running. That includes real and integer constant values like 123 or 0.0D0, and values defined in PARAMETER statements. Since "K2" looks more like a parameter name than a real or integer cosntant, the error message said "K2 is not a parameter".

CMPLX( ... , ... ) is an intinsic function, just like SQRT, MAX, etc. The two arguments can be any expressions that evaluate to real numbers. You could have said

Code:
IF (E.GT.V(M)) THEN
      CK2 = CMPLX(DSQRT(E-V(M)), 0.D0)
and not used the variable K2 at all.

Actually you could just say CK2 = DSQRT(E-V(M)) there, but you need CMPLX for the "ELSE" part of the code.
 
  • #30
Thanks very much, i think my program is working fine now. I will be back soon with new questions.
This forum is awesome.
 
  • #31
I'm almost finishing this program, there is only one problem and i think it's because the complex numbers.
When i run the program and plot the graph (with Origin), appears:
dvkqio.jpg


But the correct is:
14v1ah.jpg



The part with the complex numbers (where V>E(K)) is the problem i think, because when E>200, it works fine.

Code:
      PROGRAM ABCDE


      IMPLICIT REAL (8) (A-B,D-H,O-Z) !Define numeros reais e imaginarios
      IMPLICIT COMPLEX (8)(C)
      PARAMETER(NZ=501, L=2) !Define parametros
      DIMENSION Z(NZ), X(NZ), Y(NZ), V(NZ), D1(L,L), P(L,L), D(L,L), I(NZ)
      DIMENSION Q(L,L), E(NZ)
      COMPLEX (8) CW(NZ), CKP(L,L), CKJ (L,L), CX(NZ), CY(NZ)
!
      OPEN(UNIT=12,FILE='VALORES2.DAT',FORM='FORMATTED')
      OPEN(UNIT=13,FILE='VALORES.DAT',FORM='FORMATTED')
      OPEN(UNIT=14,FILE='POT.DAT',FORM='FORMATTED')
      OPEN(UNIT=15,FILE='GRAPH.DAT',FORM='FORMATTED')
!
!
307   FORMAT(86(2X,E14.7))
308   FORMAT(I5,86(2X,E14.7))
       AM = 0.067D0 !Massa efetiva do e- (GaAs)
       EPS = 12.5D0 !Constante dielétrica (GaAs)
       RY = 13.6058D3 * AM / EPS / EPS
       A0 = 0.5292D0 * EPS / AM
       PI = 4.D0 * DATAN(1.D0)
       CZ = (0.D0,1.D0) !Unidade complexa

      !WRITE(*,*)'INSIRA ENERGIA DA PARTICULA INCIDENTE (meV)=' !Entrada da energia da particula incidente
      !READ(*,*) E1
      !E = E1/RY

      WRITE(*,*)'INSIRA O COMPRIMENTO=' !Entrada do comprimento avaliado
      READ(*,*) ALF
      AL = ALF/A0


      DZ = AL/(NZ-1)

      CALL MESH(AL,DZ,Z) !Chama subrotina que fraciona o comprimento (em pedacos de tamanho dz)
      CALL POTE(A0,RY,AL,Z,V) !Chama subrotina que define o potencial em todo o comprimento

    !DO M=1,NZ
    !E(M)=M
    !WRITE(*,*) E(M)
    !ENDDO


      DO K=1,NZ !L=E1, pois a variavel precisava ser inteiro
      E(K)=K/RY

      CKB = DSQRT(E(K)-V(1))

      DO M=1,NZ

      IF (E(K).GT.V(M+1)) THEN
      AK2 = DSQRT(E(K)-V(M+1))
      CDM = AK2/CKB
      CKZ = CDEXP(CZ*CKB*DZ)
      CKB = AK2

      !WRITE(*,*) CK2

      ELSE
      CK2 = DSQRT(V(M+1)-E(K))*CZ
      CDM = CK2/CKB
      CKZ = CDEXP(CZ*CKB*DZ)
      CKB = CK2

      ENDIF
      !WRITE(*,*) CK2


      !WRITE(*,*) CMD

      !WRITE(*,*)  CKZ

      CW(M) = CKZ
      !WRITE(*,*)CW(M)
      CX(M) = (1.D0 + CDM)/2.D0
      !WRITE(*,*) CX(M)
      CY(M) = (1.D0 - CDM)/2.D0
      !WRITE(*,*) CY(M)



      ENDDO

      !WRITE(*,*) CKB, V(2)*RY, E



      !D1 (1,1) = X(1)
      !D1 (2,1) = Y(1)
      !D1 (1,2) = Y(1)
      !D1 (2,2) = X(1)

      CALL CALCM(CX,CY,CW,CKJ)

      CKT11= CX(1)*CKJ(1,1)+CY(1)*CKJ(2,1)

      !CKT(1,2)
      CKT21 = CY(1)*CKJ(1,1)+CX(1)*CKJ(2,1)
      !WRITE(*,*) CKT21
      !CKT(2,2)

      !CKY(1,1,M) = D(1,1)*CP(1,1)+D(1,2)*P(2,1)
      !KY(1,2,M) = D(1,1)*P(1,2)+D(1,2)*P(2,2)
      !KY(2,1,M) = D(2,1)*P(1,1)+D(2,2)*P(2,1)
      !KY(2,2,M) = D(2,1)*P(1,2)+D(2,2)*P(2,2)

      !CKT(2,1) = CT1
      !CKT(1,1) = CT2


      !Define a eficiencia
      ACF = 1.D0 - (CDABS(CKT21))**2/(CDABS(CKT11))**2
      !WRITE(*,*) CDABS(CKT21), CDABS(CKT11)


      WRITE (15,307) E(K)*RY, ACF
      ENDDO


      END PROGRAM ABCDE


!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

      SUBROUTINE CALCM(CX,CY,CW,CKJ)

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
!
      IMPLICIT REAL (8) (A-B,D-H,O-Z) !Define numeros reais e imaginarios
      IMPLICIT COMPLEX (8)(C)
      PARAMETER(NZ=501, L=2)
      DIMENSION Z(NZ), V(NZ)
      !DIMENSION
      COMPLEX (8) CX(NZ), CY(NZ), CW(NZ), CKW(L,L), CKJ (L,L), CKY(L,L,NZ)


      !Faz D*P para todos as barreiras D2*P2, D3*P3..
      DO M = 1,NZ
       CKY(1,1,M) = DCONJG(CW(M))*CX(M)
       CKY(1,2,M) = DCONJG(CW(M))*CY(M)
       CKY(2,1,M) = CW(M)*CY(M)
       CKY(2,2,M) = CW(M)*CX(M)
       !WRITE(*,*) DCONJG(CW(M))

      ENDDO
      !Faz a primeira multiplicação para o loop [D2*P2].[D3*P3]
      CKW(1,1) = CKY(1,1,2)*CKY(1,1,3) + CKY(1,2,2)*CKY(2,1,3)
      CKW(1,2) = CKY(1,1,2)*CKY(1,2,3) + CKY(1,2,2)*CKY(2,2,3)
      CKW(2,1) = CKY(2,1,2)*CKY(1,1,3) + CKY(2,2,2)*CKY(2,1,3)
      CKW(2,2) = CKY(2,1,2)*CKY(1,2,3) + CKY(2,2,2)*CKY(2,2,3)
      !WRITE(*,*) CKW(1,1)

      !Faz o resto das mutiplicações usando o resultado da ultima como um fator a multiplicar
      DO M = 4,NZ
       CKJ(1,1) = CKW(1,1)*CKY(1,1,M) + CKW(1,2)*CKY(2,1,M)
       CKJ(1,2) = CKW(1,1)*CKY(1,2,M) + CKW(1,2)*CKY(2,2,M)
       CKJ(2,1) = CKW(2,1)*CKY(1,1,M) + CKW(2,2)*CKY(2,1,M)
       CKJ(2,2) = CKW(2,1)*CKY(1,2,M) + CKW(2,2)*CKY(2,2,M)

       !Renova o valor do fator a mutiplicar
       CKW(1,1) = CKJ(1,1)
       CKW(1,2) = CKJ(1,2)
       CKW(2,1) = CKJ(2,1)
       CKW(2,2) = CKJ(2,2)
    !WRITE(*,*) CKW(1,1)
      ENDDO


      RETURN
      END  SUBROUTINE CALCM

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
!
      SUBROUTINE MESH(AL,DZ,Z)

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
!
      IMPLICIT REAL(8) (A-H,O-Z)
      PARAMETER (NZ=501)
      DIMENSION Z(NZ)
!

      DO I=1,NZ
      Z(I) = DFLOAT(I-1) * DZ
      ENDDO
 !
      RETURN
      END  SUBROUTINE MESH

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

      SUBROUTINE POTE(A0,RY,AL,Z,V) !**********

!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

      IMPLICIT REAL(8) (A-H,O-Z)
      PARAMETER (NZ=501)
      DIMENSION Z(NZ), V(NZ)

        ALH = 0.5D0 * AL  !MEIO DO SISTEMA
        DQW = 50.D0 / A0   ! DISTANCIA ENTRE POCOS
        DQWH = 0.5D0 * DQW
        QW = 50.D0 / A0   ! LARGURA DOS POCOS
        QWH = 0.5D0 * QW
        AT = DQWH + QW

        DO IZ=1,NZ
        ZW = Z(IZ) - ALH
        V(IZ) = 0.D0
        IF(DABS(ZW).GT.DQWH.AND.DABS(ZW).LT.AT)  V(IZ) = 200.D0/RY
        WRITE(14,*) Z(IZ)*A0, V(IZ)*RY
        ENDDO
 !
      RETURN
      END  SUBROUTINE POTE
 
  • #32
I think the problem is in this part ELSE
CK2 = DSQRT(V(M+1)-E(K))*CZ
CDM = CK2/CKB
CKZ = CDEXP(CZ*CKB*DZ)
CKB = CK2
 
  • #33
Anyone?
 

1. What is Fortran and why is it used for scientific computing?

Fortran is a programming language that was specifically designed for scientific and engineering applications. It is used for its efficient and reliable handling of numerical computations, making it well-suited for complex mathematical and scientific calculations.

2. How can I troubleshoot Fortran codeblocks issues?

If you are experiencing issues with your Fortran codeblocks, there are a few steps you can take to troubleshoot the problem. First, check for any syntax errors or typos in your code. Next, make sure you have the correct compiler and libraries installed. You can also try debugging your code using a debugger tool. If all else fails, seek help from online forums or a Fortran expert.

3. What are some common errors in Fortran codeblocks and how can I fix them?

Some common errors in Fortran codeblocks include missing semicolons, mismatched parentheses, and undeclared variables. To fix these errors, carefully check your code for any missing or incorrect syntax. You can also use a compiler or debugger to identify and fix errors.

4. How can I optimize my Fortran code for better performance?

To optimize your Fortran code for better performance, you can use techniques such as loop unrolling, vectorization, and parallelization. These techniques can help improve the efficiency and speed of your code, especially for complex calculations and large datasets.

5. Where can I find additional resources for troubleshooting Fortran codeblocks issues?

There are many online resources available for troubleshooting Fortran codeblocks issues. Some useful sources include online forums, official Fortran documentation, and tutorial websites. You can also consult with experienced Fortran programmers or attend workshops and conferences to learn more about troubleshooting techniques.

Similar threads

  • Programming and Computer Science
Replies
17
Views
4K
  • Programming and Computer Science
Replies
8
Views
2K
  • Programming and Computer Science
Replies
4
Views
617
  • Programming and Computer Science
Replies
5
Views
4K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
9
Views
1K
  • Programming and Computer Science
Replies
12
Views
1K
  • Programming and Computer Science
Replies
4
Views
7K
  • Programming and Computer Science
Replies
17
Views
4K
Back
Top