小编ker*_*r2x的帖子

不同长度的Fortran子字符串比较存在问题

我正在循环阅读stdin,并与一堆“ if”进行比较,以根据输入决定要做什么。

这是一段简短的代码:

CHARACTER (len= :), allocatable :: input
CHARACTER (len=4096) :: inbuffer            ! frustrating but... well, fortran :3

DO

    ! get input
    READ(*, '(a)') inbuffer     ! because apparently you can't have allocation on read so you can't just read "input". meh.
    input = TRIM(inbuffer)
    CALL debug_log(input)

    IF(input .EQ. 'uci') THEN
        CALL debug_log("   printing uci info")

    !isready
    ELSE IF(input .EQ. 'isready') THEN
        CALL debug_log("   isready -> readyok")
        WRITE(*, '(a)') "readyok"

    !ucinewgame
    ELSE IF(input .EQ. 'ucinewgame') THEN
        CALL debug_log("not implemented : …
Run Code Online (Sandbox Code Playgroud)

fortran gfortran

2
推荐指数
1
解决办法
155
查看次数

标签 统计

fortran ×1

gfortran ×1