- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
In my fortran program, there are hundreds of global variables, and they are all stored in a single module file. Then, I also have ~50 subroutines, each of which uses only some of the global variables. In this case, is there any compiling or simulation speed difference between (1) using "only" to select some of the global variables in each subroutine and (2) just using all global variables in every subroutine.
For example:
If I have a module file: module mod_global ... real :: num1, num2, num3, ..., num1000 ... end module First approach: subroutine_1 use mod_global, only : num1, num2, num3, ..., num100 ... end subroutine_1 subroutine_2 use mod_global, only : num101, ..., num200 ... end subroutine_2 Second approach: subroutine_1 use mod_global ... end subroutine_1 subroutine_2 use mod_global ... end subroutine_2
I know that it is better to control (manage) if I use "use, only" combination. However, I want to know whether there is a speed difference (both in compilation and execution) between the two approaches.
- Etiquetas:
- Intel® Fortran Compiler
Enlace copiado
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
A problem with .NOT. using ONLY is that it may thwart your intentions of what is to happen with IMPLICIT NONE. IOW a misappropriated variable declared in the module may get used for an otherwise (intended) undefined variable. I.e. you may have a hidden error in your program.
Jim Dempsey
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
There no speed difference, it merely enforces the intent of you explicitly declaring variables (and enabling IMPLICIT NONE to catch those errors).
Jim Dempsey
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
Jim,
Thank you for the comment.
Jungwoo
- Suscribirse a un feed RSS
- Marcar tema como nuevo
- Marcar tema como leído
- Flotar este Tema para el usuario actual
- Favorito
- Suscribir
- Página de impresión sencilla