! 4.2.f90 ! 2024-10-08 ! $Id: 4.2.f90 1.1 2024/10/26 14:02:16 s Exp $ ! s , current spot rate curve ! s2, next year's spot rate curve program a implicit none integer :: j, n real(8) :: s(6), s2(6) real(8) :: s_percent(6), s2_percent(6) ! input data s_percent/5.0, 5.3, 5.6, 5.8, 6.0, 6.1/ n = 6 ! calculating s(1:n) = s_percent(1:n) / 100.0 do j = 2, n s2(j - 1) = f_1(j) end do s2_percent(1:n-1) = s2(1:n-1) * 100.0 ! output print *, "4.2.f90" print *, "current spot rate curve" print '(6f5.1)', s_percent(1:n) print *, "next year's spot rate curve" print '(6f5.1)', s2_percent(1:n-1) stop contains ! function real(8) function f_1(j) ! forward rate, i = 1. implicit none integer :: j f_1 = ((1.0 + s(j)) ** j / (1.0 + s(1))) ** (1.0 / (j - 1)) - 1.0 return end function end program a ! end