CMD プロンプトで UTF-8
DOS 窓の黒い画面を見ると心の故郷に帰ったようで落ち着きますね。powershell は訳がわからないので使う気がしません。
いつの頃からか Windows の DOS窓というか今はコマンド・プロンプトでも UTF-8 が出力できるようになっていました。点字も出せます。
chcp 65001 でページが切り替わります。ただフォントも対応するものでなければならないようですが。
code でない方の旧来の visual studio から実行する場合、自動で CMD プロンプトが開きますが、プログラム中で output_unit を UTF-8 で再 open すれば大丈夫です。open 文の文字コード指定は、close 無しで再 open することにより変更できます。また block を抜けても close しませんし属性は保たれます。
block ! for Windows CMD prompt use, intrinsic :: iso_fortran_env, only: output_unit open(unit=output_unit, encoding='utf-8') call execute_command_line('CHCP 65001 > nul') ! UTF-8: CHCP 65001, JP: CHCP 432, US: CHCP 437 end block
参考:Doctor Fortran in "The Modes, They are A-Changin'" - Doctor Fortran
トランプ時代を迎えて、ホントに The times they are a-changin' でワロス
点字プロット
ついでに点字プロットを改造して、座標の数値も書けるように、ASCII 文字を位置を指定して書けるようにしてみました。脳内では随分前にできていたのですが、現実世界ではやる気がしなくてのびのびになっていました。
初めは AI にやらせようとしたのですが、あまりに無能で発狂しそうになったので、自分でやろうという気が閾値を超えました。AI に叱咤されましたw
実行結果

