My goal is to parallelize a section in my Fortran program. The flow of the program is:
- Read data from a file
- make some computations
- write the results to 2 different files
Here I want to parallelize the writing process since I’m writing into different files.
module foo
use omp_lib
implicit none
type element
integer, dimension(:), allocatable :: v1, v2
real(kind=8), dimension(:,:), allocatbale :: M
end type element
contains
subroutine test()
implicit none
type(element) :: e
do
e = read_data_from_file()
call compute_data(e)
!$OMP SECTIONS
!$OMP SECTION
!$ call write_to_file1(e)
!$OMP SECTION
!$ call write_to_file2(e)
!$OMP END SECTIONS
end do
end subroutine test
...
end module foo
But this program isn't going anything faster. So I think that I’m missing something?
singleis likely to be more performant thansectionfor the file writing.OMP PARALLELdirective, is it somewhere hidden? Perhaps you wantedOMP PARALLEL SECTIONSinstead? But Mark is right, it will not make it faster anyway because disk operations are hard to parallelize.