×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-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!

*Tek-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

Forgot Fortran

Forgot Fortran

Forgot Fortran

(OP)
Hi,

I knew Fortran long time ago but forgot all now. Can you correct the folloing program for me?

Thank you in advance.

PROGRAM Hello

  REAL a(2,2)
  a = (/1.0,2.0,3.0,4.0/)
  CALL Test(a)
  print*,a(1,1)
  
CONTAINS  
SUBROUTINE Test(a)
REAL a(2,2)
a(1,1)=a(1,1)+9.0
END SUBROUTINE Test

END PROGRAM Hello

RE: Forgot Fortran

(OP)
Why we need to put subroutine inside the "main" program?

RE: Forgot Fortran

C  ThePROGRAM Hello
  REAL a(2,2)
C a = (/1.0,2.0,3.0,4.0/) instead try :
  DATA A /1.0,2.0,3.0,4.0/
  CALL Test(a)
  print*,a(1,1)
C  CONTAINS
  END
  SUBROUTINE Test(a)
  REAL a(2,2)
  a(1,1)=a(1,1)+9.0
  RETURN
  END

The subroutine can be compiled as a separate program and linked to the main program before execution.

RE: Forgot Fortran

(OP)
PAndersen,

Thank you for your help.
>C a = (/1.0,2.0,3.0,4.0/) instead try :
>  DATA A /1.0,2.0,3.0,4.0/
Why not use a = (/1.0,2.0,3.0,4.0/)? I forget DATA already.....but are you talking Fortran77 ?



RE: Forgot Fortran

If a = (/1.0,2.0,3.0,4.0/) gives no compilation error, use it. The DATA statement is for FTN77 and older.

RE: Forgot Fortran

(OP)
Thanks a lot for your suggestion.

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 Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

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

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


Close Box

Join Tek-Tips® Today!

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

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close