I am starting to work on quite big application which uses Fortran and C++. The aim is to obtain multi-level parallelization. Since I am starting to work with OpenMp I would like to ask for advice concerning application design.
The application works as follows starting from the lowest level:
1. Fortran modules/subroutines for calculation parameters of single elements in network
2. C++ code - calls Fortran subroutines/modules and the results of calculations are next used to calculate some other stuff.
So for example we have network elements A, B, C (implemented in Fortran) and C++ code which calculate parameters of network: A(x1) + B(x1) + C(x1) + A(x2) + B(x2)
Calculations goes as follows:
1. Calculate results for A,B,C separately
2. Combine results and calculate final result using C++
The parallelization should be applied both for A,B,C (fortran code) and in C++ to call calculation for A(x1), A(x2), B(x1), B(x2), C(x1) simultaneously (so we obtain multilevel parallelization)
My questions is as follows:
Since, elements A,B,C are written in old F77 and uses a lot of common blocks - direct parallelization seems to be difficult - so is it a good idea to rework F77 code using OOP from F2008 standard just to have all variables private. This I guess should be enough to be able to call A(x1) and A(x2) simultaneously from C++. Or there is another approach (since there is a lot of common blocks I am not sure if I will be able to apply threadprivate in all required places and be sure that all works properly...)
Rewriting to get rid of the common blocks is a good plan. You don't need to go the whole OO route unless you really want to: derived types and allocatables are likely sufficient.adamk wrote:Since, elements A,B,C are written in old F77 and uses a lot of common blocks - direct parallelization seems to be difficult - so is it a good idea to rework F77 code using OOP from F2008 standard just to have all variables private.
Do you have only 5-way parallelism at the outer level, and do all these outer tasks have the same amount of computation?
I'm not sure how well cross-language nested parallelism is supported in implementations - some simple tests with the compiler(s) you are likely to use might be worth doing.