










      module scalars
      use param
                                                                  

      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.
                                                                       
                                                                 
                                 
                                
                                                                       
                                                                 
                                                                 
                                                                 
                                                        
                                                                       
                                                                 
                                                                 
            
                                              
                                                   
                     
                              
                               
                                 
                                                  
                                                                       
                                                                 
                                                                 
                        
                      
                           
                                                                       
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                    
                           
                                      
                             
                                                 
                                                                       
                                                                 
                     
                                                      
                                                                       
                                                                 
              
                                          
                                                                       
                                                                 
       
                                                           
                                             
                                                                       
                                                                 
              
                                                  
                                                                       
                                                                 
              
                                  
                                           
                                                  
                                                                   
                                                               
                                                      
                                                                       
                                                                 
                      
                                                                       
                                                                 
                                                                 
                                                                 
                                                                 
                                                        
                                
                                                                       
                                                                 
                                                        

                                                                       
                                                                 
                  
                                                                       
                                                                 
                                                                 
                                                                 
                  

                          

              
                             

                  
                               

                 
                                

                       
                                   

       
      public :: Alloc_agrif_scalars

      contains
      subroutine Alloc_agrif_scalars(Agrif_Gr)
          use Agrif_Util
          type(Agrif_grid), pointer :: Agrif_Gr
          integer :: i

      !! ALLOCATION OF VARIABLE : sc_w
          if (.not. allocated(Agrif_Gr % tabvars(1)% array1)) then
          allocate(Agrif_Gr % tabvars(1)% array1(0 : N))
          Agrif_Gr % tabvars(1)% array1 = 0
      endif
      !! ALLOCATION OF VARIABLE : Cs_w
          if (.not. allocated(Agrif_Gr % tabvars(2)% array1)) then
          allocate(Agrif_Gr % tabvars(2)% array1(0 : N))
          Agrif_Gr % tabvars(2)% array1 = 0
      endif
      !! ALLOCATION OF VARIABLE : sc_r
          if (.not. allocated(Agrif_Gr % tabvars(3)% array1)) then
          allocate(Agrif_Gr % tabvars(3)% array1(1 : N))
          Agrif_Gr % tabvars(3)% array1 = 0
      endif
      !! ALLOCATION OF VARIABLE : Cs_r
          if (.not. allocated(Agrif_Gr % tabvars(4)% array1)) then
          allocate(Agrif_Gr % tabvars(4)% array1(1 : N))
          Agrif_Gr % tabvars(4)% array1 = 0
      endif
      !! ALLOCATION OF VARIABLE : tnu2
          if (.not. allocated(Agrif_Gr % tabvars(5)% array1)) then
          allocate(Agrif_Gr % tabvars(5)% array1(1 : NT))
          Agrif_Gr % tabvars(5)% array1 = 0
      endif
      !! ALLOCATION OF VARIABLE : tnu4
          if (.not. allocated(Agrif_Gr % tabvars(6)% array1)) then
          allocate(Agrif_Gr % tabvars(6)% array1(1 : NT))
          Agrif_Gr % tabvars(6)% array1 = 0
      endif
      !! ALLOCATION OF VARIABLE : weight
          if (.not. allocated(Agrif_Gr % tabvars(7)% array2)) then
          allocate(Agrif_Gr % tabvars(7)% array2(1 : 6,0 : NWEIGHT))
          Agrif_Gr % tabvars(7)% array2 = 0
      endif
      !! ALLOCATION OF VARIABLE : got_tini
          if (.not. allocated(Agrif_Gr % tabvars_l(5)% larray1)) then
          allocate(Agrif_Gr % tabvars_l(5)% larray1(1 : NT))
      endif
      !! ALLOCATION OF VARIABLE : CPU_time
          if (.not. allocated(Agrif_Gr % tabvars(8)% sarray2)) then
          allocate(Agrif_Gr % tabvars(8)% sarray2(0 : 31,0 : NPP))
          Agrif_Gr % tabvars(8)% sarray2 = 0
      endif
      !! ALLOCATION OF VARIABLE : proc
          if (.not. allocated(Agrif_Gr % tabvars_i(174)% iarray2)) then
          allocate(Agrif_Gr % tabvars_i(174)% iarray2(0 : 31,0 : NPP))
          Agrif_Gr % tabvars_i(174)% iarray2 = 0
      endif
      end subroutine Alloc_agrif_scalars

      end module scalars

