Hi, this is my first post here so I hope I do everything right. Im trieing to optimize my fortran95 code and I stumbled over something I couldnt solve with google or the forum search here. Maybe I dont now the right keywords to search for.
Given an recursive function that could be called several million times (recursion depth is about 10). This functzion operates on several variables. Would it be better to always pass those variables in the function call, or store them as modulvariables to reduce the cost of putting thoses variables on the functionstack every time the function is called? (Im not quite sure how this works in Fortran)
My function uses several Integer variables and a few multidimensional arrays. It could look like this:
as I understand this, Fortran passes those variables as references anyway, so would it make a difference in the access time if those were module variables:
thx in advance
Given an recursive function that could be called several million times (recursion depth is about 10). This functzion operates on several variables. Would it be better to always pass those variables in the function call, or store them as modulvariables to reduce the cost of putting thoses variables on the functionstack every time the function is called? (Im not quite sure how this works in Fortran)
My function uses several Integer variables and a few multidimensional arrays. It could look like this:
Code:
recursive function max(a, b, c, array1, array2, array3) result(best)
Integer:: a, b, c, best
Integer, dimension(:,:) array1, array2
Integer dimension(:,:,:) array3
!Do something with thoses Variables
end function max
as I understand this, Fortran passes those variables as references anyway, so would it make a difference in the access time if those were module variables:
Code:
module rek
Integer:: a, b, c
Integer, dimension(:,:) array1, array2
Integer dimension(:,:,:) array3
contains
recursive function max() result(best)
!Do something with thoses Variables
end function max
end module rek
thx in advance