ob-fortran-test.org 2.3 KB

a collection of examples for ob-fortran tests

simple programs

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

variable resolution

write (*, '(i2)') N

Define for preprocessed fortran

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

arrays

Real array as input

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

matrix

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

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

Pass parameters to the program

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