A gist for Alessandro
Let us assume you have the following situation (for the sake of brevity let us have only 2 source files):
file_1.f
: it contains proceduressub_1
andsub_2
;file_2.f
: it contains proceduresub_3
that usessub_2
offile_1.f90
.
I suggest you to modify your project in the following way:
The new file file_1.f90
contains:
module file_1
!implicit none ! this can hurt your baseline code if you use implicit definitions
contains
! the following procedures are the one you have in your original files
subroutine sub_1()
! do some stuff
endsubroutine sub_1()
subroutine sub_2()
! do some other stuff
endsubroutine sub_2()
endmodule file_1
The new file file_2.f90
contains:
module file_2
use file_1
!implicit none ! this can hurt your baseline code if you use implicit definitions
contains
! the following procedures are the one you have in your original files
subroutine sub_3()
! do some stuff using sub_2 of file_1.f90
call sub_2
endsubroutine sub_3()
endmodule file_2
Now all your procedures have automatically an interface for checking calling signature errors.
You have now a compilation hierarchy: because module file_2
depends on module file_1
, this latter must be compiled before the first one.
For large projects having many modules I suggest to try FoBiS.
Now your main program must `use] your new shining modules...
program modularized
use file_1
use file_2
!do your stuff with your modules
endprogram modularized