Category:How to - Fortran

From Gumstix User Wiki
Revision as of 22:37, 13 July 2011 by Alxx (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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

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

(or add the packages to 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*, " "

To compile

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

to run

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

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*, " "
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

This category currently contains no pages or media.