In a computational code that manipulates arrays, I want to have OMP sections. One section will write an array to disk, while another section sorts it. To avoid a race condition, I give the array the firstprivate and lastprivate clause, expecting that the threads that execute the sections will both copy the array into a private variable and at the end the thread that sorts the array copies the result into the global, shared variable. This results in a segfault when I use ifort, but not when I use gfortran.
As far as I could find, there is no restriction in the OMP specs on the use of both clauses on one array. Please clarify what the issue is and how to prevent it. I have attached a very short program that segfaults when compiling with "ifort -openmp ..." Valgrid and gdb flag "invalid read" and
"Invalid write" at the lines !$omp sections and !$omp end sections.
This happens on Ubuntu 14.04 with ifort 12.1.0.
Thanks, Lennaert.