












      subroutine init_arrays (tile)      


      use Agrif_Util
      interface
        subroutine Sub_Loop_init_arrays(tile,Mmmpi,Lmmpi)
          implicit none
      integer(4), parameter :: LLm0 = 41
      integer(4), parameter :: MMm0 = 42
      integer(4), parameter :: N = 32
      integer(4), parameter :: NP_XI = 1
      integer(4), parameter :: NP_ETA = 4
      integer(4), parameter :: NNODES = NP_XI*NP_ETA
      integer(4), parameter :: NPP = 1
      integer(4), parameter :: NSUB_X = 1
      integer(4), parameter :: NSUB_E = 1
      integer(4), parameter :: NWEIGHT = 1000
      integer(4), parameter :: stdout = 6
      integer(4), parameter :: Np = N+1
      integer(4), parameter :: NSA = 28
      real, parameter :: Vtransform = 2
      integer(4), parameter :: itemp = 1
      integer(4), parameter :: ntrc_temp = 1
      integer(4), parameter :: ntrc_salt = 1
      integer(4), parameter :: ntrc_pas = 0
      integer(4), parameter :: ntrc_bio = 0
      integer(4), parameter :: ntrc_subs = 0
      integer(4), parameter :: ntrc_substot = 0
      integer(4), parameter :: ntrc_sed = 0
      integer(4), parameter :: NTA = itemp+ntrc_salt
      integer(4), parameter :: NT = itemp+ntrc_salt+ntrc_pas+ntrc_bio+nt
     &rc_sed
      integer(4), parameter :: NTot = NT
      integer(4), parameter :: isalt = itemp+1
      integer(4), parameter :: ntrc_diabio = 0
      integer(4), parameter :: ntrc_diats = 0
      integer(4), parameter :: ntrc_diauv = 0
      integer(4), parameter :: ntrc_diavrt = 0
      integer(4), parameter :: ntrc_diaek = 0
      integer(4), parameter :: ntrc_diapv = 0
      integer(4), parameter :: ntrc_diaeddy = 0
      integer(4), parameter :: ntrc_surf = 0
      integer(4) :: Mmmpi
      integer(4) :: Lmmpi
      integer(4) :: tile
        end subroutine Sub_Loop_init_arrays

      end interface
      integer(4) :: tile
      

        call Sub_Loop_init_arrays(tile, Agrif_tabvars_i(8)%iarray0, Agri
     &f_tabvars_i(7)%iarray0)

      end


      subroutine Sub_Loop_init_arrays(tile,Mmmpi,Lmmpi)

      use Agrif_Types, only : Agrif_tabvars

      implicit none

      integer(4), parameter :: LLm0 = 41
      integer(4), parameter :: MMm0 = 42
      integer(4), parameter :: N = 32
      integer(4), parameter :: NP_XI = 1
      integer(4), parameter :: NP_ETA = 4
      integer(4), parameter :: NNODES = NP_XI*NP_ETA
      integer(4), parameter :: NPP = 1
      integer(4), parameter :: NSUB_X = 1
      integer(4), parameter :: NSUB_E = 1
      integer(4), parameter :: NWEIGHT = 1000
      integer(4), parameter :: stdout = 6
      integer(4), parameter :: Np = N+1
      integer(4), parameter :: NSA = 28
      real, parameter :: Vtransform = 2
      integer(4), parameter :: itemp = 1
      integer(4), parameter :: ntrc_temp = 1
      integer(4), parameter :: ntrc_salt = 1
      integer(4), parameter :: ntrc_pas = 0
      integer(4), parameter :: ntrc_bio = 0
      integer(4), parameter :: ntrc_subs = 0
      integer(4), parameter :: ntrc_substot = 0
      integer(4), parameter :: ntrc_sed = 0
      integer(4), parameter :: NTA = itemp+ntrc_salt
      integer(4), parameter :: NT = itemp+ntrc_salt+ntrc_pas+ntrc_bio+nt
     &rc_sed
      integer(4), parameter :: NTot = NT
      integer(4), parameter :: isalt = itemp+1
      integer(4), parameter :: ntrc_diabio = 0
      integer(4), parameter :: ntrc_diats = 0
      integer(4), parameter :: ntrc_diauv = 0
      integer(4), parameter :: ntrc_diavrt = 0
      integer(4), parameter :: ntrc_diaek = 0
      integer(4), parameter :: ntrc_diapv = 0
      integer(4), parameter :: ntrc_diaeddy = 0
      integer(4), parameter :: ntrc_surf = 0
      integer(4) :: Mmmpi
      integer(4) :: Lmmpi
      integer(4) :: tile

                   

                                            
                             
                                            

                                                             
                                                            
                                           
                                                               
                                    
                                      
                                                          

                       

                                    

                        
                              

                                          
                                             
                          

                        

                                          
                        

                                                        
                      
                              

                                       
                                                                     
                                          
                         

                             

                             

                            

                            

                                             

                            

                                     

                                                               

                         

                                                      
                                                      
                                                                  
                               

                               

                              

                              

                               

                              

                              

                                

                             

                          
      integer(4) :: trd
C$    integer*4 omp_get_thread_num
                                                            
      integer(4) :: chunk_size_X
      integer(4) :: margin_X
      integer(4) :: chunk_size_E
      integer(4) :: margin_E
                                             
      integer(4) :: Istr
      integer(4) :: Iend
      integer(4) :: Jstr
      integer(4) :: Jend
      integer(4) :: i_X
      integer(4) :: j_E
      chunk_size_X=(Lmmpi+NSUB_X-1)/NSUB_X
      margin_X=(NSUB_X*chunk_size_X-Lmmpi)/2
      chunk_size_E=(Mmmpi+NSUB_E-1)/NSUB_E
      margin_E=(NSUB_E*chunk_size_E-Mmmpi)/2
      j_E=tile/NSUB_X
      i_X=tile-j_E*NSUB_X
      Istr=1+i_X*chunk_size_X-margin_X
      Iend=Istr+chunk_size_X-1
      Istr=max(Istr,1)
      Iend=min(Iend,Lmmpi)
      Jstr=1+j_E*chunk_size_E-margin_E
      Jend=Jstr+chunk_size_E-1
      Jstr=max(Jstr,1)
      Jend=min(Jend,Mmmpi)
      call init_arrays_tile (Istr,Iend,Jstr,Jend)
      return
       
      

      end subroutine Sub_Loop_init_arrays

      subroutine init_arrays_tile (Istr,Iend,Jstr,Jend)      


      use Agrif_Util
      interface
        subroutine Sub_Loop_init_arrays_tile(Istr,Iend,Jstr,Jend,padd_E,
     &Mm,padd_X,Lm,hbbl_avg,hbbl,hbl_avg,kbl,hbls,ghats,Akt,bvf,Akv,dRde
     &,dRdx,diff3d_v,diff3d_u,diff4_sponge,tnu4,diff4,diff2_sponge,tnu2,
     &diff2,visc2_sponge_p,visc2_sponge_r,visc2_p,visc2,visc2_r,tbry_nor
     &th,vbry_north,ubry_north,vbarbry_north,ubarbry_north,zetabry_north
     &,tbry_south,vbry_south,ubry_south,vbarbry_south,ubarbry_south,zeta
     &bry_south,tbry_east,vbry_east,ubry_east,vbarbry_east,ubarbry_east,
     &zetabry_east,tbry_west,vbry_west,ubry_west,vbarbry_west,ubarbry_we
     &st,zetabry_west,srflxg,srflx_avg,srflx,shflx_sen_avg,shflx_lat_avg
     &,shflx_rlw_avg,shflx_rsw_avg,shflx_sen,shflx_lat,shflx_rlw,shflx_r
     &sw,vwndg,uwndg,radswg,radlwg,prateg,rhumg,tairg,vwnd,uwnd,wspd,rad
     &sw,radlw,prate,rhum,tair,btflx,stflxg,stflx_avg,stflx,bvstrg,bustr
     &g,svstr_avg,sustr_avg,wstr_avg,bostr_avg,bvstr,bustr,svstrg,sustrg
     &,svstr,sustr,t_avg,t,got_tini,bvf_avg,omega_avg,We,w_avg,v_avg,u_a
     &vg,rho_avg,rho,v,u,DV_avg2,DU_avg2,DV_avg1,DU_avg1,Zt_avg1,rvfrc_b
     &ak,rufrc_bak,rufrc,vbar_avg,ubar_avg,zeta_avg,vbar,ubar,zeta,NORTH
     &_INTER,Mmmpi,SOUTH_INTER,EAST_INTER,Lmmpi,WEST_INTER)
          implicit none
      integer(4), parameter :: LLm0 = 41
      integer(4), parameter :: MMm0 = 42
      integer(4), parameter :: N = 32
      integer(4), parameter :: NP_XI = 1
      integer(4), parameter :: NP_ETA = 4
      integer(4), parameter :: NNODES = NP_XI*NP_ETA
      integer(4), parameter :: NPP = 1
      integer(4), parameter :: NSUB_X = 1
      integer(4), parameter :: NSUB_E = 1
      integer(4), parameter :: NWEIGHT = 1000
      integer(4), parameter :: stdout = 6
      integer(4), parameter :: Np = N+1
      integer(4), parameter :: NSA = 28
      real, parameter :: Vtransform = 2
      integer(4), parameter :: itemp = 1
      integer(4), parameter :: ntrc_temp = 1
      integer(4), parameter :: ntrc_salt = 1
      integer(4), parameter :: ntrc_pas = 0
      integer(4), parameter :: ntrc_bio = 0
      integer(4), parameter :: ntrc_subs = 0
      integer(4), parameter :: ntrc_substot = 0
      integer(4), parameter :: ntrc_sed = 0
      integer(4), parameter :: NTA = itemp+ntrc_salt
      integer(4), parameter :: NT = itemp+ntrc_salt+ntrc_pas+ntrc_bio+nt
     &rc_sed
      integer(4), parameter :: NTot = NT
      integer(4), parameter :: isalt = itemp+1
      integer(4), parameter :: ntrc_diabio = 0
      integer(4), parameter :: ntrc_diats = 0
      integer(4), parameter :: ntrc_diauv = 0
      integer(4), parameter :: ntrc_diavrt = 0
      integer(4), parameter :: ntrc_diaek = 0
      integer(4), parameter :: ntrc_diapv = 0
      integer(4), parameter :: ntrc_diaeddy = 0
      integer(4), parameter :: ntrc_surf = 0
      integer(4), parameter :: filetype_his = 1
      integer(4), parameter :: filetype_avg = 2
      integer(4), parameter :: filetype_dia = 3
      integer(4), parameter :: filetype_dia_avg = 4
      integer(4), parameter :: filetype_diaM = 5
      integer(4), parameter :: filetype_diaM_avg = 6
      integer(4), parameter :: filetype_diags_vrt = 7
      integer(4), parameter :: filetype_diags_vrt_avg = 8
      integer(4), parameter :: filetype_diags_ek = 9
      integer(4), parameter :: filetype_diags_ek_avg = 10
      integer(4), parameter :: filetype_diags_pv = 11
      integer(4), parameter :: filetype_diags_pv_avg = 12
      integer(4), parameter :: filetype_diags_eddy_avg = 17
      integer(4), parameter :: filetype_surf = 13
      integer(4), parameter :: filetype_surf_avg = 14
      integer(4), parameter :: filetype_diabio = 15
      integer(4), parameter :: filetype_diabio_avg = 16
      integer(4), parameter :: indxTime = 1
      integer(4), parameter :: indxZ = 2
      integer(4), parameter :: indxUb = 3
      integer(4), parameter :: indxVb = 4
      integer(4), parameter :: indxU = 6
      integer(4), parameter :: indxV = 7
      integer(4), parameter :: indxT = indxV+1
      integer(4), parameter :: indxS = indxV+ntrc_temp+1
      integer(4), parameter :: indxBSD = indxV+ntrc_temp+ntrc_salt+ntrc_
     &pas+ntrc_bio+1
      integer(4), parameter :: indxBSS = 101
      integer(4), parameter :: indxO = indxV+ntrc_temp+ntrc_salt+ntrc_pa
     &s+ntrc_bio+ntrc_sed+ntrc_substot+ntrc_diats+ntrc_diauv+ntrc_diavrt
     &+ntrc_diaek+ntrc_diapv+ntrc_diaeddy+ntrc_surf+ntrc_diabio+1
      integer(4), parameter :: indxW = indxO+1
      integer(4), parameter :: indxR = indxO+2
      integer(4), parameter :: indxVisc = indxO+3
      integer(4), parameter :: indxDiff = indxO+4
      integer(4), parameter :: indxAkv = indxO+5
      integer(4), parameter :: indxAkt = indxO+6
      integer(4), parameter :: indxAks = indxAkv+ntrc_temp+4
      integer(4), parameter :: indxHbl = indxAkv+ntrc_temp+5
      integer(4), parameter :: indxHbbl = indxAkv+ntrc_temp+6
      integer(4), parameter :: indxSSH = indxAkv+ntrc_temp+12
      integer(4), parameter :: indxbvf = indxSSH+1
      integer(4), parameter :: indxSUSTR = indxSSH+2
      integer(4), parameter :: indxSVSTR = indxSSH+3
      integer(4), parameter :: indxTime2 = indxSSH+4
      integer(4), parameter :: indxShflx = indxSUSTR+5
      integer(4), parameter :: indxSwflx = indxShflx+1
      integer(4), parameter :: indxShflx_rsw = indxShflx+2
      integer(4), parameter :: indxSST = indxShflx_rsw+1
      integer(4), parameter :: indxdQdSST = indxShflx_rsw+2
      integer(4), parameter :: indxWSPD = indxSST+3
      integer(4), parameter :: indxTAIR = indxSST+4
      integer(4), parameter :: indxRHUM = indxSST+5
      integer(4), parameter :: indxRADLW = indxSST+6
      integer(4), parameter :: indxRADSW = indxSST+7
      integer(4), parameter :: indxPRATE = indxSST+8
      integer(4), parameter :: indxUWND = indxSST+9
      integer(4), parameter :: indxVWND = indxSST+10
      integer(4), parameter :: indxPATM = indxSST+11
      integer(4), parameter :: indxShflx_rlw = indxSST+12
      integer(4), parameter :: indxShflx_lat = indxSST+13
      integer(4), parameter :: indxShflx_sen = indxSST+14
      integer(4), parameter :: indxWstr = indxSUSTR+23
      integer(4), parameter :: indxUWstr = indxSUSTR+24
      integer(4), parameter :: indxVWstr = indxSUSTR+25
      integer(4), parameter :: indxBostr = indxSUSTR+26
      integer(4), parameter :: indxBustr = indxSUSTR+27
      integer(4), parameter :: indxBvstr = indxBustr+1
      integer(4), parameter :: indxWWA = indxSUSTR+42
      integer(4), parameter :: indxWWD = indxWWA+1
      integer(4), parameter :: indxWWP = indxWWA+2
      integer(4), parameter :: r2dvar = 0
      integer(4), parameter :: u2dvar = 1
      integer(4), parameter :: v2dvar = 2
      integer(4), parameter :: p2dvar = 3
      integer(4), parameter :: r3dvar = 4
      integer(4), parameter :: u3dvar = 5
      integer(4), parameter :: v3dvar = 6
      integer(4), parameter :: p3dvar = 7
      integer(4), parameter :: w3dvar = 8
      integer(4), parameter :: pw3dvar = 11
      integer(4), parameter :: b3dvar = 12
      real, parameter :: qp2 = 0.0000172D0
      real, parameter :: Gslope_max = 1.D0
      real, parameter :: Rslope_max = 0.05D0
      real, parameter :: pi = 3.14159265358979323846D0
      real, parameter :: deg2rad = pi/180.D0
      real, parameter :: rad2deg = 180.D0/pi
      real, parameter :: Eradius = 6371315.0D0
      real, parameter :: Erotation = 7.292115090D-5
      real, parameter :: day2sec = 86400.D0
      real, parameter :: sec2day = 1.D0/86400.D0
      real, parameter :: year2day = 365.25D0
      real, parameter :: day2year = 1.D0/365.25D0
      real, parameter :: jul_off = 2440000.D0
      real, parameter :: g = 9.81D0
      real, parameter :: Cp = 3985.0D0
      real, parameter :: vonKar = 0.41D0
      real, parameter :: spval = -999.0D0
      logical, parameter :: mask_val = .true.
      real, parameter :: init = 0.D0
      integer(4) :: padd_E
      integer(4) :: Mm
      integer(4) :: padd_X
      integer(4) :: Lm
      real :: visc2
      logical :: NORTH_INTER
      integer(4) :: Mmmpi
      logical :: SOUTH_INTER
      logical :: EAST_INTER
      integer(4) :: Lmmpi
      logical :: WEST_INTER
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: hbbl_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: hbbl
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: hbl_avg
      integer(4), dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: kbl
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: hbls
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,0:N) :: ghats
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,0:N,1:2) :: Akt
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,0:N) :: bvf
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,0:N) :: Akv
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N) :: dRde
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N) :: dRdx
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N) :: diff3d_v
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N) :: diff3d_u
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: diff4_sponge
      real, dimension(1:NT) :: tnu4
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:NT) :: diff4
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: diff2_sponge
      real, dimension(1:NT) :: tnu2
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:NT) :: diff2
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: visc2_sponge_p
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: visc2_sponge_r
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: visc2_p
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: visc2_r
      real, dimension(-1:Lm+2+padd_X,1:N,1:NT) :: tbry_north
      real, dimension(-1:Lm+2+padd_X,1:N) :: vbry_north
      real, dimension(-1:Lm+2+padd_X,1:N) :: ubry_north
      real, dimension(-1:Lm+2+padd_X) :: vbarbry_north
      real, dimension(-1:Lm+2+padd_X) :: ubarbry_north
      real, dimension(-1:Lm+2+padd_X) :: zetabry_north
      real, dimension(-1:Lm+2+padd_X,1:N,1:NT) :: tbry_south
      real, dimension(-1:Lm+2+padd_X,1:N) :: vbry_south
      real, dimension(-1:Lm+2+padd_X,1:N) :: ubry_south
      real, dimension(-1:Lm+2+padd_X) :: vbarbry_south
      real, dimension(-1:Lm+2+padd_X) :: ubarbry_south
      real, dimension(-1:Lm+2+padd_X) :: zetabry_south
      real, dimension(-1:Mm+2+padd_E,1:N,1:NT) :: tbry_east
      real, dimension(-1:Mm+2+padd_E,1:N) :: vbry_east
      real, dimension(-1:Mm+2+padd_E,1:N) :: ubry_east
      real, dimension(-1:Mm+2+padd_E) :: vbarbry_east
      real, dimension(-1:Mm+2+padd_E) :: ubarbry_east
      real, dimension(-1:Mm+2+padd_E) :: zetabry_east
      real, dimension(-1:Mm+2+padd_E,1:N,1:NT) :: tbry_west
      real, dimension(-1:Mm+2+padd_E,1:N) :: vbry_west
      real, dimension(-1:Mm+2+padd_E,1:N) :: ubry_west
      real, dimension(-1:Mm+2+padd_E) :: vbarbry_west
      real, dimension(-1:Mm+2+padd_E) :: ubarbry_west
      real, dimension(-1:Mm+2+padd_E) :: zetabry_west
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: srflxg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: srflx_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: srflx
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: shflx_sen_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: shflx_lat_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: shflx_rlw_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: shflx_rsw_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: shflx_sen
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: shflx_lat
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: shflx_rlw
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: shflx_rsw
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: vwndg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: uwndg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: radswg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: radlwg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: prateg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: rhumg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: tairg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: vwnd
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: uwnd
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: wspd
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: radsw
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: radlw
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: prate
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: rhum
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: tair
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:NT) :: btflx
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2,1:NT) :: stflxg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:NT) :: stflx_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:NT) :: stflx
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: bvstrg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: bustrg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: svstr_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: sustr_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: wstr_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: bostr_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: bvstr
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: bustr
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: svstrg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: sustrg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: svstr
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: sustr
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N,1:NT) :: t_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N,1:3,1:NT) :: t
      logical, dimension(1:NT) :: got_tini
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,0:N) :: bvf_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,0:N) :: omega_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,0:N) :: We
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N) :: w_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N) :: v_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N) :: u_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N) :: rho_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N) :: rho
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N,1:3) :: v
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N,1:3) :: u
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: DV_avg2
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: DU_avg2
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:5) :: DV_avg1
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:5) :: DU_avg1
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: Zt_avg1
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: rvfrc_bak
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: rufrc_bak
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: rufrc
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: vbar_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: ubar_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: zeta_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:4) :: vbar
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:4) :: ubar
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:4) :: zeta
      integer(4) :: Istr
      integer(4) :: Iend
      integer(4) :: Jstr
      integer(4) :: Jend
        end subroutine Sub_Loop_init_arrays_tile

      end interface
      integer(4) :: Istr
      integer(4) :: Iend
      integer(4) :: Jstr
      integer(4) :: Jend
      

        call Sub_Loop_init_arrays_tile(Istr,Iend,Jstr,Jend, Agrif_tabvar
     &s_i(14)%iarray0, Agrif_tabvars_i(4)%iarray0, Agrif_tabvars_i(13)%i
     &array0, Agrif_tabvars_i(2)%iarray0, Agrif_tabvars(273)%array2, Agr
     &if_tabvars(120)%array2, Agrif_tabvars(274)%array2, Agrif_tabvars_i
     &(244)%iarray2, Agrif_tabvars(119)%array3, Agrif_tabvars(118)%array
     &3, Agrif_tabvars(123)%array4, Agrif_tabvars(122)%array3, Agrif_tab
     &vars(124)%array3, Agrif_tabvars(126)%array3, Agrif_tabvars(127)%ar
     &ray3, Agrif_tabvars(128)%array3, Agrif_tabvars(129)%array3, Agrif_
     &tabvars(131)%array2, Agrif_tabvars(6)%array1, Agrif_tabvars(130)%a
     &rray3, Agrif_tabvars(133)%array2, Agrif_tabvars(5)%array1, Agrif_t
     &abvars(132)%array3, Agrif_tabvars(134)%array2, Agrif_tabvars(135)%
     &array2, Agrif_tabvars(136)%array2, Agrif_tabvars_r(20)%array0, Agr
     &if_tabvars(137)%array2, Agrif_tabvars(163)%array3, Agrif_tabvars(1
     &65)%array2, Agrif_tabvars(167)%array2, Agrif_tabvars(169)%array1, 
     &Agrif_tabvars(171)%array1, Agrif_tabvars(173)%array1, Agrif_tabvar
     &s(175)%array3, Agrif_tabvars(177)%array2, Agrif_tabvars(179)%array
     &2, Agrif_tabvars(181)%array1, Agrif_tabvars(183)%array1, Agrif_tab
     &vars(185)%array1, Agrif_tabvars(187)%array3, Agrif_tabvars(189)%ar
     &ray2, Agrif_tabvars(191)%array2, Agrif_tabvars(193)%array1, Agrif_
     &tabvars(195)%array1, Agrif_tabvars(197)%array1, Agrif_tabvars(199)
     &%array3, Agrif_tabvars(201)%array2, Agrif_tabvars(203)%array2, Agr
     &if_tabvars(205)%array1, Agrif_tabvars(207)%array1, Agrif_tabvars(2
     &09)%array1, Agrif_tabvars(214)%array3, Agrif_tabvars(284)%array2, 
     &Agrif_tabvars(215)%array2, Agrif_tabvars(269)%array2, Agrif_tabvar
     &s(270)%array2, Agrif_tabvars(271)%array2, Agrif_tabvars(272)%array
     &2, Agrif_tabvars(246)%array2, Agrif_tabvars(247)%array2, Agrif_tab
     &vars(248)%array2, Agrif_tabvars(249)%array2, Agrif_tabvars(225)%ar
     &ray3, Agrif_tabvars(226)%array3, Agrif_tabvars(227)%array3, Agrif_
     &tabvars(228)%array3, Agrif_tabvars(229)%array3, Agrif_tabvars(230)
     &%array3, Agrif_tabvars(231)%array3, Agrif_tabvars(232)%array2, Agr
     &if_tabvars(233)%array2, Agrif_tabvars(234)%array2, Agrif_tabvars(2
     &35)%array2, Agrif_tabvars(236)%array2, Agrif_tabvars(237)%array2, 
     &Agrif_tabvars(238)%array2, Agrif_tabvars(239)%array2, Agrif_tabvar
     &s(240)%array3, Agrif_tabvars(245)%array4, Agrif_tabvars(276)%array
     &3, Agrif_tabvars(250)%array3, Agrif_tabvars(255)%array3, Agrif_tab
     &vars(256)%array3, Agrif_tabvars(285)%array2, Agrif_tabvars(286)%ar
     &ray2, Agrif_tabvars(287)%array2, Agrif_tabvars(290)%array2, Agrif_
     &tabvars(257)%array2, Agrif_tabvars(258)%array2, Agrif_tabvars(262)
     &%array3, Agrif_tabvars(263)%array3, Agrif_tabvars(264)%array2, Agr
     &if_tabvars(265)%array2, Agrif_tabvars(281)%array4, Agrif_tabvars(1
     &48)%array5, Agrif_tabvars_l(5)%larray1, Agrif_tabvars(278)%array3,
     & Agrif_tabvars(279)%array3, Agrif_tabvars(141)%array3, Agrif_tabva
     &rs(277)%array3, Agrif_tabvars(282)%array3, Agrif_tabvars(283)%arra
     &y3, Agrif_tabvars(280)%array3, Agrif_tabvars(139)%array3, Agrif_ta
     &bvars(149)%array4, Agrif_tabvars(150)%array4, Agrif_tabvars(151)%a
     &rray2, Agrif_tabvars(152)%array2, Agrif_tabvars(153)%array3, Agrif
     &_tabvars(154)%array3, Agrif_tabvars(155)%array2, Agrif_tabvars(156
     &)%array3, Agrif_tabvars(157)%array3, Agrif_tabvars(159)%array2, Ag
     &rif_tabvars(291)%array2, Agrif_tabvars(292)%array2, Agrif_tabvars(
     &293)%array2, Agrif_tabvars(73)%array3, Agrif_tabvars(74)%array3, A
     &grif_tabvars(75)%array3, Agrif_tabvars_l(13)%larray0, Agrif_tabvar
     &s_i(8)%iarray0, Agrif_tabvars_l(14)%larray0, Agrif_tabvars_l(11)%l
     &array0, Agrif_tabvars_i(7)%iarray0, Agrif_tabvars_l(12)%larray0)

      end


      subroutine Sub_Loop_init_arrays_tile(Istr,Iend,Jstr,Jend,padd_E,Mm
     &,padd_X,Lm,hbbl_avg,hbbl,hbl_avg,kbl,hbls,ghats,Akt,bvf,Akv,dRde,d
     &Rdx,diff3d_v,diff3d_u,diff4_sponge,tnu4,diff4,diff2_sponge,tnu2,di
     &ff2,visc2_sponge_p,visc2_sponge_r,visc2_p,visc2,visc2_r,tbry_north
     &,vbry_north,ubry_north,vbarbry_north,ubarbry_north,zetabry_north,t
     &bry_south,vbry_south,ubry_south,vbarbry_south,ubarbry_south,zetabr
     &y_south,tbry_east,vbry_east,ubry_east,vbarbry_east,ubarbry_east,ze
     &tabry_east,tbry_west,vbry_west,ubry_west,vbarbry_west,ubarbry_west
     &,zetabry_west,srflxg,srflx_avg,srflx,shflx_sen_avg,shflx_lat_avg,s
     &hflx_rlw_avg,shflx_rsw_avg,shflx_sen,shflx_lat,shflx_rlw,shflx_rsw
     &,vwndg,uwndg,radswg,radlwg,prateg,rhumg,tairg,vwnd,uwnd,wspd,radsw
     &,radlw,prate,rhum,tair,btflx,stflxg,stflx_avg,stflx,bvstrg,bustrg,
     &svstr_avg,sustr_avg,wstr_avg,bostr_avg,bvstr,bustr,svstrg,sustrg,s
     &vstr,sustr,t_avg,t,got_tini,bvf_avg,omega_avg,We,w_avg,v_avg,u_avg
     &,rho_avg,rho,v,u,DV_avg2,DU_avg2,DV_avg1,DU_avg1,Zt_avg1,rvfrc_bak
     &,rufrc_bak,rufrc,vbar_avg,ubar_avg,zeta_avg,vbar,ubar,zeta,NORTH_I
     &NTER,Mmmpi,SOUTH_INTER,EAST_INTER,Lmmpi,WEST_INTER)

      use Agrif_Types, only : Agrif_tabvars


      include 'mpif.h'
      integer(4), parameter :: LLm0 = 41
      integer(4), parameter :: MMm0 = 42
      integer(4), parameter :: N = 32
      integer(4), parameter :: NP_XI = 1
      integer(4), parameter :: NP_ETA = 4
      integer(4), parameter :: NNODES = NP_XI*NP_ETA
      integer(4), parameter :: NPP = 1
      integer(4), parameter :: NSUB_X = 1
      integer(4), parameter :: NSUB_E = 1
      integer(4), parameter :: NWEIGHT = 1000
      integer(4), parameter :: stdout = 6
      integer(4), parameter :: Np = N+1
      integer(4), parameter :: NSA = 28
      real, parameter :: Vtransform = 2
      integer(4), parameter :: itemp = 1
      integer(4), parameter :: ntrc_temp = 1
      integer(4), parameter :: ntrc_salt = 1
      integer(4), parameter :: ntrc_pas = 0
      integer(4), parameter :: ntrc_bio = 0
      integer(4), parameter :: ntrc_subs = 0
      integer(4), parameter :: ntrc_substot = 0
      integer(4), parameter :: ntrc_sed = 0
      integer(4), parameter :: NTA = itemp+ntrc_salt
      integer(4), parameter :: NT = itemp+ntrc_salt+ntrc_pas+ntrc_bio+nt
     &rc_sed
      integer(4), parameter :: NTot = NT
      integer(4), parameter :: isalt = itemp+1
      integer(4), parameter :: ntrc_diabio = 0
      integer(4), parameter :: ntrc_diats = 0
      integer(4), parameter :: ntrc_diauv = 0
      integer(4), parameter :: ntrc_diavrt = 0
      integer(4), parameter :: ntrc_diaek = 0
      integer(4), parameter :: ntrc_diapv = 0
      integer(4), parameter :: ntrc_diaeddy = 0
      integer(4), parameter :: ntrc_surf = 0
      integer(4), parameter :: filetype_his = 1
      integer(4), parameter :: filetype_avg = 2
      integer(4), parameter :: filetype_dia = 3
      integer(4), parameter :: filetype_dia_avg = 4
      integer(4), parameter :: filetype_diaM = 5
      integer(4), parameter :: filetype_diaM_avg = 6
      integer(4), parameter :: filetype_diags_vrt = 7
      integer(4), parameter :: filetype_diags_vrt_avg = 8
      integer(4), parameter :: filetype_diags_ek = 9
      integer(4), parameter :: filetype_diags_ek_avg = 10
      integer(4), parameter :: filetype_diags_pv = 11
      integer(4), parameter :: filetype_diags_pv_avg = 12
      integer(4), parameter :: filetype_diags_eddy_avg = 17
      integer(4), parameter :: filetype_surf = 13
      integer(4), parameter :: filetype_surf_avg = 14
      integer(4), parameter :: filetype_diabio = 15
      integer(4), parameter :: filetype_diabio_avg = 16
      integer(4), parameter :: indxTime = 1
      integer(4), parameter :: indxZ = 2
      integer(4), parameter :: indxUb = 3
      integer(4), parameter :: indxVb = 4
      integer(4), parameter :: indxU = 6
      integer(4), parameter :: indxV = 7
      integer(4), parameter :: indxT = indxV+1
      integer(4), parameter :: indxS = indxV+ntrc_temp+1
      integer(4), parameter :: indxBSD = indxV+ntrc_temp+ntrc_salt+ntrc_
     &pas+ntrc_bio+1
      integer(4), parameter :: indxBSS = 101
      integer(4), parameter :: indxO = indxV+ntrc_temp+ntrc_salt+ntrc_pa
     &s+ntrc_bio+ntrc_sed+ntrc_substot+ntrc_diats+ntrc_diauv+ntrc_diavrt
     &+ntrc_diaek+ntrc_diapv+ntrc_diaeddy+ntrc_surf+ntrc_diabio+1
      integer(4), parameter :: indxW = indxO+1
      integer(4), parameter :: indxR = indxO+2
      integer(4), parameter :: indxVisc = indxO+3
      integer(4), parameter :: indxDiff = indxO+4
      integer(4), parameter :: indxAkv = indxO+5
      integer(4), parameter :: indxAkt = indxO+6
      integer(4), parameter :: indxAks = indxAkv+ntrc_temp+4
      integer(4), parameter :: indxHbl = indxAkv+ntrc_temp+5
      integer(4), parameter :: indxHbbl = indxAkv+ntrc_temp+6
      integer(4), parameter :: indxSSH = indxAkv+ntrc_temp+12
      integer(4), parameter :: indxbvf = indxSSH+1
      integer(4), parameter :: indxSUSTR = indxSSH+2
      integer(4), parameter :: indxSVSTR = indxSSH+3
      integer(4), parameter :: indxTime2 = indxSSH+4
      integer(4), parameter :: indxShflx = indxSUSTR+5
      integer(4), parameter :: indxSwflx = indxShflx+1
      integer(4), parameter :: indxShflx_rsw = indxShflx+2
      integer(4), parameter :: indxSST = indxShflx_rsw+1
      integer(4), parameter :: indxdQdSST = indxShflx_rsw+2
      integer(4), parameter :: indxWSPD = indxSST+3
      integer(4), parameter :: indxTAIR = indxSST+4
      integer(4), parameter :: indxRHUM = indxSST+5
      integer(4), parameter :: indxRADLW = indxSST+6
      integer(4), parameter :: indxRADSW = indxSST+7
      integer(4), parameter :: indxPRATE = indxSST+8
      integer(4), parameter :: indxUWND = indxSST+9
      integer(4), parameter :: indxVWND = indxSST+10
      integer(4), parameter :: indxPATM = indxSST+11
      integer(4), parameter :: indxShflx_rlw = indxSST+12
      integer(4), parameter :: indxShflx_lat = indxSST+13
      integer(4), parameter :: indxShflx_sen = indxSST+14
      integer(4), parameter :: indxWstr = indxSUSTR+23
      integer(4), parameter :: indxUWstr = indxSUSTR+24
      integer(4), parameter :: indxVWstr = indxSUSTR+25
      integer(4), parameter :: indxBostr = indxSUSTR+26
      integer(4), parameter :: indxBustr = indxSUSTR+27
      integer(4), parameter :: indxBvstr = indxBustr+1
      integer(4), parameter :: indxWWA = indxSUSTR+42
      integer(4), parameter :: indxWWD = indxWWA+1
      integer(4), parameter :: indxWWP = indxWWA+2
      integer(4), parameter :: r2dvar = 0
      integer(4), parameter :: u2dvar = 1
      integer(4), parameter :: v2dvar = 2
      integer(4), parameter :: p2dvar = 3
      integer(4), parameter :: r3dvar = 4
      integer(4), parameter :: u3dvar = 5
      integer(4), parameter :: v3dvar = 6
      integer(4), parameter :: p3dvar = 7
      integer(4), parameter :: w3dvar = 8
      integer(4), parameter :: pw3dvar = 11
      integer(4), parameter :: b3dvar = 12
      real, parameter :: qp2 = 0.0000172D0
      real, parameter :: Gslope_max = 1.D0
      real, parameter :: Rslope_max = 0.05D0
      real, parameter :: pi = 3.14159265358979323846D0
      real, parameter :: deg2rad = pi/180.D0
      real, parameter :: rad2deg = 180.D0/pi
      real, parameter :: Eradius = 6371315.0D0
      real, parameter :: Erotation = 7.292115090D-5
      real, parameter :: day2sec = 86400.D0
      real, parameter :: sec2day = 1.D0/86400.D0
      real, parameter :: year2day = 365.25D0
      real, parameter :: day2year = 1.D0/365.25D0
      real, parameter :: jul_off = 2440000.D0
      real, parameter :: g = 9.81D0
      real, parameter :: Cp = 3985.0D0
      real, parameter :: vonKar = 0.41D0
      real, parameter :: spval = -999.0D0
      logical, parameter :: mask_val = .true.
      real, parameter :: init = 0.D0
      integer(4) :: padd_E
      integer(4) :: Mm
      integer(4) :: padd_X
      integer(4) :: Lm
      real :: visc2
      logical :: NORTH_INTER
      integer(4) :: Mmmpi
      logical :: SOUTH_INTER
      logical :: EAST_INTER
      integer(4) :: Lmmpi
      logical :: WEST_INTER
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: hbbl_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: hbbl
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: hbl_avg
      integer(4), dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: kbl
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: hbls
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,0:N) :: ghats
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,0:N,1:2) :: Akt
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,0:N) :: bvf
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,0:N) :: Akv
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N) :: dRde
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N) :: dRdx
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N) :: diff3d_v
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N) :: diff3d_u
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: diff4_sponge
      real, dimension(1:NT) :: tnu4
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:NT) :: diff4
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: diff2_sponge
      real, dimension(1:NT) :: tnu2
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:NT) :: diff2
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: visc2_sponge_p
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: visc2_sponge_r
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: visc2_p
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: visc2_r
      real, dimension(-1:Lm+2+padd_X,1:N,1:NT) :: tbry_north
      real, dimension(-1:Lm+2+padd_X,1:N) :: vbry_north
      real, dimension(-1:Lm+2+padd_X,1:N) :: ubry_north
      real, dimension(-1:Lm+2+padd_X) :: vbarbry_north
      real, dimension(-1:Lm+2+padd_X) :: ubarbry_north
      real, dimension(-1:Lm+2+padd_X) :: zetabry_north
      real, dimension(-1:Lm+2+padd_X,1:N,1:NT) :: tbry_south
      real, dimension(-1:Lm+2+padd_X,1:N) :: vbry_south
      real, dimension(-1:Lm+2+padd_X,1:N) :: ubry_south
      real, dimension(-1:Lm+2+padd_X) :: vbarbry_south
      real, dimension(-1:Lm+2+padd_X) :: ubarbry_south
      real, dimension(-1:Lm+2+padd_X) :: zetabry_south
      real, dimension(-1:Mm+2+padd_E,1:N,1:NT) :: tbry_east
      real, dimension(-1:Mm+2+padd_E,1:N) :: vbry_east
      real, dimension(-1:Mm+2+padd_E,1:N) :: ubry_east
      real, dimension(-1:Mm+2+padd_E) :: vbarbry_east
      real, dimension(-1:Mm+2+padd_E) :: ubarbry_east
      real, dimension(-1:Mm+2+padd_E) :: zetabry_east
      real, dimension(-1:Mm+2+padd_E,1:N,1:NT) :: tbry_west
      real, dimension(-1:Mm+2+padd_E,1:N) :: vbry_west
      real, dimension(-1:Mm+2+padd_E,1:N) :: ubry_west
      real, dimension(-1:Mm+2+padd_E) :: vbarbry_west
      real, dimension(-1:Mm+2+padd_E) :: ubarbry_west
      real, dimension(-1:Mm+2+padd_E) :: zetabry_west
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: srflxg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: srflx_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: srflx
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: shflx_sen_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: shflx_lat_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: shflx_rlw_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: shflx_rsw_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: shflx_sen
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: shflx_lat
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: shflx_rlw
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: shflx_rsw
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: vwndg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: uwndg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: radswg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: radlwg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: prateg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: rhumg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: tairg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: vwnd
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: uwnd
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: wspd
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: radsw
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: radlw
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: prate
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: rhum
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: tair
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:NT) :: btflx
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2,1:NT) :: stflxg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:NT) :: stflx_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:NT) :: stflx
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: bvstrg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: bustrg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: svstr_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: sustr_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: wstr_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: bostr_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: bvstr
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: bustr
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: svstrg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: sustrg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: svstr
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: sustr
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N,1:NT) :: t_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N,1:3,1:NT) :: t
      logical, dimension(1:NT) :: got_tini
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,0:N) :: bvf_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,0:N) :: omega_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,0:N) :: We
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N) :: w_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N) :: v_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N) :: u_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N) :: rho_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N) :: rho
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N,1:3) :: v
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:N,1:3) :: u
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: DV_avg2
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: DU_avg2
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:5) :: DV_avg1
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:5) :: DU_avg1
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: Zt_avg1
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: rvfrc_bak
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:2) :: rufrc_bak
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: rufrc
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: vbar_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: ubar_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E) :: zeta_avg
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:4) :: vbar
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:4) :: ubar
      real, dimension(-1:Lm+2+padd_X,-1:Mm+2+padd_E,1:4) :: zeta
      integer(4) :: Istr
      integer(4) :: Iend
      integer(4) :: Jstr
      integer(4) :: Jend

                                            
                             
                                            

                                                             
                                                            
                                           
                                                               
                                    
                                      
                                                          

                       

                                    

                        
                              

                                          
                                             
                          

                        

                                          
                        

                                                        
                      
                              

                                       
                                                                     
                                          
                         

                             

                             

                            

                            

                                             

                            

                                     

                                                               

                         

                                                      
                                                      
                                                                  
                               

                               

                              

                              

                               

                              

                              

                                

                             

                                                                       
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                          
                                                                       
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                   

                                 
      integer(4) :: iloop
      integer(4) :: indextemp
                                                
                                                         

                             
                                  

                      
                               

                      
                                         

                                 
                                                                       
                                                                 
                              

                                                                       
                                                                 
                                                                 
    
                                                                       
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                 

                        
                                             

                        
                                             

                         
                                              

                        
                                              

                        
                                   

                                     
                                                          

                          
                                     

                                         
                                       

                          
                                                                  

                                    
                                                                     

                                                                       
                                                                 
                                            
                                                                       
                                                                 
                                                                 
                                                                 
                                                                 
      

                                                          
                                                                       
                                                                 
                                        

                         
                                       

                          
                                        

                          
                                        

                          
                                        

                                     
                                                                

                                                                
      integer(4) :: indxWEB
      integer(4) :: indxWED
      integer(4) :: indxWER
                                                                       
                                                                 
                                                          

                                                                       
                                                                 
                                                                 
            
                                                                       
                                                                 
                                                                 
       

                                           
                                                       
                                                                       
                                                                 
                                                                 
                              
                                                                       
                                                                 
    
                                                                       
                                                                 
                                                                 
                    
                         
                       
                        
                                                                       
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                               
                         
                                                                       
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                      
                         
                                                                       
                                                                 
 
                                                          
                                                                       
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                    
                                   
                                                                 
                                                                       
                                                                 
                                                                 
                                                                 
                               
                                                                  
                                                                       
                                                                 
                                                                 
                                                                 
                                                                 
     
                                   
                                                                       
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
               
                                            
                                               
                                            
                                               
                                                                 
                                                 
                                 
                                               
                                               
                                               
                                               
                                               
                                               
                                             
                                             
                                             
                                             
                                             
                                               
                                               
                                               
                                               
                                               
                                               
                                               
                                               
                                               
                                               
                                               
                                               
                                              
                                                  
                                                  
                                                  
                                                  
                                                 
                                                 
                                               
                                               
                                                      
                                                 
                                                 
                                                 
                                                 
                                                 
                                                 
                                                 
                                                           
                                                           
                                                           
                                    
                                                
                                                
                                                
                                                
                                                 
                           
                           
                           
                           
                             
                                              
                          
                                                 
                                                 
                                                 
                              
                              
                              
                                                
                                                
                                                   
                                              
                                               
                                                   
                                                
                                                  
                                                 
                                                 
                                                              
                             
                                                 
                                                  
                                                 
                                                
                                             
                                                
                            
               
                                 

                                               
                                               
                                                       
                                                
                                                
                                                      
                                                      
                               
                               
                                       
                                       
                                                  
                                                    
                                                    
                                                  
                                                  
                                    
                                   
                                   
                                   
                                   
                                                   
                                                   
                                                   
                                                                       
                                                                 
                         
                                                    
                                  
                                                    
                                  
                                                    
                                  
                                                   
                                
                                                    
                                  
                                                    
                                  
                                                    
                                  
                                                  
                                                  
                                                     
                                                    
                                                      
                                                        
                                                  
                                                                       
                                                                 
                                                                 
                       
                                                       
                                  
                                                       
                                  
                                                  
                              
                                                   
                                
                                                        
                                                        
                                                        
                                                        
                                          
                                          
                                          
                                          
                                                       
                                    
                                                      
                                                        
                                               
                                                
                                                
                                                     
                                                   
                                                   
                                                         
                                                
                                   
                                                    
                                              
                                     
                                                
                                              
                                            
                                                           
                                                     
                           
                                  
                                                
                                                
                                                     
                                                   
                                                   
                                                         
                                                           
                                                         
                                                              
                                                           
                                                                
                                                                   
                                                                    
                                                                   
                                                   
                                 
                                                    
                                      
                                                    
                                      
                                                    
                                      
                                                    
                                      
                                                      
                                   
                                        
                                        
                                                       
                                                     
                                             
                                                               
                                              
                                                           
                                        
                                                   
                                 
                                               
                                               
                                                
                                                
                                                
                                               
                                               
                                               
                              
                              
                                
                                
                                
                              
                              
                              
                                                  
                                                  
                                                   
                                                   
                                                   
                                                  
                                                  
                                                  
                                  
                                  
                                    
                                    
                                    
                               
                               
                                  
                                                              
                                
                                       
                                                           
                                                                
                                             
                                                  
                                                     
                           
                                                                       
                                                                       
                                                                 
                             
                                                                    
                                       
                                                              
                                                             
                                                                       
                                                                 
                                                      
                                        
                                                
                                 
                                                   
                                   
                                 
                                
                                           
                                         
                                             
                                                              
                                              
                                                                       
                                                  
                                                  
                                                         
                                                         
                                                             
                                                   
                                                   
                                                       
                                                   
                                               
                                 
                                                       
                                                   
                                               
                                 
                                                     
                                                     
                                       
                                       
                                                 
                                                 
                                                   
                               
                               
                               
                                 
                                                    

                        
                   
                                      
                                      
                                                  
                                                    
                                             
                                                  
                              
                                                
                                  
                                                   
                                                    
                                               
                               
                                 
                                 
                                                 
                                
                                                    
                                  
                                              
                             
                                                                  
                                                                       
                                                                 
                                 
                                
                                                                       
                                                                 
                                                                 
                                                                 
                                                        
                                                                       
                                                                 
                                                                 
            
                                              
                                                   
                     
                              
                               
                                 
                                                  
                                                                       
                                                                 
                                                                 
                        
                      
                           
                                                                       
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                    
                           
                                      
                             
                                                 
                                                                       
                                                                 
                     
                                                      
                                                                       
                                                                 
              
                                          
                                                                       
                                                                 
       
                                                           
      real(8) :: Cu_Nbq_X
      real(8) :: Cu_Nbq_Y
      real(8) :: Cu_Nbq_Z
                                             
                                                                       
                                                                 
              
                                                  
                                                                       
                                                                 
              
                                  
                                           
                                                  
                                                                   
                                                               
                                                      
                                                                       
                                                                 
                      
                                                                       
                                                                 
                                                                 
                                                                 
                                                                 
                                                        
                                
                                                                       
                                                                 
                                                        

                                                                       
                                                                 
                  
                                                                       
                                                                 
                                                                 
                                                                 
                  

                          

              
                             

                  
                               

                 
                                

                       
                                   

                           
                                    
                       
                                             
                                                                       
                                                                 
         
                     
                                          
                                                                       
                                                                       
                                                                 
                                                      
                                
                                            
                                                 
                                                             
                                           
                                                    
                                 
                                      
                                
                                            
                                                 
                                                             
                                           
                                                    
                                 
                                      
                                 
                                              
                                                   
                                                                
                                             
                                                       
                                  
                                        
                                 
                                              
                                                   
                                                                
                                             
                                                       
                                  
                                        
                                                                       
                                                                 
              
                                                           
                                                                       
                                                                 
                                                                 
                                  
                                                                       
                                                                 
                                                
                                                                       
                                                                 
                                                                 
                              
                                                                       
                                                                 
                              
                                                                       
                                                                 
                   
                                                  
                                                                       
                                                                 
              
                                                           
                                                                       
                                                                 
                                                                 
                                  
                                                                       
                                                                 
                                                
                                                                       
                                                                 
                                                                 
                              
                                                                       
                                                                 
                              
                                                                       
                                                                 
                  
                                                  
                                                                       
                                                                 
                
                                                              
                                                                       
                                                                 
                                                                 
                                      
                                                                       
                                                                 
                                                      
                                                                       
                                                                 
                                                                 
                                  
                                                                       
                                                                 
                                    
                                                                       
                                                                 
                    
                                                     
                                                                       
                                                                 
                
                                                              
                                                                       
                                                                 
                                                                 
                                      
                                                                       
                                                                 
                                                      
                                                                       
                                                                 
                                                                 
                                  
                                                                       
                                                                 
                                    
                                                                       
                                                                 
                    
                                                     
                                                              
      integer(4) :: i
      integer(4) :: j
      integer(4) :: k
      integer(4) :: itrc
                
                           

                       
                     
      integer(4) :: ierr
                                        
      integer(4) :: IstrR
      integer(4) :: IendR
      integer(4) :: JstrR
      integer(4) :: JendR
      if (Istr.eq.1) then
        if (WEST_INTER) then
          IstrR=Istr-2
        else
          IstrR=Istr-1
        endif
      else
        IstrR=Istr
      endif
      if (Iend.eq.Lmmpi) then
        if (EAST_INTER) then
          IendR=Iend+2
        else
          IendR=Iend+1
        endif
      else
        IendR=Iend
      endif
      if (Jstr.eq.1) then
        if (SOUTH_INTER) then
          JstrR=Jstr-2
        else
          JstrR=Jstr-1
        endif
      else
        JstrR=Jstr
      endif
      if (Jend.eq.Mmmpi) then
        if (NORTH_INTER) then
          JendR=Jend+2
        else
          JendR=Jend+1
        endif
      else
        JendR=Jend
      endif
      do j=JstrR,JendR
        do i=IstrR,IendR
          zeta(i,j,1)=0.D0
          zeta(i,j,2)=init
          zeta(i,j,3)=init
          zeta(i,j,4)=init
          ubar(i,j,1)=init
          ubar(i,j,2)=init
          ubar(i,j,3)=init
          ubar(i,j,4)=init
          vbar(i,j,1)=init
          vbar(i,j,2)=init
          vbar(i,j,3)=init
          vbar(i,j,4)=init
          zeta_avg(i,j)=init
          ubar_avg(i,j)=init
          vbar_avg(i,j)=init
          rufrc(i,j)=init
          rufrc(i,j)=init
          rufrc_bak(i,j,1)=init
          rvfrc_bak(i,j,1)=init
          rufrc_bak(i,j,2)=init
          rvfrc_bak(i,j,2)=init
          Zt_avg1(i,j)=0.D0
          DU_avg1(i,j,1)=0.D0
          DV_avg1(i,j,1)=0.D0
          DU_avg1(i,j,2)=0.D0
          DV_avg1(i,j,2)=0.D0
          DU_avg2(i,j)=0.D0
          DV_avg2(i,j)=0.D0
        enddo
      enddo
      do k=1,N
        do j=JstrR,JendR
          do i=IstrR,IendR
            u(i,j,k,1)=init
            u(i,j,k,2)=init
            v(i,j,k,1)=init
            v(i,j,k,2)=init
            rho(i,j,k) =init
            rho_avg(i,j,k)=init
            u_avg(i,j,k)=init
            v_avg(i,j,k)=init
            w_avg(i,j,k)=init
          enddo
        enddo
      enddo
      do k=0,N
        do j=JstrR,JendR
          do i=IstrR,IendR
             We(i,j,k)=init
            omega_avg(i,j,k)=init
            bvf_avg(i,j,k)=init
          enddo
        enddo
      enddo
      do itrc=1,NT
        got_tini(itrc)=.false.
        do k=1,N
          do j=JstrR,JendR
            do i=IstrR,IendR
              t(i,j,k,1,itrc)=init
              t(i,j,k,2,itrc)=init
              t_avg(i,j,k,itrc)=init
            enddo
          enddo
        enddo
      enddo
      do j=JstrR,JendR
        do i=IstrR,IendR
          sustr(i,j)=init
          svstr(i,j)=init
          sustrg(i,j,1)=init
          svstrg(i,j,1)=init
          sustrg(i,j,2)=init
          svstrg(i,j,2)=init
          bustr(i,j)=init
          bvstr(i,j)=init
          bostr_avg(i,j)=init
          wstr_avg(i,j)=init
          sustr_avg(i,j)=init
          svstr_avg(i,j)=init
          bustrg(i,j,1)=init
          bvstrg(i,j,1)=init
          bustrg(i,j,2)=init
          bvstrg(i,j,2)=init
        enddo
      enddo
      do itrc=1,NT
        do j=JstrR,JendR
          do i=IstrR,IendR
            stflx(i,j,itrc)=init
            stflx_avg(i,j,itrc)=init
            stflxg(i,j,1,itrc)=init
            stflxg(i,j,2,itrc)=init
            btflx(i,j,itrc)=init
          enddo
        enddo
      enddo
      do j=JstrR,JendR
        do i=IstrR,IendR
          tair (i,j)=init
          rhum (i,j)=init
          prate (i,j)=init
          radlw (i,j)=init
          radsw (i,j)=init
          wspd(i,j)=init
          uwnd(i,j)=init
          vwnd(i,j)=init
          tairg(i,j,1)=init
          rhumg (i,j,1)=init
          prateg (i,j,1)=init
          radlwg (i,j,1)=init
          radswg (i,j,1)=init
          tairg(i,j,2)=init
          rhumg (i,j,2)=init
          prateg (i,j,2)=init
          radlwg (i,j,2)=init
          radswg (i,j,2)=init
          uwndg(i,j,1)=init
          vwndg(i,j,1)=init
          uwndg(i,j,2)=init
          vwndg(i,j,2)=init
          shflx_rsw(i,j)=init
          shflx_rlw(i,j)=init
          shflx_lat(i,j)=init
          shflx_sen(i,j)=init
          shflx_rsw_avg(i,j)=init
          shflx_rlw_avg(i,j)=init
          shflx_lat_avg(i,j)=init
          shflx_sen_avg(i,j)=init
          srflx(i,j)=init
          srflx_avg(i,j)=init
          srflxg(i,j,1)=init
          srflxg(i,j,2)=init
        enddo
      enddo
      if (.not.WEST_INTER) then
        do j=JstrR,JendR
          zetabry_west(j)=init
        enddo
        do j=JstrR,JendR
          ubarbry_west(j)=init
          vbarbry_west(j)=init
        enddo
        do k=1,N
          do j=JstrR,JendR
            ubry_west(j,k)=init
            vbry_west(j,k)=init
            do itrc=1,NT
              tbry_west(j,k,itrc)=init
            enddo
          enddo
        enddo
      endif
      if (.not.EAST_INTER) then
        do j=JstrR,JendR
          zetabry_east(j)=init
        enddo
        do j=JstrR,JendR
          ubarbry_east(j)=init
          vbarbry_east(j)=init
        enddo
        do k=1,N
          do j=JstrR,JendR
            ubry_east(j,k)=init
            vbry_east(j,k)=init
            do itrc=1,NT
              tbry_east(j,k,itrc)=init
            enddo
          enddo
        enddo
      endif
      if (.not.SOUTH_INTER) then
        do i=IstrR,IendR
          zetabry_south(i)=init
        enddo
        do i=IstrR,IendR
          ubarbry_south(i)=init
          vbarbry_south(i)=init
        enddo
        do k=1,N
          do i=IstrR,IendR
            ubry_south(i,k)=init
            vbry_south(i,k)=init
            do itrc=1,NT
              tbry_south(i,k,itrc)=init
            enddo
          enddo
        enddo
      endif
      if (.not.NORTH_INTER) then
        do i=IstrR,IendR
          zetabry_north(i)=init
        enddo
        do i=IstrR,IendR
          ubarbry_north(i)=init
          vbarbry_north(i)=init
        enddo
        do k=1,N
          do i=IstrR,IendR
            ubry_north(i,k)=init
            vbry_north(i,k)=init
            do itrc=1,NT
              tbry_north(i,k,itrc)=init
            enddo
          enddo
        enddo
      endif
        do j=JstrR,JendR
          do i=IstrR,IendR
            visc2_r(i,j)=visc2
            visc2_p(i,j)=visc2
            visc2_sponge_r(i,j)=init
            visc2_sponge_p(i,j)=init
          enddo
        enddo
        do itrc=1,NT
          do j=JstrR,JendR
            do i=IstrR,IendR
              diff2(i,j,itrc)=tnu2(itrc)
            enddo
          enddo
        enddo
          do j=JstrR,JendR
            do i=IstrR,IendR
              diff2_sponge(i,j)=init
            enddo
          enddo
        do itrc=1,NT
          do j=JstrR,JendR
            do i=IstrR,IendR
              diff4(i,j,itrc)=tnu4(itrc)
            enddo
          enddo
        enddo
          do j=JstrR,JendR
            do i=IstrR,IendR
              diff4_sponge(i,j)=init
            enddo
          enddo
        do k=1,N
          do j=JstrR,JendR
            do i=IstrR,IendR
              diff3d_u(i,j,k)=init
              diff3d_v(i,j,k)=init
            enddo
          enddo
        enddo
        do k=1,N-1
          do j=JstrR,JendR
            do i=IstrR,IendR
              dRdx(i,j,k)=0.D0
              dRde(i,j,k)=0.D0
            enddo
          enddo
        enddo
      do k=0,N
        do j=JstrR,JendR
          do i=IstrR,IendR
            Akv(i,j,k)=init
            bvf(i,j,k)=init
          enddo
        enddo
        do j=JstrR,JendR
          do i=IstrR,IendR
              Akt(i,j,k,itemp)=init
              Akt(i,j,k,isalt)=init
          enddo
        enddo
      enddo
      do k=1,N
        do j=JstrR,JendR
          do i=IstrR,IendR
            ghats(i,j,k)=init
          enddo
        enddo
      enddo
      do j=JstrR,JendR
        do i=IstrR,IendR
          hbls(i,j,1)=init
          hbls(i,j,2)=init
          kbl(i,j)=init
          hbl_avg(i,j)=init
        enddo
      enddo
      do j=JstrR,JendR
        do i=IstrR,IendR
          hbbl(i,j)=init
          hbbl_avg(i,j)=init
        enddo
      enddo
      return
       
      

      end subroutine Sub_Loop_init_arrays_tile

      module climat_ssh


        implicit none
        public :: Alloc_agrif_climat_ssh
      contains
      subroutine Alloc_agrif_climat_ssh(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : ssh
          if (.not. allocated(Agrif_Gr % tabvars(211)% array2)) then
          allocate(Agrif_Gr % tabvars(211)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(211)% array2 = 0
      endif
      end subroutine Alloc_agrif_climat_ssh
      end module climat_ssh
      module srfdat1


        implicit none
        public :: Alloc_agrif_srfdat1
      contains
      subroutine Alloc_agrif_srfdat1(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : srf_time
          if (.not. allocated(Agrif_Gr % tabvars(212)% array1)) then
          allocate(Agrif_Gr % tabvars(212)% array1(1 : 2))
          Agrif_Gr % tabvars(212)% array1 = 0
      endif
      !! ALLOCATION OF VARIABLE : srflxp
          if (.not. allocated(Agrif_Gr % tabvars(213)% array1)) then
          allocate(Agrif_Gr % tabvars(213)% array1(1 : 2))
          Agrif_Gr % tabvars(213)% array1 = 0
      endif
      end subroutine Alloc_agrif_srfdat1
      end module srfdat1
      module srfdat_srflxg


        implicit none
        public :: Alloc_agrif_srfdat_srflxg
      contains
      subroutine Alloc_agrif_srfdat_srflxg(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : srflxg
          if (.not. allocated(Agrif_Gr % tabvars(214)% array3)) then
          allocate(Agrif_Gr % tabvars(214)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : 2))
          Agrif_Gr % tabvars(214)% array3 = 0
      endif
      end subroutine Alloc_agrif_srfdat_srflxg
      end module srfdat_srflxg
      module forces_srflx


        implicit none
        public :: Alloc_agrif_forces_srflx
      contains
      subroutine Alloc_agrif_forces_srflx(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : srflx
          if (.not. allocated(Agrif_Gr % tabvars(215)% array2)) then
          allocate(Agrif_Gr % tabvars(215)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(215)% array2 = 0
      endif
      end subroutine Alloc_agrif_forces_srflx
      end module forces_srflx
      module bulkdat2_wnd


        implicit none
        public :: Alloc_agrif_bulkdat2_wnd
      contains
      subroutine Alloc_agrif_bulkdat2_wnd(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : vwndp
          if (.not. allocated(Agrif_Gr % tabvars(216)% array1)) then
          allocate(Agrif_Gr % tabvars(216)% array1(1 : 2))
          Agrif_Gr % tabvars(216)% array1 = 0
      endif
      !! ALLOCATION OF VARIABLE : uwndp
          if (.not. allocated(Agrif_Gr % tabvars(217)% array1)) then
          allocate(Agrif_Gr % tabvars(217)% array1(1 : 2))
          Agrif_Gr % tabvars(217)% array1 = 0
      endif
      end subroutine Alloc_agrif_bulkdat2_wnd
      end module bulkdat2_wnd
      module bulkdat2_tim


        implicit none
        public :: Alloc_agrif_bulkdat2_tim
      contains
      subroutine Alloc_agrif_bulkdat2_tim(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : bulk_time
          if (.not. allocated(Agrif_Gr % tabvars(218)% array1)) then
          allocate(Agrif_Gr % tabvars(218)% array1(1 : 2))
          Agrif_Gr % tabvars(218)% array1 = 0
      endif
      end subroutine Alloc_agrif_bulkdat2_tim
      end module bulkdat2_tim
      module bulkdat2_for


        implicit none
        public :: Alloc_agrif_bulkdat2_for
      contains
      subroutine Alloc_agrif_bulkdat2_for(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : radswp
      do i = 219,223
          if (.not. allocated(Agrif_Gr % tabvars(i)% array1)) then
          allocate(Agrif_Gr % tabvars(i)% array1(1 : 2))
          Agrif_Gr % tabvars(i)% array1 = 0
      endif
      enddo
      end subroutine Alloc_agrif_bulkdat2_for
      end module bulkdat2_for
      module bulkdat_wspdg


        implicit none
        public :: Alloc_agrif_bulkdat_wspdg
      contains
      subroutine Alloc_agrif_bulkdat_wspdg(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : wspdg
          if (.not. allocated(Agrif_Gr % tabvars(224)% array3)) then
          allocate(Agrif_Gr % tabvars(224)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : 2))
          Agrif_Gr % tabvars(224)% array3 = 0
      endif
      end subroutine Alloc_agrif_bulkdat_wspdg
      end module bulkdat_wspdg
      module bulk_vwndg


        implicit none
        public :: Alloc_agrif_bulk_vwndg
      contains
      subroutine Alloc_agrif_bulk_vwndg(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : vwndg
          if (.not. allocated(Agrif_Gr % tabvars(225)% array3)) then
          allocate(Agrif_Gr % tabvars(225)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : 2))
          Agrif_Gr % tabvars(225)% array3 = 0
      endif
      end subroutine Alloc_agrif_bulk_vwndg
      end module bulk_vwndg
      module bulk_uwndg


        implicit none
        public :: Alloc_agrif_bulk_uwndg
      contains
      subroutine Alloc_agrif_bulk_uwndg(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : uwndg
          if (.not. allocated(Agrif_Gr % tabvars(226)% array3)) then
          allocate(Agrif_Gr % tabvars(226)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : 2))
          Agrif_Gr % tabvars(226)% array3 = 0
      endif
      end subroutine Alloc_agrif_bulk_uwndg
      end module bulk_uwndg
      module bulkdat_radswg


        implicit none
        public :: Alloc_agrif_bulkdat_radswg
      contains
      subroutine Alloc_agrif_bulkdat_radswg(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : radswg
          if (.not. allocated(Agrif_Gr % tabvars(227)% array3)) then
          allocate(Agrif_Gr % tabvars(227)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : 2))
          Agrif_Gr % tabvars(227)% array3 = 0
      endif
      end subroutine Alloc_agrif_bulkdat_radswg
      end module bulkdat_radswg
      module bulkdat_radlwg


        implicit none
        public :: Alloc_agrif_bulkdat_radlwg
      contains
      subroutine Alloc_agrif_bulkdat_radlwg(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : radlwg
          if (.not. allocated(Agrif_Gr % tabvars(228)% array3)) then
          allocate(Agrif_Gr % tabvars(228)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : 2))
          Agrif_Gr % tabvars(228)% array3 = 0
      endif
      end subroutine Alloc_agrif_bulkdat_radlwg
      end module bulkdat_radlwg
      module bulkdat_prateg


        implicit none
        public :: Alloc_agrif_bulkdat_prateg
      contains
      subroutine Alloc_agrif_bulkdat_prateg(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : prateg
          if (.not. allocated(Agrif_Gr % tabvars(229)% array3)) then
          allocate(Agrif_Gr % tabvars(229)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : 2))
          Agrif_Gr % tabvars(229)% array3 = 0
      endif
      end subroutine Alloc_agrif_bulkdat_prateg
      end module bulkdat_prateg
      module bulkdat_rhumg


        implicit none
        public :: Alloc_agrif_bulkdat_rhumg
      contains
      subroutine Alloc_agrif_bulkdat_rhumg(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : rhumg
          if (.not. allocated(Agrif_Gr % tabvars(230)% array3)) then
          allocate(Agrif_Gr % tabvars(230)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : 2))
          Agrif_Gr % tabvars(230)% array3 = 0
      endif
      end subroutine Alloc_agrif_bulkdat_rhumg
      end module bulkdat_rhumg
      module bulkdat_tairg


        implicit none
        public :: Alloc_agrif_bulkdat_tairg
      contains
      subroutine Alloc_agrif_bulkdat_tairg(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : tairg
          if (.not. allocated(Agrif_Gr % tabvars(231)% array3)) then
          allocate(Agrif_Gr % tabvars(231)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : 2))
          Agrif_Gr % tabvars(231)% array3 = 0
      endif
      end subroutine Alloc_agrif_bulkdat_tairg
      end module bulkdat_tairg
      module bulk_vwnd


        implicit none
        public :: Alloc_agrif_bulk_vwnd
      contains
      subroutine Alloc_agrif_bulk_vwnd(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : vwnd
          if (.not. allocated(Agrif_Gr % tabvars(232)% array2)) then
          allocate(Agrif_Gr % tabvars(232)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(232)% array2 = 0
      endif
      end subroutine Alloc_agrif_bulk_vwnd
      end module bulk_vwnd
      module bulk_uwnd


        implicit none
        public :: Alloc_agrif_bulk_uwnd
      contains
      subroutine Alloc_agrif_bulk_uwnd(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : uwnd
          if (.not. allocated(Agrif_Gr % tabvars(233)% array2)) then
          allocate(Agrif_Gr % tabvars(233)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(233)% array2 = 0
      endif
      end subroutine Alloc_agrif_bulk_uwnd
      end module bulk_uwnd
      module bulk_wspd


        implicit none
        public :: Alloc_agrif_bulk_wspd
      contains
      subroutine Alloc_agrif_bulk_wspd(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : wspd
          if (.not. allocated(Agrif_Gr % tabvars(234)% array2)) then
          allocate(Agrif_Gr % tabvars(234)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(234)% array2 = 0
      endif
      end subroutine Alloc_agrif_bulk_wspd
      end module bulk_wspd
      module bulk_radsw


        implicit none
        public :: Alloc_agrif_bulk_radsw
      contains
      subroutine Alloc_agrif_bulk_radsw(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : radsw
          if (.not. allocated(Agrif_Gr % tabvars(235)% array2)) then
          allocate(Agrif_Gr % tabvars(235)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(235)% array2 = 0
      endif
      end subroutine Alloc_agrif_bulk_radsw
      end module bulk_radsw
      module bulk_radlw


        implicit none
        public :: Alloc_agrif_bulk_radlw
      contains
      subroutine Alloc_agrif_bulk_radlw(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : radlw
          if (.not. allocated(Agrif_Gr % tabvars(236)% array2)) then
          allocate(Agrif_Gr % tabvars(236)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(236)% array2 = 0
      endif
      end subroutine Alloc_agrif_bulk_radlw
      end module bulk_radlw
      module bulk_prate


        implicit none
        public :: Alloc_agrif_bulk_prate
      contains
      subroutine Alloc_agrif_bulk_prate(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : prate
          if (.not. allocated(Agrif_Gr % tabvars(237)% array2)) then
          allocate(Agrif_Gr % tabvars(237)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(237)% array2 = 0
      endif
      end subroutine Alloc_agrif_bulk_prate
      end module bulk_prate
      module bulk_rhum


        implicit none
        public :: Alloc_agrif_bulk_rhum
      contains
      subroutine Alloc_agrif_bulk_rhum(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : rhum
          if (.not. allocated(Agrif_Gr % tabvars(238)% array2)) then
          allocate(Agrif_Gr % tabvars(238)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(238)% array2 = 0
      endif
      end subroutine Alloc_agrif_bulk_rhum
      end module bulk_rhum
      module bulk_tair


        implicit none
        public :: Alloc_agrif_bulk_tair
      contains
      subroutine Alloc_agrif_bulk_tair(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : tair
          if (.not. allocated(Agrif_Gr % tabvars(239)% array2)) then
          allocate(Agrif_Gr % tabvars(239)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(239)% array2 = 0
      endif
      end subroutine Alloc_agrif_bulk_tair
      end module bulk_tair
      module forces_btflx


        implicit none
        public :: Alloc_agrif_forces_btflx
      contains
      subroutine Alloc_agrif_forces_btflx(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      integer(4), parameter :: ntrc_sed = 0
      integer(4), parameter :: ntrc_bio = 0
      integer(4), parameter :: ntrc_pas = 0
      integer(4), parameter :: ntrc_salt = 1
      integer(4), parameter :: itemp = 1
      integer(4), parameter :: NT = itemp+ntrc_salt+ntrc_pas+ntrc_bio+nt
     &rc_sed
      !! ALLOCATION OF VARIABLE : btflx
          if (.not. allocated(Agrif_Gr % tabvars(240)% array3)) then
          allocate(Agrif_Gr % tabvars(240)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : NT))
          Agrif_Gr % tabvars(240)% array3 = 0
      endif
      end subroutine Alloc_agrif_forces_btflx
      end module forces_btflx
      module stfdat4


        implicit none
        public :: Alloc_agrif_stfdat4
      contains
      subroutine Alloc_agrif_stfdat4(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      integer(4), parameter :: ntrc_sed = 0
      integer(4), parameter :: ntrc_bio = 0
      integer(4), parameter :: ntrc_pas = 0
      integer(4), parameter :: ntrc_salt = 1
      integer(4), parameter :: itemp = 1
      integer(4), parameter :: NT = itemp+ntrc_salt+ntrc_pas+ntrc_bio+nt
     &rc_sed
      !! ALLOCATION OF VARIABLE : stf_id
          if (.not. allocated(Agrif_Gr % tabvars_i(301)% iarray1)) then
          allocate(Agrif_Gr % tabvars_i(301)% iarray1(1 : NT))
          Agrif_Gr % tabvars_i(301)% iarray1 = 0
      endif
      !! ALLOCATION OF VARIABLE : stf_tid
          if (.not. allocated(Agrif_Gr % tabvars_i(302)% iarray1)) then
          allocate(Agrif_Gr % tabvars_i(302)% iarray1(1 : NT))
          Agrif_Gr % tabvars_i(302)% iarray1 = 0
      endif
      end subroutine Alloc_agrif_stfdat4
      end module stfdat4
      module stfdat3


        implicit none
        public :: Alloc_agrif_stfdat3
      contains
      subroutine Alloc_agrif_stfdat3(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      integer(4), parameter :: ntrc_sed = 0
      integer(4), parameter :: ntrc_bio = 0
      integer(4), parameter :: ntrc_pas = 0
      integer(4), parameter :: ntrc_salt = 1
      integer(4), parameter :: itemp = 1
      integer(4), parameter :: NT = itemp+ntrc_salt+ntrc_pas+ntrc_bio+nt
     &rc_sed
      !! ALLOCATION OF VARIABLE : lstfgrd
      do i = 303,306
          if (.not. allocated(Agrif_Gr % tabvars_i(i)% iarray1)) then
          allocate(Agrif_Gr % tabvars_i(i)% iarray1(1 : NT))
          Agrif_Gr % tabvars_i(i)% iarray1 = 0
      endif
      enddo
      end subroutine Alloc_agrif_stfdat3
      end module stfdat3
      module stfdat1


        implicit none
        public :: Alloc_agrif_stfdat1
      contains
      subroutine Alloc_agrif_stfdat1(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      integer(4), parameter :: ntrc_sed = 0
      integer(4), parameter :: ntrc_bio = 0
      integer(4), parameter :: ntrc_pas = 0
      integer(4), parameter :: ntrc_salt = 1
      integer(4), parameter :: itemp = 1
      integer(4), parameter :: NT = itemp+ntrc_salt+ntrc_pas+ntrc_bio+nt
     &rc_sed
      !! ALLOCATION OF VARIABLE : stf_scale
          if (.not. allocated(Agrif_Gr % tabvars(241)% array1)) then
          allocate(Agrif_Gr % tabvars(241)% array1(1 : NT))
          Agrif_Gr % tabvars(241)% array1 = 0
      endif
      !! ALLOCATION OF VARIABLE : stf_cycle
          if (.not. allocated(Agrif_Gr % tabvars(242)% array1)) then
          allocate(Agrif_Gr % tabvars(242)% array1(1 : NT))
          Agrif_Gr % tabvars(242)% array1 = 0
      endif
      !! ALLOCATION OF VARIABLE : stf_time
          if (.not. allocated(Agrif_Gr % tabvars(243)% array2)) then
          allocate(Agrif_Gr % tabvars(243)% array2(1 : 2,1 : NT))
          Agrif_Gr % tabvars(243)% array2 = 0
      endif
      !! ALLOCATION OF VARIABLE : stflxp
          if (.not. allocated(Agrif_Gr % tabvars(244)% array2)) then
          allocate(Agrif_Gr % tabvars(244)% array2(1 : 2,1 : NT))
          Agrif_Gr % tabvars(244)% array2 = 0
      endif
      end subroutine Alloc_agrif_stfdat1
      end module stfdat1
      module stfdat_stflxg


        implicit none
        public :: Alloc_agrif_stfdat_stflxg
      contains
      subroutine Alloc_agrif_stfdat_stflxg(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      integer(4), parameter :: ntrc_sed = 0
      integer(4), parameter :: ntrc_bio = 0
      integer(4), parameter :: ntrc_pas = 0
      integer(4), parameter :: ntrc_salt = 1
      integer(4), parameter :: itemp = 1
      integer(4), parameter :: NT = itemp+ntrc_salt+ntrc_pas+ntrc_bio+nt
     &rc_sed
      !! ALLOCATION OF VARIABLE : stflxg
          if (.not. allocated(Agrif_Gr % tabvars(245)% array4)) then
          allocate(Agrif_Gr % tabvars(245)% array4(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : 2,1 : NT))
          Agrif_Gr % tabvars(245)% array4 = 0
      endif
      end subroutine Alloc_agrif_stfdat_stflxg
      end module stfdat_stflxg
      module frc_shflx_sen


        implicit none
        public :: Alloc_agrif_frc_shflx_sen
      contains
      subroutine Alloc_agrif_frc_shflx_sen(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : shflx_sen
          if (.not. allocated(Agrif_Gr % tabvars(246)% array2)) then
          allocate(Agrif_Gr % tabvars(246)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(246)% array2 = 0
      endif
      end subroutine Alloc_agrif_frc_shflx_sen
      end module frc_shflx_sen
      module frc_shflx_lat


        implicit none
        public :: Alloc_agrif_frc_shflx_lat
      contains
      subroutine Alloc_agrif_frc_shflx_lat(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : shflx_lat
          if (.not. allocated(Agrif_Gr % tabvars(247)% array2)) then
          allocate(Agrif_Gr % tabvars(247)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(247)% array2 = 0
      endif
      end subroutine Alloc_agrif_frc_shflx_lat
      end module frc_shflx_lat
      module frc_shflx_rlw


        implicit none
        public :: Alloc_agrif_frc_shflx_rlw
      contains
      subroutine Alloc_agrif_frc_shflx_rlw(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : shflx_rlw
          if (.not. allocated(Agrif_Gr % tabvars(248)% array2)) then
          allocate(Agrif_Gr % tabvars(248)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(248)% array2 = 0
      endif
      end subroutine Alloc_agrif_frc_shflx_rlw
      end module frc_shflx_rlw
      module frc_shflx_rsw


        implicit none
        public :: Alloc_agrif_frc_shflx_rsw
      contains
      subroutine Alloc_agrif_frc_shflx_rsw(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : shflx_rsw
          if (.not. allocated(Agrif_Gr % tabvars(249)% array2)) then
          allocate(Agrif_Gr % tabvars(249)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(249)% array2 = 0
      endif
      end subroutine Alloc_agrif_frc_shflx_rsw
      end module frc_shflx_rsw
      module forces_stflx


        implicit none
        public :: Alloc_agrif_forces_stflx
      contains
      subroutine Alloc_agrif_forces_stflx(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      integer(4), parameter :: ntrc_sed = 0
      integer(4), parameter :: ntrc_bio = 0
      integer(4), parameter :: ntrc_pas = 0
      integer(4), parameter :: ntrc_salt = 1
      integer(4), parameter :: itemp = 1
      integer(4), parameter :: NT = itemp+ntrc_salt+ntrc_pas+ntrc_bio+nt
     &rc_sed
      !! ALLOCATION OF VARIABLE : stflx
          if (.not. allocated(Agrif_Gr % tabvars(250)% array3)) then
          allocate(Agrif_Gr % tabvars(250)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : NT))
          Agrif_Gr % tabvars(250)% array3 = 0
      endif
      end subroutine Alloc_agrif_forces_stflx
      end module forces_stflx
      module bmsdat1


        implicit none
        public :: Alloc_agrif_bmsdat1
      contains
      subroutine Alloc_agrif_bmsdat1(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : tbms
      do i = 251,254
          if (.not. allocated(Agrif_Gr % tabvars(i)% array1)) then
          allocate(Agrif_Gr % tabvars(i)% array1(1 : 2))
          Agrif_Gr % tabvars(i)% array1 = 0
      endif
      enddo
      end subroutine Alloc_agrif_bmsdat1
      end module bmsdat1
      module bmsdat_bvstrg


        implicit none
        public :: Alloc_agrif_bmsdat_bvstrg
      contains
      subroutine Alloc_agrif_bmsdat_bvstrg(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : bvstrg
          if (.not. allocated(Agrif_Gr % tabvars(255)% array3)) then
          allocate(Agrif_Gr % tabvars(255)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : 2))
          Agrif_Gr % tabvars(255)% array3 = 0
      endif
      end subroutine Alloc_agrif_bmsdat_bvstrg
      end module bmsdat_bvstrg
      module bmsdat_bustrg


        implicit none
        public :: Alloc_agrif_bmsdat_bustrg
      contains
      subroutine Alloc_agrif_bmsdat_bustrg(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : bustrg
          if (.not. allocated(Agrif_Gr % tabvars(256)% array3)) then
          allocate(Agrif_Gr % tabvars(256)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : 2))
          Agrif_Gr % tabvars(256)% array3 = 0
      endif
      end subroutine Alloc_agrif_bmsdat_bustrg
      end module bmsdat_bustrg
      module forces_bvstr


        implicit none
        public :: Alloc_agrif_forces_bvstr
      contains
      subroutine Alloc_agrif_forces_bvstr(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : bvstr
          if (.not. allocated(Agrif_Gr % tabvars(257)% array2)) then
          allocate(Agrif_Gr % tabvars(257)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(257)% array2 = 0
      endif
      end subroutine Alloc_agrif_forces_bvstr
      end module forces_bvstr
      module forces_bustr


        implicit none
        public :: Alloc_agrif_forces_bustr
      contains
      subroutine Alloc_agrif_forces_bustr(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : bustr
          if (.not. allocated(Agrif_Gr % tabvars(258)% array2)) then
          allocate(Agrif_Gr % tabvars(258)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(258)% array2 = 0
      endif
      end subroutine Alloc_agrif_forces_bustr
      end module forces_bustr
      module smsdat1


        implicit none
        public :: Alloc_agrif_smsdat1
      contains
      subroutine Alloc_agrif_smsdat1(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : sms_time
          if (.not. allocated(Agrif_Gr % tabvars(259)% array1)) then
          allocate(Agrif_Gr % tabvars(259)% array1(1 : 2))
          Agrif_Gr % tabvars(259)% array1 = 0
      endif
      !! ALLOCATION OF VARIABLE : svstrp
          if (.not. allocated(Agrif_Gr % tabvars(260)% array1)) then
          allocate(Agrif_Gr % tabvars(260)% array1(1 : 2))
          Agrif_Gr % tabvars(260)% array1 = 0
      endif
      !! ALLOCATION OF VARIABLE : sustrp
          if (.not. allocated(Agrif_Gr % tabvars(261)% array1)) then
          allocate(Agrif_Gr % tabvars(261)% array1(1 : 2))
          Agrif_Gr % tabvars(261)% array1 = 0
      endif
      end subroutine Alloc_agrif_smsdat1
      end module smsdat1
      module smsdat_svstrg


        implicit none
        public :: Alloc_agrif_smsdat_svstrg
      contains
      subroutine Alloc_agrif_smsdat_svstrg(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : svstrg
          if (.not. allocated(Agrif_Gr % tabvars(262)% array3)) then
          allocate(Agrif_Gr % tabvars(262)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : 2))
          Agrif_Gr % tabvars(262)% array3 = 0
      endif
      end subroutine Alloc_agrif_smsdat_svstrg
      end module smsdat_svstrg
      module smsdat_sustrg


        implicit none
        public :: Alloc_agrif_smsdat_sustrg
      contains
      subroutine Alloc_agrif_smsdat_sustrg(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : sustrg
          if (.not. allocated(Agrif_Gr % tabvars(263)% array3)) then
          allocate(Agrif_Gr % tabvars(263)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : 2))
          Agrif_Gr % tabvars(263)% array3 = 0
      endif
      end subroutine Alloc_agrif_smsdat_sustrg
      end module smsdat_sustrg
      module forces_svstr


        implicit none
        public :: Alloc_agrif_forces_svstr
      contains
      subroutine Alloc_agrif_forces_svstr(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : svstr
          if (.not. allocated(Agrif_Gr % tabvars(264)% array2)) then
          allocate(Agrif_Gr % tabvars(264)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(264)% array2 = 0
      endif
      end subroutine Alloc_agrif_forces_svstr
      end module forces_svstr
      module forces_sustr


        implicit none
        public :: Alloc_agrif_forces_sustr
      contains
      subroutine Alloc_agrif_forces_sustr(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : sustr
          if (.not. allocated(Agrif_Gr % tabvars(265)% array2)) then
          allocate(Agrif_Gr % tabvars(265)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(265)% array2 = 0
      endif
      end subroutine Alloc_agrif_forces_sustr
      end module forces_sustr
      module avg_Akt


        implicit none
        public :: Alloc_agrif_avg_Akt
      contains
      subroutine Alloc_agrif_avg_Akt(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      integer(4), parameter :: N = 32
      !! ALLOCATION OF VARIABLE : Akt_avg
          if (.not. allocated(Agrif_Gr % tabvars(266)% array4)) then
          allocate(Agrif_Gr % tabvars(266)% array4(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,0 : N,1 : 2))
          Agrif_Gr % tabvars(266)% array4 = 0
      endif
      end subroutine Alloc_agrif_avg_Akt
      end module avg_Akt
      module avg_Akv


        implicit none
        public :: Alloc_agrif_avg_Akv
      contains
      subroutine Alloc_agrif_avg_Akv(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      integer(4), parameter :: N = 32
      !! ALLOCATION OF VARIABLE : Akv_avg
          if (.not. allocated(Agrif_Gr % tabvars(267)% array3)) then
          allocate(Agrif_Gr % tabvars(267)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,0 : N))
          Agrif_Gr % tabvars(267)% array3 = 0
      endif
      end subroutine Alloc_agrif_avg_Akv
      end module avg_Akv
      module avg_diff3d


        implicit none
        public :: Alloc_agrif_avg_diff3d
      contains
      subroutine Alloc_agrif_avg_diff3d(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      integer(4), parameter :: N = 32
      !! ALLOCATION OF VARIABLE : diff3d_avg
          if (.not. allocated(Agrif_Gr % tabvars(268)% array3)) then
          allocate(Agrif_Gr % tabvars(268)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : N))
          Agrif_Gr % tabvars(268)% array3 = 0
      endif
      end subroutine Alloc_agrif_avg_diff3d
      end module avg_diff3d
      module avg_shflx_sen


        implicit none
        public :: Alloc_agrif_avg_shflx_sen
      contains
      subroutine Alloc_agrif_avg_shflx_sen(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : shflx_sen_avg
          if (.not. allocated(Agrif_Gr % tabvars(269)% array2)) then
          allocate(Agrif_Gr % tabvars(269)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(269)% array2 = 0
      endif
      end subroutine Alloc_agrif_avg_shflx_sen
      end module avg_shflx_sen
      module avg_shflx_lat


        implicit none
        public :: Alloc_agrif_avg_shflx_lat
      contains
      subroutine Alloc_agrif_avg_shflx_lat(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : shflx_lat_avg
          if (.not. allocated(Agrif_Gr % tabvars(270)% array2)) then
          allocate(Agrif_Gr % tabvars(270)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(270)% array2 = 0
      endif
      end subroutine Alloc_agrif_avg_shflx_lat
      end module avg_shflx_lat
      module avg_shflx_rlw


        implicit none
        public :: Alloc_agrif_avg_shflx_rlw
      contains
      subroutine Alloc_agrif_avg_shflx_rlw(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : shflx_rlw_avg
          if (.not. allocated(Agrif_Gr % tabvars(271)% array2)) then
          allocate(Agrif_Gr % tabvars(271)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(271)% array2 = 0
      endif
      end subroutine Alloc_agrif_avg_shflx_rlw
      end module avg_shflx_rlw
      module avg_shflx_rsw


        implicit none
        public :: Alloc_agrif_avg_shflx_rsw
      contains
      subroutine Alloc_agrif_avg_shflx_rsw(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : shflx_rsw_avg
          if (.not. allocated(Agrif_Gr % tabvars(272)% array2)) then
          allocate(Agrif_Gr % tabvars(272)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(272)% array2 = 0
      endif
      end subroutine Alloc_agrif_avg_shflx_rsw
      end module avg_shflx_rsw
      module avg_hbbl


        implicit none
        public :: Alloc_agrif_avg_hbbl
      contains
      subroutine Alloc_agrif_avg_hbbl(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : hbbl_avg
          if (.not. allocated(Agrif_Gr % tabvars(273)% array2)) then
          allocate(Agrif_Gr % tabvars(273)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(273)% array2 = 0
      endif
      end subroutine Alloc_agrif_avg_hbbl
      end module avg_hbbl
      module avg_hbl


        implicit none
        public :: Alloc_agrif_avg_hbl
      contains
      subroutine Alloc_agrif_avg_hbl(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : hbl_avg
          if (.not. allocated(Agrif_Gr % tabvars(274)% array2)) then
          allocate(Agrif_Gr % tabvars(274)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(274)% array2 = 0
      endif
      end subroutine Alloc_agrif_avg_hbl
      end module avg_hbl
      module avg_btflx


        implicit none
        public :: Alloc_agrif_avg_btflx
      contains
      subroutine Alloc_agrif_avg_btflx(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      integer(4), parameter :: ntrc_sed = 0
      integer(4), parameter :: ntrc_bio = 0
      integer(4), parameter :: ntrc_pas = 0
      integer(4), parameter :: ntrc_salt = 1
      integer(4), parameter :: itemp = 1
      integer(4), parameter :: NT = itemp+ntrc_salt+ntrc_pas+ntrc_bio+nt
     &rc_sed
      !! ALLOCATION OF VARIABLE : btflx_avg
          if (.not. allocated(Agrif_Gr % tabvars(275)% array3)) then
          allocate(Agrif_Gr % tabvars(275)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : NT))
          Agrif_Gr % tabvars(275)% array3 = 0
      endif
      end subroutine Alloc_agrif_avg_btflx
      end module avg_btflx
      module avg_stflx


        implicit none
        public :: Alloc_agrif_avg_stflx
      contains
      subroutine Alloc_agrif_avg_stflx(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      integer(4), parameter :: ntrc_sed = 0
      integer(4), parameter :: ntrc_bio = 0
      integer(4), parameter :: ntrc_pas = 0
      integer(4), parameter :: ntrc_salt = 1
      integer(4), parameter :: itemp = 1
      integer(4), parameter :: NT = itemp+ntrc_salt+ntrc_pas+ntrc_bio+nt
     &rc_sed
      !! ALLOCATION OF VARIABLE : stflx_avg
          if (.not. allocated(Agrif_Gr % tabvars(276)% array3)) then
          allocate(Agrif_Gr % tabvars(276)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : NT))
          Agrif_Gr % tabvars(276)% array3 = 0
      endif
      end subroutine Alloc_agrif_avg_stflx
      end module avg_stflx
      module avg_w


        implicit none
        public :: Alloc_agrif_avg_w
      contains
      subroutine Alloc_agrif_avg_w(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      integer(4), parameter :: N = 32
      !! ALLOCATION OF VARIABLE : w_avg
          if (.not. allocated(Agrif_Gr % tabvars(277)% array3)) then
          allocate(Agrif_Gr % tabvars(277)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : N))
          Agrif_Gr % tabvars(277)% array3 = 0
      endif
      end subroutine Alloc_agrif_avg_w
      end module avg_w
      module avg_bvf


        implicit none
        public :: Alloc_agrif_avg_bvf
      contains
      subroutine Alloc_agrif_avg_bvf(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      integer(4), parameter :: N = 32
      !! ALLOCATION OF VARIABLE : bvf_avg
          if (.not. allocated(Agrif_Gr % tabvars(278)% array3)) then
          allocate(Agrif_Gr % tabvars(278)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,0 : N))
          Agrif_Gr % tabvars(278)% array3 = 0
      endif
      end subroutine Alloc_agrif_avg_bvf
      end module avg_bvf
      module avg_omega


        implicit none
        public :: Alloc_agrif_avg_omega
      contains
      subroutine Alloc_agrif_avg_omega(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      integer(4), parameter :: N = 32
      !! ALLOCATION OF VARIABLE : omega_avg
          if (.not. allocated(Agrif_Gr % tabvars(279)% array3)) then
          allocate(Agrif_Gr % tabvars(279)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,0 : N))
          Agrif_Gr % tabvars(279)% array3 = 0
      endif
      end subroutine Alloc_agrif_avg_omega
      end module avg_omega
      module avg_rho


        implicit none
        public :: Alloc_agrif_avg_rho
      contains
      subroutine Alloc_agrif_avg_rho(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      integer(4), parameter :: N = 32
      !! ALLOCATION OF VARIABLE : rho_avg
          if (.not. allocated(Agrif_Gr % tabvars(280)% array3)) then
          allocate(Agrif_Gr % tabvars(280)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : N))
          Agrif_Gr % tabvars(280)% array3 = 0
      endif
      end subroutine Alloc_agrif_avg_rho
      end module avg_rho
      module avg_t


        implicit none
        public :: Alloc_agrif_avg_t
      contains
      subroutine Alloc_agrif_avg_t(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      integer(4), parameter :: ntrc_sed = 0
      integer(4), parameter :: ntrc_bio = 0
      integer(4), parameter :: ntrc_pas = 0
      integer(4), parameter :: ntrc_salt = 1
      integer(4), parameter :: itemp = 1
      integer(4), parameter :: NT = itemp+ntrc_salt+ntrc_pas+ntrc_bio+nt
     &rc_sed
      integer(4), parameter :: N = 32
      !! ALLOCATION OF VARIABLE : t_avg
          if (.not. allocated(Agrif_Gr % tabvars(281)% array4)) then
          allocate(Agrif_Gr % tabvars(281)% array4(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : N,1 : NT))
          Agrif_Gr % tabvars(281)% array4 = 0
      endif
      end subroutine Alloc_agrif_avg_t
      end module avg_t
      module avg_v


        implicit none
        public :: Alloc_agrif_avg_v
      contains
      subroutine Alloc_agrif_avg_v(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      integer(4), parameter :: N = 32
      !! ALLOCATION OF VARIABLE : v_avg
          if (.not. allocated(Agrif_Gr % tabvars(282)% array3)) then
          allocate(Agrif_Gr % tabvars(282)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : N))
          Agrif_Gr % tabvars(282)% array3 = 0
      endif
      end subroutine Alloc_agrif_avg_v
      end module avg_v
      module avg_u


        implicit none
        public :: Alloc_agrif_avg_u
      contains
      subroutine Alloc_agrif_avg_u(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      integer(4), parameter :: N = 32
      !! ALLOCATION OF VARIABLE : u_avg
          if (.not. allocated(Agrif_Gr % tabvars(283)% array3)) then
          allocate(Agrif_Gr % tabvars(283)% array3(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0,1 : N))
          Agrif_Gr % tabvars(283)% array3 = 0
      endif
      end subroutine Alloc_agrif_avg_u
      end module avg_u
      module avg_srflx


        implicit none
        public :: Alloc_agrif_avg_srflx
      contains
      subroutine Alloc_agrif_avg_srflx(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : srflx_avg
          if (.not. allocated(Agrif_Gr % tabvars(284)% array2)) then
          allocate(Agrif_Gr % tabvars(284)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(284)% array2 = 0
      endif
      end subroutine Alloc_agrif_avg_srflx
      end module avg_srflx
      module avg_svstr


        implicit none
        public :: Alloc_agrif_avg_svstr
      contains
      subroutine Alloc_agrif_avg_svstr(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : svstr_avg
          if (.not. allocated(Agrif_Gr % tabvars(285)% array2)) then
          allocate(Agrif_Gr % tabvars(285)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(285)% array2 = 0
      endif
      end subroutine Alloc_agrif_avg_svstr
      end module avg_svstr
      module avg_sustr


        implicit none
        public :: Alloc_agrif_avg_sustr
      contains
      subroutine Alloc_agrif_avg_sustr(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : sustr_avg
          if (.not. allocated(Agrif_Gr % tabvars(286)% array2)) then
          allocate(Agrif_Gr % tabvars(286)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(286)% array2 = 0
      endif
      end subroutine Alloc_agrif_avg_sustr
      end module avg_sustr
      module avg_wstr


        implicit none
        public :: Alloc_agrif_avg_wstr
      contains
      subroutine Alloc_agrif_avg_wstr(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : wstr_avg
          if (.not. allocated(Agrif_Gr % tabvars(287)% array2)) then
          allocate(Agrif_Gr % tabvars(287)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(287)% array2 = 0
      endif
      end subroutine Alloc_agrif_avg_wstr
      end module avg_wstr
      module avg_bvstr


        implicit none
        public :: Alloc_agrif_avg_bvstr
      contains
      subroutine Alloc_agrif_avg_bvstr(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : bvstr_avg
          if (.not. allocated(Agrif_Gr % tabvars(288)% array2)) then
          allocate(Agrif_Gr % tabvars(288)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(288)% array2 = 0
      endif
      end subroutine Alloc_agrif_avg_bvstr
      end module avg_bvstr
      module avg_bustr


        implicit none
        public :: Alloc_agrif_avg_bustr
      contains
      subroutine Alloc_agrif_avg_bustr(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : bustr_avg
          if (.not. allocated(Agrif_Gr % tabvars(289)% array2)) then
          allocate(Agrif_Gr % tabvars(289)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(289)% array2 = 0
      endif
      end subroutine Alloc_agrif_avg_bustr
      end module avg_bustr
      module avg_bostr


        implicit none
        public :: Alloc_agrif_avg_bostr
      contains
      subroutine Alloc_agrif_avg_bostr(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : bostr_avg
          if (.not. allocated(Agrif_Gr % tabvars(290)% array2)) then
          allocate(Agrif_Gr % tabvars(290)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(290)% array2 = 0
      endif
      end subroutine Alloc_agrif_avg_bostr
      end module avg_bostr
      module avg_vbar


        implicit none
        public :: Alloc_agrif_avg_vbar
      contains
      subroutine Alloc_agrif_avg_vbar(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : vbar_avg
          if (.not. allocated(Agrif_Gr % tabvars(291)% array2)) then
          allocate(Agrif_Gr % tabvars(291)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(291)% array2 = 0
      endif
      end subroutine Alloc_agrif_avg_vbar
      end module avg_vbar
      module avg_ubar


        implicit none
        public :: Alloc_agrif_avg_ubar
      contains
      subroutine Alloc_agrif_avg_ubar(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : ubar_avg
          if (.not. allocated(Agrif_Gr % tabvars(292)% array2)) then
          allocate(Agrif_Gr % tabvars(292)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(292)% array2 = 0
      endif
      end subroutine Alloc_agrif_avg_ubar
      end module avg_ubar
      module avg_zeta


        implicit none
        public :: Alloc_agrif_avg_zeta
      contains
      subroutine Alloc_agrif_avg_zeta(Agrif_Gr)
        use Agrif_Util
        type(Agrif_grid), pointer :: Agrif_Gr
        integer :: i
      !! ALLOCATION OF VARIABLE : zeta_avg
          if (.not. allocated(Agrif_Gr % tabvars(293)% array2)) then
          allocate(Agrif_Gr % tabvars(293)% array2(-1 :  Agrif_tabvars_i
     &(2)%iarray0+2+ Agrif_tabvars_i(13)%iarray0,-1 :  Agrif_tabvars_i(4
     &)%iarray0+2+ Agrif_tabvars_i(14)%iarray0))
          Agrif_Gr % tabvars(293)% array2 = 0
      endif
      end subroutine Alloc_agrif_avg_zeta
      end module avg_zeta
