Is there an easy way to prepare Fortran code for parallel calling

I want to solve several large ODE systems in a C ++ program in parallel using OpenMP. For some reason, I need to use the ODE solver, for which I could only find the Fortran 90 routine, and the code is too large to just translate it to C.

I know that Fortran makes extensive use of static memory and therefore I need to encode code for concurrent calls; but I am not very familiar with this language:

  • Is there a standard (automated) solution for my problem?
  • What parts of the code do I need to change?

The second question boils down to: How and when does Fortran allocate and free memory for variables and (how) does it reuse memory from function arguments?

So far, I have already figured out that partitions COMMONcorrespond to global variables in C, but can be made thread-local using the Fortran OpenMP directive !$OMP THREADPRIVATE(/…/). It's right? What about other local variables? They are also statically distributed, right? What is the easiest way to tell Fortran to distribute them dynamically? Should I use a statement ALLOCATEor keyword RECURSIVE, respectively. gfortran -frecursive, help or is there some way to just transfer a large chunk of memory from C ++ and let Fortran use it for all its variables? ( EQUIVALENCE?) OpenMP THREADPRIVATEalways allocates from the heap, so I would not want to use it for all local variables - right?

+1
1

, , . recursive , , , , save. . recursive, . , . BTW, gfortran, -fopenmp, -frecursive.

! , , save!

real :: ivar = 1

- . DATA . , threadprivate.

allocate, . . openmp .

threadprivate , . , , , , .

common C-. . save .

+3

Source: https://habr.com/ru/post/1628370/


All Articles