| Thread Tools | Search this thread |
|---|
opmkl
| November 4, 2009 9:23 AM PST Is there a penalty (in terms of speed) associated with the use of RECURSIVE subroutines? | ||||
I am wondering if using RECURSIVE subroutines is a good practice. I have the following code: RECURSIVE SUBROUTINE MY_RECURSIVE_SUB(A,ALPHA,ALPHA_TARGET,D_ALPHA_MAX,FLAG) USE MODULE_WHERE_T_COMPLICATED_STRUCTURE_IS_DEFINED IMPLICIT NONE TYPE(T_COMPLICATED_STRUCTURE),INTENT(INOUT) :: A LOGICAL,INTENT(IN) :: FLAG REAL(KIND=8),INTENT(INOUT) :: ALPHA,ALPHA_TARGET,D_ALPHA_MAX ... IF (FLAG) THEN IF (ABS(ALPHA-ALPHA_TARGET)>D_ALPHA_MAX) THEN CALL MY_RECURSIVE_SUB(A,ALPHA,ALPHA_TARGET,D_ALPHA_MAX,.FALSE.) ALPHA_TARGET = ALPHA ELSE ... do some work with A ... ENDIF ELSE ... do some work with A ... ENDIF END SUBROUTINE MY_RECURSIVE_SUB A is a very large and complicated derived type structure which contains allocatable arrays, other derived type variables, etc. When the subroutine recursively calls itself, is a copy of A made? Is there a speed penalty associated with such a coding approach? Thanks, Olivier | |||||
|
|||||||||||||
|
|||||||||||||
|
|||||||||||||
|
|||||||||||||
| 8491 users have contributed to 31629 threads and 100770 posts to date. |
|---|
| In the past 24 hours, we have 28 new thread(s) 120 new posts(s), and 168 new user(s). In the past 3 days, the most popular thread for everyone has been Implicite multithreading ??? The most posts were made to Crash when loading skeleton The post with the most views is Dear Steve, excuse me for a d Please welcome our newest member shadowwolf99 |