Difference between revisions of "Category:How to - Fortran"

From Gumstix User Wiki
Jump to: navigation, search
m (add an example of a system call in fortran)
m
 
Line 2: Line 2:
 
or you can install gfortran separately.
 
or you can install gfortran separately.
  
To ensure its installed (or include the packages in your image recipe)
+
To ensure its installed  
  
 
  opkg update
 
  opkg update
Line 10: Line 10:
 
  opkg install libgfortran-dev
 
  opkg install libgfortran-dev
  
(or include the packages in your image recipe)
+
(or add the packages to your image recipe)
  
 
Then write a program to test its installed
 
Then write a program to test its installed

Latest revision as of 22:37, 13 July 2011

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