bpv_xquest
bpv_xquest

Reputation: 55

How to compile f77 and f90 files together with gfortran

I have a few dozens files with f77-functions and I would like to include them into my f90-program. How do I bring it altogether with gfortran? If I just try to

gfortran myprogram.f90

it complains for f77-code in the other files. As I understand, it would like to see all files put into definite standard (f77 of f90).

Upvotes: 1

Views: 3541

Answers (1)

casey
casey

Reputation: 6915

Your problems aren't F77 vs F90, they are fixed-form vs free-form. You cannot combine both source formats into a single file. You have two options:

  1. Modify all of your source into one format (use free-form if you are going to do this), then compile your program as you are doing now.

  2. Put all the fixed-form stuff in one bunch of source files and all the free-form stuff in another bunch, then do:

    gfortran -omyprogram free-form-stuff.f90 fixed-form-stuff.f
    

    This will compile each source file separately and then link them together into one executable.

Upvotes: 6

Related Questions