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

From Gumstix User Wiki
Jump to: navigation, search
(Created page with "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 ...")
 
m
 
(One intermediate revision by the same user not shown)
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
  
Then
+
(or add the packages to your image recipe)
 +
 
 +
Then write a program to test its installed
  
 
  vim hello.f90
 
  vim hello.f90
Line 31: Line 33:
 
    
 
    
 
  Hello Fortran World!
 
  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:~#
 
  user@overo:~#

Latest revision as of 21: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.