Angelo Graziosi
2018-09-06 16:00:58 UTC
Often a module calls 'elements' (variables, functions, subroutines etc.) from other modules. The 'called' module can be 'used' once, at the beginning of the 'calling' module or repeated for each function/subroutine 'using' it. In short,
CASE 1
======
module foo
use bar, only: bar0, bar1, bar2,...
! using bar0
... bar0 ...
contains
subroutine sub_bar1()
...
... bar1 ...
end sub...
subroutine sub_bar2()
...
... bar2 ...
end sub...
...
end module foo
CASE 2
======
module foo
use bar, only: bar0
! using bar0
... bar0 ...
contains
subroutine sub_bar1()
use bar, only: bar1
...
... bar1 ...
end sub...
subroutine sub_bar2()
use bar, only: bar2
...
... bar2 ...
end sub...
...
end module foo
Which is better? CASE1 or CASE 2?
TIA.
Ciao,
Angelo.
CASE 1
======
module foo
use bar, only: bar0, bar1, bar2,...
! using bar0
... bar0 ...
contains
subroutine sub_bar1()
...
... bar1 ...
end sub...
subroutine sub_bar2()
...
... bar2 ...
end sub...
...
end module foo
CASE 2
======
module foo
use bar, only: bar0
! using bar0
... bar0 ...
contains
subroutine sub_bar1()
use bar, only: bar1
...
... bar1 ...
end sub...
subroutine sub_bar2()
use bar, only: bar2
...
... bar2 ...
end sub...
...
end module foo
Which is better? CASE1 or CASE 2?
TIA.
Ciao,
Angelo.