


















































































































 


































































































































































 



































































































































































































 



















































 










 








































































































































































































































 










                                
                                

                                
                                

                                
                                

                                


















































































module NullEvol_DiagMod
   implicit none

 contains

  subroutine NullEvol_DiagReArray(cctkGH, FieldName, TruncateFile, F3Dn, F3Ds, tmp, xgrid, time)
    use NullDecomp_Vars, only: Lmax
    use NullDecomp_SpinDecomp, only: SpinDecompCoefs
    use NullDecomp_IO
    use NullGrid_Vars, only: lsh, nx, zz
 
    implicit none

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

    integer*8, intent(in) :: cctkGH
    character(*), intent(in) :: FieldName
    logical,      intent(in) :: TruncateFile
    REAL*8,    intent(in) :: xgrid(nx), time
    REAL*8,    dimension(lsh(1), lsh(2), nx) :: F3Dn, F3Ds
    COMPLEX*16, dimension(lsh(1), lsh(2), 2)  :: tmp
 
    COMPLEX*16, dimension(0:Lmax, -Lmax:Lmax) :: coef

    

    integer i
    double precision c1,c2,c3

    interface
  integer*8 function CCTK_PointerTo (var)
  implicit none
  type(*),dimension(..),TARGET :: var
  end function CCTK_PointerTo
  end interface
  interface
  integer function CCTK_Equals (arg1, arg2)
  implicit none
  integer*8 arg1
  character(*) arg2
  end function CCTK_Equals
  integer function CCTK_MyProc (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_MyProc
  integer function CCTK_nProcs (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_nProcs
  integer function CCTK_IsThornActive (name)
  implicit none
  character(*) name
  end function CCTK_IsThornActive
  integer*8 function CCTK_NullPointer ()
  implicit none
  end function CCTK_NullPointer
  end interface
  interface
  INTEGER*4 function IO_TruncateOutputFiles (GH)
  implicit none
  integer*8 GH
  end function IO_TruncateOutputFiles
  end interface
    REAL*8 Diagnostics_Coord_x
  integer, parameter :: cctki_use_Diagnostics_Coord_x = kind(Diagnostics_Coord_x)
  integer*8 boundary_data
  integer, parameter :: cctki_use_boundary_data = kind(boundary_data)
  integer*8 initial_J_data
  integer, parameter :: cctki_use_initial_J_data = kind(initial_J_data)
  INTEGER*4 DEBUG_skip_B_update
  integer, parameter :: cctki_use_DEBUG_skip_B_update = kind(DEBUG_skip_B_update)
  INTEGER*4 DEBUG_skip_CB_update
  integer, parameter :: cctki_use_DEBUG_skip_CB_update = kind(DEBUG_skip_CB_update)
  INTEGER*4 DEBUG_skip_CK_update
  integer, parameter :: cctki_use_DEBUG_skip_CK_update = kind(DEBUG_skip_CK_update)
  INTEGER*4 DEBUG_skip_J_update
  integer, parameter :: cctki_use_DEBUG_skip_J_update = kind(DEBUG_skip_J_update)
  INTEGER*4 DEBUG_skip_NU_update
  integer, parameter :: cctki_use_DEBUG_skip_NU_update = kind(DEBUG_skip_NU_update)
  INTEGER*4 DEBUG_skip_Q_update
  integer, parameter :: cctki_use_DEBUG_skip_Q_update = kind(DEBUG_skip_Q_update)
  INTEGER*4 DEBUG_skip_U_update
  integer, parameter :: cctki_use_DEBUG_skip_U_update = kind(DEBUG_skip_U_update)
  INTEGER*4 DEBUG_skip_W_update
  integer, parameter :: cctki_use_DEBUG_skip_W_update = kind(DEBUG_skip_W_update)
  INTEGER*4 DEBUG_skip_evolution
  integer, parameter :: cctki_use_DEBUG_skip_evolution = kind(DEBUG_skip_evolution)
  INTEGER*4 debug_verbose
  integer, parameter :: cctki_use_debug_verbose = kind(debug_verbose)
  INTEGER*4 first_order_scheme
  integer, parameter :: cctki_use_first_order_scheme = kind(first_order_scheme)
  INTEGER*4 old_J_xderiv
  integer, parameter :: cctki_use_old_J_xderiv = kind(old_J_xderiv)
  COMMON /NullEvolverest/Diagnostics_Coord_x, boundary_data, initial_J_data, DEBUG_skip_B_update, DEBUG_skip_CB_update, DEBUG_skip_&
  &CK_update, DEBUG_skip_J_update, DEBUG_skip_NU_update, DEBUG_skip_Q_update, DEBUG_skip_U_update, DEBUG_skip_W_update, DEBUG_skip_&
  &evolution, debug_verbose, first_order_scheme, old_J_xderiv
  REAL*8 ID_AMP
  integer, parameter :: cctki_use_ID_AMP = kind(ID_AMP)
  REAL*8 Jcoeff_r0
  integer, parameter :: cctki_use_Jcoeff_r0 = kind(Jcoeff_r0)
  REAL*8 Jcoeff_r0i
  integer, parameter :: cctki_use_Jcoeff_r0i = kind(Jcoeff_r0i)
  REAL*8 Jcoeff_r0r
  integer, parameter :: cctki_use_Jcoeff_r0r = kind(Jcoeff_r0r)
  REAL*8 Jcoeff_r1
  integer, parameter :: cctki_use_Jcoeff_r1 = kind(Jcoeff_r1)
  REAL*8 Jcoeff_r1i
  integer, parameter :: cctki_use_Jcoeff_r1i = kind(Jcoeff_r1i)
  REAL*8 Jcoeff_r1r
  integer, parameter :: cctki_use_Jcoeff_r1r = kind(Jcoeff_r1r)
  REAL*8 Jcoeff_r3
  integer, parameter :: cctki_use_Jcoeff_r3 = kind(Jcoeff_r3)
  REAL*8 Jcoeff_r3i
  integer, parameter :: cctki_use_Jcoeff_r3i = kind(Jcoeff_r3i)
  REAL*8 Jcoeff_r3r
  integer, parameter :: cctki_use_Jcoeff_r3r = kind(Jcoeff_r3r)
  REAL*8 N_dissip_one_outside_eq
  integer, parameter :: cctki_use_N_dissip_one_outside_eq = kind(N_dissip_one_outside_eq)
  REAL*8 N_dissip_zero_outside_eq
  integer, parameter :: cctki_use_N_dissip_zero_outside_eq = kind(N_dissip_zero_outside_eq)
  REAL*8 dissip_J
  integer, parameter :: cctki_use_dissip_J = kind(dissip_J)
  REAL*8 dissip_Jx
  integer, parameter :: cctki_use_dissip_Jx = kind(dissip_Jx)
  REAL*8 dissip_Q
  integer, parameter :: cctki_use_dissip_Q = kind(dissip_Q)
  REAL*8 dissip_W
  integer, parameter :: cctki_use_dissip_W = kind(dissip_W)
  REAL*8 dissip_fudge_maxx
  integer, parameter :: cctki_use_dissip_fudge_maxx = kind(dissip_fudge_maxx)
  REAL*8 null_dissip
  integer, parameter :: cctki_use_null_dissip = kind(null_dissip)
  REAL*8 psmax
  integer, parameter :: cctki_use_psmax = kind(psmax)
  REAL*8 psmin
  integer, parameter :: cctki_use_psmin = kind(psmin)
  REAL*8 qsmax
  integer, parameter :: cctki_use_qsmax = kind(qsmax)
  REAL*8 qsmin
  integer, parameter :: cctki_use_qsmin = kind(qsmin)
  REAL*8 wrot
  integer, parameter :: cctki_use_wrot = kind(wrot)
  REAL*8 xmax
  integer, parameter :: cctki_use_xmax = kind(xmax)
  REAL*8 xmin
  integer, parameter :: cctki_use_xmin = kind(xmin)
  integer*8 dissip_mask_type
  integer, parameter :: cctki_use_dissip_mask_type = kind(dissip_mask_type)
  INTEGER*4 ID_POWER
  integer, parameter :: cctki_use_ID_POWER = kind(ID_POWER)
  INTEGER*4 ID_l
  integer, parameter :: cctki_use_ID_l = kind(ID_l)
  INTEGER*4 ID_m
  integer, parameter :: cctki_use_ID_m = kind(ID_m)
  INTEGER*4 dissip_fudge
  integer, parameter :: cctki_use_dissip_fudge = kind(dissip_fudge)
  INTEGER*4 use_rsYlm
  integer, parameter :: cctki_use_use_rsYlm = kind(use_rsYlm)
  COMMON /NullEvolvepriv/ID_AMP, Jcoeff_r0, Jcoeff_r0i, Jcoeff_r0r, Jcoeff_r1, Jcoeff_r1i, Jcoeff_r1r, Jcoeff_r3, Jcoeff_r3i, Jcoef&
  &f_r3r, N_dissip_one_outside_eq, N_dissip_zero_outside_eq, dissip_J, dissip_Jx, dissip_Q, dissip_W, dissip_fudge_maxx, null_dissi&
  &p, psmax, psmin, qsmax, qsmin, wrot, xmax, xmin, dissip_mask_type, ID_POWER, ID_l, ID_m, dissip_fudge, use_rsYlm
  REAL*8 CCTKH0
  integer, parameter :: cctki_use_CCTKH0 = kind(CCTKH0)
  REAL*8 cctk_initial_time
  integer, parameter :: cctki_use_cctk_initial_time = kind(cctk_initial_time)
  REAL*8 CCTKH1
  integer, parameter :: cctki_use_CCTKH1 = kind(CCTKH1)
  integer*8 CCTKH2
  integer, parameter :: cctki_use_CCTKH2 = kind(CCTKH2)
  integer*8 CCTKH3
  integer, parameter :: cctki_use_CCTKH3 = kind(CCTKH3)
  INTEGER*4 cctk_itlast
  integer, parameter :: cctki_use_cctk_itlast = kind(cctk_itlast)
  INTEGER*4 CCTKH4
  integer, parameter :: cctki_use_CCTKH4 = kind(CCTKH4)
  COMMON /CACTUSrest/CCTKH0, cctk_initial_time, CCTKH1, CCTKH2, CCTKH3, cctk_itlast, CCTKH4
  REAL*8 null_rwt
  integer, parameter :: cctki_use_null_rwt = kind(null_rwt)
  REAL*8 null_xin
  integer, parameter :: cctki_use_null_xin = kind(null_xin)
  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 N_radial_pts
  integer, parameter :: cctki_use_N_radial_pts = kind(N_radial_pts)
  INTEGER*4 CCTKH5
  integer, parameter :: cctki_use_CCTKH5 = kind(CCTKH5)
  COMMON /NULLGRIDrest/null_rwt, null_xin, N_ang_ev_outside_eq, N_ang_ghost_pts, N_ang_pts_inside_eq, N_ang_stencil_size, N_radial_&
  &pts, CCTKH5
  integer*8 CCTKH7
  integer, parameter :: cctki_use_CCTKH7 = kind(CCTKH7)
  INTEGER*4 CCTKH6
  integer, parameter :: cctki_use_CCTKH6 = kind(CCTKH6)
  INTEGER*4 poison_test
  integer, parameter :: cctki_use_poison_test = kind(poison_test)
  COMMON /NULLINTERPrest/CCTKH7, CCTKH6, poison_test
  integer*8 timestep_method
  integer, parameter :: cctki_use_timestep_method = kind(timestep_method)
  INTEGER*4 CCTKH8
  integer, parameter :: cctki_use_CCTKH8 = kind(CCTKH8)
  COMMON /TIMErest/timestep_method, CCTKH8

    i = nint((Diagnostics_Coord_x-xgrid(1)) / (xgrid(2)-xgrid(1)))
    if(i.eq.1) i=2
    if(i.eq.nx) i=nx-1

    c1 = (Diagnostics_Coord_x-xgrid(i))*(Diagnostics_Coord_x-xgrid(i+1))&
            /(xgrid(i-1)-xgrid(i))/(xgrid(i-1)-xgrid(i+1))
    c2 = (Diagnostics_Coord_x-xgrid(i-1))*(Diagnostics_Coord_x-xgrid(i+1))&
             /(xgrid(i)-xgrid(i-1))/(xgrid(i)-xgrid(i+1))
    c3 = (Diagnostics_Coord_x-xgrid(i-1))*(Diagnostics_Coord_x-xgrid(i))&
             /(xgrid(i+1)-xgrid(i-1))/(xgrid(i+1)-xgrid(i))

    tmp(:,:,1) = F3Dn(:,:,i-1)*c1 + F3Dn(:,:,i)*c2 + F3Dn(:,:,i+1)*c3
    tmp(:,:,2) = F3Ds(:,:,i-1)*c1 + F3Ds(:,:,i)*c2 + F3Ds(:,:,i+1)*c3
    call SpinDecompCoefs(cctkGH, lsh(1), lsh(2), 0_ik, zz, tmp, coef)

    
    if (CCTK_MyProc(cctkGH) .gt. 0) then
       return
    endif

   
    call NullDecomp_WriteCoefFile(FieldName, TruncateFile, 0_ik, Lmax, coef, time)

  end subroutine 

  subroutine NullEvol_DiagImArray(cctkGH, FieldName, TruncateFile, SpinWeight, F3Dn, F3Ds, tmp, xgrid, time)
    use NullDecomp_Vars, only: Lmax
    use NullDecomp_SpinDecomp, only: SpinDecompCoefs
    use NullDecomp_IO
    use NullGrid_Vars, only: lsh, nx, zz
 
    implicit none

    integer*8, intent(in) :: cctkGH
    character(*), intent(in) :: FieldName
    logical,      intent(in) :: TruncateFile
    INTEGER*4,     intent(in) :: SpinWeight
    REAL*8,    intent(in) :: xgrid(nx), time
    COMPLEX*16, dimension(lsh(1), lsh(2), nx) :: F3Dn, F3Ds
    COMPLEX*16, dimension(lsh(1), lsh(2), 2)  :: tmp
 
    COMPLEX*16, dimension(SpinWeight:Lmax, -Lmax:Lmax) :: coef

    

    integer i
    double precision c1,c2,c3

    interface
  integer*8 function CCTK_PointerTo (var)
  implicit none
  type(*),dimension(..),TARGET :: var
  end function CCTK_PointerTo
  end interface
  interface
  integer function CCTK_Equals (arg1, arg2)
  implicit none
  integer*8 arg1
  character(*) arg2
  end function CCTK_Equals
  integer function CCTK_MyProc (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_MyProc
  integer function CCTK_nProcs (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_nProcs
  integer function CCTK_IsThornActive (name)
  implicit none
  character(*) name
  end function CCTK_IsThornActive
  integer*8 function CCTK_NullPointer ()
  implicit none
  end function CCTK_NullPointer
  end interface
  interface
  INTEGER*4 function IO_TruncateOutputFiles (GH)
  implicit none
  integer*8 GH
  end function IO_TruncateOutputFiles
  end interface
    REAL*8 Diagnostics_Coord_x
  integer, parameter :: cctki_use_Diagnostics_Coord_x = kind(Diagnostics_Coord_x)
  integer*8 boundary_data
  integer, parameter :: cctki_use_boundary_data = kind(boundary_data)
  integer*8 initial_J_data
  integer, parameter :: cctki_use_initial_J_data = kind(initial_J_data)
  INTEGER*4 DEBUG_skip_B_update
  integer, parameter :: cctki_use_DEBUG_skip_B_update = kind(DEBUG_skip_B_update)
  INTEGER*4 DEBUG_skip_CB_update
  integer, parameter :: cctki_use_DEBUG_skip_CB_update = kind(DEBUG_skip_CB_update)
  INTEGER*4 DEBUG_skip_CK_update
  integer, parameter :: cctki_use_DEBUG_skip_CK_update = kind(DEBUG_skip_CK_update)
  INTEGER*4 DEBUG_skip_J_update
  integer, parameter :: cctki_use_DEBUG_skip_J_update = kind(DEBUG_skip_J_update)
  INTEGER*4 DEBUG_skip_NU_update
  integer, parameter :: cctki_use_DEBUG_skip_NU_update = kind(DEBUG_skip_NU_update)
  INTEGER*4 DEBUG_skip_Q_update
  integer, parameter :: cctki_use_DEBUG_skip_Q_update = kind(DEBUG_skip_Q_update)
  INTEGER*4 DEBUG_skip_U_update
  integer, parameter :: cctki_use_DEBUG_skip_U_update = kind(DEBUG_skip_U_update)
  INTEGER*4 DEBUG_skip_W_update
  integer, parameter :: cctki_use_DEBUG_skip_W_update = kind(DEBUG_skip_W_update)
  INTEGER*4 DEBUG_skip_evolution
  integer, parameter :: cctki_use_DEBUG_skip_evolution = kind(DEBUG_skip_evolution)
  INTEGER*4 debug_verbose
  integer, parameter :: cctki_use_debug_verbose = kind(debug_verbose)
  INTEGER*4 first_order_scheme
  integer, parameter :: cctki_use_first_order_scheme = kind(first_order_scheme)
  INTEGER*4 old_J_xderiv
  integer, parameter :: cctki_use_old_J_xderiv = kind(old_J_xderiv)
  COMMON /NullEvolverest/Diagnostics_Coord_x, boundary_data, initial_J_data, DEBUG_skip_B_update, DEBUG_skip_CB_update, DEBUG_skip_&
  &CK_update, DEBUG_skip_J_update, DEBUG_skip_NU_update, DEBUG_skip_Q_update, DEBUG_skip_U_update, DEBUG_skip_W_update, DEBUG_skip_&
  &evolution, debug_verbose, first_order_scheme, old_J_xderiv
  REAL*8 ID_AMP
  integer, parameter :: cctki_use_ID_AMP = kind(ID_AMP)
  REAL*8 Jcoeff_r0
  integer, parameter :: cctki_use_Jcoeff_r0 = kind(Jcoeff_r0)
  REAL*8 Jcoeff_r0i
  integer, parameter :: cctki_use_Jcoeff_r0i = kind(Jcoeff_r0i)
  REAL*8 Jcoeff_r0r
  integer, parameter :: cctki_use_Jcoeff_r0r = kind(Jcoeff_r0r)
  REAL*8 Jcoeff_r1
  integer, parameter :: cctki_use_Jcoeff_r1 = kind(Jcoeff_r1)
  REAL*8 Jcoeff_r1i
  integer, parameter :: cctki_use_Jcoeff_r1i = kind(Jcoeff_r1i)
  REAL*8 Jcoeff_r1r
  integer, parameter :: cctki_use_Jcoeff_r1r = kind(Jcoeff_r1r)
  REAL*8 Jcoeff_r3
  integer, parameter :: cctki_use_Jcoeff_r3 = kind(Jcoeff_r3)
  REAL*8 Jcoeff_r3i
  integer, parameter :: cctki_use_Jcoeff_r3i = kind(Jcoeff_r3i)
  REAL*8 Jcoeff_r3r
  integer, parameter :: cctki_use_Jcoeff_r3r = kind(Jcoeff_r3r)
  REAL*8 N_dissip_one_outside_eq
  integer, parameter :: cctki_use_N_dissip_one_outside_eq = kind(N_dissip_one_outside_eq)
  REAL*8 N_dissip_zero_outside_eq
  integer, parameter :: cctki_use_N_dissip_zero_outside_eq = kind(N_dissip_zero_outside_eq)
  REAL*8 dissip_J
  integer, parameter :: cctki_use_dissip_J = kind(dissip_J)
  REAL*8 dissip_Jx
  integer, parameter :: cctki_use_dissip_Jx = kind(dissip_Jx)
  REAL*8 dissip_Q
  integer, parameter :: cctki_use_dissip_Q = kind(dissip_Q)
  REAL*8 dissip_W
  integer, parameter :: cctki_use_dissip_W = kind(dissip_W)
  REAL*8 dissip_fudge_maxx
  integer, parameter :: cctki_use_dissip_fudge_maxx = kind(dissip_fudge_maxx)
  REAL*8 null_dissip
  integer, parameter :: cctki_use_null_dissip = kind(null_dissip)
  REAL*8 psmax
  integer, parameter :: cctki_use_psmax = kind(psmax)
  REAL*8 psmin
  integer, parameter :: cctki_use_psmin = kind(psmin)
  REAL*8 qsmax
  integer, parameter :: cctki_use_qsmax = kind(qsmax)
  REAL*8 qsmin
  integer, parameter :: cctki_use_qsmin = kind(qsmin)
  REAL*8 wrot
  integer, parameter :: cctki_use_wrot = kind(wrot)
  REAL*8 xmax
  integer, parameter :: cctki_use_xmax = kind(xmax)
  REAL*8 xmin
  integer, parameter :: cctki_use_xmin = kind(xmin)
  integer*8 dissip_mask_type
  integer, parameter :: cctki_use_dissip_mask_type = kind(dissip_mask_type)
  INTEGER*4 ID_POWER
  integer, parameter :: cctki_use_ID_POWER = kind(ID_POWER)
  INTEGER*4 ID_l
  integer, parameter :: cctki_use_ID_l = kind(ID_l)
  INTEGER*4 ID_m
  integer, parameter :: cctki_use_ID_m = kind(ID_m)
  INTEGER*4 dissip_fudge
  integer, parameter :: cctki_use_dissip_fudge = kind(dissip_fudge)
  INTEGER*4 use_rsYlm
  integer, parameter :: cctki_use_use_rsYlm = kind(use_rsYlm)
  COMMON /NullEvolvepriv/ID_AMP, Jcoeff_r0, Jcoeff_r0i, Jcoeff_r0r, Jcoeff_r1, Jcoeff_r1i, Jcoeff_r1r, Jcoeff_r3, Jcoeff_r3i, Jcoef&
  &f_r3r, N_dissip_one_outside_eq, N_dissip_zero_outside_eq, dissip_J, dissip_Jx, dissip_Q, dissip_W, dissip_fudge_maxx, null_dissi&
  &p, psmax, psmin, qsmax, qsmin, wrot, xmax, xmin, dissip_mask_type, ID_POWER, ID_l, ID_m, dissip_fudge, use_rsYlm
  REAL*8 CCTKH0
  integer, parameter :: cctki_use_CCTKH0 = kind(CCTKH0)
  REAL*8 cctk_initial_time
  integer, parameter :: cctki_use_cctk_initial_time = kind(cctk_initial_time)
  REAL*8 CCTKH1
  integer, parameter :: cctki_use_CCTKH1 = kind(CCTKH1)
  integer*8 CCTKH2
  integer, parameter :: cctki_use_CCTKH2 = kind(CCTKH2)
  integer*8 CCTKH3
  integer, parameter :: cctki_use_CCTKH3 = kind(CCTKH3)
  INTEGER*4 cctk_itlast
  integer, parameter :: cctki_use_cctk_itlast = kind(cctk_itlast)
  INTEGER*4 CCTKH4
  integer, parameter :: cctki_use_CCTKH4 = kind(CCTKH4)
  COMMON /CACTUSrest/CCTKH0, cctk_initial_time, CCTKH1, CCTKH2, CCTKH3, cctk_itlast, CCTKH4
  REAL*8 null_rwt
  integer, parameter :: cctki_use_null_rwt = kind(null_rwt)
  REAL*8 null_xin
  integer, parameter :: cctki_use_null_xin = kind(null_xin)
  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 N_radial_pts
  integer, parameter :: cctki_use_N_radial_pts = kind(N_radial_pts)
  INTEGER*4 CCTKH5
  integer, parameter :: cctki_use_CCTKH5 = kind(CCTKH5)
  COMMON /NULLGRIDrest/null_rwt, null_xin, N_ang_ev_outside_eq, N_ang_ghost_pts, N_ang_pts_inside_eq, N_ang_stencil_size, N_radial_&
  &pts, CCTKH5
  integer*8 CCTKH7
  integer, parameter :: cctki_use_CCTKH7 = kind(CCTKH7)
  INTEGER*4 CCTKH6
  integer, parameter :: cctki_use_CCTKH6 = kind(CCTKH6)
  INTEGER*4 poison_test
  integer, parameter :: cctki_use_poison_test = kind(poison_test)
  COMMON /NULLINTERPrest/CCTKH7, CCTKH6, poison_test
  integer*8 timestep_method
  integer, parameter :: cctki_use_timestep_method = kind(timestep_method)
  INTEGER*4 CCTKH8
  integer, parameter :: cctki_use_CCTKH8 = kind(CCTKH8)
  COMMON /TIMErest/timestep_method, CCTKH8

    i = nint((Diagnostics_Coord_x-xgrid(1)) / (xgrid(2)-xgrid(1)))
    if(i.eq.1) i=2
    if(i.eq.nx) i=nx-1

    c1 = (Diagnostics_Coord_x-xgrid(i))*(Diagnostics_Coord_x-xgrid(i+1))&
            /(xgrid(i-1)-xgrid(i))/(xgrid(i-1)-xgrid(i+1))
    c2 = (Diagnostics_Coord_x-xgrid(i-1))*(Diagnostics_Coord_x-xgrid(i+1))&
             /(xgrid(i)-xgrid(i-1))/(xgrid(i)-xgrid(i+1))
    c3 = (Diagnostics_Coord_x-xgrid(i-1))*(Diagnostics_Coord_x-xgrid(i))&
             /(xgrid(i+1)-xgrid(i-1))/(xgrid(i+1)-xgrid(i))

    tmp(:,:,1) = F3Dn(:,:,i-1)*c1 + F3Dn(:,:,i)*c2 + F3Dn(:,:,i+1)*c3
    tmp(:,:,2) = F3Ds(:,:,i-1)*c1 + F3Ds(:,:,i)*c2 + F3Ds(:,:,i+1)*c3
    call SpinDecompCoefs(cctkGH, lsh(1), lsh(2), SpinWeight, zz, tmp, coef)

    
    if (CCTK_MyProc(cctkGH) .gt. 0) then
       return
    endif

   
    call NullDecomp_WriteCoefFile(FieldName, TruncateFile, SpinWeight, Lmax, coef, time)

  end subroutine 

end module NullEvol_DiagMod
