值是正确分配的,但不适用于计算

时间:2017-04-04 05:54:19

标签: fortran

我正在做一个for循环来计算当前值。当j = 1时,我会得到正确的产品和总和,但当j到2到20时,产品将只有0.我可能知道我错过了什么?

program q5
implicit none
integer :: j, k, lx, d, ld, row, col
real :: pv, v, qd, sum, product
real, dimension(110,3) :: arr

sum = 0.0
product = 0.0
lx = 0
ld = 0
qd = 0.0

!connect file
open( unit = 1, file = 'Females_Australian_Life_Tables_2010-12.csv' )

do row = 1, 110
    read( 1, *) arr(row,:)
    write(*,*) arr(row,:)
enddo

do j = 1, 20
    d = 66 + j - 1
    v = 1 / ( 1 + 0.05 )
    lx = arr(66,2)
    ld = arr(d,2)
    qd = arr(d,3)
    product = ( ld/lx ) * qd * (v**j)
    sum = sum + product
                            print*, '*************', lx, ld, qd, '**********'
                            print*, 'j=', j
                            print*, '        product                     ', product
                            print*, '        sum                         ', sum
enddo

pv = 30000 * sum

!disconnect file
close( 1 )

print*, 'The present value is', pv
end program q5

this is the error I have got

0 个答案:

没有答案