Topic: Modify variable inside a subroutine
What I am asking is not safe at all, but I work on an old code, and that seems to be the fastest way to do it.
So, I have a main program, and a module with subroutine. This module is call by my main program. In my subroutine, a lot of variable are modified, and I want all these modifications to be effective in my main program after calling my subroutine.
Example :
MODULE myModule
IMPLICIT NONE
CONTAINS
subroutine mySub()
integer :: a, b, c
a=2;b=5;c=3
end subroutine mySub
program main
use myModule
integer :: a, b, c
a = 0
call mySub()
a = a +1
end program main
I want my program to give the value 3 to variable 'a', not 1. I know I can do :
subroutine mySub(a,b,c)
integer, intent(inout) :: a, b, c
But that's not what I want, because there are too many variables (like 100). Is there a way to automatically have all my variable in my subroutine act as an intent(out) value without call them in the call of my subroutine?
In fortran77, when you had a program and a subroutine in the same file, it was possible to modifiy variables in the subroutine, and used the new value in the main program after calling the subroutine. I ask for the same thing.
Sorry for my bad english...