Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Modularization versus performance

lccostajr
Beginner
856 Views
Hi,

I have a big piece of code in Fortran and I would like to subdivide it in 50 subroutines. However, I am a little bit concerned about the performance of my program. These new 50 subroutine would not have many parameters (most of them would have zero) once the program uses common blocks.

Could somebody please tell me if performance should really be a concern in my case? What should I have in mind about performance when doing changes like this?

Thanks in advance,
Luiz
0 Kudos
4 Replies
TimP
Honored Contributor III
856 Views
You should keep inner loops inside any subroutines where significant time will be spent. This is particularly important where you depend on auto-vectorization. To some extent, inter-procedural optimization may be able to compensate when this rule can't be followed, particularly in the case of internal (CONTAINS) subroutines.
0 Kudos
jimdempseyatthecove
Honored Contributor III
856 Views
Luiz,

If the calling context will be mostly the same for all 50 subroutines, and when there will be only one such context (e.g. former old Fortran code had them in COMMON), then consider placing these variables into a module and USE that module. Effectively a similar approach to the COMMON approach.

***

If the calling context will be mostly the same for all 50 subroutines, and when there will be multiple suchcontexts, then consider creating a user defined type structure and then create multiple of these, but pass only the reference to each subroutine. This does require edition code for YourTypeVariable%variable.

Jim Dempsey


0 Kudos
maryjane27
Beginner
856 Views
If the calling context will be mostly the same for all 50 subroutines, and when there will be only one such context (e.g. former old Fortran code had them in COMMON), then consider placing these variables into a module and USE that module. Effectively a similar approach to the COMMON approach.



http://howtoplanaweddingebook.com/
0 Kudos
rase
New Contributor I
856 Views
In case of small subroutines or functions you should consider to add the PURE declaration which might provide additional performance gains on condition the prerequisites for PURE are fullfilled.
0 Kudos
Reply