I want to define two variable with the same name from two module For example, I have two modules which are as follows:
module boundary
implicit none
real(kind=8)::pi
save
contains
....
end module boundary
.............
module scheme
implicit none
real(kind=8)::pi
save
contains
....
end module scheme
............
The above let fortran set space for this variable, some submodule aftercontains will use pi, and then in the following program, I want to
set both variable(same name) into a specified value and they must be same.
Can I do that?
subroutine initialize ()
use scheme,only:pi
use boundary,only:pi
pi=acos(-1.d0)
end subroutine initialize
pi=acos(-1.d0)is indeed meant to update both module variables, then we can address that. [Most likely, it has to be said, with "you can't do that, but here's probably what you mean".]