## Fortran Question

I found the problem.

 Mentor What was it?
 I dont 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.
 There is no errors anymore but when i run the program asking for print CEF appears NaN (not a number), i dont 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
 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.
 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 dont 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) ===|
 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.
 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) ===|
 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
 Recognitions: Science Advisor 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.

 Quote by AlephZero 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..

Recognitions:
 Quote by felipearcaro 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.

 Thanks very much, i think my program is working fine now. I will be back soon with new questions. This forum is awesome.
 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: But the correct is: 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
 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
 Anyone?