calc_ffh Subroutine

private subroutine calc_ffh(calc_m_stt)

Note

Function that returns …

  • the digital filter to apply to the height distribution
  • the starting statistical moments PARAM%m_stt%sk, PARAM%m_stt%ku
  • whether the exponential function will be used, PARAM%reajust_skku

Arguments

Type IntentOptional Attributes Name
logical(kind=I4), intent(inout) :: calc_m_stt

compute starting moments ?


Calls

proc~~calc_ffh~~CallsGraph proc~calc_ffh calc_ffh calc_fftw3_real_bwd calc_fftw3_real_bwd proc~calc_ffh->calc_fftw3_real_bwd calc_fftw3_real_fwd calc_fftw3_real_fwd proc~calc_ffh->calc_fftw3_real_fwd calc_moments calc_moments proc~calc_ffh->calc_moments

Called by

proc~~calc_ffh~~CalledByGraph proc~calc_ffh calc_ffh proc~read_job read_job proc~read_job->proc~calc_ffh proc~prg_surf prg_surf proc~prg_surf->proc~read_job program~main main program~main->proc~prg_surf

Source Code

   subroutine calc_ffh(calc_m_stt)
   !================================================================================================
   !<@note Function that returns ...
   !<
   !< - the digital filter to apply to the height distribution \( \text{PARAM%fhi} = \sqrt{ \left| FFT(\text{PARAM%imp_acf}) \right| } \)
   !< - the starting statistical moments PARAM%m_stt%sk, PARAM%m_stt%ku
   !< - whether the exponential function will be used, PARAM%reajust_skku
   !<
   !<@endnote
   !------------------------------------------------------------------------------------------------
   implicit none
   logical(kind=I4), intent(inout) :: calc_m_stt  !! *compute starting moments ?*

      integer(kind=I4) :: w, h, l

      complex(kind=R8), dimension(:,:), allocatable :: cmple
      real   (kind=R8), dimension(:,:), allocatable :: tab_tmp

      type(MOMENT_STAT) :: m_h

      w = PARAM%width
      h = PARAM%height
      l = PARAM%npts

      allocate( cmple(1:w, 1:h)  )

      write(SPY,*) 'calc_ffh -> PARAM%fhi = sqrt( abs( FFT(PARAM%imp_acf) ) )'

      call calc_fftw3_real_fwd( tab_in = PARAM%imp_acf(1:w, 1:h),  &  ! IN
                                tab_ou = cmple(1:w, 1:h),          &  ! OUT
                                  long = w,                        &  ! IN
                                  larg = h )                          ! IN

      PARAM%fhi(1:w, 1:h) = sqrt( abs( cmple(1:w, 1:h) ) )

      if ( calc_m_stt ) then

         ! determine starting statistical moments, if not already done
         !.......................................................................
         write(SPY,*) 'calc_ffh -> PARAM%m_stt calculated'

         cmple(1:w, 1:h) = cmplx( PARAM%fhi(1:w, 1:h), 0, kind = R8 )

         allocate( tab_tmp(1:w, 1:h) )

         call calc_fftw3_real_bwd( tab_in = cmple(1:w, 1:h),        &  ! IN
                                   tab_ou = tab_tmp(1:w, 1:h),      &  ! OUT
                                     long = w,                      &  ! IN
                                     larg = h)                         ! IN

         call calc_moments( tab     = tab_tmp(1:w, 1:h),      &  ! IN
                             mx     = m_h,                    &  ! OUT
                             nb_mom = 4 )                        ! IN

         PARAM%m_stt%mu = 0
         PARAM%m_stt%va = 1
         PARAM%m_end%mu = 0
         PARAM%m_end%va = m_h%va

         PARAM%m_stt%sk = sqrt( UN*l ) *  PARAM%m_end%sk      /  m_h%sk
         PARAM%m_stt%ku =          l   * (PARAM%m_end%ku -3.) / (m_h%ku - 3.) + 3.

         PARAM%reajust_skku = .false.

         if ( PARAM%m_stt%ku < PARAM%m_stt%sk**2 + 1.) then

            PARAM%m_stt%ku = PARAM%m_stt%sk**2 + 1.

            PARAM%reajust_skku = .true.

         endif

         deallocate( tab_tmp )
         !.......................................................................

      else

         write(SPY,*) 'calc_ffh -> PARAM%m_stt NOT calculated, set to PARAM%m_end'

         PARAM%m_stt%sk = PARAM%m_end%sk
         PARAM%m_stt%ku = PARAM%m_end%ku

      endif

      deallocate( cmple )

   return
   endsubroutine calc_ffh