I am calling the lapack subroutine DLAPMT in the following snippet of my code:
c Permute matrix c_all according to IPERM1
do i=1, n_sources
call DLAPMT (.TRUE., nsim, ndim, c_all(:,:,i,k,l), nsim, IPERM1)
In this case n_sources is 2, g_layers is 1 and n_layers is 1. Therefore it should call DLAPMT twice. The first time it works fine. The second time it reaches DLAPMT, it kills the process due to a segmentation error. I've checked and all the inputs are exactly the same the second time around. What could be causing this problem?