Why Segmentation fault is happening in this openmp code?

后端 未结 2 1917
生来不讨喜
生来不讨喜 2020-11-22 16:53

main program:

program main                                                                                                                                            


        
2条回答
  •  Happy的楠姐
    2020-11-22 17:17

    Segmentation fault is due to stack memory limit when using OpenMP. Using the solutions from the previous answer did not solve the problem for me on my Windows OS. Using memory allocation into heap rather than stack memory seems to work:

    integer, parameter :: nmax = 202000  
    real(dp), dimension(:), allocatable :: e_in
    integer i
    
    allocate(e_in(nmax))
    
    e_in = 0
    
    ! rest of code
    
    deallocate(e_in)
    

    Plus this would not involve changing any default environment parameters.

    Acknowledgement to and refer to ohm314's solution here: large array using heap memory allocation

提交回复
热议问题