I decided to try to use openmp to parallelize some code. It was not working, and through trial and error I have found that the problem lies with a dynamic character string (it's size depends on another variable passed to the subroutine).
Here is the simplified version of my code:
character(len=Npart*3) :: key !$OMP PARALLEL DEFAULT(SHARED) PRIVATE(i,j,key) do r=1,basis_dim do i=1,Npart do j=i+1,Npart ! (some stuff) write(key,trim(formatting))mlist,char(0) (some other stuff) enddo enddo enddo enddo !$OMP END DO !$OMP END PARALLEL
When I run this code, I get a various segmentation faults. However, if I specify a fixed string length like
character(len=5) :: key
everything works perfectly.
Any ideas what the problem is?
Thank you for your help!