Fortran 案例中的文本输入?
Text input in fortran cases?
我正在用 Fortran 编写一段代码:
write(*,*) "What do you want to do?"
read(*,*) question
select case(question)
case(1)
call sleep (1)
goto 10 (returns at the beginning)
case default
write(*,*) "Ok, then good job :)"
write(*,*) "I exit in 3 seconds..."
call sleep (1)
write(*,*) "I exit in 2 seconds.."
call sleep (1)
write(*,*) "I exit in 1 seconds."
call sleep (2)
goto 20 (kills the program)
我想使用 "Yes" 和 "No" 而不是“1”和“2”
我怎样才能做到这一点?谢谢!
这是一个在 select/case 块中使用字符串 ("Title") 的示例:
https://pages.mtu.edu/~shene/COURSES/cs201/NOTES/chap03/select.html
CHARACTER(LEN=4) :: Title
INTEGER :: DrMD = 0, PhD = 0, MS = 0, BS = 0, Others = 0
SELECT CASE (Title)
CASE ("DrMD")
DrMD = DrMD + 1
CASE ("PhD")
PhD = PhD + 1
CASE ("MS")
MS = MS + 1
CASE ("BS")
BS = BS + 1
CASE DEFAULT
Others = Others + 1
END SELECT
我正在用 Fortran 编写一段代码:
write(*,*) "What do you want to do?"
read(*,*) question
select case(question)
case(1)
call sleep (1)
goto 10 (returns at the beginning)
case default
write(*,*) "Ok, then good job :)"
write(*,*) "I exit in 3 seconds..."
call sleep (1)
write(*,*) "I exit in 2 seconds.."
call sleep (1)
write(*,*) "I exit in 1 seconds."
call sleep (2)
goto 20 (kills the program)
我想使用 "Yes" 和 "No" 而不是“1”和“2” 我怎样才能做到这一点?谢谢!
这是一个在 select/case 块中使用字符串 ("Title") 的示例:
https://pages.mtu.edu/~shene/COURSES/cs201/NOTES/chap03/select.html
CHARACTER(LEN=4) :: Title
INTEGER :: DrMD = 0, PhD = 0, MS = 0, BS = 0, Others = 0
SELECT CASE (Title)
CASE ("DrMD")
DrMD = DrMD + 1
CASE ("PhD")
PhD = PhD + 1
CASE ("MS")
MS = MS + 1
CASE ("BS")
BS = BS + 1
CASE DEFAULT
Others = Others + 1
END SELECT