# How to use Real Array Index in Matrix dimension?

• Fortran
• yuvan

#### yuvan

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
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

"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).
Could you clarify what you are to do? Maybe post a mathematical expression of the problem you are trying to solve. (I don't understand what "integrating a matrix" means.)

I am unable to make dimension of matrix real (I think that is the problem, I may be wrong!).
What do you mean by that? Dimensions of arrays are always integers.

Fortran:
CALL XAA(AN(I,IM),BN(I,IM),XA)
CALL XBB(AN(I,IM),BN(I,IM),XB)
What do these subroutines do?

Fortran:
IM=1 !INITIALISE
...
DT=0.1
DT1=0.001
DO WHILE(DK1<=100) !TIME STEP FOR INTEGRATION
DO WHILE(DK2<=1000) !CALCULATE MATRIX
IM is set to 1, and never modified afterwards. DK1 and DK2 are not initialised. If you need to iterate over IM, then don't use a do while but set up a do loop on IM instead.

Fortran:
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)
IL is never initialised. And I don't understand why you are defining such huge matrices while you are using only two of the elements in the second index.

Fortran:
AN(I,INT(DK1))=AN(I,IM)
BN(I,INT(DK1))=BN(I,IM)
...
DK1=DK1+DT
DT < 1, so INT(DK1) will not change at each iteration.

Looking back at what I wrote above, I strongly suggest you iterate over integer indices using do loops.

Fortran:
INTEGER::IM,I,E,IL,DK1
...
DO DK1=1,100 !TIME STEP FOR INTEGRATION
E=REAL(DK1)*0.1
This is very strange. You already have an integer index, so I don't understand why you convert it to real in order to recover an integer E, which again will not change at every step of the loop.

jim mcnamara
The subroutines provide the value of XA and XB which are function of both AN and BN. IM is changing inside the inner loop. I don't know, can I keep AN(I,IM)=AN(I,IM+1) but I fear it might not interchange value (However, I tried AN(I,IM)=AN(I,IM+1) but no change in result). As far as I know if I don't use initial value for KD1, KD2 they "ll take initial value as 0.0. I have also put E=REAL(DK1)*0.1 because I need loop with 0.1 step size and if I use step size 0.1 in loop mentioned it shows error that loop size only be integer. Dimension of matrix be integer. In AN(I,IM) values of I and IM have to be integer. If I use real values in place of 'I' and 'IM' , it shows Warning: Legacy Extension: REAL array index at (1) .

I have no idea what you just said, but it sounds like you want an array with a REAL index. Asking for element #6 of an array makes sense. Asking for element #6.5 does not. If it doesn't make sense, you can't code it.

FactChecker and DrClaude
The subroutines provide the value of XA and XB which are function of both AN and BN. IM is changing inside the inner loop. I don't know, can I keep AN(I,IM)=AN(I,IM+1) but I fear it might not interchange value (However, I tried AN(I,IM)=AN(I,IM+1) but no change in result).
My point is that AN and AN1 are declared with dimension (30,50000) but you are using at most two values in the second index for AN, AN(I,1) and AN(I,2), and only one for AN1, AN1(I,IL) with a constant IL.

As far as I know if I don't use initial value for KD1, KD2 they "ll take initial value as 0.0.
That's incorrect. The value of a variable that has been previously set is undefined. You cannot assume that it will be 0.

I have also put E=REAL(DK1)*0.1 because I need loop with 0.1 step size and if I use step size 0.1 in loop mentioned it shows error that loop size only be integer. Dimension of matrix be integer. In AN(I,IM) values of I and IM have to be integer. If I use real values in place of 'I' and 'IM' , it shows Warning: Legacy Extension: REAL array index at (1) .
Yes, real indices are forbidden in Fortran 90. My point is that E will have the same value for many iterations in a row.

