Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Getting started using Fortran 90

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
johnu1960
Posts: 20
Joined: 2014-02-04 02:28

Getting started using Fortran 90

#1 Post by johnu1960 »

I will be starting a class soon in high performance computing. One of the languages being used will be Fortran 90 and I would like to get it setup and learn a little about it. I have installed libnetcdf-dev which " includes everything needed for developing in C, C++, Fortran 77, and Fortran 90." Has anyone used this language on Debian and can you point me to documentation on how to get started? If there is some built in documentation, how can I access it? (Sorry .... I am a new Debian user :? ). Any help would be greatly appreciated.

User avatar
drl
Posts: 427
Joined: 2006-09-20 02:27
Location: Saint Paul, Minnesota, USA

Re: Getting started using Fortran 90

#2 Post by drl »

Hi.

I think you have installed a library that is suitable for dealing with netcdf: NetCDF (network Common Data Form) is an interface for scientific
data access


If you intend to use Fortran I suggest you install gfortran:

Code: Select all

apt-get install gfortran
which will install the compiler, libraries, etc.

Code: Select all

Package: gfortran
...
Description-en: GNU Fortran 95 compiler
 This is the GNU Fortran 95 compiler, which compiles Fortran 95 on platforms
 supported by the gcc compiler. It uses the gcc backend to generate optimized
 code.
It, in turn, will probably cause other items it be installed, libraries, gcc, ld, etc.

When you think you are done, enter:

Code: Select all

gfortran
and you should see:

Code: Select all

gfortran: fatal error: no input files
if it is not installed, you'll see something like:

Code: Select all

gfortran: command not found
There are other items that may be useful in the future, like make, etc. These are most easily installed with a package build-essential.

Other Fortran compilers are available (e.g Intel for personal use, g95, neither of which is in the repositories; gfortran is the easiest to install.)

Best wishes ... cheers, drl

A sample Fortran code, hi.f90:

Code: Select all

program hi

! @(#) hi	Demonstrate Fortran-90.

! http://gcc.gnu.org/onlinedocs/gcc-4.4.0/gfortran/
!  GET_005fCOMMAND.html TRIM.html GET_005fCOMMAND_005fARGUMENT.html

    integer :: i
    character (len=32) :: arg
    integer :: count
    character (len=255) :: cmd, line
!1234567890123456789012345678901234567890123456789012345678901234567890
! Default unit numbers:  0 STDERR, 5 STDIN, 6 STDOUT
! open(0,file="/dev/null")        ! comment out to get debugging output
    call get_command (cmd)
    write (0,*) " Command line   = ", trim (cmd)

    count = command_argument_count ()
    write (line, fmt="(a,i2)") " Argument count = ", count
    write (0,*) trim (line)

    if (count <= 0) then
      write (0,*) " Hello, world from Fortran-90."
    else
      do i = 1, count
        call get_command_argument (i, arg)
        write (line, fmt="(a,i2,a,a,a)") " Argument    ", i, " = ", trim &
       & (arg)
        write (0,*) trim (line)
      end do
    end if
!234567890123456789012345678901234567890123456789012345678901234567890
    do 11111 i = 1, 3
      write (*,*) " i = ", i
11111 continue
end
when compiled with gfortran hi.90 will create a linked program a.out, which, when run as ./a.out xx yy zz will produce:

Code: Select all

$ ./a.out xx yy zz
  Command line   = ./a.out xx yy zz
  Argument count =  3
  Argument     1 = xx
  Argument     2 = yy
  Argument     3 = zz
  i =            1
  i =            2
  i =            3
["Sure, I can help you with that." -- USBank voice recognition system.
( Mn, 2.6.x, AMD-64 3000+, ASUS A8V Deluxe, 3 GB, SATA + IDE, NV34 )
Debian Wiki | Packages | Backports | Netinstall

johnu1960
Posts: 20
Joined: 2014-02-04 02:28

Re: Getting started using Fortran 90

#3 Post by johnu1960 »

Thanks drl! So far so good.

User avatar
drl
Posts: 427
Joined: 2006-09-20 02:27
Location: Saint Paul, Minnesota, USA

Re: Getting started using Fortran 90

#4 Post by drl »

Hi.
johnu1960 wrote:Thanks drl! So far so good.
That's good news -- keep us posted ... cheers, drl
["Sure, I can help you with that." -- USBank voice recognition system.
( Mn, 2.6.x, AMD-64 3000+, ASUS A8V Deluxe, 3 GB, SATA + IDE, NV34 )
Debian Wiki | Packages | Backports | Netinstall

Post Reply