I am trying to compare the time needed for writing a file between "-serial" version and "-openmp" with onethread doing the IO operation.
The result showed that;
Serial: 10.2 s
I'd like to know to some guidance to improve this.
Thanks in advance;
!$ use omp_lib
!$omp end master
!$omp end parallel
print*,'time =', finish_time
end program Console1
I don't see the motivation for writing single datum formatted fields to a file, or for putting it in a parallel section.
When parallel sections are used for practical purposes, of course, it is at least as interesting to know the elapsed time as the total CPU time of all threads. I suppose it is possible that a parallel region, presumably with a critical region in the I/O run-time library, will take longer than a serial region, in case that is what you are trying to find out.
I'll go ahead and move this thread to the "Threading on Intel Parallel Architectures" forum, which would be a more natural fit. You might get more guidance there.
The parallel version of the library function for "write" must take into consideration the possibility of multiple threads performing a write to the same unit at the same time. Therefor the mt version of the runtime library for write function must contain a critical section (hopefully on per unit). This will slow down the writes. Try reducing the number of calls to write
write(101,'(F10.3,/)') (A(i,j,k), i=1,nx)
You may have to experiment with the / and $ edit descriptors to get what you want.