Category:How to - Fortran

From Gumstix User Wiki
Revision as of 21:36, 13 July 2011 by Alxx (Talk | contribs) (add an example of a system call in fortran)

Jump to: navigation, search

GCC contains gfortran as part of it(usually) but the library does not get pulled in. or you can install gfortran separately.

To ensure its installed (or include the packages in your image recipe)

opkg update
opkg install gfortran
opkg install gfortran-symlinks
opkg install libgfortran
opkg install libgfortran-dev

(or include the packages in your image recipe)

Then write a program to test its installed

vim hello.f90
! hello.f90
program hello
implicit none
print*, " "
print*, "Hello World!"
print*, " "
end

To compile

user@overo:~# gfortran -o hellof hello.f90


to run

user@overo:~# ./hellof 
 
Hello Fortran World!
 
user@overo:~#

program to do a system call

vim utime.f90


! utime.f90
! program to do a system call to uptime
program utime
implicit none
character(6) :: command
command = 'uptime'
print*, " "
call system(command)
print*, " "
end
user@overo:~# gfortran -o utime utime.f90
user@overo:~# ./utime
 
11:06:43 up 7 days, 23:03,  2 users,  load average: 0.00, 0.00, 0.00
 
user@overo:~#

This category currently contains no pages or media.