mushi82
Programmer
- Feb 7, 2012
- 1
Hi all,
I am totally new to fortran. I have to convert a code that is actually written in the fortran to matlab. There is only one subroutine that is totally mysterious for me. I am posting the part of code I have problem with, below:
1. subroutine cciri(xMODIP,mth,UT,R12,alat,along,foF2,M3000)
2. implicit real*8 (a-h,o-z)
3. real*8 M3000
4. character*10 filena
5. character*2 cm
6. dimension FF0(988),xm0(441),F2(13,76,2),FM3(9,49,2)
7. integer QM(7),QF(9)
8. save
9. data QF/11,11,8,4,1,0,0,0,0/,QM/6,7,5,2,1,0,0/
10. data montha,monthb,Rga/13,14,-10.0D0/
11. if (mth.ne.montha) then
12. write(cm,'(I2.2)') mth+10
13. filena='ccir'//cm//'.asc'
14. open(77,file=filena,status='OLD')
15. read(77,'(4E16.8)') F2,FM3
16. close(77)
17. montha=mth
18. endif
19. if (R12.ne.Rga.or.mth.ne.monthb) then
20. RR2=R12/100.0D0
21. RR1=1.0D0-RR2
22. do i=1,76
23. do j=1,13
24. k=j+13*(i-1)
25. FF0(k)=F2(j,i,1)*RR1+F2(j,i,2)*RR2
26. enddo
27. enddo
28. do i=1,49
29. do j=1,9
30. k=j+9*(i-1)
31. xm0(k)=FM3(j,i,1)*RR1+FM3(j,i,2)*RR2
32. enddo
33. enddo
34. Rga=R12
35. monthb=mth
36. endif
Just for reference, here are few lines taken from the files ccirXX.asc
0.56421361E+01 -0.81572428E-01 0.20138618E+00 0.42779669E-01
0.44377025E-01 0.38025160E-02 -0.87150786E-03 0.21708569E-01
-0.23025220E-01 -0.33594195E-02 0.21446483E-03 -0.18263943E-02
-0.12104558E-01 -0.10026588E+01 -0.77602589E+00 0.80115181E+00
-0.27182043E+00 0.54614949E+00 -0.18997940E+00 0.82413152E-01
-0.38998052E-01 -0.97885408E-01 0.13837354E+00 0.10652158E+00
Can anybody please explain lines 15 & 25 & 31 to me. I mean on line 15, variables F2 and FM3 are loaded as variables while on line 25 & 31 they are treated as 3D arrays? How is this possible? What is the logic behind this code? Mind you that the code is running absolutely fine in frotran.
Please help!.
I am totally new to fortran. I have to convert a code that is actually written in the fortran to matlab. There is only one subroutine that is totally mysterious for me. I am posting the part of code I have problem with, below:
1. subroutine cciri(xMODIP,mth,UT,R12,alat,along,foF2,M3000)
2. implicit real*8 (a-h,o-z)
3. real*8 M3000
4. character*10 filena
5. character*2 cm
6. dimension FF0(988),xm0(441),F2(13,76,2),FM3(9,49,2)
7. integer QM(7),QF(9)
8. save
9. data QF/11,11,8,4,1,0,0,0,0/,QM/6,7,5,2,1,0,0/
10. data montha,monthb,Rga/13,14,-10.0D0/
11. if (mth.ne.montha) then
12. write(cm,'(I2.2)') mth+10
13. filena='ccir'//cm//'.asc'
14. open(77,file=filena,status='OLD')
15. read(77,'(4E16.8)') F2,FM3
16. close(77)
17. montha=mth
18. endif
19. if (R12.ne.Rga.or.mth.ne.monthb) then
20. RR2=R12/100.0D0
21. RR1=1.0D0-RR2
22. do i=1,76
23. do j=1,13
24. k=j+13*(i-1)
25. FF0(k)=F2(j,i,1)*RR1+F2(j,i,2)*RR2
26. enddo
27. enddo
28. do i=1,49
29. do j=1,9
30. k=j+9*(i-1)
31. xm0(k)=FM3(j,i,1)*RR1+FM3(j,i,2)*RR2
32. enddo
33. enddo
34. Rga=R12
35. monthb=mth
36. endif
Just for reference, here are few lines taken from the files ccirXX.asc
0.56421361E+01 -0.81572428E-01 0.20138618E+00 0.42779669E-01
0.44377025E-01 0.38025160E-02 -0.87150786E-03 0.21708569E-01
-0.23025220E-01 -0.33594195E-02 0.21446483E-03 -0.18263943E-02
-0.12104558E-01 -0.10026588E+01 -0.77602589E+00 0.80115181E+00
-0.27182043E+00 0.54614949E+00 -0.18997940E+00 0.82413152E-01
-0.38998052E-01 -0.97885408E-01 0.13837354E+00 0.10652158E+00
Can anybody please explain lines 15 & 25 & 31 to me. I mean on line 15, variables F2 and FM3 are loaded as variables while on line 25 & 31 they are treated as 3D arrays? How is this possible? What is the logic behind this code? Mind you that the code is running absolutely fine in frotran.
Please help!.