I have programmed some fortran subroutines. I saved the subroutines in a Desktop folder called subroutines
. When I compile a fortran program, say main.f90
(located in a different folder than subroutines
), that uses subroutines (e.g. sub1.f90
, sub2.f90
) of the folder subroutines
, I need to copy every subroutine into the folder of main.f90
and then compile like this:
gfortran -o main main.f90 sub1.f90 sub2.f90
which outputs the executable file as desired.
My question is: Is there any compiler option in gfortran to include files from the subroutine
folder without having to copy each subroutine to the folder of main.f90
?
I have tried these two options:
gfortran -L/home/user/Desktop/subroutines -o main main.f90 sub1.f90 sub2.f90
gfortran -I/home/user/Desktop/subroutines -o main main.f90 sub1.f90 sub2.f90
both of these compiler options return the error: gfortran: No such file or directory
The only available fortran compiler in my PC is gfortran (no ifort).
.f90
file separately and then linking finally. The-I
flag relates to the search path for include files and module files. – francescalus