×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

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!
  • Students Click Here

*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

Jobs

Interface between Fortran77 program and Fortran90 program

Interface between Fortran77 program and Fortran90 program

Interface between Fortran77 program and Fortran90 program

(OP)
Hi all,
I'm new to Fortran programming, so I might probably ask some really trivial questions - please forgive me.
I have two source codes of big programs. One is coded in Fortran77 and the other one in Fortran90.
Now, I need to build an interface so that the Fortran90 program can call some subroutines/functions in the Fortran77 program.

Now, I know that usually you would use a module for that purpose: just put all the subroutines and functions you want inside the module, and call it from your main program.
However, in my case, the two programs are very big and spread across many files and obviously there are two "program units. Does that change anything? If so, how?

In general, what would you suggest be the best way of building such an interface between the two?

Cheers,
Dave

RE: Interface between Fortran77 program and Fortran90 program

Nothing needs to change. They can call each other. Also not all routines have to live in modules - it just makes it easier to type use modulename rather than declaring a whole bunch of externals. Some implementations allow you to get away without declaring any externs.

CODE --> suby.f

subroutine f77sub
          print *, 'f77sub'
          print *, 'calling f90'
          call f90sub
      end subroutine f77sub 

CODE --> main.f90

subroutine f90sub
    print *, "f90sub"
end subroutine f90sub


program main
    print *, 'In f90'
    print *, 'calling f77'
    call f77sub
end program main 
To build

gfortran main.f90 suby.f77

RE: Interface between Fortran77 program and Fortran90 program

Well, it was mentioned that each set of sources is an actual program, each with its own "program" unit.

In any case, there is no need for a formal interface, if you don't want one.

So, it all depends what you want to achieve...if the Fortran 90 needs nothing from the "main" of the Fortran 77 and all it needs is to benefit from the subroutines, they all can be compiled into a single executable.

If you need the "main" from the Fotran 77 program to drive, manage the subroutines for the Fortran 90 program, then, you may need to turn the Fortran 77 "main" into a subroutine.

Get the picture?

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