As I am initializing IM=1, for first iteration IM+1=2, i.e. it "ll calculate AN(I,2) and BN(I,2) and these value "ll be used in the next iteration for subroutine and subsequently calculate AN(I,3) and BN(I,3). These values (AN(I,3) and BN(I,3)) "ll be used again for next iteration and son on till loop ends.
I am sorry, I use KD1=0. and KD2=0. and running the code. I "ll be back once code finish running.

I am still getting NaN values.

I am still getting NaN values.
You'll have to post your revised code and the subroutines.

I am unable to upload files. It is showing "The uploaded file does not have an allowed extension. " although I am just trying to upload .f90 and .dat files.

This the code.

Fortran:
PROGRAM MODEL
IMPLICIT NONE
REAL::DT,DT1,DK1,DK2
INTEGER::I,J,IL,IM
REAL::XN2(1),XO2(1)
REAL,DIMENSION(21,50000)::AN,BN,AN1,BN1
REAL,DIMENSION(21)::XA,XB
REAL,DIMENSION(21,21)::WA,WB,WAB,WBA
REAL,DIMENSION(21)::SUMA,SUMAB,SUMB,SUMBA
XN2=1E-7
XO2=1E-8
OPEN(1,FILE='TEST1.dat')
OPEN(2,FILE='TEST2.dat')
OPEN(3,FILE='TEST3.dat')
OPEN(4,FILE='TEST4.dat')
DO I=1,21  ! 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.01
DK1=1.0
DK2=1.0
DO WHILE(DK1<=10) !TIME STEP FOR INTEGRATION
DO WHILE(DK2<=100) !CALCULATE MATRIX
CALL XAA(WA,WAB,SUMA,SUMAB,XN2,XO2,AN(I,IM),BN(I,IM),XA)
CALL XBB(WB,WBA,SUMB,SUMBA,XN2,XO2,AN(I,IM),BN(I,IM),XB)
AN(I,IM+1)=AN(I,IM)+XA(I)*DT1
BN(I,IM+1)=BN(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(1111,*)I,AN(I,INT(DK1)),BN(I,INT(DK1))
DK1=DK1+DT
ENDDO
ENDDO
END PROGRAM MODEL
!SUBROUTINES XAA

SUBROUTINE XAA(WA,WAB,SUMA,SUMAB,XN2,XO2,AN,BN,XA)
INTEGER::I,J
REAL,DIMENSION(21,50000)::AN,BN
REAL,intent(out)::XA(21)
REAL::XN2(1),XO2(1)
REAL,DIMENSION(21,21)::WA,WAB
REAL,DIMENSION(21)::SUMA,SUMAB
SUMA(:)=0.0
SUMAB(:)=0.0
DO I=1,21
DO J=1,21
SUMA(I)=SUMA(I)+WA(I,J)*XN2(1)
SUMAB(I)=SUMAB(I)+WAB(I,J)*XO2(1)
ENDDO
XA(I)=SUMA(I)*AN(I,1)+SUMAB(I)*BN(I,1)
ENDDO
RETURN
END SUBROUTINE XAA
!SUBROUTINES XBB

SUBROUTINE XBB(WB,WBA,SUMB,SUMBA,XN2,XO2,AN,BN,XB)
INTEGER::I,J
REAL::XN2(1),XO2(1)
REAL,DIMENSION(21,50000)::AN,BN
REAL,intent(out)::XB(21)
REAL,DIMENSION(21,21)::WB,WBA
REAL,DIMENSION(21)::SUMB,SUMBA
SUMB(:)=0.0
SUMBA(:)=0.0
DO I=1,21
DO J=1,21
SUMB(I)=SUMB(I)+WB(I,J)*XN2(1)
SUMBA(I)=SUMBA(I)+WBA(I,J)*XO2(1)
ENDDO
XB(I)=SUMB(I)*AN(I,1)+SUMBA(I)*BN(I,1)
ENDDO
RETURN
END SUBROUTINE XBB

Last edited by a moderator:
Lordy.

If you want us to debug your code for you, for heaven's sake please
1. Use CODE tags
2. Indent
3. Maybe even toss in a comment or two

If you want us to debug your code for you, for heaven's sake please
1. Use CODE tags
2. Indent
3. Maybe even toss in a comment or two
4. Listen to the replies you have already gotten.

IL is still used before being initialised.

Have you checked that after the calls to the subroutines XA, and XB contain valid values?

Though I am experience in FORTRAN 77, new to FORTRAN 90.
You apparently don't have much experience working with arrays in Fortran 77 -- the array size must be an integer, as must the lower bound and upper bound if your array doesn't start at index 1. This requirement is still in place for Fortran 90 and later versions.

I am unable to upload files. It is showing "The uploaded file does not have an allowed extension. " although I am just trying to upload .f90 and .dat files.
Your files are just text, so you shouldn't upload them -- just copy them as you did, but use code tags, as has already been requested at least twice before. There's a sticky at the top of this forum section that talks about how to use code tags.

Last edited:
FactChecker
You apparently don't have much experience working with arrays in Fortran 77 -- the array size must be an integer, as must the lower bound and upper bound if your array doesn't start at index 1. This requirement is still in place for Fortran 90 and later versions.
Yes, you are right but in Fortran 77 maximum dimension of arrays can just be given to array. In this case almost all parameters start from index 1.

Your files are just text, so you shouldn't upload them -- just copy them as you did, but use code tags, as has already been requested at least twice before. There's a sticky at the top of this forum section that talks about how to use code tags.

Fortran:
PROGRAM MODEL
IMPLICIT NONE
REAL::DT,DT1,DK1,DK2
INTEGER::I,J,IL,IM
REAL::XN2(1),XO2(1)
REAL,DIMENSION(21,50000)::AN,BN,AN1,BN1
REAL,DIMENSION(21)::XA,XB
REAL,DIMENSION(21,21)::WA,WB,WAB,WBA
REAL,DIMENSION(21)::SUMA,SUMAB,SUMB,SUMBA
XN2=1E-7
XO2=1E-8
OPEN(1,FILE='TEST1.dat')
OPEN(2,FILE='TEST2.dat')
OPEN(3,FILE='TEST3.dat')
OPEN(4,FILE='TEST4.dat')
DO I=1,21  ! 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.01
DK1=1.0
DK2=1.0
DO WHILE(DK1<=10) !TIME STEP FOR INTEGRATION
DO WHILE(DK2<=100) !CALCULATE MATRIX
CALL XAA(WA,WAB,SUMA,SUMAB,XN2,XO2,AN(I,IM),BN(I,IM),XA)
CALL XBB(WB,WBA,SUMB,SUMBA,XN2,XO2,AN(I,IM),BN(I,IM),XB)
AN(I,IM+1)=AN(I,IM)+XA(I)*DT1
BN(I,IM+1)=BN(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(1111,*)I,AN(I,INT(DK1)),BN(I,INT(DK1))
DK1=DK1+DT
ENDDO
ENDDO
END PROGRAM MODEL
!SUBROUTINES XAA

SUBROUTINE XAA(WA,WAB,SUMA,SUMAB,XN2,XO2,AN,BN,XA)
INTEGER::I,J
REAL,DIMENSION(21,50000)::AN,BN
REAL,intent(out)::XA(21)
REAL::XN2(1),XO2(1)
REAL,DIMENSION(21,21)::WA,WAB
REAL,DIMENSION(21)::SUMA,SUMAB
SUMA(:)=0.0
SUMAB(:)=0.0
DO I=1,21
DO J=1,21
SUMA(I)=SUMA(I)+WA(I,J)*XN2(1)
SUMAB(I)=SUMAB(I)+WAB(I,J)*XO2(1)
ENDDO
XA(I)=SUMA(I)*AN(I,1)+SUMAB(I)*BN(I,1)
ENDDO
RETURN
END SUBROUTINE XAA
!SUBROUTINES XBB

SUBROUTINE XBB(WB,WBA,SUMB,SUMBA,XN2,XO2,AN,BN,XB)
INTEGER::I,J
REAL::XN2(1),XO2(1)
REAL,DIMENSION(21,50000)::AN,BN
REAL,intent(out)::XB(21)
REAL,DIMENSION(21,21)::WB,WBA
REAL,DIMENSION(21)::SUMB,SUMBA
SUMB(:)=0.0
SUMBA(:)=0.0
DO I=1,21
DO J=1,21
SUMB(I)=SUMB(I)+WB(I,J)*XN2(1)
SUMBA(I)=SUMBA(I)+WBA(I,J)*XO2(1)
ENDDO
XB(I)=SUMB(I)*AN(I,1)+SUMBA(I)*BN(I,1)
ENDDO
RETURN
END SUBROUTINE XBB
DATA USED( consider same for files TEST1,TEST2,TEST3,TEST4.dat for testing)
Fortran:
   .3351E-05   .1584E-04   .4531E-03   .2750E-02   .9303E-02   .2231E-01   .4259E-01   .6890E-01   .9843E-01   .1274E+00   .1520E+00   .1700E+00   .1791E+00   .1807E+00   .1753E+00   .1646E+00   .1499E+00   .1331E+00   .1153E+00   .9739E-01   .7988E-01
.3714E-03   .4264E-03   .9550E-05   .8971E-03   .4635E-02   .9706E-02   .1240E-01   .1025E-01   .4583E-02   .1947E-03   .2953E-02   .1710E-01   .4350E-01   .7996E-01   .1221E+00   .1646E+00   .2023E+00   .2319E+00   .2507E+00   .2575E+00   .2514E+00
.3903E-02   .5923E-02   .3246E-02   .4251E-03   .7885E-04   .2323E-03   .2627E-04   .2026E-02   .8449E-02   .1758E-01   .2448E-01   .2484E-01   .1797E-01   .7816E-02   .6181E-03   .2603E-02   .1772E-01   .4667E-01   .8691E-01   .1332E+00   .1780E+00
.1692E-01   .1926E-01   .7494E-02   .5691E-03   .1428E-03   .1368E-03   .1243E-03   .1237E-02   .1856E-02   .7478E-03   .9851E-04   .3577E-02   .1229E-01   .2327E-01   .3126E-01   .3212E-01   .2510E-01   .1355E-01   .3215E-02   .3350E-03   .8883E-02
.4154E-01   .2521E-01   .1681E-02   .2245E-02   .4817E-02   .1956E-02   .1060E-03   .2328E-04   .1950E-04   .8686E-03   .2933E-02   .4209E-02   .2958E-02   .5385E-03   .5314E-03   .5667E-02   .1540E-01   .2606E-01   .3291E-01   .3271E-01   .2537E-01
.6854E-01   .1188E-01   .4408E-02   .1539E-01   .6104E-02   .2891E-04   .1383E-02   .1471E-02   .2750E-03   .1065E-04   .3577E-04   .1205E-03   .1472E-02   .4135E-02   .6109E-02   .5446E-02   .2536E-02   .1376E-03   .1294E-02   .7118E-02   .1579E-01
.8233E-01   .6251E-05   .2740E-01   .1304E-01   .1706E-03   .7704E-02   .6633E-02   .1083E-02   .1075E-03   .6636E-03   .2542E-03   .6455E-05   .1807E-03   .7305E-04   .1377E-03   .1582E-02   .4386E-02   .6844E-02   .7060E-02   .4728E-02   .1550E-02
.7438E-01   .1740E-01   .3357E-01   .1529E-07   .1644E-01   .1201E-01   .2711E-03   .3262E-02   .5321E-02   .2076E-02   .7360E-04   .1725E-03   .1775E-03   .1809E-06   .2331E-03   .4298E-03   .1538E-03   .6866E-04   .1231E-02   .3690E-02   .6138E-02
.5187E-01   .5424E-01   .9800E-02   .1898E-01   .2090E-01   .6235E-05   .1075E-01   .1072E-01   .1308E-02   .9517E-03   .3509E-02   .2412E-02   .4599E-03   .3968E-05   .9514E-04   .8087E-05   .1248E-03   .5256E-03   .6575E-03   .2858E-03   .2680E-05
.2870E-01   .7597E-01   .1964E-02   .3888E-01   .9182E-03   .1764E-01   .1503E-01   .6316E-04   .7022E-02   .9292E-02   .2459E-02   .6694E-04   .1877E-02   .2170E-02   .8554E-03   .6283E-04   .6326E-04   .2955E-04   .1497E-04   .2737E-03   .6715E-03
.1273E-01   .6741E-01   .3161E-01   .1820E-01   .1535E-01   .2348E-01   .1630E-05   .1532E-01   .1199E-01   .2464E-03   .4314E-02   .7779E-02   .3451E-02   .1146E-03   .6882E-03   .1580E-02   .1070E-02   .2627E-03   .1529E-05   .2519E-04   .8109E-05
.4567E-02   .4254E-01   .6289E-01   .5124E-04   .3834E-01   .9218E-03   .2080E-01   .1402E-01   .3964E-03   .1281E-01   .1030E-01   .6388E-03   .2290E-02   .6118E-02   .4138E-02   .7526E-03   .6818E-04   .8522E-03   .1027E-02   .5083E-03   .8330E-04
.1338E-02   .2030E-01   .6434E-01   .2237E-01   .1875E-01   .1614E-01   .2163E-01   .9311E-03   .2023E-01   .8902E-02   .6107E-03   .1047E-01   .9348E-02   .1307E-02   .8594E-03   .4330E-02   .4304E-02   .1660E-02   .8071E-04   .2358E-03   .6988E-03
.3178E-03   .7515E-02   .4306E-01   .5308E-01   .2482E-04   .3610E-01   .7097E-04   .2467E-01   .9006E-02   .3850E-02   .1766E-01   .6374E-02   .5032E-03   .8260E-02   .8727E-02   .2255E-02   .9788E-04   .2548E-02   .3870E-02   .2477E-02   .6432E-03
.6106E-04   .2180E-02   .2063E-01   .5584E-01   .2074E-01   .1417E-01   .1989E-01   .1560E-01   .4829E-02   .2211E-01   .3065E-02   .5695E-02   .1508E-01   .5331E-02   .2149E-03   .6121E-02   .8047E-02   .3382E-02   .8714E-04   .1017E-02   .2786E-02
.9642E-05   .4966E-03   .7392E-02   .3653E-01   .4687E-01   .6047E-03   .3168E-01   .8114E-03   .2611E-01   .2608E-02   .1118E-01   .1674E-01   .9222E-03   .6076E-02   .1295E-01   .5164E-02   .5578E-04   .4033E-02   .7073E-02   .4459E-02   .8376E-03
.1204E-05   .8856E-04   .2012E-02   .1657E-01   .4595E-01   .2252E-01   .7546E-02   .2428E-01   .7315E-02   .1209E-01   .1759E-01   .5973E-02   .1378E-01   .1230E-01   .3167E-03   .5445E-02   .1117E-01   .5506E-02   .1250E-03   .2080E-02   .5467E-02
.9707E-07   .1244E-04   .4189E-03   .5464E-02   .2754E-01   .4158E-01   .2945E-02   .2395E-01   .5169E-02   .2207E-01   .3976E-04   .1834E-01   .8871E-02   .1232E-02   .1367E-01   .9527E-02   .2066E-03   .4247E-02   .9551E-02   .6085E-02   .7907E-03
.5923E-08   .1323E-05   .6628E-04   .1329E-02   .1120E-01   .3526E-01   .2491E-01   .1906E-02   .2566E-01   .1048E-02   .1888E-01   .8205E-02   .4303E-02   .1736E-01   .3949E-02   .2569E-02   .1242E-01   .8102E-02   .3361E-03   .2738E-02   .7662E-02
.9980E-09   .9868E-07   .7949E-05   .2433E-03   .3270E-02   .1846E-01   .3503E-01   .7503E-02   .1350E-01   .1189E-01   .1263E-01   .4297E-02   .1834E-01   .1102E-02   .8770E-02   .1403E-01   .1794E-02   .3013E-02   .1083E-01   .7530E-02   .7853E-03
.3901E-10   .6676E-08   .7142E-06   .3379E-04   .7014E-03   .6569E-02   .2485E-01   .2640E-01   .4489E-04   .2114E-01   .7116E-03   .1912E-01   .7594E-03   .1229E-01   .1136E-01   .4765E-04   .1056E-01   .1100E-01   .1035E-02   .2633E-02   .8965E-02
Lordy.

If you want us to debug your code for you, for heaven's sake please
1. Use CODE tags
2. Indent
3. Maybe even toss in a comment or two
I didn't find any CODE tags options in comment section, @fortran90 @ubuntu @arrays @realindex​

I didn't find any CODE tags options in comment section, @fortran90 @ubuntu @arrays @realindex​
This is what we are talking about:

#### Attachments

7.9 KB · Views: 777
I still don't see any initialisation of IL...

I still don't see any initialisation of IL...
I did like this and getting all values as zeros. Did I do it wrong way?

Fortran:
IM=1
IL=1
AN(I,IM)=0.0
BN(I,IM)=0.0
DT=0.1
DT1=0.01
DK1=1.0
DK2=1.0
DO WHILE(DK1<=10)
DO WHILE(DK2<=100)
..
..
N(I,IM)=AN1(I,IL)
BN(I,IM)=BN1(I,IL)
DK2=DK2+DT1
IM=IM+1
IL=IL+1
ENDDO
AN(I,INT(DK1))=AN(I,IM)
BN(I,INT(DK1))=BN(I,IM)
WRITE(1111,*)I,AN(I,INT(DK1)),BN(I,INT(DK1))
DK1=DK1+DT
ENDDO

Last edited by a moderator:
Did I do it wrong way?

I am losing patience. You have been asked, politely, to use code tags. You refuse. [Edit: they are there now because you made it necessary for a mod to do it] You have been asked, politely, to indent. You refuse. You have been asked, politely, to comment. You refuse. And, in general, you seem to be disregarding the vast majority of our advice.

This is your problem. It doesn't harm any of us if it never gets solved. You might want to think about that when deciding how much effort you want to put into this relative to how much effort you expect us to put into this.

Last edited:
Code tags. You can do them manually very easily.
[ code=fortran ]
Your
code
goes
here
[ /code ]

These are called HTML tags. I put some spaces in them so they did not act like tags, but display simple text. Remove the spaces, then paste your properly indented code from your editor directly on the line or lines between the two tags. Everything will be fine. You'll get help. Your code is a wall of gunk to me right now. Programmers or people with some skill in programming are sensitive to formatting. It helps us see errors right away.

If you paste text then add code tags later it will not restore formatting that the forum edit removed, since it did not start with code tags at the very beginning.

And with indenting, so people can see the structure.

Fortran:
IM=1
IL=1
AN(I,IM)=0.0
BN(I,IM)=0.0
DT=0.1
DT1=0.01
DK1=1.0
DK2=1.0
DO WHILE(DK1<=10)
DO WHILE(DK2<=100)
..
..
N(I,IM)=AN1(I,IL)
BN(I,IM)=BN1(I,IL)
DK2=DK2+DT1
IM=IM+1
IL=IL+1
ENDDO
AN(I,INT(DK1))=AN(I,IM)
BN(I,INT(DK1))=BN(I,IM)
WRITE(1111,*)I,AN(I,INT(DK1)),BN(I,INT(DK1))
DK1=DK1+DT
ENDDO

Since the author refuses to comment his code, it's hard to spot all the mistakes, but one that is almost certainly there (and made apparent by indenting) is that DK2 never gets reset after the inner loop is traversed once.