Silverfrost Forums

Welcome to our forums

array rank error!

23 Dec 2011 11:48 #9391

tried to run a program but having this error, pls help me out!

C:\projects\job1.F95(10) : error 199 - Array RAINFALL appears in this expression as rank 1, but was declared as rank 2 C:\projects\job1.F95(13) : error 199 - Array RAINFALL appears in this expression as rank 1, but was declared as rank 2 Compilation failed.

here is the program:

implicit none real :: Total=0.0, Average=0.0 real, Dimension(1,12) :: RainFall integer :: Month print*, 'type in the rainfall values' print*, 'one per line' do Month=1,12 read*, RainFall(Month) enddo do Month=1,12 Total=Total+RainFall(Month) enddo Average=Total/12 print*, 'Average monthly rainfall was' print*, Average

end
23 Dec 2011 12:37 #9392

Dimension(1,12) declares a 2 dimensional array with the first index going from 1 to 1 and the second index going from 1 to 12.

23 Dec 2011 1:30 #9393

Change

real, Dimension(1,12) :: RainFall

to

real, Dimension(1:12) :: RainFall

Please login to reply.