


















































































































 


































































































































































 



































































































































































































 



















































 










 








































































































































































































































 










                                
                                

                                
                                

                                
                                

                                





































module NullEvol_hyper_u
contains
  subroutine NullEvol_u (i, jns, bns, qns, uns, u_wt, u_x_wt, x_wt, mask)
    use NullEvol_Mask
    use NullInterp
    use NullGrid_Vars 
    implicit none

    INTEGER*4,                                   intent (in)    :: i
    COMPLEX*16, dimension (lsh(1),lsh(2),nx), intent (in)    :: jns, qns
    REAL*8,    dimension (lsh(1),lsh(2),nx), intent (in)    :: bns 
    COMPLEX*16, dimension (lsh(1),lsh(2),nx), intent (inout) :: uns
    COMPLEX*16, dimension (lsh(1),lsh(2)),    intent (in)    :: u_wt, u_x_wt
    REAL*8,    dimension (lsh(1),lsh(2)),    intent (in)    :: x_wt
    INTEGER*4,     dimension (lsh(1),lsh(2)),    intent (in)    :: mask

    COMPLEX*16 ::  x2Uc_x, uE, x2UE_x
    REAL*8    ::  xc, xE
    INTEGER*4     :: i1, i2

    
    COMPLEX*16, dimension (lsh(1),lsh(2)) :: x2U_x

    x2U_x = exp(2. * bns(:,:,i)) / rwt * (&
                                - jns(:,:,i) * conjg(qns(:,:,i))& 
        + sqrt(1. + jns(:,:,i) * conjg(jns(:,:,i))) * qns(:,:,i)) 

    if(minval(mask).eq.0) then

       do i2 = 1, lsh(2)
          do i1 = 1, lsh(1)
             
             
             

             if(mask(i1,i2).eq.0) then

                xE = x_wt(i1,i2)
                uE = u_wt(i1,i2)
                x2UE_x = x_wt(i1,i2)**2 * u_x_wt(i1,i2)

                if(abs(xbh(i-1)-xE).lt.1.e-5*dx) then
                   uns(i1,i2,i-1) = u_wt(i1,i2)
                else if(xE < xbh(i-1)) then
                   
                   
   
                   
                   xc = (xE + xbh(i-1))/2
                   x2Uc_x = x2UE_x * (xb(i) -xc)/(xb(i)-xE) &
                          + x2U_x(i1,i2)  * (xE-xc)/(xE-xb(i))
                   uns(i1,i2,i-1) = uE + x2Uc_x * ( xbh(i-1)-xE ) / (xbh(i-1)*xE)
                end if

                if(abs(xbh(i)-xE).lt.1.e-5*dx) then
                   uns(i1,i2,i) = u_wt(i1,i2)
                else
                   
                   
                   xc = (xE + xbh(i))/2
                   x2Uc_x = x2UE_x * (xb(i)-xc)/(xb(i)-xE)&
                          + x2U_x(i1,i2)  * (xE-xc)/(xE-xb(i))
                   uns(i1,i2,i) = uE + x2Uc_x * ( xbh(i)-xE ) / (xbh(i)*xE)
                end if

             end if 

          end do
       end do
    end if

    
    uns(:,:,i) = uns(:,:,i) * (1 - mask) + mask * (uns(:,:,i-1) + dx*x2U_x/xbh(i-1)/xbh(i))

  end subroutine NullEvol_u
end module NullEvol_hyper_u   
