Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Modules and subroutines

$
0
0

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

  1. Module variables_m

 

  1. integer lon,lonmax,xx,yy     ! longitude
  1. integer lat,latmax     ! latitude
  2. integer yr,yrmax       ! year
  3. integer mon,monmax     ! month
  4. integer num            ! arbitral number
  5. integer i,j,k
  6. parameter (lonmax=320) ! num of grids (longitude)
  7. parameter (latmax=160) ! num of grids (latitude)
  8. parameter (yrmax=101)  ! num of years totally
  9. parameter (monmax=12)  ! num of months per year
  10. real:: idata(lonmax,latmax*monmax*yrmax)
  11. real data(lonmax,latmax,monmax,yrmax)
  1. real, dimension(1:10)::ave
  2. integer count,tt,sy,ey
  3. real:: summ

 

  1. end module variables_m
  1. module readbinaryfile_m
  2. use variables_m
  3. contains
  4. subroutine readbinaryfile()

 

 

 

 

 

  1. open(8,file='monthly_temperature_1900to2000.bin',access='direct',recl=lonmax*1)
  1. do num=1,latmax*monmax*yrmax
  1. do           lon=1,lonmax
  2. read(8,rec=num) idata(lon,num)
  3. end do
  4. enddo    
  5. close(8)
  6. end subroutine readbinaryfile    
  1. end module readbinaryfile_m
  1. module printallvalues_m
  2. use variables_m
  3. use readbinaryfile_m
  1. implicit none
  1. contains
  2. subroutine printallvalues()
  1. integer lon,lonmax,xx,yy     ! longitude
  2. integer lat,latmax     ! latitude
  3. integer yr,yrmax       ! year
  4. integer mon,monmax     ! month
  5. integer num            ! arbitral number
  6. integer i,j,k
  7. parameter (lonmax=320) ! num of grids (longitude)
  8. parameter (latmax=160) ! num of grids (latitude)
  9. parameter (yrmax=101)  ! num of years totally
  10. parameter (monmax=12)  ! num of months per year
  11. real:: idata(lonmax,latmax*monmax*yrmax)
  12. real data(lonmax,latmax,monmax,yrmax)
  1. real, dimension(1:10)::ave
  2. integer count,tt,sy,ey
  3. real:: summ
  1. open(9,file='all_values.csv',status='replace')
  2. num=1
  1. do yr=1,yrmax
  1. do mon=1,monmax
  2. do lat=1,latmax
  3. do lon=1,lonmax
  4. data(lon,lat,mon,yr)=idata(lon,num)
  5. write(9,*) data(lon,lat,mon,yr)
  6. end do
  7. num=num+1
  8. end do
  1. end do
  2. end do
  1. close(9)
  1. end subroutine printallvalues
  1. end module printallvalues_m
  1. module decadalmeantemperature_m
  2. use variables_m
  3. use readbinaryfile_m
  4. use printallvalues_m
  5. implicit none
  6. contains
  1. subroutine decadalmeantemperature()
  1. integer lon,lonmax,xx,yy     ! longitude
  2. integer lat,latmax     ! latitude
  3. integer yr,yrmax       ! year
  4. integer mon,monmax     ! month
  5. integer num            ! arbitral number
  6. integer i,j,k
  7. parameter (lonmax=320) ! num of grids (longitude)
  8. parameter (latmax=160) ! num of grids (latitude)
  9. parameter (yrmax=101)  ! num of years totally
  10. parameter (monmax=12)  ! num of months per year
  11. real:: idata(lonmax,latmax*monmax*yrmax)
  12. real data(lonmax,latmax,monmax,yrmax)
  1. real, dimension(1:10)::ave
  2. integer count,tt,sy,ey
  3. real:: summ
  1. open(10,file='10 Years average.csv',status='replace')
  2. write(10,*) 'Interval',',','Average Decadel Temp'
  1. sy=1
  2. ey=10  
  1. do k=1,10
    1. summ=0.0
    2. count=0
  2. do yr= sy,ey
  1. ave=0.0

.yy=1899+sy

  1. xx=1899+ey
  1. do           mon=1, 12
  2. do           lat=1,160
  3. do           lon=1,320
  4. summ =summ+ data(lon,lat,mon,yr)
  5. count=count+1
  1. end do
  2. end do
  3. end do
  4. end do
  1. sy=ey+1
  1. ey=ey+10
  2. if (ey==100) then
  3. ey=101
  4. end if
    1. ave(k) =summ/count
  5. write(10,*) yy,'-',xx,',', ave(k)
  1. end do
  1. close(10)
  1. end subroutine decadalmeantemperature
  2. end module decadalmeantemperature_m
  1. program envfluidmechanics
  1. use variables_m
  2. use readbinaryfile_m
  3. use printallvalues_m
  1. use decadalmeantemperature_m
  2. call decadalmeantemperature

 

 

  1. end program envfluidmechanics

 


Viewing all articles
Browse latest Browse all 3270


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>