728x90
반응형
! 온도변환 인터페이스 사용 버전 p222
PROGRAM Temperature_Conversion_7
    implicit none
    
    INTERFACE
        Function Celsius_to_Fahr(Temp)        
        real :: Celsius_to_Fahr
        real, intent(in) :: Temp                
        END Function Celsius_to_Fahr
    END INTERFACE
    
    real :: fahrenheit, celsius
    character(1) :: response
        
    DO
        ! Get a Celsius temperature
        write (*, '(1x, A)', ADVANCE = "NO") "Enter a Celsius temperature:"
        read *, Celsius
    
        ! Use the module function Fahr_to_Celsius to convert it to Celsius       
        Fahrenheit = Celsius_to_Fahr(celsius)
        
        ! Output the result
        print '(1x, 2(F6.2, A))', celsius, & 
            " in Celsius is equivalent to ", fahrenheit, " in Fahrenheit"
        
        ! Check if more temperautre ar to ber converted
        write (*, '(/ 1x, A)', ADVANCE = "NO") &
               "More temperatures to convert (Y or N)?"
        read *, response
                
        IF (response /= "Y") EXIT
    END DO
pause
    END PROGRAM Temperature_Conversion_7

    
Function Celsius_to_Fahr(Temp)
    implicit none
    real :: Celsius_to_Fahr
    real, intent(in) :: Temp        
    Celsius_to_Fahr = (Temp - 32.0) /1.8
End Function Celsius_to_Fahr

 

 

 

 

https://aeir.tistory.com/entry/%ED%8F%AC%ED%8A%B8%EB%9E%80-%EA%B0%95%EC%A2%8C-%EC%84%9C%EB%B8%8C%EB%A3%A8%ED%8B%B4-%EB%B6%80%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%A8?category=940076 

 

포트란 강좌 :: 서브루틴 부프로그램

보호되어 있는 글입니다. 내용을 보시려면 비밀번호를 입력하세요.

aeir.tistory.com

 

728x90
반응형

+ Recent posts