子例程并在Fortran + OpenMP中分配问题

时间:2019-05-20 14:54:26

标签: fortran openmp

我不知道下面如何解决子例程/函数调用和内存分配问题。编译可以进行但测试运行会报告错误:' Fortran运行时错误:尝试取消分配未分配的'anco_pair_list''和*Program received signal SIGSEGV: Segmentation fault - invalid memory reference*. 完整的代码可以在http://www.atomic-theory.uni-jena.de/programexchange/ratip-2012.tgz上找到 目前,我仅使用Auger组件。解压缩该文件,您可以找到主程序xauger.f90和make文件make-auger。主要计算在rabs_auger.f90中,尤其是两个子例程:auger_calculate_amplitudes和auger_channel_amplitude。

subroutine auger_calculate_amplitudes()
   !--------------------------------------------------------------------
      !
      integer       :: i, j, n, nw, nocsf
      real(kind=dp) :: energy
      type(nkappa)  :: subshell
      integer, dimension(:), allocatable :: ndx
      !
      n = asf_final%csf_set%nocsf + asf_initial%csf_set%nocsf
      !
      allocate( auger_csp%P(1:n_grasp2k), auger_csp%Q(1:n_grasp2k) )
      allocate( cowf_csp%P(1:10), cowf_csp%Q(1:10) )
      allocate( ndx(1:n) )
      !$omp parallel do private(i,j) schedule(dynamic)
      do  i = 1,number_of_transitions
         if (transition(i)%energy < zero) then
            transition(i)%probability = zero
            transition(i)%alpha_2     = zero
            transition(i)%alpha_4     = zero
            transition(i)%eta_2       = zero
            transition(i)%eta_4       = zero
            cycle
         end if
         !
        do  j = 1,transition(i)%number_of_channels
        energy = transition(i)%energy
         call set_configuration_scheme(asf_final%csf_set,asf_cont%csf_set,&
                  -1,transition(i)%channel(j)%kappa,                      &
              transition(i)%totalJ_f,transition(i)%parity_f,          &
              transition(i)%totalJ_i,transition(i)%parity_i,          &
                     append=.false.,index=ndx)
        !
        auger%no_f = asf_cont%csf_set%nocsf
        allocate( auger%ndx_f(auger%no_f) )
        auger%ndx_f(1:auger%no_f) = ndx(1:auger%no_f)
        !
            nw = asf_cont%csf_set%nwshells
            if (rabs_use_stop  .and. nw /= asf_final%csf_set%nwshells + 1) then
               stop "auger_calculate_amplitudes(): program stop A."
            end if
            ! 
        nocsf = asf_cont%csf_set%nocsf
           call anco_calculate_csf_matrix(asf_cont%csf_set,1,nocsf,1,nocsf)
           call cowf_set_drs_coefficients(transition(i)%asff,             &
                                         asf_cont%csf_set,ndx)
        subshell = nkappa(-1,transition(i)%channel(j)%kappa)
            call cowf_set_yk_coefficients(subshell,asf_cont%csf_set)
            call cowf_set_xk_coefficients(subshell,asf_cont%csf_set)
            !
            cowf_start_homogeneous         = .true.
            cowf_phaseshift_wkb            = .true.
            cowf_phaseshift_zero_potential = .false.
            cowf_phaseshift_coulomb        = .false.
        !
        cowf_norm_wkb                  = .true.
            call cowf_iterate_csp(energy,subshell)
            !
            auger_csp = cowf_csp
            transition(i)%channel(j)%phase = auger_csp%phase
            !
     call add_csf_to_basis(asf_initial%csf_set,asf_cont%csf_set,      &
           transition(i)%totalJ_i,transition(i)%parity_i,index=ndx)
            if (auger_print_csf_scheme) then
               call print_configuration_scheme(6,asf_cont%csf_set)
            end if
        !
        auger%no_i = asf_cont%csf_set%nocsf - auger%no_f
        allocate( auger%ndx_i(auger%no_i) )
 auger%ndx_i(1:auger%no_i) =ndx(1+auger%no_f:asf_cont%csf_set%nocsf)
        allocate( auger%matrix(1:auger%no_f,1:auger%no_i) )
        !
        call auger_pure_matrix(asf_cont%csf_set,i)
        call auger_channel_amplitude(i,j)
            !
        deallocate( auger%ndx_f, auger%ndx_i, auger%matrix  )
            call deallocate_csf_basis(asf_cont%csf_set)
     end do
     !
         call auger_transition_properties(transition(i))
      end do
       !$omp end parallel do
      deallocate( ndx, auger_csp%P, auger_csp%Q)
      !
   end subroutine auger_calculate_amplitudes

0 个答案:

没有答案