Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

beginner in Fortran77

beginner in Fortran77

beginner in Fortran77


i just started learning Fortran 77 language, (i have already some programming knowledge in C and Pascal but i need to learn fortran 77 for use in other programm which is based on this language). So i started learning it using a book called "Fortran 77 and numerical methods by C Xavier". There i wanted to test some simple programs, for example this programm for calculating triangle area:

C Program for area of triangle

1 format(1X,'type the sides A, B, C')
read(*,2) A, B, C
2 format(3F10.3)
write(*,3) Area
3 Format(1X,'Area=',F10.3)

so the problem when i run the programm is that only the first variable is read "wihtout waiting that i give the second and third variables" and area is directly given as "Area= NaN" some, no error is given while
running, i tried 2 compilers (Intel and Force 2.0.9) with same results. When i modify the format to format(F10.3,F10.3,F10.3) its also not working. What i could do is to read the 3 variables in differents read statements and the program will be like this:

C Program for area of triangle

1 format(1X,'type the sides A, B, C')
read(*,2) A
2 format(F10.3)
read(*,3) B
3 format(F10.3)
read(*,4) C
4 format(F10.3)
write(*,5) Area
5 Format(1X,'Area=',F10.3)

In this case its working, so something seems to be wrong in my read and format statement of the 3 variable, i gave exactly the same what is given in the book im using, and there many other programs have read statements in the same manner, so i dont know what im doing wrong or missing. Im very thankful for your support !


RE: beginner in Fortran77

How are you entering the inputs? Do you understand what you specified in the format statement for the input? F10.3 means that you;re allocating 10 characters in the input stream for a single floating point value with 3 decimal places. That means that the second input cannot be anywhere but in the next 10 characters.

FAQ731-376: Eng-Tips.com Forum Policies

Need help writing a question or understanding a reply? forum1529: Translation Assistance for Engineers

Of course I can. I can do anything. I can do absolutely anything. I'm an expert!

RE: beginner in Fortran77

Might be better if you picked up a more modern version of Fortran like 95, 2003 or even 2008. You don't have the problems of fixed formatting and you have dynamic arrays and type definitions which will help you a lot more.

Re your problem: read as * instead of specifying a format: that way it is free format input. Might be an idea to print the values after you have read them to see what you have read.

RE: beginner in Fortran77


first i thank ev. body for support. I found out the problem, when i put format(3F10.3) which is equivalent to put format(F10.3,F10.3,F10.3) then the 3 variables have to be input in the same form as the Format so
A,B,C together and then i have to press enter, when i put Format(F10.3) then i can put the 3 variables after each other as i was trying to do..ok it can be seen evident, but as i said im new in this language..

Concerning xwb´s comment, thank you for recommending newer versions of fortran, i believe many things have been inproved and new things added there, but as i wrote i have other other software(s) based on Fortran77 and old codes as well, that i need to understand them as they are, if i were experienced in Fortran amy be it would be the same for me..

Thanks ev. body,


RE: beginner in Fortran77

Note that Fortran 90 onward is backward compatible with Fortran 77 (only a very few minor exceptions). So... you can read/write F77 with a newer version compiler. And, the newer compilers are much more likely to find "bugs" in some of your older codes.

Dan smile

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


White Paper - How ESI is Helping Move New Medical Device Product to Market Quicker & More Cost Effic
Early Supplier Involvement has long been a strategy employed by manufacturers to produce innovative products. Now, it almost seems like a necessity. Because decisions made in the design phase can positively affect product quality and costs, this can help add value to OEM bottom lines. This white paper will discuss many facets of ESI, including why it’s so valuable today, what challenges limit the benefits of ESI, how cost is impacted, and more. Download Now
White Paper - Moving to a Driverless Future
This white paper describes what we see as the best practices to support a sustainable engineering process for autonomous vehicle design. It exposes how to use simulation and testing in common frameworks to enable design exploration, verification and validation for the development of autonomous cars at a system, software and full-vehicle level to drive a mature product development process for automated driving. Download Now
Research Report - How Engineers are Using Remote Access
Remote access enables engineers to work from anywhere provided they have an internet connection. We surveyed our audience of engineers, designers and product managers to learn how they use remote access within their organizations. We wanted to know which industries have adopted remote access, which software they are using, and what features matter most. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close