! 飽和水蒸気圧の計算 program sat_press implicit none real :: temp ! 温度 real :: satpress ! 飽和水蒸気圧 integer :: i real :: func_sat_press ! 関数の宣言 ! 0 ℃の時の飽和水蒸気圧の計算 (サブルーチンを使用) temp = 0.0 call sub_sat_press( temp, satpress ) write( 6, * ) 'Saturated pressure at ', temp, ' degrees Celsius is ', satpress, ' hPa' ! 100 ℃の時の飽和水蒸気圧の計算 (関数を使用) temp = 100.0 satpress = func_sat_press( temp ) write( 6, * ) 'Saturated pressure at ', temp, ' degrees Celsius is ', satpress, ' hPa' ! 飽和水蒸気圧が 650 hPa となる温度を探す do i = 0, 100 temp = real( i ) satpress = func_sat_press( temp ) if ( satpress >= 650.0 ) exit end do write( 6, * ) 'Temperature for saturation at Mt. Fuji is about ', temp, ' degrees Celsius.' end program sat_press ! 飽和水蒸気圧を計算するサブルーチン subroutine sub_sat_press( temp, satpress ) implicit none real, intent(in ) :: temp real, intent(out) :: satpress real :: a = 7.5, b = 237.3 satpress = 6.11 * 10.0**( a*temp / ( temp+b ) ) end subroutine sub_sat_press ! 飽和水蒸気圧を計算する関数 function func_sat_press( temp ) result( satpress ) implicit none real, intent(in ) :: temp real :: satpress real :: a = 7.5, b = 237.3 satpress = 6.11 * 10.0**( a*temp / ( temp+b ) ) end function func_sat_press