Suppose I have a module which defines some basic constants such as
integer, parameter :: i8 = selected_int_kind(8)
If I include this in my main program and I also include a module which does some other things (call this module functions) but functions also uses constants, then am I essentially including constants twice in my main program?
If so, is this bad? Can it be dangerous at all to include a module too many times in a program?
No, it is fine to do this. All you are doing with the
usestatement is providing access to the variables and functions defined in your module via use association. It is not like declaring variables each time they areuse‘d (they are in fact redeclared however).The only thing to be wary of are circular dependencies, where module
Auses moduleBand moduleBuses moduleA. This is not allowed.Edit: From Metcalf et al. Fortran 95/2003 explained, pg. 72:
Whilst this quote doesn’t directly answer your question, it reiterates that really the only thing you can’t do is have a circular dependency. So the following is perfectly valid: