














































 







  










































































 


































































































































































 
























































































































































































 



















































 










 








































































































































































































































 










                                
                                

                                
                                

                                
                                

                                



















































































      subroutine SetUpFortranArrays(cctk_dim,cctk_gsh,cctk_lsh,cctk_lbnd
     &,cctk_ubnd,cctk_tile_min,cctk_tile_max,cctk_ash,cctk_alignment,cct
     &k_alignment_offset,cctk_from,cctk_to,cctk_bbox,cctk_delta_time,cct
     &k_time,cctk_delta_space,cctk_origin_space,cctk_levfac,cctk_levoff,
     &cctk_levoffdenom,cctk_timefac,cctk_convlevel,cctk_convfac,cctk_ngh
     &ostzones,cctk_iteration,cctkGH,cctk_ash1,cctk_ash2,cctk_ash3, X0ba
     &r_a_1d,X0bar_a_2d,X0bar_a_3d,X0bar_a_4d,X0bar_b_1d,X0bar_b_2d,X0ba
     &r_b_3d,X0bar_b_4d,X0bar_c_1d,X0bar_c_2d,X0bar_c_3d,X0bar_c_4d,X0ba
     &r_d_1d,X0bar_d_2d,X0bar_d_3d,X0bar_d_4d,X0bar_e_1d,X0bar_e_2d,X0ba
     &r_e_3d,X0bar_e_4d,X0bar_f_1d,X0bar_f_2d,X0bar_f_3d,X0bar_f_4d,X0ba
     &r_g_2d,X0bar_h_2d,X0bar_i_2d,X0bar_j_2d,X0bar_k_2d,X0bar_l_2d,X0fo
     &o1d,X0foo2d,X0foo3d,X0foo4d,X1bar_a_2d,X1bar_a_3d,X1bar_a_4d,X1bar
     &_b_2d,X1bar_b_3d,X1bar_b_4d,X1bar_c_2d,X1bar_c_3d,X1bar_c_4d,X1bar
     &_d_2d,X1bar_d_3d,X1bar_d_4d,X1bar_e_2d,X1bar_e_3d,X1bar_e_4d,X1bar
     &_f_2d,X1bar_f_3d,X1bar_f_4d,X1bar_g_2d,X1bar_h_2d,X1bar_i_2d,X1bar
     &_j_2d,X1bar_k_2d,X1bar_l_2d,X1foo2d,X1foo3d,X1foo4d,X2bar_a_3d,X2b
     &ar_a_4d,X2bar_b_3d,X2bar_b_4d,X2bar_c_3d,X2bar_c_4d,X2bar_d_3d,X2b
     &ar_d_4d,X2bar_e_3d,X2bar_e_4d,X2bar_f_3d,X2bar_f_4d,X2foo3d,X2foo4
     &d,X3bar_a_4d,X3bar_b_4d,X3bar_c_4d,X3bar_d_4d,X3bar_e_4d,X3bar_f_4
     &d,X3foo4d,bar_c_1d_length,bar_c_3d_length,bar_c_4d_length,bar_d_1d
     &_length,bar_d_3d_length,bar_d_4d_length,bar_e_1d_length,bar_e_2d_l
     &ength,bar_e_3d_length,bar_e_4d_length,bar_f_1d_length,bar_f_2d_len
     &gth,bar_f_3d_length,bar_f_4d_length,bar_g_2d_length,bar_h_2d_lengt
     &h,bar_i_2d_length,bar_j_2d_length,bar_k_2d_length,bar_l_2d_length,
     &bar_a_0d,bar_a_1d,bar_a_2d,bar_a_3d,bar_a_4d,bar_b_1d,bar_b_2d,bar
     &_b_3d,bar_b_4d,bar_c_1d,bar_c_2d,bar_c_3d,bar_c_4d,bar_d_1d,bar_d_
     &2d,bar_d_3d,bar_d_4d,bar_e_1d,bar_e_2d,bar_e_3d,bar_e_4d,bar_f_1d,
     &bar_f_2d,bar_f_3d,bar_f_4d,bar_g_2d,bar_h_2d,bar_i_2d,bar_j_2d,bar
     &_k_2d,bar_l_2d,gf1d,gf2d,gf3d,gf4d)

      implicit none


      INTEGER cctk_dim
      integer, parameter :: cctki_use_cctk_dim = kind(cctk_dim)
      INTEGER cctk_gsh (cctk_dim)
      integer, parameter :: cctki_use_cctk_gsh = kind(cctk_gsh)
      INTEGER cctk_lsh (cctk_dim)
      integer, parameter :: cctki_use_cctk_lsh = kind(cctk_lsh)
      INTEGER cctk_lbnd (cctk_dim)
      integer, parameter :: cctki_use_cctk_lbnd = kind(cctk_lbnd)
      INTEGER cctk_ubnd (cctk_dim)
      integer, parameter :: cctki_use_cctk_ubnd = kind(cctk_ubnd)
      INTEGER cctk_tile_min (cctk_dim)
      integer, parameter :: cctki_use_cctk_tile_min = kind(cctk_tile_min
     &)
      INTEGER cctk_tile_max (cctk_dim)
      integer, parameter :: cctki_use_cctk_tile_max = kind(cctk_tile_max
     &)
      INTEGER cctk_ash (cctk_dim)
      integer, parameter :: cctki_use_cctk_ash = kind(cctk_ash)
      INTEGER cctk_alignment
      integer, parameter :: cctki_use_cctk_alignment = kind(cctk_alignme
     &nt)
      INTEGER cctk_alignment_offset
      integer, parameter :: cctki_use_cctk_alignment_offset = kind(cctk_
     &alignment_offset)
      INTEGER cctk_from (cctk_dim)
      integer, parameter :: cctki_use_cctk_from = kind(cctk_from)
      INTEGER cctk_to (cctk_dim)
      integer, parameter :: cctki_use_cctk_to = kind(cctk_to)
      INTEGER cctk_bbox (2*cctk_dim)
      integer, parameter :: cctki_use_cctk_bbox = kind(cctk_bbox)
      REAL*8 cctk_delta_time
      integer, parameter :: cctki_use_cctk_delta_time = kind(cctk_delta_
     &time)
      REAL*8 cctk_time
      integer, parameter :: cctki_use_cctk_time = kind(cctk_time)
      REAL*8 cctk_delta_space (cctk_dim)
      integer, parameter :: cctki_use_cctk_delta_space = kind(cctk_delta
     &_space)
      REAL*8 cctk_origin_space (cctk_dim)
      integer, parameter :: cctki_use_cctk_origin_space = kind(cctk_orig
     &in_space)
      INTEGER cctk_levfac (cctk_dim)
      integer, parameter :: cctki_use_cctk_levfac = kind(cctk_levfac)
      INTEGER cctk_levoff (cctk_dim)
      integer, parameter :: cctki_use_cctk_levoff = kind(cctk_levoff)
      INTEGER cctk_levoffdenom (cctk_dim)
      integer, parameter :: cctki_use_cctk_levoffdenom = kind(cctk_levof
     &fdenom)
      INTEGER cctk_timefac
      integer, parameter :: cctki_use_cctk_timefac = kind(cctk_timefac)
      INTEGER cctk_convlevel
      integer, parameter :: cctki_use_cctk_convlevel = kind(cctk_convlev
     &el)
      INTEGER cctk_convfac
      integer, parameter :: cctki_use_cctk_convfac = kind(cctk_convfac)
      INTEGER cctk_nghostzones (cctk_dim)
      integer, parameter :: cctki_use_cctk_nghostzones = kind(cctk_nghos
     &tzones)
      INTEGER cctk_iteration
      integer, parameter :: cctki_use_cctk_iteration = kind(cctk_iterati
     &on)
      integer*8 cctkGH
      integer, parameter :: cctki_use_cctkGH = kind(cctkGH)
      INTEGER cctk_ash1
      integer, parameter :: cctki_use_cctk_ash1 = kind(cctk_ash1)
      INTEGER cctk_ash2
      integer, parameter :: cctki_use_cctk_ash2 = kind(cctk_ash2)
      INTEGER cctk_ash3
      integer, parameter :: cctki_use_cctk_ash3 = kind(cctk_ash3)
      INTEGER X0bar_a_1d
      INTEGER X0bar_a_2d
      INTEGER X0bar_a_3d
      INTEGER X0bar_a_4d
      INTEGER X0bar_b_1d
      INTEGER X0bar_b_2d
      INTEGER X0bar_b_3d
      INTEGER X0bar_b_4d
      INTEGER X0bar_c_1d
      INTEGER X0bar_c_2d
      INTEGER X0bar_c_3d
      INTEGER X0bar_c_4d
      INTEGER X0bar_d_1d
      INTEGER X0bar_d_2d
      INTEGER X0bar_d_3d
      INTEGER X0bar_d_4d
      INTEGER X0bar_e_1d
      INTEGER X0bar_e_2d
      INTEGER X0bar_e_3d
      INTEGER X0bar_e_4d
      INTEGER X0bar_f_1d
      INTEGER X0bar_f_2d
      INTEGER X0bar_f_3d
      INTEGER X0bar_f_4d
      INTEGER X0bar_g_2d
      INTEGER X0bar_h_2d
      INTEGER X0bar_i_2d
      INTEGER X0bar_j_2d
      INTEGER X0bar_k_2d
      INTEGER X0bar_l_2d
      INTEGER X0foo1d
      INTEGER X0foo2d
      INTEGER X0foo3d
      INTEGER X0foo4d
      INTEGER X1bar_a_2d
      INTEGER X1bar_a_3d
      INTEGER X1bar_a_4d
      INTEGER X1bar_b_2d
      INTEGER X1bar_b_3d
      INTEGER X1bar_b_4d
      INTEGER X1bar_c_2d
      INTEGER X1bar_c_3d
      INTEGER X1bar_c_4d
      INTEGER X1bar_d_2d
      INTEGER X1bar_d_3d
      INTEGER X1bar_d_4d
      INTEGER X1bar_e_2d
      INTEGER X1bar_e_3d
      INTEGER X1bar_e_4d
      INTEGER X1bar_f_2d
      INTEGER X1bar_f_3d
      INTEGER X1bar_f_4d
      INTEGER X1bar_g_2d
      INTEGER X1bar_h_2d
      INTEGER X1bar_i_2d
      INTEGER X1bar_j_2d
      INTEGER X1bar_k_2d
      INTEGER X1bar_l_2d
      INTEGER X1foo2d
      INTEGER X1foo3d
      INTEGER X1foo4d
      INTEGER X2bar_a_3d
      INTEGER X2bar_a_4d
      INTEGER X2bar_b_3d
      INTEGER X2bar_b_4d
      INTEGER X2bar_c_3d
      INTEGER X2bar_c_4d
      INTEGER X2bar_d_3d
      INTEGER X2bar_d_4d
      INTEGER X2bar_e_3d
      INTEGER X2bar_e_4d
      INTEGER X2bar_f_3d
      INTEGER X2bar_f_4d
      INTEGER X2foo3d
      INTEGER X2foo4d
      INTEGER X3bar_a_4d
      INTEGER X3bar_b_4d
      INTEGER X3bar_c_4d
      INTEGER X3bar_d_4d
      INTEGER X3bar_e_4d
      INTEGER X3bar_f_4d
      INTEGER X3foo4d
      INTEGER bar_c_1d_length
      INTEGER bar_c_3d_length
      INTEGER bar_c_4d_length
      INTEGER bar_d_1d_length
      INTEGER bar_d_3d_length
      INTEGER bar_d_4d_length
      INTEGER bar_e_1d_length
      INTEGER bar_e_2d_length
      INTEGER bar_e_3d_length
      INTEGER bar_e_4d_length
      INTEGER bar_f_1d_length
      INTEGER bar_f_2d_length
      INTEGER bar_f_3d_length
      INTEGER bar_f_4d_length
      INTEGER bar_g_2d_length
      INTEGER bar_h_2d_length
      INTEGER bar_i_2d_length
      INTEGER bar_j_2d_length
      INTEGER bar_k_2d_length
      INTEGER bar_l_2d_length
      REAL*8 bar_a_0d
      integer, parameter :: cctki_use_bar_a_0d = kind(bar_a_0d)
      REAL*8 bar_a_1d (X0bar_a_1d)
      integer, parameter :: cctki_use_bar_a_1d = kind(bar_a_1d)
      REAL*8 bar_a_2d (X0bar_a_2d,X1bar_a_2d)
      integer, parameter :: cctki_use_bar_a_2d = kind(bar_a_2d)
      REAL*8 bar_a_3d (X0bar_a_3d,X1bar_a_3d,X2bar_a_3d)
      integer, parameter :: cctki_use_bar_a_3d = kind(bar_a_3d)
      REAL*8 bar_a_4d (X0bar_a_4d,X1bar_a_4d,X2bar_a_4d,X3bar_a_4d)
      integer, parameter :: cctki_use_bar_a_4d = kind(bar_a_4d)
      REAL*8 bar_b_1d (X0bar_b_1d)
      integer, parameter :: cctki_use_bar_b_1d = kind(bar_b_1d)
      REAL*8 bar_b_2d (X0bar_b_2d,X1bar_b_2d)
      integer, parameter :: cctki_use_bar_b_2d = kind(bar_b_2d)
      REAL*8 bar_b_3d (X0bar_b_3d,X1bar_b_3d,X2bar_b_3d)
      integer, parameter :: cctki_use_bar_b_3d = kind(bar_b_3d)
      REAL*8 bar_b_4d (X0bar_b_4d,X1bar_b_4d,X2bar_b_4d,X3bar_b_4d)
      integer, parameter :: cctki_use_bar_b_4d = kind(bar_b_4d)
      REAL*8 bar_c_1d (X0bar_c_1d,bar_c_1d_length)
      integer, parameter :: cctki_use_bar_c_1d = kind(bar_c_1d)
      REAL*8 bar_c_2d (X0bar_c_2d,X1bar_c_2d)
      integer, parameter :: cctki_use_bar_c_2d = kind(bar_c_2d)
      REAL*8 bar_c_3d (X0bar_c_3d,X1bar_c_3d,X2bar_c_3d,bar_c_3d_length)
     &
      integer, parameter :: cctki_use_bar_c_3d = kind(bar_c_3d)
      REAL*8 bar_c_4d (X0bar_c_4d,X1bar_c_4d,X2bar_c_4d,X3bar_c_4d,bar_c
     &_4d_length)
      integer, parameter :: cctki_use_bar_c_4d = kind(bar_c_4d)
      REAL*8 bar_d_1d (X0bar_d_1d,bar_d_1d_length)
      integer, parameter :: cctki_use_bar_d_1d = kind(bar_d_1d)
      REAL*8 bar_d_2d (X0bar_d_2d,X1bar_d_2d)
      integer, parameter :: cctki_use_bar_d_2d = kind(bar_d_2d)
      REAL*8 bar_d_3d (X0bar_d_3d,X1bar_d_3d,X2bar_d_3d,bar_d_3d_length)
     &
      integer, parameter :: cctki_use_bar_d_3d = kind(bar_d_3d)
      REAL*8 bar_d_4d (X0bar_d_4d,X1bar_d_4d,X2bar_d_4d,X3bar_d_4d,bar_d
     &_4d_length)
      integer, parameter :: cctki_use_bar_d_4d = kind(bar_d_4d)
      REAL*8 bar_e_1d (X0bar_e_1d,bar_e_1d_length)
      integer, parameter :: cctki_use_bar_e_1d = kind(bar_e_1d)
      REAL*8 bar_e_2d (X0bar_e_2d,X1bar_e_2d,bar_e_2d_length)
      integer, parameter :: cctki_use_bar_e_2d = kind(bar_e_2d)
      REAL*8 bar_e_3d (X0bar_e_3d,X1bar_e_3d,X2bar_e_3d,bar_e_3d_length)
     &
      integer, parameter :: cctki_use_bar_e_3d = kind(bar_e_3d)
      REAL*8 bar_e_4d (X0bar_e_4d,X1bar_e_4d,X2bar_e_4d,X3bar_e_4d,bar_e
     &_4d_length)
      integer, parameter :: cctki_use_bar_e_4d = kind(bar_e_4d)
      REAL*8 bar_f_1d (X0bar_f_1d,bar_f_1d_length)
      integer, parameter :: cctki_use_bar_f_1d = kind(bar_f_1d)
      REAL*8 bar_f_2d (X0bar_f_2d,X1bar_f_2d,bar_f_2d_length)
      integer, parameter :: cctki_use_bar_f_2d = kind(bar_f_2d)
      REAL*8 bar_f_3d (X0bar_f_3d,X1bar_f_3d,X2bar_f_3d,bar_f_3d_length)
     &
      integer, parameter :: cctki_use_bar_f_3d = kind(bar_f_3d)
      REAL*8 bar_f_4d (X0bar_f_4d,X1bar_f_4d,X2bar_f_4d,X3bar_f_4d,bar_f
     &_4d_length)
      integer, parameter :: cctki_use_bar_f_4d = kind(bar_f_4d)
      REAL*8 bar_g_2d (X0bar_g_2d,X1bar_g_2d,bar_g_2d_length)
      integer, parameter :: cctki_use_bar_g_2d = kind(bar_g_2d)
      REAL*8 bar_h_2d (X0bar_h_2d,X1bar_h_2d,bar_h_2d_length)
      integer, parameter :: cctki_use_bar_h_2d = kind(bar_h_2d)
      REAL*8 bar_i_2d (X0bar_i_2d,X1bar_i_2d,bar_i_2d_length)
      integer, parameter :: cctki_use_bar_i_2d = kind(bar_i_2d)
      REAL*8 bar_j_2d (X0bar_j_2d,X1bar_j_2d,bar_j_2d_length)
      integer, parameter :: cctki_use_bar_j_2d = kind(bar_j_2d)
      REAL*8 bar_k_2d (X0bar_k_2d,X1bar_k_2d,bar_k_2d_length)
      integer, parameter :: cctki_use_bar_k_2d = kind(bar_k_2d)
      REAL*8 bar_l_2d (X0bar_l_2d,X1bar_l_2d,bar_l_2d_length)
      integer, parameter :: cctki_use_bar_l_2d = kind(bar_l_2d)
      REAL*8 gf1d (X0foo1d)
      integer, parameter :: cctki_use_gf1d = kind(gf1d)
      REAL*8 gf2d (X0foo2d,X1foo2d)
      integer, parameter :: cctki_use_gf2d = kind(gf2d)
      REAL*8 gf3d (X0foo3d,X1foo3d,X2foo3d)
      integer, parameter :: cctki_use_gf3d = kind(gf3d)
      REAL*8 gf4d (X0foo4d,X1foo4d,X2foo4d,X3foo4d)
      integer, parameter :: cctki_use_gf4d = kind(gf4d)
      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

      integer i,j,k,m,ierr
      integer myproc
      integer lsh_1d(1),lsh_2d(2),lsh_3d(3),lsh_4d(4)
      integer gsh_1d(1),gsh_2d(2),gsh_3d(3),gsh_4d(4)
      integer lbnd_1d(1),lbnd_2d(2),lbnd_3d(3),lbnd_4d(4)
      integer ubnd_1d(1),ubnd_2d(2),ubnd_3d(3),ubnd_4d(4)
      integer nghostzones_1d(1),nghostzones_2d(2),nghostzones_3d(3),ngho
     &stzones_4d(4)
      integer bbox_1d(2),bbox_2d(4),bbox_3d(6),bbox_4d(8)
      integer varindex1,varindex2,varindex3,varindex4
      integer groupindex1,groupindex2,groupindex3,groupindex4

      print *
      print *,"In SetUpFortranArrays"
      print *,"---------------------"
      print *

      call CCTK_VarIndex(varindex1,"testarrays::gf1d")
      call CCTK_VarIndex(varindex2,"testarrays::gf2d")
      call CCTK_VarIndex(varindex3,"testarrays::gf3d")
      call CCTK_VarIndex(varindex4,"testarrays::gf4d")
      call CCTK_GroupIndex(groupindex1,"testarrays::foo1d")
      call CCTK_GroupIndex(groupindex2,"testarrays::foo2d")
      call CCTK_GroupIndex(groupindex3,"testarrays::foo3d")
      call CCTK_GroupIndex(groupindex4,"testarrays::foo4d")

      print *,"Checking array queries"
      print *,"----------------------"

      print *
      print *,"Local shape (GN/VN/GI/VI) ..."
      call CCTK_GrouplshGN(ierr,cctkGH,1,lsh_1d,"testarrays::foo1d")
      print *,lsh_1d(1)
      call CCTK_GrouplshVN(ierr,cctkGH,1,lsh_1d,"testarrays::gf1d")
      print *,lsh_1d(1)
      call CCTK_GrouplshGI(ierr,cctkGH,1,lsh_1d,groupindex1)
      print *,lsh_1d(1)
      call CCTK_GrouplshVI(ierr,cctkGH,1,lsh_1d,varindex1)
      print *,lsh_1d(1)

      call CCTK_GrouplshGN(ierr,cctkGH,2,lsh_2d,"testarrays::foo2d")
      print *,lsh_2d(1),lsh_2d(2)
      call CCTK_GrouplshVN(ierr,cctkGH,2,lsh_2d,"testarrays::gf2d")
      print *,lsh_2d(1),lsh_2d(2)
      call CCTK_GrouplshGI(ierr,cctkGH,2,lsh_2d,groupindex2)
      print *,lsh_2d(1),lsh_2d(2)
      call CCTK_GrouplshVI(ierr,cctkGH,2,lsh_2d,varindex2)
      print *,lsh_2d(1),lsh_2d(2)

      call CCTK_GrouplshGN(ierr,cctkGH,3,lsh_3d,"testarrays::foo3d")
      print *,lsh_3d(1),lsh_3d(2),lsh_3d(3)
      call CCTK_GrouplshVN(ierr,cctkGH,3,lsh_3d,"testarrays::gf3d")
      print *,lsh_3d(1),lsh_3d(2),lsh_3d(3)
      call CCTK_GrouplshGI(ierr,cctkGH,3,lsh_3d,groupindex3)
      print *,lsh_3d(1),lsh_3d(2),lsh_3d(3)
      call CCTK_GrouplshVI(ierr,cctkGH,3,lsh_3d,varindex3)
      print *,lsh_3d(1),lsh_3d(2),lsh_3d(3)

      call CCTK_GrouplshGN(ierr,cctkGH,4,lsh_4d,"testarrays::foo4d")
      print *,lsh_4d(1),lsh_4d(2),lsh_4d(3),lsh_4d(4)
      call CCTK_GrouplshVN(ierr,cctkGH,4,lsh_4d,"testarrays::gf4d")
      print *,lsh_4d(1),lsh_4d(2),lsh_4d(3),lsh_4d(4)
      call CCTK_GrouplshGI(ierr,cctkGH,4,lsh_4d,groupindex4)
      print *,lsh_4d(1),lsh_4d(2),lsh_4d(3),lsh_4d(4)
      call CCTK_GrouplshVI(ierr,cctkGH,4,lsh_4d,varindex4)
      print *,lsh_4d(1),lsh_4d(2),lsh_4d(3),lsh_4d(4)

      print *
      print *,"Global shape (GN/VN/GI/VI) ..."
      call CCTK_GroupgshGN(ierr,cctkGH,1,gsh_1d,"testarrays::foo1d")
      print *,gsh_1d(1)
      call CCTK_GroupgshVN(ierr,cctkGH,1,gsh_1d,"testarrays::gf1d")
      print *,gsh_1d(1)
      call CCTK_GroupgshGI(ierr,cctkGH,1,gsh_1d,groupindex1)
      print *,gsh_1d(1)
      call CCTK_GroupgshVI(ierr,cctkGH,1,gsh_1d,varindex1)
      print *,gsh_1d(1)

      call CCTK_GroupgshGN(ierr,cctkGH,2,gsh_2d,"testarrays::foo2d")
      print *,gsh_2d(1),gsh_2d(2)
      call CCTK_GroupgshVN(ierr,cctkGH,2,gsh_2d,"testarrays::gf2d")
      print *,gsh_2d(1),gsh_2d(2)
      call CCTK_GroupgshGI(ierr,cctkGH,2,gsh_2d,groupindex2)
      print *,gsh_2d(1),gsh_2d(2)
      call CCTK_GroupgshVI(ierr,cctkGH,2,gsh_2d,varindex2)
      print *,gsh_2d(1),gsh_2d(2)

      call CCTK_GroupgshGN(ierr,cctkGH,3,gsh_3d,"testarrays::foo3d")
      print *,gsh_3d(1),gsh_3d(2),gsh_3d(3)
      call CCTK_GroupgshVN(ierr,cctkGH,3,gsh_3d,"testarrays::gf3d")
      print *,gsh_3d(1),gsh_3d(2),gsh_3d(3)
      call CCTK_GroupgshGI(ierr,cctkGH,3,gsh_3d,groupindex3)
      print *,gsh_3d(1),gsh_3d(2),gsh_3d(3)
      call CCTK_GroupgshVI(ierr,cctkGH,3,gsh_3d,varindex3)
      print *,gsh_3d(1),gsh_3d(2),gsh_3d(3)

      call CCTK_GroupgshGN(ierr,cctkGH,4,gsh_4d,"testarrays::foo4d")
      print *,gsh_4d(1),gsh_4d(2),gsh_4d(3),gsh_4d(4)
      call CCTK_GroupgshVN(ierr,cctkGH,4,gsh_4d,"testarrays::gf4d")
      print *,gsh_4d(1),gsh_4d(2),gsh_4d(3),gsh_4d(4)
      call CCTK_GroupgshGI(ierr,cctkGH,4,gsh_4d,groupindex4)
      print *,gsh_4d(1),gsh_4d(2),gsh_4d(3),gsh_4d(4)
      call CCTK_GroupgshVI(ierr,cctkGH,4,gsh_4d,varindex4)
      print *,gsh_4d(1),gsh_4d(2),gsh_4d(3),gsh_4d(4)

      print *
      print *,"Lower bounds (GN/VN/GI/VI) ..."
      call CCTK_GrouplbndGN(ierr,cctkGH,1,lbnd_1d,"testarrays::foo1d")
      print *,lbnd_1d(1)
      call CCTK_GrouplbndVN(ierr,cctkGH,1,lbnd_1d,"testarrays::gf1d")
      print *,lbnd_1d(1)
      call CCTK_GrouplbndGI(ierr,cctkGH,1,lbnd_1d,groupindex1)
      print *,lbnd_1d(1)
      call CCTK_GrouplbndVI(ierr,cctkGH,1,lbnd_1d,varindex1)
      print *,lbnd_1d(1)

      call CCTK_GrouplbndGN(ierr,cctkGH,2,lbnd_2d,"testarrays::foo2d")
      print *,lbnd_2d(1),lbnd_2d(2)
      call CCTK_GrouplbndVN(ierr,cctkGH,2,lbnd_2d,"testarrays::gf2d")
      print *,lbnd_2d(1),lbnd_2d(2)
      call CCTK_GrouplbndGI(ierr,cctkGH,2,lbnd_2d,groupindex2)
      print *,lbnd_2d(1),lbnd_2d(2)
      call CCTK_GrouplbndVI(ierr,cctkGH,2,lbnd_2d,varindex2)
      print *,lbnd_2d(1),lbnd_2d(2)

      call CCTK_GrouplbndGN(ierr,cctkGH,3,lbnd_3d,"testarrays::foo3d")
      print *,lbnd_3d(1),lbnd_3d(2),lbnd_3d(3)
      call CCTK_GrouplbndVN(ierr,cctkGH,3,lbnd_3d,"testarrays::gf3d")
      print *,lbnd_3d(1),lbnd_3d(2),lbnd_3d(3)
      call CCTK_GrouplbndGI(ierr,cctkGH,3,lbnd_3d,groupindex3)
      print *,lbnd_3d(1),lbnd_3d(2),lbnd_3d(3)
      call CCTK_GrouplbndVI(ierr,cctkGH,3,lbnd_3d,varindex3)
      print *,lbnd_3d(1),lbnd_3d(2),lbnd_3d(3)

      call CCTK_GrouplbndGN(ierr,cctkGH,4,lbnd_4d,"testarrays::foo4d")
      print *,lbnd_4d(1),lbnd_4d(2),lbnd_4d(3),lbnd_4d(4)
      call CCTK_GrouplbndVN(ierr,cctkGH,4,lbnd_4d,"testarrays::gf4d")
      print *,lbnd_4d(1),lbnd_4d(2),lbnd_4d(3),lbnd_4d(4)
      call CCTK_GrouplbndGI(ierr,cctkGH,4,lbnd_4d,groupindex4)
      print *,lbnd_4d(1),lbnd_4d(2),lbnd_4d(3),lbnd_4d(4)
      call CCTK_GrouplbndVI(ierr,cctkGH,4,lbnd_4d,varindex4)
      print *,lbnd_4d(1),lbnd_4d(2),lbnd_4d(3),lbnd_4d(4)

      print *
      print *,"Upper bounds (GN/VN/GI/VI) ..."
      call CCTK_GroupubndGN(ierr,cctkGH,1,ubnd_1d,"testarrays::foo1d")
      print *,ubnd_1d(1)
      call CCTK_GroupubndVN(ierr,cctkGH,1,ubnd_1d,"testarrays::gf1d")
      print *,ubnd_1d(1)
      call CCTK_GroupubndGI(ierr,cctkGH,1,ubnd_1d,groupindex1)
      print *,ubnd_1d(1)
      call CCTK_GroupubndVI(ierr,cctkGH,1,ubnd_1d,varindex1)
      print *,ubnd_1d(1)

      call CCTK_GroupubndGN(ierr,cctkGH,2,ubnd_2d,"testarrays::foo2d")
      print *,ubnd_2d(1),ubnd_2d(2)
      call CCTK_GroupubndVN(ierr,cctkGH,2,ubnd_2d,"testarrays::gf2d")
      print *,ubnd_2d(1),ubnd_2d(2)
      call CCTK_GroupubndGI(ierr,cctkGH,2,ubnd_2d,groupindex2)
      print *,ubnd_2d(1),ubnd_2d(2)
      call CCTK_GroupubndVI(ierr,cctkGH,2,ubnd_2d,varindex2)
      print *,ubnd_2d(1),ubnd_2d(2)

      call CCTK_GroupubndGN(ierr,cctkGH,3,ubnd_3d,"testarrays::foo3d")
      print *,ubnd_3d(1),ubnd_3d(2),ubnd_3d(3)
      call CCTK_GroupubndVN(ierr,cctkGH,3,ubnd_3d,"testarrays::gf3d")
      print *,ubnd_3d(1),ubnd_3d(2),ubnd_3d(3)
      call CCTK_GroupubndGI(ierr,cctkGH,3,ubnd_3d,groupindex3)
      print *,ubnd_3d(1),ubnd_3d(2),ubnd_3d(3)
      call CCTK_GroupubndVI(ierr,cctkGH,3,ubnd_3d,varindex3)
      print *,ubnd_3d(1),ubnd_3d(2),ubnd_3d(3)

      call CCTK_GroupubndGN(ierr,cctkGH,4,ubnd_4d,"testarrays::foo4d")
      print *,ubnd_4d(1),ubnd_4d(2),ubnd_4d(3),ubnd_4d(4)
      call CCTK_GroupubndVN(ierr,cctkGH,4,ubnd_4d,"testarrays::gf4d")
      print *,ubnd_4d(1),ubnd_4d(2),ubnd_4d(3),ubnd_4d(4)
      call CCTK_GroupubndGI(ierr,cctkGH,4,ubnd_4d,groupindex4)
      print *,ubnd_4d(1),ubnd_4d(2),ubnd_4d(3),ubnd_4d(4)
      call CCTK_GroupubndVI(ierr,cctkGH,4,ubnd_4d,varindex4)
      print *,ubnd_4d(1),ubnd_4d(2),ubnd_4d(3),ubnd_4d(4)

      print *
      print *,"Ghostzones (GN/VN/GI/VI) ..."
      call CCTK_GroupnghostzonesGN(ierr,cctkGH,1,nghostzones_1d,"testarr
     &ays::foo1d")
      print *,nghostzones_1d(1)
      call CCTK_GroupnghostzonesVN(ierr,cctkGH,1,nghostzones_1d,"testarr
     &ays::gf1d")
      print *,nghostzones_1d(1)
      call CCTK_GroupnghostzonesGI(ierr,cctkGH,1,nghostzones_1d,groupind
     &ex1)
      print *,nghostzones_1d(1)
      call CCTK_GroupnghostzonesVI(ierr,cctkGH,1,nghostzones_1d,varindex
     &1)
      print *,nghostzones_1d(1)

      call CCTK_GroupnghostzonesGN(ierr,cctkGH,2,nghostzones_2d,"testarr
     &ays::foo2d")
      print *,nghostzones_2d(1),nghostzones_2d(2)
      call CCTK_GroupnghostzonesVN(ierr,cctkGH,2,nghostzones_2d,"testarr
     &ays::gf2d")
      print *,nghostzones_2d(1),nghostzones_2d(2)
      call CCTK_GroupnghostzonesGI(ierr,cctkGH,2,nghostzones_2d,groupind
     &ex2)
      print *,nghostzones_2d(1),nghostzones_2d(2)
      call CCTK_GroupnghostzonesVI(ierr,cctkGH,2,nghostzones_2d,varindex
     &2)
      print *,nghostzones_2d(1),nghostzones_2d(2)

      call CCTK_GroupnghostzonesGN(ierr,cctkGH,3,nghostzones_3d,"testarr
     &ays::foo3d")
      print *,nghostzones_3d(1),nghostzones_3d(2),nghostzones_3d(3)
      call CCTK_GroupnghostzonesVN(ierr,cctkGH,3,nghostzones_3d,"testarr
     &ays::gf3d")
      print *,nghostzones_3d(1),nghostzones_3d(2),nghostzones_3d(3)
      call CCTK_GroupnghostzonesGI(ierr,cctkGH,3,nghostzones_3d,groupind
     &ex3)
      print *,nghostzones_3d(1),nghostzones_3d(2),nghostzones_3d(3)
      call CCTK_GroupnghostzonesVI(ierr,cctkGH,3,nghostzones_3d,varindex
     &3)
      print *,nghostzones_3d(1),nghostzones_3d(2),nghostzones_3d(3)

      call CCTK_GroupnghostzonesGN(ierr,cctkGH,4,nghostzones_4d,"testarr
     &ays::foo4d")
      print *,nghostzones_4d(1),nghostzones_4d(2),nghostzones_4d(3),ngho
     &stzones_4d(4)
      call CCTK_GroupnghostzonesVN(ierr,cctkGH,4,nghostzones_4d,"testarr
     &ays::gf4d")
      print *,nghostzones_4d(1),nghostzones_4d(2),nghostzones_4d(3),ngho
     &stzones_4d(4)
      call CCTK_GroupnghostzonesGI(ierr,cctkGH,4,nghostzones_4d,groupind
     &ex4)
      print *,nghostzones_4d(1),nghostzones_4d(2),nghostzones_4d(3),ngho
     &stzones_4d(4)
      call CCTK_GroupnghostzonesVI(ierr,cctkGH,4,nghostzones_4d,varindex
     &4)
      print *,nghostzones_4d(1),nghostzones_4d(2),nghostzones_4d(3),ngho
     &stzones_4d(4)

      print *
      print *,"Bounding box (GN/VN/GI/VI) ..."
      call CCTK_GroupbboxGN(ierr,cctkGH,2,bbox_1d,"testarrays::foo1d")
      print *,bbox_1d(1),bbox_1d(2)
      call CCTK_GroupbboxVN(ierr,cctkGH,2,bbox_1d,"testarrays::gf1d")
      print *,bbox_1d(1),bbox_1d(2)
      call CCTK_GroupbboxGI(ierr,cctkGH,2,bbox_1d,groupindex1)
      print *,bbox_1d(1),bbox_1d(2)
      call CCTK_GroupbboxVI(ierr,cctkGH,2,bbox_1d,varindex1)
      print *,bbox_1d(1),bbox_1d(2)

      call CCTK_GroupbboxGN(ierr,cctkGH,4,bbox_2d,"testarrays::foo2d")
      print *,bbox_2d(1),bbox_2d(2),bbox_2d(3),bbox_2d(4)
      call CCTK_GroupbboxVN(ierr,cctkGH,4,bbox_2d,"testarrays::gf2d")
      print *,bbox_2d(1),bbox_2d(2),bbox_2d(3),bbox_2d(4)
      call CCTK_GroupbboxGI(ierr,cctkGH,4,bbox_2d,groupindex2)
      print *,bbox_2d(1),bbox_2d(2),bbox_2d(3),bbox_2d(4)
      call CCTK_GroupbboxVI(ierr,cctkGH,4,bbox_2d,varindex2)
      print *,bbox_2d(1),bbox_2d(2),bbox_2d(3),bbox_2d(4)

      call CCTK_GroupbboxGN(ierr,cctkGH,6,bbox_3d,"testarrays::foo3d")
      print *,bbox_3d(1),bbox_3d(2),bbox_3d(3),
     &     bbox_3d(4),bbox_3d(5),bbox_3d(6)
      call CCTK_GroupbboxVN(ierr,cctkGH,6,bbox_3d,"testarrays::gf3d")
      print *,bbox_3d(1),bbox_3d(2),bbox_3d(3),
     &     bbox_3d(4),bbox_3d(5),bbox_3d(6)
      call CCTK_GroupbboxGI(ierr,cctkGH,6,bbox_3d,groupindex3)
      print *,bbox_3d(1),bbox_3d(2),bbox_3d(3),
     &     bbox_3d(4),bbox_3d(5),bbox_3d(6)
      call CCTK_GroupbboxVI(ierr,cctkGH,6,bbox_3d,varindex3)
      print *,bbox_3d(1),bbox_3d(2),bbox_3d(3),
     &     bbox_3d(4),bbox_3d(5),bbox_3d(6)

      call CCTK_GroupbboxGN(ierr,cctkGH,8,bbox_4d,"testarrays::foo4d")
      print *,bbox_4d(1),bbox_4d(2),bbox_4d(3),
     &     bbox_4d(4),bbox_4d(5),bbox_4d(6),bbox_4d(7),bbox_4d(8)
      call CCTK_GroupbboxVN(ierr,cctkGH,8,bbox_4d,"testarrays::gf4d")
      print *,bbox_4d(1),bbox_4d(2),bbox_4d(3),
     &     bbox_4d(4),bbox_4d(5),bbox_4d(6),bbox_4d(7),bbox_4d(8)
      call CCTK_GroupbboxGI(ierr,cctkGH,8,bbox_4d,groupindex4)
      print *,bbox_4d(1),bbox_4d(2),bbox_4d(3),
     &     bbox_4d(4),bbox_4d(5),bbox_4d(6),bbox_4d(7),bbox_4d(8)
      call CCTK_GroupbboxVI(ierr,cctkGH,8,bbox_4d,varindex4)
      print *,bbox_4d(1),bbox_4d(2),bbox_4d(3),
     &     bbox_4d(4),bbox_4d(5),bbox_4d(6),bbox_4d(7),bbox_4d(8)

      print *
      print *,"1D Array size is ",lsh_1d(1)
      do i=1,lsh_1d(1)
         gf1d(i) = dble(lbnd_1d(1)+i)
      end do

      print *,"2D Array size is ",lsh_2d(1),lsh_2d(2)
      do i=1,lsh_2d(1)
         do j=1,lsh_2d(2)
               gf2d(i,j) = (lbnd_2d(1)+i)*(lbnd_2d(2)+j)
         end do
      end do

      print *,"3D Array size is ",lsh_3d(1),lsh_3d(2),lsh_3d(3)
      do i=1,lsh_3d(1)
         do j=1,lsh_3d(2)
            do k=1,lsh_3d(3)
               gf3d(i,j,k) = (lbnd_3d(1)+i)*(lbnd_3d(2)+j)*
     &              (lbnd_3d(3)+k)
            end do
         end do
      end do

      print *,"4D Array size is ",lsh_4d(1),lsh_4d(2),lsh_4d(3),lsh_4d(4
     &)
      do i=1,lsh_4d(1)
         do j=1,lsh_4d(2)
            do k=1,lsh_4d(3)
               do m=1,lsh_4d(4)
                 gf4d(i,j,k,m) = (lbnd_4d(1)+i)*(lbnd_4d(2)+j)*
     &                (lbnd_4d(3)+k)*(lbnd_4d(4)+m)
               end do
            end do
         end do
      end do
      
      end subroutine SetUpFortranArrays


      subroutine UseFortranArrays(cctk_dim,cctk_gsh,cctk_lsh,cctk_lbnd,c
     &ctk_ubnd,cctk_tile_min,cctk_tile_max,cctk_ash,cctk_alignment,cctk_
     &alignment_offset,cctk_from,cctk_to,cctk_bbox,cctk_delta_time,cctk_
     &time,cctk_delta_space,cctk_origin_space,cctk_levfac,cctk_levoff,cc
     &tk_levoffdenom,cctk_timefac,cctk_convlevel,cctk_convfac,cctk_nghos
     &tzones,cctk_iteration,cctkGH,cctk_ash1,cctk_ash2,cctk_ash3, X0bar_
     &a_1d,X0bar_a_2d,X0bar_a_3d,X0bar_a_4d,X0bar_b_1d,X0bar_b_2d,X0bar_
     &b_3d,X0bar_b_4d,X0bar_c_1d,X0bar_c_2d,X0bar_c_3d,X0bar_c_4d,X0bar_
     &d_1d,X0bar_d_2d,X0bar_d_3d,X0bar_d_4d,X0bar_e_1d,X0bar_e_2d,X0bar_
     &e_3d,X0bar_e_4d,X0bar_f_1d,X0bar_f_2d,X0bar_f_3d,X0bar_f_4d,X0bar_
     &g_2d,X0bar_h_2d,X0bar_i_2d,X0bar_j_2d,X0bar_k_2d,X0bar_l_2d,X0foo1
     &d,X0foo2d,X0foo3d,X0foo4d,X1bar_a_2d,X1bar_a_3d,X1bar_a_4d,X1bar_b
     &_2d,X1bar_b_3d,X1bar_b_4d,X1bar_c_2d,X1bar_c_3d,X1bar_c_4d,X1bar_d
     &_2d,X1bar_d_3d,X1bar_d_4d,X1bar_e_2d,X1bar_e_3d,X1bar_e_4d,X1bar_f
     &_2d,X1bar_f_3d,X1bar_f_4d,X1bar_g_2d,X1bar_h_2d,X1bar_i_2d,X1bar_j
     &_2d,X1bar_k_2d,X1bar_l_2d,X1foo2d,X1foo3d,X1foo4d,X2bar_a_3d,X2bar
     &_a_4d,X2bar_b_3d,X2bar_b_4d,X2bar_c_3d,X2bar_c_4d,X2bar_d_3d,X2bar
     &_d_4d,X2bar_e_3d,X2bar_e_4d,X2bar_f_3d,X2bar_f_4d,X2foo3d,X2foo4d,
     &X3bar_a_4d,X3bar_b_4d,X3bar_c_4d,X3bar_d_4d,X3bar_e_4d,X3bar_f_4d,
     &X3foo4d,bar_c_1d_length,bar_c_3d_length,bar_c_4d_length,bar_d_1d_l
     &ength,bar_d_3d_length,bar_d_4d_length,bar_e_1d_length,bar_e_2d_len
     &gth,bar_e_3d_length,bar_e_4d_length,bar_f_1d_length,bar_f_2d_lengt
     &h,bar_f_3d_length,bar_f_4d_length,bar_g_2d_length,bar_h_2d_length,
     &bar_i_2d_length,bar_j_2d_length,bar_k_2d_length,bar_l_2d_length,ba
     &r_a_0d,bar_a_1d,bar_a_2d,bar_a_3d,bar_a_4d,bar_b_1d,bar_b_2d,bar_b
     &_3d,bar_b_4d,bar_c_1d,bar_c_2d,bar_c_3d,bar_c_4d,bar_d_1d,bar_d_2d
     &,bar_d_3d,bar_d_4d,bar_e_1d,bar_e_2d,bar_e_3d,bar_e_4d,bar_f_1d,ba
     &r_f_2d,bar_f_3d,bar_f_4d,bar_g_2d,bar_h_2d,bar_i_2d,bar_j_2d,bar_k
     &_2d,bar_l_2d,gf1d,gf2d,gf3d,gf4d)
      
      implicit none


      INTEGER cctk_dim
      integer, parameter :: cctki_use_cctk_dim = kind(cctk_dim)
      INTEGER cctk_gsh (cctk_dim)
      integer, parameter :: cctki_use_cctk_gsh = kind(cctk_gsh)
      INTEGER cctk_lsh (cctk_dim)
      integer, parameter :: cctki_use_cctk_lsh = kind(cctk_lsh)
      INTEGER cctk_lbnd (cctk_dim)
      integer, parameter :: cctki_use_cctk_lbnd = kind(cctk_lbnd)
      INTEGER cctk_ubnd (cctk_dim)
      integer, parameter :: cctki_use_cctk_ubnd = kind(cctk_ubnd)
      INTEGER cctk_tile_min (cctk_dim)
      integer, parameter :: cctki_use_cctk_tile_min = kind(cctk_tile_min
     &)
      INTEGER cctk_tile_max (cctk_dim)
      integer, parameter :: cctki_use_cctk_tile_max = kind(cctk_tile_max
     &)
      INTEGER cctk_ash (cctk_dim)
      integer, parameter :: cctki_use_cctk_ash = kind(cctk_ash)
      INTEGER cctk_alignment
      integer, parameter :: cctki_use_cctk_alignment = kind(cctk_alignme
     &nt)
      INTEGER cctk_alignment_offset
      integer, parameter :: cctki_use_cctk_alignment_offset = kind(cctk_
     &alignment_offset)
      INTEGER cctk_from (cctk_dim)
      integer, parameter :: cctki_use_cctk_from = kind(cctk_from)
      INTEGER cctk_to (cctk_dim)
      integer, parameter :: cctki_use_cctk_to = kind(cctk_to)
      INTEGER cctk_bbox (2*cctk_dim)
      integer, parameter :: cctki_use_cctk_bbox = kind(cctk_bbox)
      REAL*8 cctk_delta_time
      integer, parameter :: cctki_use_cctk_delta_time = kind(cctk_delta_
     &time)
      REAL*8 cctk_time
      integer, parameter :: cctki_use_cctk_time = kind(cctk_time)
      REAL*8 cctk_delta_space (cctk_dim)
      integer, parameter :: cctki_use_cctk_delta_space = kind(cctk_delta
     &_space)
      REAL*8 cctk_origin_space (cctk_dim)
      integer, parameter :: cctki_use_cctk_origin_space = kind(cctk_orig
     &in_space)
      INTEGER cctk_levfac (cctk_dim)
      integer, parameter :: cctki_use_cctk_levfac = kind(cctk_levfac)
      INTEGER cctk_levoff (cctk_dim)
      integer, parameter :: cctki_use_cctk_levoff = kind(cctk_levoff)
      INTEGER cctk_levoffdenom (cctk_dim)
      integer, parameter :: cctki_use_cctk_levoffdenom = kind(cctk_levof
     &fdenom)
      INTEGER cctk_timefac
      integer, parameter :: cctki_use_cctk_timefac = kind(cctk_timefac)
      INTEGER cctk_convlevel
      integer, parameter :: cctki_use_cctk_convlevel = kind(cctk_convlev
     &el)
      INTEGER cctk_convfac
      integer, parameter :: cctki_use_cctk_convfac = kind(cctk_convfac)
      INTEGER cctk_nghostzones (cctk_dim)
      integer, parameter :: cctki_use_cctk_nghostzones = kind(cctk_nghos
     &tzones)
      INTEGER cctk_iteration
      integer, parameter :: cctki_use_cctk_iteration = kind(cctk_iterati
     &on)
      integer*8 cctkGH
      integer, parameter :: cctki_use_cctkGH = kind(cctkGH)
      INTEGER cctk_ash1
      integer, parameter :: cctki_use_cctk_ash1 = kind(cctk_ash1)
      INTEGER cctk_ash2
      integer, parameter :: cctki_use_cctk_ash2 = kind(cctk_ash2)
      INTEGER cctk_ash3
      integer, parameter :: cctki_use_cctk_ash3 = kind(cctk_ash3)
      INTEGER X0bar_a_1d
      INTEGER X0bar_a_2d
      INTEGER X0bar_a_3d
      INTEGER X0bar_a_4d
      INTEGER X0bar_b_1d
      INTEGER X0bar_b_2d
      INTEGER X0bar_b_3d
      INTEGER X0bar_b_4d
      INTEGER X0bar_c_1d
      INTEGER X0bar_c_2d
      INTEGER X0bar_c_3d
      INTEGER X0bar_c_4d
      INTEGER X0bar_d_1d
      INTEGER X0bar_d_2d
      INTEGER X0bar_d_3d
      INTEGER X0bar_d_4d
      INTEGER X0bar_e_1d
      INTEGER X0bar_e_2d
      INTEGER X0bar_e_3d
      INTEGER X0bar_e_4d
      INTEGER X0bar_f_1d
      INTEGER X0bar_f_2d
      INTEGER X0bar_f_3d
      INTEGER X0bar_f_4d
      INTEGER X0bar_g_2d
      INTEGER X0bar_h_2d
      INTEGER X0bar_i_2d
      INTEGER X0bar_j_2d
      INTEGER X0bar_k_2d
      INTEGER X0bar_l_2d
      INTEGER X0foo1d
      INTEGER X0foo2d
      INTEGER X0foo3d
      INTEGER X0foo4d
      INTEGER X1bar_a_2d
      INTEGER X1bar_a_3d
      INTEGER X1bar_a_4d
      INTEGER X1bar_b_2d
      INTEGER X1bar_b_3d
      INTEGER X1bar_b_4d
      INTEGER X1bar_c_2d
      INTEGER X1bar_c_3d
      INTEGER X1bar_c_4d
      INTEGER X1bar_d_2d
      INTEGER X1bar_d_3d
      INTEGER X1bar_d_4d
      INTEGER X1bar_e_2d
      INTEGER X1bar_e_3d
      INTEGER X1bar_e_4d
      INTEGER X1bar_f_2d
      INTEGER X1bar_f_3d
      INTEGER X1bar_f_4d
      INTEGER X1bar_g_2d
      INTEGER X1bar_h_2d
      INTEGER X1bar_i_2d
      INTEGER X1bar_j_2d
      INTEGER X1bar_k_2d
      INTEGER X1bar_l_2d
      INTEGER X1foo2d
      INTEGER X1foo3d
      INTEGER X1foo4d
      INTEGER X2bar_a_3d
      INTEGER X2bar_a_4d
      INTEGER X2bar_b_3d
      INTEGER X2bar_b_4d
      INTEGER X2bar_c_3d
      INTEGER X2bar_c_4d
      INTEGER X2bar_d_3d
      INTEGER X2bar_d_4d
      INTEGER X2bar_e_3d
      INTEGER X2bar_e_4d
      INTEGER X2bar_f_3d
      INTEGER X2bar_f_4d
      INTEGER X2foo3d
      INTEGER X2foo4d
      INTEGER X3bar_a_4d
      INTEGER X3bar_b_4d
      INTEGER X3bar_c_4d
      INTEGER X3bar_d_4d
      INTEGER X3bar_e_4d
      INTEGER X3bar_f_4d
      INTEGER X3foo4d
      INTEGER bar_c_1d_length
      INTEGER bar_c_3d_length
      INTEGER bar_c_4d_length
      INTEGER bar_d_1d_length
      INTEGER bar_d_3d_length
      INTEGER bar_d_4d_length
      INTEGER bar_e_1d_length
      INTEGER bar_e_2d_length
      INTEGER bar_e_3d_length
      INTEGER bar_e_4d_length
      INTEGER bar_f_1d_length
      INTEGER bar_f_2d_length
      INTEGER bar_f_3d_length
      INTEGER bar_f_4d_length
      INTEGER bar_g_2d_length
      INTEGER bar_h_2d_length
      INTEGER bar_i_2d_length
      INTEGER bar_j_2d_length
      INTEGER bar_k_2d_length
      INTEGER bar_l_2d_length
      REAL*8 bar_a_0d
      integer, parameter :: cctki_use_bar_a_0d = kind(bar_a_0d)
      REAL*8 bar_a_1d (X0bar_a_1d)
      integer, parameter :: cctki_use_bar_a_1d = kind(bar_a_1d)
      REAL*8 bar_a_2d (X0bar_a_2d,X1bar_a_2d)
      integer, parameter :: cctki_use_bar_a_2d = kind(bar_a_2d)
      REAL*8 bar_a_3d (X0bar_a_3d,X1bar_a_3d,X2bar_a_3d)
      integer, parameter :: cctki_use_bar_a_3d = kind(bar_a_3d)
      REAL*8 bar_a_4d (X0bar_a_4d,X1bar_a_4d,X2bar_a_4d,X3bar_a_4d)
      integer, parameter :: cctki_use_bar_a_4d = kind(bar_a_4d)
      REAL*8 bar_b_1d (X0bar_b_1d)
      integer, parameter :: cctki_use_bar_b_1d = kind(bar_b_1d)
      REAL*8 bar_b_2d (X0bar_b_2d,X1bar_b_2d)
      integer, parameter :: cctki_use_bar_b_2d = kind(bar_b_2d)
      REAL*8 bar_b_3d (X0bar_b_3d,X1bar_b_3d,X2bar_b_3d)
      integer, parameter :: cctki_use_bar_b_3d = kind(bar_b_3d)
      REAL*8 bar_b_4d (X0bar_b_4d,X1bar_b_4d,X2bar_b_4d,X3bar_b_4d)
      integer, parameter :: cctki_use_bar_b_4d = kind(bar_b_4d)
      REAL*8 bar_c_1d (X0bar_c_1d,bar_c_1d_length)
      integer, parameter :: cctki_use_bar_c_1d = kind(bar_c_1d)
      REAL*8 bar_c_2d (X0bar_c_2d,X1bar_c_2d)
      integer, parameter :: cctki_use_bar_c_2d = kind(bar_c_2d)
      REAL*8 bar_c_3d (X0bar_c_3d,X1bar_c_3d,X2bar_c_3d,bar_c_3d_length)
     &
      integer, parameter :: cctki_use_bar_c_3d = kind(bar_c_3d)
      REAL*8 bar_c_4d (X0bar_c_4d,X1bar_c_4d,X2bar_c_4d,X3bar_c_4d,bar_c
     &_4d_length)
      integer, parameter :: cctki_use_bar_c_4d = kind(bar_c_4d)
      REAL*8 bar_d_1d (X0bar_d_1d,bar_d_1d_length)
      integer, parameter :: cctki_use_bar_d_1d = kind(bar_d_1d)
      REAL*8 bar_d_2d (X0bar_d_2d,X1bar_d_2d)
      integer, parameter :: cctki_use_bar_d_2d = kind(bar_d_2d)
      REAL*8 bar_d_3d (X0bar_d_3d,X1bar_d_3d,X2bar_d_3d,bar_d_3d_length)
     &
      integer, parameter :: cctki_use_bar_d_3d = kind(bar_d_3d)
      REAL*8 bar_d_4d (X0bar_d_4d,X1bar_d_4d,X2bar_d_4d,X3bar_d_4d,bar_d
     &_4d_length)
      integer, parameter :: cctki_use_bar_d_4d = kind(bar_d_4d)
      REAL*8 bar_e_1d (X0bar_e_1d,bar_e_1d_length)
      integer, parameter :: cctki_use_bar_e_1d = kind(bar_e_1d)
      REAL*8 bar_e_2d (X0bar_e_2d,X1bar_e_2d,bar_e_2d_length)
      integer, parameter :: cctki_use_bar_e_2d = kind(bar_e_2d)
      REAL*8 bar_e_3d (X0bar_e_3d,X1bar_e_3d,X2bar_e_3d,bar_e_3d_length)
     &
      integer, parameter :: cctki_use_bar_e_3d = kind(bar_e_3d)
      REAL*8 bar_e_4d (X0bar_e_4d,X1bar_e_4d,X2bar_e_4d,X3bar_e_4d,bar_e
     &_4d_length)
      integer, parameter :: cctki_use_bar_e_4d = kind(bar_e_4d)
      REAL*8 bar_f_1d (X0bar_f_1d,bar_f_1d_length)
      integer, parameter :: cctki_use_bar_f_1d = kind(bar_f_1d)
      REAL*8 bar_f_2d (X0bar_f_2d,X1bar_f_2d,bar_f_2d_length)
      integer, parameter :: cctki_use_bar_f_2d = kind(bar_f_2d)
      REAL*8 bar_f_3d (X0bar_f_3d,X1bar_f_3d,X2bar_f_3d,bar_f_3d_length)
     &
      integer, parameter :: cctki_use_bar_f_3d = kind(bar_f_3d)
      REAL*8 bar_f_4d (X0bar_f_4d,X1bar_f_4d,X2bar_f_4d,X3bar_f_4d,bar_f
     &_4d_length)
      integer, parameter :: cctki_use_bar_f_4d = kind(bar_f_4d)
      REAL*8 bar_g_2d (X0bar_g_2d,X1bar_g_2d,bar_g_2d_length)
      integer, parameter :: cctki_use_bar_g_2d = kind(bar_g_2d)
      REAL*8 bar_h_2d (X0bar_h_2d,X1bar_h_2d,bar_h_2d_length)
      integer, parameter :: cctki_use_bar_h_2d = kind(bar_h_2d)
      REAL*8 bar_i_2d (X0bar_i_2d,X1bar_i_2d,bar_i_2d_length)
      integer, parameter :: cctki_use_bar_i_2d = kind(bar_i_2d)
      REAL*8 bar_j_2d (X0bar_j_2d,X1bar_j_2d,bar_j_2d_length)
      integer, parameter :: cctki_use_bar_j_2d = kind(bar_j_2d)
      REAL*8 bar_k_2d (X0bar_k_2d,X1bar_k_2d,bar_k_2d_length)
      integer, parameter :: cctki_use_bar_k_2d = kind(bar_k_2d)
      REAL*8 bar_l_2d (X0bar_l_2d,X1bar_l_2d,bar_l_2d_length)
      integer, parameter :: cctki_use_bar_l_2d = kind(bar_l_2d)
      REAL*8 gf1d (X0foo1d)
      integer, parameter :: cctki_use_gf1d = kind(gf1d)
      REAL*8 gf2d (X0foo2d,X1foo2d)
      integer, parameter :: cctki_use_gf2d = kind(gf2d)
      REAL*8 gf3d (X0foo3d,X1foo3d,X2foo3d)
      integer, parameter :: cctki_use_gf3d = kind(gf3d)
      REAL*8 gf4d (X0foo4d,X1foo4d,X2foo4d,X3foo4d)
      integer, parameter :: cctki_use_gf4d = kind(gf4d)
      INTEGER*4 tghost4d
      integer, parameter :: cctki_use_tghost4d = kind(tghost4d)
      INTEGER*4 tsize4d
      integer, parameter :: cctki_use_tsize4d = kind(tsize4d)
      INTEGER*4 xghost1d
      integer, parameter :: cctki_use_xghost1d = kind(xghost1d)
      INTEGER*4 xghost2d
      integer, parameter :: cctki_use_xghost2d = kind(xghost2d)
      INTEGER*4 xghost3d
      integer, parameter :: cctki_use_xghost3d = kind(xghost3d)
      INTEGER*4 xghost4d
      integer, parameter :: cctki_use_xghost4d = kind(xghost4d)
      INTEGER*4 xsize1d
      integer, parameter :: cctki_use_xsize1d = kind(xsize1d)
      INTEGER*4 xsize2d
      integer, parameter :: cctki_use_xsize2d = kind(xsize2d)
      INTEGER*4 xsize3d
      integer, parameter :: cctki_use_xsize3d = kind(xsize3d)
      INTEGER*4 xsize4d
      integer, parameter :: cctki_use_xsize4d = kind(xsize4d)
      INTEGER*4 yghost2d
      integer, parameter :: cctki_use_yghost2d = kind(yghost2d)
      INTEGER*4 yghost3d
      integer, parameter :: cctki_use_yghost3d = kind(yghost3d)
      INTEGER*4 yghost4d
      integer, parameter :: cctki_use_yghost4d = kind(yghost4d)
      INTEGER*4 ysize2d
      integer, parameter :: cctki_use_ysize2d = kind(ysize2d)
      INTEGER*4 ysize3d
      integer, parameter :: cctki_use_ysize3d = kind(ysize3d)
      INTEGER*4 ysize4d
      integer, parameter :: cctki_use_ysize4d = kind(ysize4d)
      INTEGER*4 zghost3d
      integer, parameter :: cctki_use_zghost3d = kind(zghost3d)
      INTEGER*4 zghost4d
      integer, parameter :: cctki_use_zghost4d = kind(zghost4d)
      INTEGER*4 zsize3d
      integer, parameter :: cctki_use_zsize3d = kind(zsize3d)
      INTEGER*4 zsize4d
      integer, parameter :: cctki_use_zsize4d = kind(zsize4d)
      COMMON /TestArrayspriv/tghost4d, tsize4d, xghost1d, xghost2d, xgho
     &st3d, xghost4d, xsize1d, xsize2d, xsize3d, xsize4d, yghost2d, ygho
     &st3d, yghost4d, ysize2d, ysize3d, ysize4d, zghost3d, zghost4d, zsi
     &ze3d, zsize4d

      integer i,j,k,m,ierr
      integer lsh_1d(1),lsh_2d(2),lsh_3d(3),lsh_4d(4)
      integer nghostzones_1d(1),nghostzones_2d(2),nghostzones_3d(3),ngho
     &stzones_4d(4)

      print *
      print *,"In UseFortranArrays"
      print *,"-------------------"

      call CCTK_GrouplshGN(ierr,cctkGH,1,lsh_1d,"testarrays::foo1d")
      call CCTK_GrouplshGN(ierr,cctkGH,2,lsh_2d,"testarrays::foo2d")
      call CCTK_GrouplshGN(ierr,cctkGH,3,lsh_3d,"testarrays::foo3d")
      call CCTK_GrouplshGN(ierr,cctkGH,4,lsh_4d,"testarrays::foo4d")

      call CCTK_GroupnghostzonesGN(ierr,cctkGH,1,nghostzones_1d,"testarr
     &ays::foo1d")
      call CCTK_GroupnghostzonesGN(ierr,cctkGH,2,nghostzones_2d,"testarr
     &ays::foo2d")
      call CCTK_GroupnghostzonesGN(ierr,cctkGH,3,nghostzones_3d,"testarr
     &ays::foo3d")
      call CCTK_GroupnghostzonesGN(ierr,cctkGH,4,nghostzones_4d,"testarr
     &ays::foo4d")

c
c
      print *,"1D Array size is ",lsh_1d(1)
      do i=1+nghostzones_1d(1),lsh_1d(1)-nghostzones_1d(1)
         gf1d(i)=gf1d(i)+1
      end do
      print *,"Syncing 1D array ..."
      call CCTK_SyncGroup(ierr,cctkGH,"testarrays::foo1d")

c
c
      print *,"2D Array size is ",lsh_2d(1),lsh_2d(2)
      do i=1+nghostzones_2d(1),lsh_2d(1)-nghostzones_2d(1)
         do j=1+nghostzones_2d(2),lsh_2d(2)-nghostzones_2d(2)
            gf2d(i,j)=gf2d(i,j)+1
         end do
      end do
      print *,"Syncing 2D array ..."
      call CCTK_SyncGroup(ierr,cctkGH,"testarrays::foo2d")
      
c
c
      print *,"3D Array size is ",lsh_3d(1),lsh_3d(2),lsh_3d(3)
      do i=1+nghostzones_3d(1),lsh_3d(1)-nghostzones_3d(1)
         do j=1+nghostzones_3d(2),lsh_3d(2)-nghostzones_3d(2)
            do k=1+nghostzones_3d(3),lsh_3d(3)-nghostzones_3d(3)
               gf3d(i,j,k)=gf3d(i,j,k)+1
            end do
         end do
      end do
      print *,"Syncing 3D array ..."
      call CCTK_SyncGroup(ierr,cctkGH,"testarrays::foo3d")
      print *
      
c
c
      print *,"4D Array size is ",lsh_4d(1),lsh_4d(2),lsh_4d(3),lsh_4d(4
     &)
      do i=1+nghostzones_4d(1),lsh_4d(1)-nghostzones_4d(1)
         do j=1+nghostzones_4d(2),lsh_4d(2)-nghostzones_4d(2)
            do k=1+nghostzones_4d(3),lsh_4d(3)-nghostzones_4d(3)
               do m=1+nghostzones_4d(4),lsh_4d(4)-nghostzones_4d(4)
                  gf4d(i,j,k,m)=gf4d(i,j,k,m)+1
               end do
            end do
         end do
      end do
      print *,"Syncing 4D array ..."
      call CCTK_SyncGroup(ierr,cctkGH,"testarrays::foo4d")
      print *

      end subroutine UseFortranArrays

