Hello everyone,
I am new to fortran.. I am facing difficulty in calling subroutine and module from main program. When I run the program , its gives error about line 95 d.
sometimes it gives error SALFORD RUN TIME ERROR-STACK OVER FLOW
Please check any mistake in the following code:
Regards,
Ali
- Module variables_m
- integer lon,lonmax,xx,yy ! longitude
- integer lat,latmax ! latitude
- integer yr,yrmax ! year
- integer mon,monmax ! month
- integer num ! arbitral number
- integer i,j,k
- parameter (lonmax=320) ! num of grids (longitude)
- parameter (latmax=160) ! num of grids (latitude)
- parameter (yrmax=101) ! num of years totally
- parameter (monmax=12) ! num of months per year
- real:: idata(lonmax,latmax*monmax*yrmax)
- real data(lonmax,latmax,monmax,yrmax)
- real, dimension(1:10)::ave
- integer count,tt,sy,ey
- real:: summ
- end module variables_m
- module readbinaryfile_m
- use variables_m
- contains
- subroutine readbinaryfile()
- open(8,file='monthly_temperature_1900to2000.bin',access='direct',recl=lonmax*1)
- do num=1,latmax*monmax*yrmax
- do lon=1,lonmax
- read(8,rec=num) idata(lon,num)
- end do
- enddo
- close(8)
- end subroutine readbinaryfile
- end module readbinaryfile_m
- module printallvalues_m
- use variables_m
- use readbinaryfile_m
- implicit none
- contains
- subroutine printallvalues()
- integer lon,lonmax,xx,yy ! longitude
- integer lat,latmax ! latitude
- integer yr,yrmax ! year
- integer mon,monmax ! month
- integer num ! arbitral number
- integer i,j,k
- parameter (lonmax=320) ! num of grids (longitude)
- parameter (latmax=160) ! num of grids (latitude)
- parameter (yrmax=101) ! num of years totally
- parameter (monmax=12) ! num of months per year
- real:: idata(lonmax,latmax*monmax*yrmax)
- real data(lonmax,latmax,monmax,yrmax)
- real, dimension(1:10)::ave
- integer count,tt,sy,ey
- real:: summ
- open(9,file='all_values.csv',status='replace')
- num=1
- do yr=1,yrmax
- do mon=1,monmax
- do lat=1,latmax
- do lon=1,lonmax
- data(lon,lat,mon,yr)=idata(lon,num)
- write(9,*) data(lon,lat,mon,yr)
- end do
- num=num+1
- end do
- end do
- end do
- close(9)
- end subroutine printallvalues
- end module printallvalues_m
- module decadalmeantemperature_m
- use variables_m
- use readbinaryfile_m
- use printallvalues_m
- implicit none
- contains
- subroutine decadalmeantemperature()
- integer lon,lonmax,xx,yy ! longitude
- integer lat,latmax ! latitude
- integer yr,yrmax ! year
- integer mon,monmax ! month
- integer num ! arbitral number
- integer i,j,k
- parameter (lonmax=320) ! num of grids (longitude)
- parameter (latmax=160) ! num of grids (latitude)
- parameter (yrmax=101) ! num of years totally
- parameter (monmax=12) ! num of months per year
- real:: idata(lonmax,latmax*monmax*yrmax)
- real data(lonmax,latmax,monmax,yrmax)
- real, dimension(1:10)::ave
- integer count,tt,sy,ey
- real:: summ
- open(10,file='10 Years average.csv',status='replace')
- write(10,*) 'Interval',',','Average Decadel Temp'
- sy=1
- ey=10
- do k=1,10
- summ=0.0
- count=0
- do yr= sy,ey
- ave=0.0
.yy=1899+sy
- xx=1899+ey
- do mon=1, 12
- do lat=1,160
- do lon=1,320
- summ =summ+ data(lon,lat,mon,yr)
- count=count+1
- end do
- end do
- end do
- end do
- sy=ey+1
- ey=ey+10
- if (ey==100) then
- ey=101
- end if
- ave(k) =summ/count
- write(10,*) yy,'-',xx,',', ave(k)
- end do
- close(10)
- end subroutine decadalmeantemperature
- end module decadalmeantemperature_m
- program envfluidmechanics
- use variables_m
- use readbinaryfile_m
- use printallvalues_m
- use decadalmeantemperature_m
- call decadalmeantemperature
- end program envfluidmechanics