ob-fortran-test.org 2.3 KB

simple programs

:PROPERTIES: :ID: 459384e8-1797-4f11-867e-dde0473ea7cc :END:

print *, 'Hello world'

integer, parameter :: i = 10 write (*, '(i2)') i

variable resolution

:PROPERTIES: :ID: d8d1dfd3-5f0c-48fe-b55d-777997e02242 :END:

write (*, '(i2)') N

Define for preprocessed fortran

implicit none write (*, '(i2)') N

write (*, '(a4)') s

arrays

:PROPERTIES: :ID: c28569d9-04ce-4cad-ab81-1ea29f691465 :END: Real array as input

write (*, '(3f5.2)'), s

1.0
2.0

write (*, '(2f5.2)'), s

matrix

:PROPERTIES: :ID: 3f73ab19-d25a-428d-8c26-e8c6aa933976 :END: Real matrix as input

0.0 42.0
0.0 0.0
0.0 0.0
0.0 0.0 0.0
0.0 0.0 42.0

write (*, '(i2)'), nint(s(1,2))

write (*, '(i2)'), nint(s(2,3))

failing

:PROPERTIES: :ID: 891ead4a-f87a-473c-9ae0-1cf348bcd04f :END: Should fail (TODO: add input variables for the case with explicit program statement)

program ex print *, "output of ex program" end program ex

Fails to compile (TODO: error check in ob-fortran.el)

print *, s

Should fail to compile with gfortran

program ex integer*8 :: i end program ex

programs input parameters

:PROPERTIES: :ID: 2d5330ea-9934-4737-9ed6-e1d3dae2dfa4 :END: Pass parameters to the program

character(len=255) :: cmd call get_command_argument(1, cmd) write (*,*) trim(cmd)