|
[Sponsors] |
February 12, 2020, 16:18 |
Parallel Fortran 95 code using Openmp
|
#1 |
New Member
Shivank
Join Date: May 2019
Posts: 27
Rep Power: 7 |
Hello everyone
Hope this is a right forum to ask for help regarding Parallelization of a serial fortran cfd code. I have written a very basic CFD code in fortran 95 (explicit) to solve for flow over a flat plate using method of pseudo-compressibility. It has subroutines to solve continuity, x-momentum and y-momentum. I am trying to convert this code from series to parallel and have gone through some literature on Openmp present online. I still cannot make the transition. I am trying to distribute the solving of each equation(subroutine) using !$OMP SECTIONS work sharing construct to each thread, and do loops using !$OMP DO, but it does not seem to work. Does anybody have an example or basic learning parallel cfd fortran code that they can share or even just help me out, it would be great. Thanks in advance |
|
February 13, 2020, 01:42 |
|
#2 |
Senior Member
Mehdi Babamehdi
Join Date: Jan 2011
Posts: 158
Rep Power: 15 |
your question is so vague. what do you mean when you say it does not work, you mean it was not scaled well or something else.
If your code has not been scaled, As far as I know there is some rule for parallelization, does not matter for which field you want to use it. Please first read some literatures about rules in parallelization, and then start change your code. Keep it in mind, if your code is quite complicated, it would not be easy to parallelize it, and expect your code to be scaled (if it does not make some problem as well).. I recommend the book "An Introduction to Parallel Programming" by Peter Pacheco, but it only talks about programming part not algorithms. Last edited by mb.pejvak; February 16, 2020 at 02:06. |
|
February 13, 2020, 05:35 |
|
#3 |
Senior Member
|
I subscribe to all previous suggestions.
In general, however, that's the idea, splitting work of EVERY loop that scales with number of cells/faces/nodes/etc. The point is that you need to be very careful in how you write stuff in these loops, in order to prevent errors and facilitate actual splitting of the work. |
|
February 13, 2020, 06:34 |
|
#4 |
Super Moderator
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,428
Rep Power: 49 |
Copy that. Writing OpenMP parallel code that is correct is relatively easy. Making it scale, especially on NUMA systems, often requires a bit more effort.
That being said, here is a minimal example for one subroutine, as you requested: Code:
SUBROUTINE push(f_1,f_2) use types use parameters use vars_and_data implicit none REAL(DP), DIMENSION(0:26,ncc), INTENT(IN) :: f_1 REAL(DP), DIMENSION(0:26,ncc), INTENT(OUT) :: f_2 INTEGER(I4B) :: n, i !$OMP PARALLEL PRIVATE(n,i) !$OMP DO SCHEDULE(STATIC) do n=1, ncc do i=0, 26 f_2(i,links(i,n)) = f_1(i,n) end do end do !$OMP END DO !$OMP END PARALLEL END SUBROUTINE push |
|
February 14, 2020, 12:34 |
|
#5 |
New Member
Shivank
Join Date: May 2019
Posts: 27
Rep Power: 7 |
Thank you Sir for the snippet, this is exactly what I was looking for.
|
|
February 14, 2020, 12:36 |
|
#6 |
New Member
Shivank
Join Date: May 2019
Posts: 27
Rep Power: 7 |
My apologies for not putting my question in a comprehensible way, I am just getting started with parallel programming for CFD. I will definitely look into more literature and the book you have recommended. Thank you again
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Parallel Fortran | ho_afshar | Main CFD Forum | 11 | November 9, 2018 04:26 |
Need help on checking HLL and Rusanov fortran code. | pinball1997 | Main CFD Forum | 0 | April 4, 2018 08:44 |
How to make code run in parallel? | cwang5 | OpenFOAM Programming & Development | 1 | May 30, 2011 05:47 |
fortran code - boundary layer - frank white | Ed | Main CFD Forum | 1 | February 12, 2009 18:30 |
Speeding my Fortran Code | S | Main CFD Forum | 11 | March 31, 2005 15:50 |