





















































































































 


































































































































































 

























































































































































































 





















































 










 








































































































































































































































 










                                
                                

                                
                                

                                
                                

                                

















































































module NullInterp_Interp
  use cctk
  implicit none

contains

  
  
  
  subroutine NullInterp_cinterp(cctkGH, tmp_cgfn, tmp_cgfs, jn, js, spin) 
    use NullGrid_Vars
    use NullInterp_InterpUtil
    implicit none

    integer*8, intent(in) :: cctkGH
    INTEGER*4,     intent(in) :: spin

    COMPLEX*16, dimension(:,:), intent(inout) :: tmp_cgfn, tmp_cgfs
    COMPLEX*16, dimension(:,:), intent(inout) :: jn, js

    INTEGER*4, parameter :: izero = 0
    integer, parameter :: ik = kind(izero)

    integer, dimension(2), save :: gf_indices

    logical, save :: NotCalled = .true.
    integer :: ierr, i, j
    COMPLEX*16, save :: inactive_value = (0.0, 0.0)

    integer*8 stereo_patch_type
  integer, parameter :: cctki_use_stereo_patch_type = kind(stereo_patch_type)
  INTEGER*4 deriv_accuracy
  integer, parameter :: cctki_use_deriv_accuracy = kind(deriv_accuracy)
  INTEGER*4 poison_test
  integer, parameter :: cctki_use_poison_test = kind(poison_test)
  COMMON /NullInterprest/stereo_patch_type, deriv_accuracy, poison_test
  REAL*8 mask_testinterp_tolerance
  integer, parameter :: cctki_use_mask_testinterp_tolerance = kind(mask_testinterp_tolerance)
  REAL*8 poison_value
  integer, parameter :: cctki_use_poison_value = kind(poison_value)
  integer*8 interpolation_name
  integer, parameter :: cctki_use_interpolation_name = kind(interpolation_name)
  INTEGER*4 extended_guard_zone
  integer, parameter :: cctki_use_extended_guard_zone = kind(extended_guard_zone)
  INTEGER*4 interpolation_order
  integer, parameter :: cctki_use_interpolation_order = kind(interpolation_order)
  INTEGER*4 skip_interpolation
  integer, parameter :: cctki_use_skip_interpolation = kind(skip_interpolation)
  INTEGER*4 use_edge_check
  integer, parameter :: cctki_use_use_edge_check = kind(use_edge_check)
  COMMON /NullInterppriv/mask_testinterp_tolerance, poison_value, interpolation_name, extended_guard_zone, interpolation_order, ski&
  &p_interpolation, use_edge_check
  REAL*8 CCTKH1
  integer, parameter :: cctki_use_CCTKH1 = kind(CCTKH1)
  REAL*8 CCTKH2
  integer, parameter :: cctki_use_CCTKH2 = kind(CCTKH2)
  INTEGER*4 N_ang_ev_outside_eq
  integer, parameter :: cctki_use_N_ang_ev_outside_eq = kind(N_ang_ev_outside_eq)
  INTEGER*4 N_ang_ghost_pts
  integer, parameter :: cctki_use_N_ang_ghost_pts = kind(N_ang_ghost_pts)
  INTEGER*4 N_ang_pts_inside_eq
  integer, parameter :: cctki_use_N_ang_pts_inside_eq = kind(N_ang_pts_inside_eq)
  INTEGER*4 N_ang_stencil_size
  integer, parameter :: cctki_use_N_ang_stencil_size = kind(N_ang_stencil_size)
  INTEGER*4 CCTKH0
  integer, parameter :: cctki_use_CCTKH0 = kind(CCTKH0)
  INTEGER*4 CCTKH3
  integer, parameter :: cctki_use_CCTKH3 = kind(CCTKH3)
  COMMON /NULLGRIDrest/CCTKH1, CCTKH2, N_ang_ev_outside_eq, N_ang_ghost_pts, N_ang_pts_inside_eq, N_ang_stencil_size, CCTKH0, CCTKH3

    if (NotCalled ) then
       NotCalled  = .false.

       
       
       call CCTK_VarIndex(gf_indices(1), "NullInterp::tmp_cgfs")
       call CCTK_VarIndex(gf_indices(2), "NullInterp::tmp_cgfn")
    endif

    tmp_cgfn = jn(1:lsh(1),1:lsh(2))
    tmp_cgfs = js(1:lsh(1),1:lsh(2))

    call CCTK_SyncGroup(ierr, cctkGH, "NullInterp::tmp_cgf")
    if (ierr .ne. 0 ) then
       call CCTK_Warn(0,51,"NullInterp_Interp.F90","NullInterp", "Error syncing group tmp_cgf")
    endif

    if (poison_test.ne.0) inactive_value = poison_value * dcmplx(1.0, 1.0)

    call NullInterp_Util_cinterp(cctkGH, lsh, tmp_cgfn, tmp_cgfs, int(gf_indices,ik), spin, guard)

    do j = 1, lsh(2)
       do i = 1, lsh(1)
          if (EG(i,j).ne.0) then
             jn(i,j) = tmp_cgfn(i,j)
             js(i,j) = tmp_cgfs(i,j)
          else
             jn(i,j) = inactive_value
             js(i,j) = inactive_value
          end if
       end do
    end do
 
  end subroutine NullInterp_cinterp

  
  
  
  subroutine NullInterp_rinterp(cctkGH, tmp_rgfn, tmp_rgfs, bn, bs)
    use NullGrid_Vars
    use NullInterp_InterpUtil
    implicit none

    integer*8, intent(in) :: cctkGH

    REAL*8, dimension(:,:), intent(inout) :: tmp_rgfn, tmp_rgfs
    REAL*8, dimension(:,:), intent(inout) :: bn, bs

    INTEGER*4, parameter :: izero = 0
    integer, parameter :: ik = kind(izero)

    integer, save, dimension(2) :: gf_indices
    logical, save :: NotCalled = .true.
    integer :: ierr, i, j
    REAL*8, save :: inactive_value = 0.0

    integer*8 stereo_patch_type
  integer, parameter :: cctki_use_stereo_patch_type = kind(stereo_patch_type)
  INTEGER*4 deriv_accuracy
  integer, parameter :: cctki_use_deriv_accuracy = kind(deriv_accuracy)
  INTEGER*4 poison_test
  integer, parameter :: cctki_use_poison_test = kind(poison_test)
  COMMON /NullInterprest/stereo_patch_type, deriv_accuracy, poison_test
  REAL*8 mask_testinterp_tolerance
  integer, parameter :: cctki_use_mask_testinterp_tolerance = kind(mask_testinterp_tolerance)
  REAL*8 poison_value
  integer, parameter :: cctki_use_poison_value = kind(poison_value)
  integer*8 interpolation_name
  integer, parameter :: cctki_use_interpolation_name = kind(interpolation_name)
  INTEGER*4 extended_guard_zone
  integer, parameter :: cctki_use_extended_guard_zone = kind(extended_guard_zone)
  INTEGER*4 interpolation_order
  integer, parameter :: cctki_use_interpolation_order = kind(interpolation_order)
  INTEGER*4 skip_interpolation
  integer, parameter :: cctki_use_skip_interpolation = kind(skip_interpolation)
  INTEGER*4 use_edge_check
  integer, parameter :: cctki_use_use_edge_check = kind(use_edge_check)
  COMMON /NullInterppriv/mask_testinterp_tolerance, poison_value, interpolation_name, extended_guard_zone, interpolation_order, ski&
  &p_interpolation, use_edge_check
  REAL*8 CCTKH1
  integer, parameter :: cctki_use_CCTKH1 = kind(CCTKH1)
  REAL*8 CCTKH2
  integer, parameter :: cctki_use_CCTKH2 = kind(CCTKH2)
  INTEGER*4 N_ang_ev_outside_eq
  integer, parameter :: cctki_use_N_ang_ev_outside_eq = kind(N_ang_ev_outside_eq)
  INTEGER*4 N_ang_ghost_pts
  integer, parameter :: cctki_use_N_ang_ghost_pts = kind(N_ang_ghost_pts)
  INTEGER*4 N_ang_pts_inside_eq
  integer, parameter :: cctki_use_N_ang_pts_inside_eq = kind(N_ang_pts_inside_eq)
  INTEGER*4 N_ang_stencil_size
  integer, parameter :: cctki_use_N_ang_stencil_size = kind(N_ang_stencil_size)
  INTEGER*4 CCTKH0
  integer, parameter :: cctki_use_CCTKH0 = kind(CCTKH0)
  INTEGER*4 CCTKH3
  integer, parameter :: cctki_use_CCTKH3 = kind(CCTKH3)
  COMMON /NULLGRIDrest/CCTKH1, CCTKH2, N_ang_ev_outside_eq, N_ang_ghost_pts, N_ang_pts_inside_eq, N_ang_stencil_size, CCTKH0, CCTKH3

    if (NotCalled ) then
       NotCalled  = .false.
       
       
       call CCTK_VarIndex(gf_indices(1), "NullInterp::tmp_rgfs")
       call CCTK_VarIndex(gf_indices(2), "NullInterp::tmp_rgfn")
    endif
    tmp_rgfn = bn(1:lsh(1),1:lsh(2))
    tmp_rgfs = bs(1:lsh(1),1:lsh(2))
    call CCTK_SyncGroup(ierr, cctkGH, "NullInterp::tmp_rgf")
    if (ierr .ne. 0 ) then
       call CCTK_Warn(0,106,"NullInterp_Interp.F90","NullInterp", "Error syncing group tmp_rgf")
    endif

    if (poison_test.ne.0) inactive_value = poison_value

    call NullInterp_Util_rinterp(cctkGH, lsh, tmp_rgfn, tmp_rgfs, int(gf_indices,ik), guard)

    do j = 1, lsh(2)
       do i = 1, lsh(1)
          if (EG(i,j).ne.0) then
             bn(i,j) = tmp_rgfn(i,j)
             bs(i,j) = tmp_rgfs(i,j)
          else
             bn(i,j) = inactive_value
             bs(i,j) = inactive_value
          end if
       end do
    end do
 
  end subroutine NullInterp_rinterp

  
  
  
  subroutine NullInterp_3cinterp(cctkGH,&
       tmp_cgfn1, tmp_cgfs1,&
       tmp_cgfn2, tmp_cgfs2,&
       tmp_cgfn3, tmp_cgfs3,&
       jn1, js1, jn2, js2, jn3, js3,&
       spin1, spin2, spin3) 
    use NullGrid_Vars
    use NullInterp_InterpUtil
    implicit none

    INTEGER*4, parameter :: izero = 0
    integer, parameter :: ik = kind(izero)

    integer*8, intent(in) :: cctkGH
    INTEGER*4,     intent(in) :: spin1, spin2, spin3

    COMPLEX*16, dimension(:,:), intent(inout) ::&
         tmp_cgfn1, tmp_cgfs1,& 
         tmp_cgfn2, tmp_cgfs2,&
         tmp_cgfn3, tmp_cgfs3
    COMPLEX*16, dimension(:,:), intent(inout) ::&
         jn1, js1, jn2, js2, jn3, js3

    integer, save, dimension(6) :: gf_indices
    logical, save :: NotCalled = .true.
    integer :: ierr, i, j
    COMPLEX*16, save :: inactive_value = (0.0, 0.0)

    integer*8 stereo_patch_type
  integer, parameter :: cctki_use_stereo_patch_type = kind(stereo_patch_type)
  INTEGER*4 deriv_accuracy
  integer, parameter :: cctki_use_deriv_accuracy = kind(deriv_accuracy)
  INTEGER*4 poison_test
  integer, parameter :: cctki_use_poison_test = kind(poison_test)
  COMMON /NullInterprest/stereo_patch_type, deriv_accuracy, poison_test
  REAL*8 mask_testinterp_tolerance
  integer, parameter :: cctki_use_mask_testinterp_tolerance = kind(mask_testinterp_tolerance)
  REAL*8 poison_value
  integer, parameter :: cctki_use_poison_value = kind(poison_value)
  integer*8 interpolation_name
  integer, parameter :: cctki_use_interpolation_name = kind(interpolation_name)
  INTEGER*4 extended_guard_zone
  integer, parameter :: cctki_use_extended_guard_zone = kind(extended_guard_zone)
  INTEGER*4 interpolation_order
  integer, parameter :: cctki_use_interpolation_order = kind(interpolation_order)
  INTEGER*4 skip_interpolation
  integer, parameter :: cctki_use_skip_interpolation = kind(skip_interpolation)
  INTEGER*4 use_edge_check
  integer, parameter :: cctki_use_use_edge_check = kind(use_edge_check)
  COMMON /NullInterppriv/mask_testinterp_tolerance, poison_value, interpolation_name, extended_guard_zone, interpolation_order, ski&
  &p_interpolation, use_edge_check
  REAL*8 CCTKH1
  integer, parameter :: cctki_use_CCTKH1 = kind(CCTKH1)
  REAL*8 CCTKH2
  integer, parameter :: cctki_use_CCTKH2 = kind(CCTKH2)
  INTEGER*4 N_ang_ev_outside_eq
  integer, parameter :: cctki_use_N_ang_ev_outside_eq = kind(N_ang_ev_outside_eq)
  INTEGER*4 N_ang_ghost_pts
  integer, parameter :: cctki_use_N_ang_ghost_pts = kind(N_ang_ghost_pts)
  INTEGER*4 N_ang_pts_inside_eq
  integer, parameter :: cctki_use_N_ang_pts_inside_eq = kind(N_ang_pts_inside_eq)
  INTEGER*4 N_ang_stencil_size
  integer, parameter :: cctki_use_N_ang_stencil_size = kind(N_ang_stencil_size)
  INTEGER*4 CCTKH0
  integer, parameter :: cctki_use_CCTKH0 = kind(CCTKH0)
  INTEGER*4 CCTKH3
  integer, parameter :: cctki_use_CCTKH3 = kind(CCTKH3)
  COMMON /NULLGRIDrest/CCTKH1, CCTKH2, N_ang_ev_outside_eq, N_ang_ghost_pts, N_ang_pts_inside_eq, N_ang_stencil_size, CCTKH0, CCTKH3





    if (NotCalled ) then
       NotCalled  = .false.

       
       
       call CCTK_VarIndex(gf_indices(1), "NullInterp::tmp_cgfs1")
       call CCTK_VarIndex(gf_indices(2), "NullInterp::tmp_cgfn1")
       call CCTK_VarIndex(gf_indices(3), "NullInterp::tmp_cgfs2")
       call CCTK_VarIndex(gf_indices(4), "NullInterp::tmp_cgfn2")
       call CCTK_VarIndex(gf_indices(5), "NullInterp::tmp_cgfs3")
       call CCTK_VarIndex(gf_indices(6), "NullInterp::tmp_cgfn3")
    endif

    tmp_cgfn1 = jn1(1:lsh(1),1:lsh(2))
    tmp_cgfs1 = js1(1:lsh(1),1:lsh(2))
    tmp_cgfn2 = jn2(1:lsh(1),1:lsh(2))
    tmp_cgfs2 = js2(1:lsh(1),1:lsh(2))
    tmp_cgfn3 = jn3(1:lsh(1),1:lsh(2))
    tmp_cgfs3 = js3(1:lsh(1),1:lsh(2))

    call CCTK_SyncGroup(ierr, cctkGH, "NullInterp::tmp_cgf3")
    if (ierr .ne. 0 ) then
       call CCTK_Warn(0,186,"NullInterp_Interp.F90","NullInterp", "Error syncing group tmp_cgf3")
    endif

    if (poison_test.ne.0) inactive_value = poison_value * dcmplx(1.0, 1.0)

    call NullInterp_Util_3cinterp(cctkGH,lsh,&
         tmp_cgfn1, tmp_cgfs1,&
         tmp_cgfn2, tmp_cgfs2,&
         tmp_cgfn3, tmp_cgfs3,&
         int(gf_indices,ik), spin1, spin2, spin3, guard)

    do j = 1, lsh(2)
       do i = 1, lsh(1)
          if (EG(i,j).ne.0) then

             jn1(i,j) = tmp_cgfn1(i,j)
             js1(i,j) = tmp_cgfs1(i,j)

             jn2(i,j) = tmp_cgfn2(i,j)
             js2(i,j) = tmp_cgfs2(i,j)

             jn3(i,j) = tmp_cgfn3(i,j)
             js3(i,j) = tmp_cgfs3(i,j)

          else

             jn1(i,j) = inactive_value
             js1(i,j) = inactive_value

             jn2(i,j) = inactive_value
             js2(i,j) = inactive_value

             jn3(i,j) = inactive_value
             js3(i,j) = inactive_value

          end if
       end do
    end do
 
  end subroutine NullInterp_3cinterp

end module NullInterp_Interp
