1 #+Title: a collection of examples for ob-fortran tests
6 :ID: 459384e8-1797-4f11-867e-dde0473ea7cc
9 #+begin_src fortran :results silent
10 print *, 'Hello world'
13 #+name: fortran_parameter
14 #+begin_src fortran :results silent
15 integer, parameter :: i = 10
21 :ID: d8d1dfd3-5f0c-48fe-b55d-777997e02242
23 #+begin_src fortran :var N = 15 :results silent
27 Define for preprocessed fortran
28 #+begin_src fortran :defines N 42 :results silent
33 #+begin_src fortran :var s="word" :results silent
38 :ID: c28569d9-04ce-4cad-ab81-1ea29f691465
41 #+begin_src fortran :var s='(1.0 2.0 3.0) :results silent
42 write (*, '(3f5.2)'), s
49 #+begin_src fortran :var s=test_tbl :results silent
50 write (*, '(2f5.2)'), s
55 :ID: 3f73ab19-d25a-428d-8c26-e8c6aa933976
58 #+name: fortran-input-matrix1
63 #+name: fortran-input-matrix2
67 #+begin_src fortran :var s=fortran-input-matrix1 :results silent
68 write (*, '(i2)'), nint(s(1,2))
71 #+begin_src fortran :var s=fortran-input-matrix2 :results silent
72 write (*, '(i2)'), nint(s(2,3))
77 :ID: 891ead4a-f87a-473c-9ae0-1cf348bcd04f
79 Should fail (TODO: add input variables for the case with explicit
81 #+begin_src fortran :var s="word" :results silent
83 print *, "output of ex program"
87 Fails to compile (TODO: error check in ob-fortran.el)
88 #+begin_src fortran :var s='(1 ()) :results silent
92 Should fail to compile with gfortran
93 #+begin_src fortran :flags --std=f95 --pedantic-error :results silent
99 * programs input parameters
101 :ID: 2d5330ea-9934-4737-9ed6-e1d3dae2dfa4
103 Pass parameters to the program
104 #+begin_src fortran :cmdline "23" :results silent
105 character(len=255) :: cmd
106 call get_command_argument(1, cmd)
107 write (*,*) trim(cmd)