does anyone use fortran?

Discussion in 'OT Technology' started by tsi90, Feb 4, 2005.

  1. tsi90

    tsi90 _____

    Joined:
    Oct 20, 2003
    Messages:
    1,624
    Likes Received:
    0
    Location:
    MN
    Dooes anyone still use it? I am an engineering major and I have to take the class. I asked my dad (who is a programer) and he says its almost never used anymore but the teacher says its still used a lot in science and engineering.
     
  2. zabuni

    zabuni New Member

    Joined:
    Jan 2, 2005
    Messages:
    64
    Likes Received:
    0
    Very few places.

    1. Legacy code. Lots of old science stuff still uses Fortran. When given the choice between spending millions to change languages and thousands to update it, you choose Fortran.

    2. Parts of Fortran are heavily optimized for high performance mathematical computations. They have been updating the code over the course of decades, so for things like matrix multiplication, nothing quite matches it for speed. This makes it quite good for scientific simulations.

    Computer Scientists don't like Fortran because the syntax is obtuse, and it is a poor general purpose programming language. But for the reasons above, it is still used in many places.
     
  3. monolith

    monolith My soul grows ever weary and the end is ever near. OT Supporter

    Joined:
    May 9, 2004
    Messages:
    32,604
    Likes Received:
    260
    Location:
    Southern California
    :dunno: :dunno: :dunno: :dunno:


    Other than that I do agree...
     
  4. EvilSS

    EvilSS New Member

    Joined:
    Jun 11, 2003
    Messages:
    5,104
    Likes Received:
    0
    Location:
    STL
    It is used alot in science still. As much as the language sucks, it is tuned for scientific applications. It handles mathematics with little effort. For example, it can handle complex numbers out of the box. Most professional programmers don't ever see or use it and think it's dead. If you are going into science/engineering you should learn it.

    Here is a sample program I snagged online. It solves quadratic equasions. Give you an idea of the syntax. OT crushed the formatting, so you can see it here too:
    http://amath.colorado.edu/scico/samplecode/fortran/quadratic90.html
    Code:
     
    PROGRAM quadratic
    real :: a,b,c
    real :: discrm, x, y
     
    print*
    print*
    print*, '		 2'
    print*, '	 A x + B x + C = 0'
    print*
    write(*,'(A)',advance='no') 'Enter coefficients A, B, C: '
    read*, A, B, C
    print 97, A,B,C
    x = -b / (2*a)
    discrm = b*b - 4*a*c
    if ( discrm < 0 ) then						 ! COMPLEX ROOTS
    		y = sqrt(-discrm) / (2*a)
    		print 99, 1, x, ' +', y
    		print 99, 2, x, ' -', y
    else												 ! REAL ROOTS
    		y = sqrt(discrm) / (2*a)
    		print 98, 1, x+y
    		print 98, 2, x-y
    end if
     
    97 format(/,F8.3,' x^2 +',F8.3,' x + ',F8.3,' = 0',/)
    98 format('Root #', I1, ' is x=', F12.6)
    99 format('Root #', I1, ' is x=', F12.6,A,F12.6,' i')
     
    END
     
    
     
  5. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    Actually, FORTRAN has been modified so that code needn't look like shit now. You can write decent FORTRAN code at this point. Learning to do so would be better than that shite above.
     
  6. EvilSS

    EvilSS New Member

    Joined:
    Jun 11, 2003
    Messages:
    5,104
    Likes Received:
    0
    Location:
    STL
    That is Fortran 90. You want shite, do it in Fortran 77. That's what I had to learn because my college cheaped out and we had to use some archaic mainframe system. We input our program into the terminals, ran it, walked across the hall, waited for some jackass to get our printout, find an error, go back to the terminal, repeat. repeat. repeat. repeat.

    Do you know how hard it is to debug a program when you can only output to a printer?!

    And again, OT crushed the formatting of the code.
     
  7. CompiledMonkey

    CompiledMonkey New Member

    Joined:
    Oct 26, 2001
    Messages:
    8,528
    Likes Received:
    0
    Location:
    Richmond, VA
    What makes Fortran a better language for math routines than C/C++? Does it have more math related functions built in?
     
  8. samm

    samm Next in Line

    Joined:
    Dec 22, 2000
    Messages:
    2,630
    Likes Received:
    0
    Location:
    San Jose, CA
    This is a heavily debated question by both parties. Here is how I understand it:

    1) Fortran is often prefered by scientists because it is somewhat of a higher level language than C. It is also a much older language. It has built in intrinsics such as matrix multiply, trig functions, etc.

    2) A Fortran compiler can make much stronger assumptions than C compilers can when working with pointers. For example, I am reasonably sure than mutlidimensional arrays in Fortran are stored in a contiguous block of memory. This is not the case in C, at least for dynamically allocated arrays (there are ways around this using a macro to index into the array though). In C, a two dimensional array would be written like this:

    A[j]
    which translates to
    *(*(A + i) + j)

    The extra dereference you see takes away some optimizations the compiler can perform. Fortran more or less hides pointers from the programmer.

    3) I can use an IBM Fortran compiler on my G5 to achieve roughly 35 GFlops of performance. This simply is not possible using a C compiler. Fortran compilers can parallelize vector and matrix processing with a compiler flag. Intel has highly efficient Fortran compilers for their architectures as well.
     
  9. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    It's very handy for math things from what I understand. I know my mom had to learn a bit of it last term for her stat class because it's the language that's used in SPSS, the stats package that they were using. I think the MATLAB language may be based on fortran as well.
     

Share This Page