Advertisement
chemoelectric

Hello, there, fellow engineering graduates!

Mar 30th, 2023
2,318
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Fortran 11.27 KB | Source Code | 0 0
  1. program foo
  2.  
  3.   implicit none
  4.  
  5.   integer, parameter :: stack_max = 1000
  6.  
  7.   integer :: stack(0:stack_max - 1)
  8.   integer :: sp = 0  ! "Stack pointer"
  9.  
  10.   integer :: var0 = 0
  11.   integer :: var1 = 0
  12.   integer :: var2 = 0
  13.   integer :: var3 = 0
  14.   integer :: var4 = 0
  15.   integer :: var5 = 0
  16.   integer :: var6 = 0
  17.   integer :: var7 = 0
  18.   integer :: var8 = 0
  19.   integer :: var9 = 0
  20.   integer :: var10 = 0
  21.   integer :: var11 = 0
  22.   integer :: var12 = 0
  23.   integer :: var13 = 0
  24.   integer :: var14 = 0
  25.  
  26.  
  27.   goto 10000
  28. 10000 continue
  29.   if (stack_max <= sp) error stop
  30.   stack(sp) = 420
  31.   sp = sp + 1
  32.   goto 10010
  33. 10010 continue
  34.   if (sp <= 0) error stop
  35.   stack(sp - 1) = -stack(sp - 1)
  36.   goto 10020
  37. 10020 continue
  38.   if (sp <= 0) error stop
  39.   sp = sp - 1
  40.   var0 = stack(sp)
  41.   goto 10030
  42. 10030 continue
  43.   if (stack_max <= sp) error stop
  44.   stack(sp) = 300
  45.   sp = sp + 1
  46.   goto 10040
  47. 10040 continue
  48.   if (sp <= 0) error stop
  49.   sp = sp - 1
  50.   var1 = stack(sp)
  51.   goto 10050
  52. 10050 continue
  53.   if (stack_max <= sp) error stop
  54.   stack(sp) = 300
  55.   sp = sp + 1
  56.   goto 10060
  57. 10060 continue
  58.   if (sp <= 0) error stop
  59.   sp = sp - 1
  60.   var2 = stack(sp)
  61.   goto 10070
  62. 10070 continue
  63.   if (stack_max <= sp) error stop
  64.   stack(sp) = 300
  65.   sp = sp + 1
  66.   goto 10080
  67. 10080 continue
  68.   if (sp <= 0) error stop
  69.   stack(sp - 1) = -stack(sp - 1)
  70.   goto 10090
  71. 10090 continue
  72.   if (sp <= 0) error stop
  73.   sp = sp - 1
  74.   var3 = stack(sp)
  75.   goto 10100
  76. 10100 continue
  77.   if (stack_max <= sp) error stop
  78.   stack(sp) = 7
  79.   sp = sp + 1
  80.   goto 10110
  81. 10110 continue
  82.   if (sp <= 0) error stop
  83.   sp = sp - 1
  84.   var4 = stack(sp)
  85.   goto 10120
  86. 10120 continue
  87.   if (stack_max <= sp) error stop
  88.   stack(sp) = 15
  89.   sp = sp + 1
  90.   goto 10130
  91. 10130 continue
  92.   if (sp <= 0) error stop
  93.   sp = sp - 1
  94.   var5 = stack(sp)
  95.   goto 10140
  96. 10140 continue
  97.   if (stack_max <= sp) error stop
  98.   stack(sp) = 200
  99.   sp = sp + 1
  100.   goto 10150
  101. 10150 continue
  102.   if (sp <= 0) error stop
  103.   sp = sp - 1
  104.   var6 = stack(sp)
  105.   goto 10160
  106. 10160 continue
  107.   if (stack_max <= sp) error stop
  108.   stack(sp) = var2
  109.   sp = sp + 1
  110.   goto 10170
  111. 10170 continue
  112.   if (sp <= 0) error stop
  113.   sp = sp - 1
  114.   var7 = stack(sp)
  115.   goto 10180
  116. 10180 continue
  117.   if (stack_max <= sp) error stop
  118.   stack(sp) = var7
  119.   sp = sp + 1
  120.   goto 10190
  121. 10190 continue
  122.   if (stack_max <= sp) error stop
  123.   stack(sp) = var3
  124.   sp = sp + 1
  125.   goto 10200
  126. 10200 continue
  127.   if (sp <= 1) error stop
  128.   sp = sp - 1
  129.   stack(sp - 1) = b2i (stack(sp - 1) > stack(sp))
  130.   goto 10210
  131. 10210 continue
  132.   if (sp <= 0) error stop
  133.   sp = sp - 1
  134.   if (stack(sp) == 0) goto 11030
  135.   goto 10220
  136. 10220 continue
  137.   if (stack_max <= sp) error stop
  138.   stack(sp) = var0
  139.   sp = sp + 1
  140.   goto 10230
  141. 10230 continue
  142.   if (sp <= 0) error stop
  143.   sp = sp - 1
  144.   var8 = stack(sp)
  145.   goto 10240
  146. 10240 continue
  147.   if (stack_max <= sp) error stop
  148.   stack(sp) = var8
  149.   sp = sp + 1
  150.   goto 10250
  151. 10250 continue
  152.   if (stack_max <= sp) error stop
  153.   stack(sp) = var1
  154.   sp = sp + 1
  155.   goto 10260
  156. 10260 continue
  157.   if (sp <= 1) error stop
  158.   sp = sp - 1
  159.   stack(sp - 1) = b2i (stack(sp - 1) < stack(sp))
  160.   goto 10270
  161. 10270 continue
  162.   if (sp <= 0) error stop
  163.   sp = sp - 1
  164.   if (stack(sp) == 0) goto 10960
  165.   goto 10280
  166. 10280 continue
  167.   if (stack_max <= sp) error stop
  168.   stack(sp) = 0
  169.   sp = sp + 1
  170.   goto 10290
  171. 10290 continue
  172.   if (sp <= 0) error stop
  173.   sp = sp - 1
  174.   var9 = stack(sp)
  175.   goto 10300
  176. 10300 continue
  177.   if (stack_max <= sp) error stop
  178.   stack(sp) = 0
  179.   sp = sp + 1
  180.   goto 10310
  181. 10310 continue
  182.   if (sp <= 0) error stop
  183.   sp = sp - 1
  184.   var10 = stack(sp)
  185.   goto 10320
  186. 10320 continue
  187.   if (stack_max <= sp) error stop
  188.   stack(sp) = 32
  189.   sp = sp + 1
  190.   goto 10330
  191. 10330 continue
  192.   if (sp <= 0) error stop
  193.   sp = sp - 1
  194.   var11 = stack(sp)
  195.   goto 10340
  196. 10340 continue
  197.   if (stack_max <= sp) error stop
  198.   stack(sp) = 0
  199.   sp = sp + 1
  200.   goto 10350
  201. 10350 continue
  202.   if (sp <= 0) error stop
  203.   sp = sp - 1
  204.   var12 = stack(sp)
  205.   goto 10360
  206. 10360 continue
  207.   if (stack_max <= sp) error stop
  208.   stack(sp) = var12
  209.   sp = sp + 1
  210.   goto 10370
  211. 10370 continue
  212.   if (stack_max <= sp) error stop
  213.   stack(sp) = var6
  214.   sp = sp + 1
  215.   goto 10380
  216. 10380 continue
  217.   if (sp <= 1) error stop
  218.   sp = sp - 1
  219.   stack(sp - 1) = b2i (stack(sp - 1) < stack(sp))
  220.   goto 10390
  221. 10390 continue
  222.   if (sp <= 0) error stop
  223.   sp = sp - 1
  224.   if (stack(sp) == 0) goto 10890
  225.   goto 10400
  226. 10400 continue
  227.   if (stack_max <= sp) error stop
  228.   stack(sp) = var10
  229.   sp = sp + 1
  230.   goto 10410
  231. 10410 continue
  232.   if (stack_max <= sp) error stop
  233.   stack(sp) = var10
  234.   sp = sp + 1
  235.   goto 10420
  236. 10420 continue
  237.   if (sp <= 1) error stop
  238.   sp = sp - 1
  239.   stack(sp - 1) = stack(sp - 1) * stack(sp)
  240.   goto 10430
  241. 10430 continue
  242.   if (stack_max <= sp) error stop
  243.   stack(sp) = 200
  244.   sp = sp + 1
  245.   goto 10440
  246. 10440 continue
  247.   if (sp <= 1) error stop
  248.   sp = sp - 1
  249.   stack(sp - 1) = stack(sp - 1) / stack(sp)
  250.   goto 10450
  251. 10450 continue
  252.   if (sp <= 0) error stop
  253.   sp = sp - 1
  254.   var13 = stack(sp)
  255.   goto 10460
  256. 10460 continue
  257.   if (stack_max <= sp) error stop
  258.   stack(sp) = var9
  259.   sp = sp + 1
  260.   goto 10470
  261. 10470 continue
  262.   if (stack_max <= sp) error stop
  263.   stack(sp) = var9
  264.   sp = sp + 1
  265.   goto 10480
  266. 10480 continue
  267.   if (sp <= 1) error stop
  268.   sp = sp - 1
  269.   stack(sp - 1) = stack(sp - 1) * stack(sp)
  270.   goto 10490
  271. 10490 continue
  272.   if (stack_max <= sp) error stop
  273.   stack(sp) = 200
  274.   sp = sp + 1
  275.   goto 10500
  276. 10500 continue
  277.   if (sp <= 1) error stop
  278.   sp = sp - 1
  279.   stack(sp - 1) = stack(sp - 1) / stack(sp)
  280.   goto 10510
  281. 10510 continue
  282.   if (sp <= 0) error stop
  283.   sp = sp - 1
  284.   var14 = stack(sp)
  285.   goto 10520
  286. 10520 continue
  287.   if (stack_max <= sp) error stop
  288.   stack(sp) = var13
  289.   sp = sp + 1
  290.   goto 10530
  291. 10530 continue
  292.   if (stack_max <= sp) error stop
  293.   stack(sp) = var14
  294.   sp = sp + 1
  295.   goto 10540
  296. 10540 continue
  297.   if (sp <= 1) error stop
  298.   sp = sp - 1
  299.   stack(sp - 1) = stack(sp - 1) + stack(sp)
  300.   goto 10550
  301. 10550 continue
  302.   if (stack_max <= sp) error stop
  303.   stack(sp) = 800
  304.   sp = sp + 1
  305.   goto 10560
  306. 10560 continue
  307.   if (sp <= 1) error stop
  308.   sp = sp - 1
  309.   stack(sp - 1) = b2i (stack(sp - 1) > stack(sp))
  310.   goto 10570
  311. 10570 continue
  312.   if (sp <= 0) error stop
  313.   sp = sp - 1
  314.   if (stack(sp) == 0) goto 10700
  315.   goto 10580
  316. 10580 continue
  317.   if (stack_max <= sp) error stop
  318.   stack(sp) = 48
  319.   sp = sp + 1
  320.   goto 10590
  321. 10590 continue
  322.   if (stack_max <= sp) error stop
  323.   stack(sp) = var12
  324.   sp = sp + 1
  325.   goto 10600
  326. 10600 continue
  327.   if (sp <= 1) error stop
  328.   sp = sp - 1
  329.   stack(sp - 1) = stack(sp - 1) + stack(sp)
  330.   goto 10610
  331. 10610 continue
  332.   if (sp <= 0) error stop
  333.   sp = sp - 1
  334.   var11 = stack(sp)
  335.   goto 10620
  336. 10620 continue
  337.   if (stack_max <= sp) error stop
  338.   stack(sp) = var12
  339.   sp = sp + 1
  340.   goto 10630
  341. 10630 continue
  342.   if (stack_max <= sp) error stop
  343.   stack(sp) = 9
  344.   sp = sp + 1
  345.   goto 10640
  346. 10640 continue
  347.   if (sp <= 1) error stop
  348.   sp = sp - 1
  349.   stack(sp - 1) = b2i (stack(sp - 1) > stack(sp))
  350.   goto 10650
  351. 10650 continue
  352.   if (sp <= 0) error stop
  353.   sp = sp - 1
  354.   if (stack(sp) == 0) goto 10680
  355.   goto 10660
  356. 10660 continue
  357.   if (stack_max <= sp) error stop
  358.   stack(sp) = 64
  359.   sp = sp + 1
  360.   goto 10670
  361. 10670 continue
  362.   if (sp <= 0) error stop
  363.   sp = sp - 1
  364.   var11 = stack(sp)
  365.   goto 10680
  366. 10680 continue
  367.   if (stack_max <= sp) error stop
  368.   stack(sp) = var6
  369.   sp = sp + 1
  370.   goto 10690
  371. 10690 continue
  372.   if (sp <= 0) error stop
  373.   sp = sp - 1
  374.   var12 = stack(sp)
  375.   goto 10700
  376. 10700 continue
  377.   if (stack_max <= sp) error stop
  378.   stack(sp) = var10
  379.   sp = sp + 1
  380.   goto 10710
  381. 10710 continue
  382.   if (stack_max <= sp) error stop
  383.   stack(sp) = var9
  384.   sp = sp + 1
  385.   goto 10720
  386. 10720 continue
  387.   if (sp <= 1) error stop
  388.   sp = sp - 1
  389.   stack(sp - 1) = stack(sp - 1) * stack(sp)
  390.   goto 10730
  391. 10730 continue
  392.   if (stack_max <= sp) error stop
  393.   stack(sp) = 100
  394.   sp = sp + 1
  395.   goto 10740
  396. 10740 continue
  397.   if (sp <= 1) error stop
  398.   sp = sp - 1
  399.   stack(sp - 1) = stack(sp - 1) / stack(sp)
  400.   goto 10750
  401. 10750 continue
  402.   if (stack_max <= sp) error stop
  403.   stack(sp) = var7
  404.   sp = sp + 1
  405.   goto 10760
  406. 10760 continue
  407.   if (sp <= 1) error stop
  408.   sp = sp - 1
  409.   stack(sp - 1) = stack(sp - 1) + stack(sp)
  410.   goto 10770
  411. 10770 continue
  412.   if (sp <= 0) error stop
  413.   sp = sp - 1
  414.   var9 = stack(sp)
  415.   goto 10780
  416. 10780 continue
  417.   if (stack_max <= sp) error stop
  418.   stack(sp) = var13
  419.   sp = sp + 1
  420.   goto 10790
  421. 10790 continue
  422.   if (stack_max <= sp) error stop
  423.   stack(sp) = var14
  424.   sp = sp + 1
  425.   goto 10800
  426. 10800 continue
  427.   if (sp <= 1) error stop
  428.   sp = sp - 1
  429.   stack(sp - 1) = stack(sp - 1) - stack(sp)
  430.   goto 10810
  431. 10810 continue
  432.   if (stack_max <= sp) error stop
  433.   stack(sp) = var8
  434.   sp = sp + 1
  435.   goto 10820
  436. 10820 continue
  437.   if (sp <= 1) error stop
  438.   sp = sp - 1
  439.   stack(sp - 1) = stack(sp - 1) + stack(sp)
  440.   goto 10830
  441. 10830 continue
  442.   if (sp <= 0) error stop
  443.   sp = sp - 1
  444.   var10 = stack(sp)
  445.   goto 10840
  446. 10840 continue
  447.   if (stack_max <= sp) error stop
  448.   stack(sp) = var12
  449.   sp = sp + 1
  450.   goto 10850
  451. 10850 continue
  452.   if (stack_max <= sp) error stop
  453.   stack(sp) = 1
  454.   sp = sp + 1
  455.   goto 10860
  456. 10860 continue
  457.   if (sp <= 1) error stop
  458.   sp = sp - 1
  459.   stack(sp - 1) = stack(sp - 1) + stack(sp)
  460.   goto 10870
  461. 10870 continue
  462.   if (sp <= 0) error stop
  463.   sp = sp - 1
  464.   var12 = stack(sp)
  465.   goto 10880
  466. 10880 continue
  467.   goto 10360
  468. 10890 continue
  469.   if (stack_max <= sp) error stop
  470.   stack(sp) = var11
  471.   sp = sp + 1
  472.   goto 10900
  473. 10900 continue
  474.   if (sp <= 0) error stop
  475.   sp = sp - 1
  476.   write (*, '(A1)', advance = 'no') achar (stack(sp))
  477.   goto 10910
  478. 10910 continue
  479.   if (stack_max <= sp) error stop
  480.   stack(sp) = var8
  481.   sp = sp + 1
  482.   goto 10920
  483. 10920 continue
  484.   if (stack_max <= sp) error stop
  485.   stack(sp) = var4
  486.   sp = sp + 1
  487.   goto 10930
  488. 10930 continue
  489.   if (sp <= 1) error stop
  490.   sp = sp - 1
  491.   stack(sp - 1) = stack(sp - 1) + stack(sp)
  492.   goto 10940
  493. 10940 continue
  494.   if (sp <= 0) error stop
  495.   sp = sp - 1
  496.   var8 = stack(sp)
  497.   goto 10950
  498. 10950 continue
  499.   goto 10240
  500. 10960 continue
  501.   if (stack_max <= sp) error stop
  502.   stack(sp) = 10
  503.   sp = sp + 1
  504.   goto 10970
  505. 10970 continue
  506.   if (sp <= 0) error stop
  507.   sp = sp - 1
  508.   write (*, '(A1)', advance = 'no') achar (stack(sp))
  509.   goto 10980
  510. 10980 continue
  511.   if (stack_max <= sp) error stop
  512.   stack(sp) = var7
  513.   sp = sp + 1
  514.   goto 10990
  515. 10990 continue
  516.   if (stack_max <= sp) error stop
  517.   stack(sp) = var5
  518.   sp = sp + 1
  519.   goto 11000
  520. 11000 continue
  521.   if (sp <= 1) error stop
  522.   sp = sp - 1
  523.   stack(sp - 1) = stack(sp - 1) - stack(sp)
  524.   goto 11010
  525. 11010 continue
  526.   if (sp <= 0) error stop
  527.   sp = sp - 1
  528.   var7 = stack(sp)
  529.   goto 11020
  530. 11020 continue
  531.   goto 10180
  532. 11030 continue
  533.   goto 11040
  534. 11040 continue  ! End of program.
  535.  
  536. contains
  537.  
  538.   ! Boolean to integer:
  539.   elemental function b2i (b) result (i)
  540.     logical, intent(in) :: b
  541.     integer :: i
  542.     if (b) then
  543.       i = 1
  544.     else
  545.       i = 0
  546.     end if
  547.   end function b2i
  548.  
  549.   ! Integer to boolean:
  550.   elemental function i2b (i) result (b)
  551.     integer, intent(in) :: i
  552.     logical :: b
  553.     b = (i /= 0)
  554.   end function i2b
  555.  
  556.   subroutine write_pool_string (i)
  557.     integer, intent(in) :: i
  558.     character(len = :), allocatable :: s
  559.     select case (i)
  560.     case default
  561.       error stop
  562.     end select
  563.     write (*, '(A)', advance = 'no') s
  564.   end subroutine write_pool_string
  565.  
  566. end program foo
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement