|
1 | 1 | program donut
|
2 | 2 |
|
3 |
| -use, intrinsic :: iso_fortran_env, only : wp=>real64, stdout => output_unit |
| 3 | +use, intrinsic:: iso_fortran_env, only: stdout => output_unit |
4 | 4 |
|
5 | 5 | implicit none (type, external)
|
6 | 6 |
|
7 | 7 | character, parameter :: ESC = achar(27)
|
8 | 8 | character(3), parameter :: LF = ESC // "[d" !< line feed
|
9 |
| -character(3), parameter :: TL = ESC // "[2J" !< erase screen and move to top left |
| 9 | +character(4), parameter :: TL = ESC // "[2J" !< erase screen and move to top left |
10 | 10 | character, parameter :: TAB(0:11) = [".", ",", "-", "~", ":", ";", "=", "!", "*", "#", "$", "@"]
|
11 |
| -real(wp), parameter :: PI = 4*atan(1.) |
| 11 | +real, parameter :: PI = 4*atan(1.) |
12 | 12 |
|
13 | 13 | integer :: cols, rows, L, k
|
14 | 14 |
|
15 |
| -real(wp) :: a=0, b=0, i, j |
| 15 | +real :: a=0, b=0, i, j |
16 | 16 |
|
17 |
| -real(wp), allocatable :: z(:) |
| 17 | +real, allocatable :: z(:) |
18 | 18 | character, allocatable :: screen(:)
|
19 | 19 |
|
20 |
| -real(wp) :: sini,cosj,sinA,sinj,cosA,cosj2, mess, cosi,cosB,t,sinB |
| 20 | +real :: sini,cosj,sinA,sinj,cosA,cosj2, mess, cosi,cosB,t,sinB |
21 | 21 | integer :: x,y,o,N,ii, u, Nloop
|
22 | 22 | character(5) :: buf
|
23 | 23 |
|
@@ -74,9 +74,9 @@ program donut
|
74 | 74 | cosi = cos(i)
|
75 | 75 | mess = 1 / (sini*cosj2*sinA+sinj*cosA+5)
|
76 | 76 | t = sini*cosj2*cosA - sinj*sinA
|
77 |
| - x = 40 + 30*mess*(cosi*cosj2*cosB - t*sinB) |
78 |
| - y = 12 + 15*mess*(cosi*cosj2*sinB + t*cosB) |
79 |
| - o = min(L, x+cols*y) !< C program goes out of bounds |
| 77 | + x = int(40 + 30*mess*(cosi*cosj2*cosB - t*sinB)) |
| 78 | + y = int(12 + 15*mess*(cosi*cosj2*sinB + t*cosB)) |
| 79 | + o = min(L-1, x+cols*y) !< C program goes out of bounds |
80 | 80 | N = int(8*((sinj*sinA - sini*cosj*cosA)*cosB - sini*cosj*sinA - sinj*cosA - cosi * cosj*sinB))
|
81 | 81 | if(rows>y .and. y>0 .and. x>0 .and. cols>x .and. mess>z(o)) then
|
82 | 82 | z(o) = mess
|
|
0 commit comments