Advertisement
Wolfed_7

Untitled

Feb 20th, 2022
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. c Main part
  2. PROGRAM main
  3.  
  4. COMMON /const/ rad
  5. COMMON /input/ Xmin, Xmax, Xstep, Ymin, Ymax, Ystep
  6.  
  7. rad = 3.1415927 / 180
  8. PRINT *, rad
  9.  
  10. CALL inputf
  11. CALL outputf
  12. END
  13.  
  14. c Input values from file
  15. SUBROUTINE inputf
  16.  
  17. COMMON /const/ rad
  18. COMMON /input/ Xmin, Xmax, Xstep, Ymin, Ymax, Ystep
  19.  
  20. OPEN (1, FILE='input.txt', ACTION='READ', STATUS='OLD', ERR=1)
  21. READ (1, *, ERR=1) Xmin, Xmax, Xstep, Ymin, Ymax, Ystep
  22. IF (Xmin .GT. Xmax .OR. Ymin .GT. Ymax) GOTO 1
  23. GOTO 2
  24.  
  25. 1 PAUSE 'Error: please check the input file'
  26. STOP
  27. 2 END
  28.  
  29. c Write cosec(x+y) result in output file
  30. SUBROUTINE outputf
  31.  
  32. COMMON /const/ rad
  33. COMMON /input/ Xmin, Xmax, Xstep, Ymin, Ymax, Ystep
  34.  
  35. OPEN (2, FILE='output.txt', ACTION='WRITE', ERR=3)
  36.  
  37. c Draw the table top
  38. WRITE (2, 13) '| y\x '
  39. WRITE (2, 11) Xmin
  40. ri = Xmin + Xstep
  41. DO WHILE (ri .LT. Xmax)
  42. WRITE (2, 11) ri
  43. ri = ri + Xstep
  44. END DO
  45. WRITE (2, 11) Xmax
  46. WRITE (2, 13) '|'
  47. WRITE (2, 14)
  48.  
  49. c I cant round iparts up, so... +2 instead of +1
  50. iparts = (Xmax - Xmin) / Xstep + 2
  51. DO i = 0, iparts, 1
  52. WRITE (2, 12)
  53. END DO
  54. WRITE (2, 13) '|'
  55.  
  56. c Do something blablabla fix it
  57. c I HATE FORTRAN
  58.  
  59.  
  60. GOTO 4
  61. 3 PAUSE 'Error: please check the output file'
  62. STOP
  63.  
  64. 10 FORMAT ('|'E11.4' '\)
  65. 11 FORMAT ('|'F11.4' '\)
  66. 12 FORMAT ('|'12('—')\)
  67. 13 FORMAT (a\)
  68. 14 FORMAT (/1x\)
  69.  
  70. 4 END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement