- #1
- 10
- 0
I am developing a FORTRAN code (.f90) which "ll calculate some matrix in some time interval (dt1=0.001) and these matrices have to be integrated in some time steps (dt=0.1). Though I am experience in FORTRAN 77, new to FORTRAN 90. I am unable to make dimension of matrix real (I think that is the problem, I may be wrong!).Below is the part of a long program. I am trying (from last 1 month) different methods but no success, output are NaN,even if I use E just after writing output in method2. I am using gfortran in Ubuntu 16.04. Need help. Thank you so much.
Method1
Method2
<Moderator's note: code tags added>
Method1
Fortran:
REAL::DT,DT1,DK1,DK2
INTEGER::IM,I,IL
REAL,DIMENSION(30,50000)::AN,BN,AN1,BN1
REAL,DIMENSION(30)::XA,XB
DO I=1,30 ! NO. OF LINES TO READ PARAMETERS USED IN SUBROUTINES
IM=1 !INITIALISE
AN(I,IM)=0.0
BN(I,IM)=0.0
DT=0.1
DT1=0.001
DO WHILE(DK1<=100) !TIME STEP FOR INTEGRATION
DO WHILE(DK2<=1000) !CALCULATE MATRIX
CALL XAA(AN(I,IM),BN(I,IM),XA)
CALL XBB(AN(I,IM),BN(I,IM),XB)
AN(I,IM+1)=AN(I,IM)+XA(I)*DT1
AB(I,IM+1)=AB(I,IM)+XB(I)*DT1
AN1(I,IL)=AN(I,IM+1) !INTERCHANGE TO REDUCE MEMORY STORAGE & ITERATE
BN1(I,IL)=BN(I,IM+1)
AN(I,IM)=AN1(I,IL)
BN(I,IM)=BN1(I,IL)
DK2=DK2+DT1
ENDDO
AN(I,INT(DK1))=AN(I,IM)
BN(I,INT(DK1))=BN(I,IM)
WRITE(*,*)I,AN(I,INT(DK1)),BN(I,INT(DK1))
DK1=DK1+DT
ENDDO
ENDDO
Method2
Fortran:
REAL::DT,DT1,DK2
INTEGER::IM,I,E,IL,DK1
REAL,DIMENSION(30,50000)::AN,BN,AN1,BN1
REAL,DIMENSION(30)::XA,XB
DO I=1,30 ! NO. OF LINES TO READ PARAMETERS USED IN SUBROUTINES
IM=1 !INITIALISE
AN(I,IM)=0.0
BN(I,IM)=0.0
DT=0.1
DT1=0.001
DO DK1=1,100 !TIME STEP FOR INTEGRATION
E=REAL(DK1)*0.1
DO WHILE(DK2<=1000) !CALCULATE MATRIX
CALL XAA(AN(I,IM),BN(I,IM),XA)
CALL XBB(AN(I,IM),BN(I,IM),XB)
AN(I,IM+1)=AN(I,IM)+XA(I)*DT1
AB(I,IM+1)=AB(I,IM)+XB(I)*DT1
AN1(I,IL)=AN(I,IM+1) !INTERCHANGE TO REDUCE MEMORY STORAGE & ITERATE
BN1(I,IL)=BN(I,IM+1)
AN(I,IM)=AN1(I,IL)
BN(I,IM)=BN1(I,IL)
DK2=DK2+DT1
ENDDO
AN(I,E)=AN(I,IM)
BN(I,E)=BN(I,IM)
WRITE(*,*)I,AN(I,E),BN(I,E)
ENDDO
ENDDO