Monte Carlo: estimated pi = 3.160000
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀1.0⠀⡤⠤⠤⠤⠤⢤⣤⣤⣤⣤⢤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⡤⠤⠤⡤⠤⠤⡤⠤⡤⠤⠤⠤⠤⠤⠤⢤⠤⠤⠤⢤⠤⠤⠤⢤⠤⠤⠤⠤⠤⠤⠤⠤⠤⢤⠤⠤⠤⡄⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡇⠀⠀⠈⠐⠀⡀⠈⠠⠘⠉⡉⠑⡓⡢⠤⢌⣓⡀⠀⠁⠆⠠⠀⠀⠈⠈⡀⠂⠨⠠⠀⠄⠀⠀⢀⠀⠀⠀⠀⠈⠂⢔⡀⠀⠀⠀⠐⠀⠈⠀⠂⠀⡀⠀⠤⠠⠀⠀⠈⠀⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡗⠂⡀⢀⠀⠀⢄⠀⠀⠀⠀⠀⠈⠈⠁⠁⠀⠀⠈⠑⠖⡢⢴⡀⢀⠀⢀⠁⢀⠀⠀⠄⠀⡁⠀⠀⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⠀⠆⠀⠀⢀⠀⠀⠀⠂⠀⠀⠀⠀⠁⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡇⠀⢀⠀⠀⠀⠠⠀⠄⠀⠌⡁⠀⡀⠀⠀⠁⠀⠘⠀⡐⡄⠐⠈⠉⠒⠤⣀⡀⠀⠠⠀⠀⠀⠔⠠⠂⠀⠢⢀⠄⠐⠀⠀⡉⠈⠅⠀⢀⠀⠀⠀⠀⠀⠀⢐⠔⠈⠐⠀⠈⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡇⠀⠀⠐⠀⠈⠀⠀⠀⠀⡀⠀⠀⠀⠀⢀⠀⠀⠀⠀⢈⠐⡀⠀⠂⠠⠀⠐⠙⠓⠤⣅⠐⠀⢀⠀⢀⠂⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠀⠀⠠⠁⠈⠀⠀⡠⠀⢀⠀⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡇⠀⡐⠐⠂⠀⠀⠀⢀⠄⠈⢐⠀⠠⠈⠀⠠⠀⡀⠀⠀⠀⠀⠐⠈⠐⠀⠀⠰⠀⠆⠀⠙⠤⣀⠀⠀⠀⠀⠀⠀⠂⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠑⢐⠀⠈⠀⠀⠀⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡇⡠⠠⠀⠀⠐⠁⠂⠁⠀⠀⠂⠀⠀⠀⠀⡀⠀⠁⠐⠠⠀⠀⠀⠀⡢⠀⠂⠀⠠⠀⠀⠀⠂⠀⢕⠤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠂⠐⠀⠂⠁⠄⠀⠀⡀⠈⠀⠄⠈⡈⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠄⠄⠀⠀⠰⠄⠀⠠⠄⡄⠀⡐⠀⠀⢁⠀⠀⠄⠀⠀⠀⢀⠀⠀⠈⠀⠀⠀⠠⣐⠀⠀⠈⠉⠑⣄⡠⡀⠀⠀⠂⠀⢀⠰⠀⠀⠀⠆⠀⢠⠀⠀⠀⠀⠀⠠⠀⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡇⠐⠀⠐⠀⠁⠀⠀⡀⠀⡀⠀⠤⠂⠀⠀⠀⠀⠀⠀⠀⡀⠀⠀⣀⠀⠁⢀⠀⡀⢀⠐⠀⢀⠀⠀⢈⠀⠄⠀⠱⠬⡠⠀⠁⠀⢁⠉⠀⠀⠀⡁⠐⠂⠀⠠⠀⠀⠁⠀⠀⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡇⠀⠅⠀⠀⠀⠀⡀⠀⡈⠀⠐⠀⠀⠀⠀⠀⠀⠐⠄⠀⠀⠐⠠⡀⠀⠀⠀⠠⢀⠀⠐⠂⠀⠀⠀⠀⠠⠐⠆⠀⠀⠘⢄⢀⠐⠂⠠⠀⠁⠀⠀⠠⠀⠀⠀⠀⠂⠠⡠⠀⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡧⠀⠂⠀⡠⠐⡀⠀⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠀⠀⠀⠀⠀⠀⠂⠁⠀⠌⠀⠀⠐⠀⣀⠈⠀⠂⠨⢀⠀⠀⠀⢀⢩⢦⠀⠀⠁⠠⠀⠀⠀⠀⠆⠀⠀⠀⠀⠀⠆⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡗⠀⠀⠈⡀⠔⠀⡀⠀⡀⠀⠂⡀⠀⠀⢂⠀⠈⠀⠀⠐⠁⠠⠀⠀⠀⠀⠀⠀⠢⠠⠀⠄⠄⠀⠀⠀⠄⠀⠀⢆⢀⠀⠀⠁⠀⠑⢆⠁⠈⠀⠘⠀⠀⠄⠂⠀⠀⠀⠀⠀⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡗⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠀⠄⡀⠀⠀⠀⠀⠀⡘⠀⠂⠄⠁⠀⠀⠠⠀⡀⢀⠄⠐⠈⠉⠀⠀⠠⡀⠀⠁⠤⠄⡀⡀⠄⢀⠐⠠⠣⡀⠀⠀⠀⠀⠌⡀⠄⠀⠐⠀⠀⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡇⠀⢀⠀⠀⢀⠀⠀⠀⠀⠈⠀⠐⠀⢀⠐⡈⠀⠀⠀⠀⠄⠀⠈⠀⠠⠒⡀⠁⠀⠀⢀⠀⠁⠀⠀⠂⠀⠀⠄⠄⠂⠄⠀⡸⠀⠂⠀⠀⠑⢄⢐⠠⠐⠀⠀⠂⠀⠀⠀⠀⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡷⠀⠀⠀⢀⠀⡀⡀⠀⢀⠤⢀⠀⡂⠀⠀⠀⠐⠀⠀⠀⠠⡀⢁⠀⠀⠂⠀⠠⠁⠁⠄⠀⠀⢀⠁⠠⢠⠄⠀⠀⠁⡠⠐⠂⠌⠀⠀⠁⠠⠈⠢⡀⠀⠀⠁⠈⠀⠀⠐⠀⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣯⠀⠠⡀⢈⠄⣠⠀⠀⠀⠐⠀⠀⠄⠀⡐⠀⠀⠐⠀⠂⠄⠀⡀⠀⠰⠄⠀⠀⠀⠀⠀⠀⠂⡀⡀⠀⠄⠀⠐⠀⠀⢰⠀⠄⠀⠀⠀⠀⠒⠀⡀⢱⠁⠠⠀⠀⠂⠀⠀⠀⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠄⡀⠀⠀⠤⠀⠄⢀⠢⠁⠀⡀⠤⡀⣠⢀⠠⠀⢀⠄⠀⠀⠀⠀⠄⠀⠠⡀⠀⠠⠀⠀⠈⠐⠐⠀⠀⠀⠠⠀⠈⠀⠀⠐⠀⠀⠂⠀⢱⡈⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡇⠄⠀⠀⠀⠄⠡⠄⠀⠀⠀⠀⠀⠀⢁⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠠⠀⡀⠠⠀⠠⠀⠀⠀⠄⠀⠀⠐⠀⠀⠄⠀⠠⡀⠠⠀⠀⠀⠊⠀⠀⠀⡀⠀⠘⡤⠀⠠⠀⠠⠀⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡇⠀⠈⠀⠀⡐⠀⠂⢀⠒⠀⠀⠁⠀⠈⠀⠀⠌⠀⠀⠐⠀⠁⠀⠁⠈⠈⠂⠀⠀⠀⠁⠁⠀⠀⠀⡀⠀⠀⠀⢌⠀⠊⠀⠀⠐⡀⡀⠀⠀⠐⠁⠐⠠⠀⢸⠀⢈⠀⠀⠀⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣧⠀⠠⢀⠀⠈⢀⠁⠀⠀⠀⠂⠀⠀⠀⠁⠀⠀⠀⠘⠀⠀⠂⠐⠀⠀⠨⠐⠀⠀⠀⡀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠂⠀⠀⠀⠀⠀⠀⠀⠄⠀⠈⠀⢀⢣⠀⠀⠑⠀⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡗⠀⠆⠀⠀⡀⠑⡀⡀⠀⠀⠂⢂⠀⠂⠁⠌⡂⠀⠀⠀⠀⠀⠀⠠⠀⠀⢀⠀⠀⠂⠄⠀⠀⠀⠀⠀⠀⠀⠠⠀⠀⠀⠀⠠⠀⠀⠄⠀⠀⠐⠈⠑⠠⢁⠀⠀⢣⠄⠀⠀⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡇⠀⠄⡀⠄⡄⠈⠀⠈⠀⠈⠀⠀⠄⠢⡀⠀⠀⠕⠠⠀⠀⠀⠀⡀⠀⠀⠐⠀⠀⠀⠁⠀⠀⡀⡈⠀⠀⠀⠀⠀⠀⠀⣀⠈⠀⠀⠰⠀⠀⠀⠀⡈⠀⡀⠀⠁⠈⡆⠀⠐⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡏⠄⠀⠀⠀⠀⠀⠂⠀⢀⠀⠀⠀⡀⠠⠁⠀⠀⠄⠀⢀⠀⡀⡀⠀⠀⠀⠂⠘⠀⠀⡁⠀⠀⠀⠀⠀⠠⣀⠀⠀⠈⠂⠀⠀⠀⠁⠈⠀⠀⠄⠰⠀⠄⠀⠉⠀⠐⠸⡀⠀⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡇⠀⠄⠀⠁⠀⡀⠠⠀⠀⠀⠀⠀⢀⠀⠀⠀⠈⠂⠀⠀⡀⠈⢀⠀⠂⠠⡀⠠⢀⠀⠀⠀⠈⠤⠀⠀⠁⢀⠀⠈⠀⠄⠂⠀⠀⠨⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⡇⠀⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡇⠀⠀⠄⠀⠠⠀⡢⠀⢀⠀⠐⠀⠂⠈⠜⠂⠀⠀⠘⠀⠀⡀⠐⠐⢀⠀⠀⠀⠀⠐⠀⠐⠀⠂⠀⠀⠅⠀⠀⠠⠀⠀⢁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⠀⠁⠐⠀⢱⡐⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡇⠐⠀⠐⠁⠀⠀⠲⡀⠀⠀⠀⠀⠀⠁⠀⠥⠀⠁⠀⠐⠀⠂⠠⡠⠀⠀⠀⢀⢀⠀⠐⠀⠀⠀⠁⠀⢀⠀⠀⠀⠀⠀⠀⠀⢀⠀⠩⠀⠀⡈⠀⠀⠅⠀⠈⠂⠀⠀⢈⡆⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠠⢀⠄⢠⠀⠀⠀⠀⠉⠀⠀⡀⠀⠨⠀⠀⠀⠀⠀⠐⠀⢀⢀⠅⠀⠀⠀⠀⠀⠡⠐⠁⠀⠀⢀⠄⠀⠀⠀⠂⠀⠀⠀⠀⢀⠀⠀⢀⡀⢣⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡇⢀⠀⠀⠀⠊⠔⠀⠠⠀⠀⠀⠀⠀⠀⠀⠐⠃⢀⠀⠀⠀⠀⠀⠀⠁⢀⠀⠀⠀⠂⠀⠀⠀⠈⠀⠀⠈⠀⠀⠀⡀⠅⠂⠠⠀⡀⠀⢔⠈⠂⢀⠂⡉⡈⠀⠠⠀⠈⠀⢹⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡇⠀⠠⠄⠈⠀⠀⠁⠠⠀⠀⠀⠂⠀⠐⠠⠄⣀⠀⠥⠀⡁⠈⠀⠀⠀⠀⢀⡀⠄⠈⠀⠀⠠⠄⡀⠀⠀⠄⠐⠃⠁⠠⠀⠀⠀⠄⠂⠀⠀⠀⠀⡀⠀⠀⠁⠀⠀⠁⢀⢸⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡇⠐⠀⠀⠀⠐⠐⢈⠈⠄⠁⠄⠀⠀⠑⠔⢀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠈⡀⠀⠀⠀⠀⠀⠁⠀⢈⠀⠀⠀⠀⠀⠀⠕⠀⠀⢀⠀⠀⠀⠀⡀⠀⠀⠀⠤⠂⠂⠀⠀⠀⠈⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡇⠀⠠⠀⠀⠀⠀⠀⠀⠀⢀⠀⠈⠀⠀⢄⠀⠀⠀⠀⠀⠀⡠⠠⠈⠐⠀⠀⠀⠀⠀⠀⠀⡀⠈⠀⠐⠀⠐⠀⠤⠀⠈⠀⠀⠀⠀⠀⠂⠀⠀⠀⠀⠄⠀⠀⡀⠀⠀⠀⠀⡇⠀⠀⠀
⠀⠀0.0⠀⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠁⠀⠀⠀
⠀⠀⠀⠀⠀⠀0.0⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀1.0⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
Sin curve
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀1.0⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡗⠒⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠤⠔⠒⠒⠂⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠒⠉⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⡠⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⢀⠎⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⡰⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⢀⠎⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⢀⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⡠⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠠⠧⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⢤⡷⠥⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠧⠀⠀
-pi/2⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠0.0⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ pi/2⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡰⠁⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡰⠁⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠎⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡰⠁⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠊⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠃⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢀⡠⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⣀⣀⣀⠤⠔⠊⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣇⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀-1.0⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
続行するには何かキーを押してください . . .
ソース・プログラム
ASCII 文字は負数で仮想画面に書き込んでおくことで、出力時に点字か ASCII かの処理を振り分けています。文字の上には点字を書かないようにしています。また、今までいい加減だったスケールした座標系で描く部分も完成させました。
Unix 系の shell では、chcp 65001 の部分はコメントアウトします。little endian を仮定しています。
module uniplot implicit none private public :: fig_t type :: fig_t private integer :: nx, ny real :: x0 = -1.0, y0 = -1.0, x1 = 1.0, y1 = 1.0 integer, allocatable :: array(:, :) contains procedure :: init procedure :: show procedure :: text0 procedure :: point0 procedure :: line0 procedure :: text procedure :: point procedure :: line end type fig_t contains subroutine init(fig, nx, ny, x0, y0, x1, y1) class(fig_t), intent(out) :: fig integer, intent(in) :: nx, ny real, intent(in), optional :: x0, y0, x1, y1 fig%nx = nx fig%ny = ny if (present(x0)) fig%x0 = x0 if (present(y0)) fig%y0 = y0 if (present(x1)) fig%x1 = x1 if (present(y1)) fig%y1 = y1 allocate(fig%array(0:(nx+1)/2, 0:(ny+3)/4), source = 0) end subroutine init ! Braille 2 * 4 dots ! ix !iy 0 1 : 0 8 ! 1 : 2 16 ! 2 : 4 32 ! 3 : 64 128 ! + 0x2800 Unicode : offset : 0x2800 = 0010_1000 0000_0000 -> 4,6,6bits -> 0010, 100000, 000000 ! ! Unicode to UTF-8 : 1110_0000, 1000_0000, 1000_0000 ! 1110..., 1000...., 1000...., ! 0010, 10_0000, 00_0000 ! 0x2800 ! icode : 00_00xx, xx_xxxx ! 1110_0010, 1010_00xx, 10xx_xxxx ! subroutine show(fig) class(fig_t), intent(in) :: fig integer :: iy do iy = 0, ubound(fig%array, 2) print '(*(a))', reverse_endian(to_utf8(fig%array(:, iy))) ! little endian end do end subroutine show pure elemental integer function icode(kx, ky) integer, intent(in) :: kx, ky if (ky == 3) then icode = 64 + 64 * kx else ! 0, 1, 2 icode = 2**(ky + 3*kx) end if end function icode pure elemental integer function to_utf8(i) integer, intent(in) :: i integer, parameter :: n_unicode = 10240 ! 0x2800 ! 0010_1000 0000_0000 integer, parameter :: n_offset= 14712960 ! 0xE08080 ! 1110_0000 1000_0000 1000_0000 integer :: k if (i >= 0) then ! Braille k = i + n_unicode to_utf8 = n_offset + 256 * (256 * mod(k/4096, 16) + mod(k/64, 64)) + mod(k, 64) else ! ascii to_utf8 = -i ! ascii passed as a negative number end if end function to_utf8 pure elemental character(len = 4) function reverse_endian(i) integer, intent(in) :: i character:: tmp(4) tmp = transfer(i, ' ', size = 4) reverse_endian = transfer(tmp(4:1:-1), ' ') !array 4 to len 4 characters end function reverse_endian subroutine text0(fig, ix, iy, txt) class(fig_t), intent(in out) :: fig integer, intent(in) :: ix, iy character(len = *), intent(in) :: txt integer :: i, iax, iay iax = ix / 2 iay = iy / 4 do i = 1, len_trim(txt) ! clipping if (0<=i+iax .and. i+iax<=fig%nx/2 .and. 0<=iay .and. iay<=fig%ny/4) then fig%array(i + iax - 1, iay) = -iachar(txt(i:i)) ! ascii chars passed as a negative number end if end do end subroutine text0 subroutine point0(fig, ix, iy) class(fig_t), intent(in out) :: fig integer, intent(in) :: ix, iy integer :: iax, iay iax = ix / 2 iay = iy / 4 ! clipping if (0<=ix .and. ix<=fig%nx .and. 0<=iy .and. iy<=fig%ny) then if (fig%array(iax, iay) >= 0) & ! don't overwrite text fig%array(iax, iay) = ior(fig%array(iax, iay), icode(mod(ix, 2), mod(iy, 4))) end if end subroutine point0 subroutine line0(fig, ix0, iy0, ix1, iy1) class(fig_t), intent(in out) :: fig integer, intent(in) :: ix0, iy0, ix1, iy1 integer :: i, ix, iy, nx, ny real :: d nx = ix1 - ix0 ny = iy1 - iy0 if (nx == 0 .and. ny ==0) then call fig%point0(ix, iy) else if (abs(nx) < abs(ny)) then d = nx / real(ny) do i = 0, abs(ny) ix = nint(ix0 + d * sign(i, ny)) iy = iy0 + sign(i, ny) call fig%point0(ix, iy) end do else d = ny / real(nx) do i = 0, abs(nx) iy = nint(iy0 + d * sign(i, nx)) ix = ix0 + sign(i, nx) call fig%point0(ix, iy) end do end if end subroutine line0 subroutine text(fig, x, y, txt) class(fig_t), intent(in out) :: fig real, intent(in) :: x, y character(len = *), intent(in) :: txt integer :: ix, iy, iax, iay ix = nint( (x - fig%x0) / (fig%x1 - fig%x0) * fig%nx) iy = nint(fig%ny - (y - fig%y0) / (fig%y1 - fig%y0) * fig%ny) call fig%text0(ix, iy, txt) end subroutine text subroutine point(fig, x, y) class(fig_t), intent(in out) :: fig real, intent(in) :: x, y integer :: ix, iy, iax, iay ix = nint( (x - fig%x0) / (fig%x1 - fig%x0) * fig%nx) iy = nint(fig%ny - (y - fig%y0) / (fig%y1 - fig%y0) * fig%ny) call fig%point0(ix, iy) end subroutine point subroutine line(fig, x, y, ipen) class(fig_t), intent(in out) :: fig real, intent(in) :: x, y integer, intent(in) :: ipen integer, save :: ix0 = 0, iy0 = 0 integer :: ix, iy ix = nint( (x - fig%x0) / (fig%x1 - fig%x0) * fig%nx) iy = nint(fig%ny - (y - fig%y0) / (fig%y1 - fig%y0) * fig%ny) if (ipen == 1) call fig%line0(ix0, iy0, ix, iy) ix0 = ix iy0 = iy end subroutine line end module uniplot program uniplot_main implicit none block ! for Windows CMD prompt use, intrinsic :: iso_fortran_env, only: output_unit open(unit=output_unit, encoding='utf-8') call execute_command_line('CHCP 65001 > nul') ! UTF-8: CHCP 65001, JP: CHCP 432, US: CHCP 437 end block fig_1: block use :: uniplot real, allocatable :: x(:), y(:) type(fig_t) :: fig1 integer :: nx, ny integer :: n n = 10**3 allocate(x(n), y(n)) rand: block call random_seed() call random_number(x) call random_number(y) end block rand nx = 140 ny = nx print * print *, repeat(' ', 14), 'Monte Carlo: estimated pi =', 4.0 * count(x**2 + y**2 < 1.0) / n call fig1%init(nx, ny, -0.1, -0.1, 1.05, 1.05) ! draw box call fig1%line(0.0, 0.0, 0) call fig1%line(0.0, 1.0, 1) call fig1%line(1.0, 1.0, 1) call fig1%line(1.0, 0.0, 1) call fig1%line(0.0, 0.0, 1) call fig1%text(-0.06, 0.0, '0.0') call fig1%text(-0.06, 1.0, '1.0') call fig1%text(-0.005, -0.05, '0.0') call fig1%text( 0.985, -0.05, '1.0') ! draw 1/4 circle circle: block integer :: i real :: x, y call fig1%line(0.0, 1.0, 0) do i = 0, nx x = i / real(nx) y = sqrt(1.0 - x**2) call fig1%line(x, y, 1) end do end block circle ! plot random dots random_dots: block integer :: i do i = 1, n call fig1%point(x(i), y(i)) end do end block random_dots call fig1%show() end block fig_1 fig_2: block ! Sin curve use :: uniplot type(fig_t) :: fig2 real, parameter :: pi = 4 * atan(1.0) integer :: nx, ny nx = 100 ny = nx print * print *, repeat(' ', 20), 'Sin curve' call fig2%init(nx, ny, -1.7, -1.1, 1.7, 1.1) ! draw axes call fig2%line(-1.6, 0.0, 0) call fig2%line( 1.6, 0.0, 1) call fig2%line( 0.0, -1.1, 0) call fig2%line( 0.0, 1.1, 1) call fig2%line( 0.0, 1.0, 0) call fig2%line( 0.1, 1.0, 1) call fig2%line( 0.0, -1.0, 0) call fig2%line( 0.1, -1.0, 1) call fig2%text(-0.05, -0.05, '0.0') call fig2%text(-0.05, 1.05, '1.0') call fig2%text(-0.10, -1.05, '-1.0') call fig2%line(-1.57, 0.0 , 0) call fig2%line(-1.57, 0.05, 1) call fig2%line( 1.57, 0.0 , 0) call fig2%line( 1.57, 0.05, 1) call fig2%text( 1.40, -0.05, ' pi/2') call fig2%text(-1.65, -0.05, '-pi/2') ! draw Sin curve sine: block integer :: i real :: x, y call fig2%line(-pi/2, -1.0, 0) do i = 0, nx x = -pi/2 + i * pi / nx y = sin(x) call fig2%line(x, y, 1) end do end block sine call fig2%show() end block fig_2 end program uniplot_main




