- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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/
http://howtoplanaweddingebook.com/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page