I am trying to reset the save variable inside a routine, a way I theorize going around this is having a reset() function that zeros out the data inside, however I cannot directly call this function as it is inside the "contains" keyword, is there a way to override this protection? I've looked into "interface" and "external" keywords but the documentation for this particular question seems sparce
program main
implicit none
call count ! 1
call count ! 2
call count ! 3
! cannot make a call to reset
! is there any way to remove this
! protection and access this directly?
call reset
call count ! 1 etc...
end program main
subroutine count
integer, save :: numcalled = 0
numcalled = numcalled + 1
print *, numcalled
return
contains
subroutine reset
numcalled = 0
end subroutine reset
end subroutine count
This is a small example to get the idea of what I aim to do to a project with a bunch of "save" variables and I need to reset these as this code will be called several times and stuff needs to be fresh for each function call (no static variables floating around with bad state), if I can override this protection to access subroutines inside a "contains" keyword this would be a very minimally invasive task