C JA3DBM    SOURCE    CHAT      05/01/13    00:47:49     5004
      SUBROUTINE JA3DBM(JTL,JTR,WVEC_L,WVEC_R,NVECT,TVEC1,TVEC2,
     &                   ga,v_inf)
C************************************************************************
C
C PROJET            :  CASTEM 2000
C
C NOM               :  JA3DBM (Bas-Mach jacobian for 3D)
C
C DESCRIPTION       :  Voir KONJA2
C
C LANGAGE           :  FORTRAN 77 + ESOPE 2000 (avec estensions CISI)
C
C AUTEUR            :  S. KUDRIAKOV, A. BECCANTINI DM2S/SFME/LTMF
C
C************************************************************************
C
c----------------------------------------------------------------------
c GENERAL DESCRIPTION:
c   This subroutine provides the jacobians, which are
c   the derivatives of the numerical flux function,
c   with respect to the right and left conservative variables
c   The low-mach number corrections are made.
c
c EQUATIONS: 3D Euler equations of gas dynamics
c
c
c REFERENCE: 1) JCP, 129, 364-382 (1996)
c             " A Sequel to AUSM: AUSM+ ";
c                M.S.Liou
c            2) AIAA Journal, Sept. 1998
c          "Low-Diffusion Flux-Splitting Methods for Flows at All Speeds"
c             J.R.Edwards and M.S.Liou
c----------------------------------------------------------------------
c----------------------------------------------------------------------
c INPUT:
c
c      alpha   -- parameter of the AUSM+ scheme in the Pressure function;
c                 ( -3/4 <= alpha <= 3/16 ) (imposed as a parameter)
c
c      beta    -- parameter of the AUSM+ scheme in the Mach function;
c                 ( -1/16 <= beta <= 1/2 )  (imposed as a parameter)
c
c      wvec_l == (gamg,rhog,pg,ung,utg,uvg)  --
c                                vector of the primitive variables
c                                     at the left cell;
c
c      wvec_r == (gamd,rhod,pd,und,utd,uvd)  --
c                                vector of the primitive variables
c                                     at the right cell;
c
c      nvect, tvec1, tvec2  --- normal and tangent vectors
c                               to the cell interface
c
c      ga    ----  ratio of the specific heats of the gas
c
c      v_inf  -- parameter for choosing the reference velocity
c                 when the magnitude of the physical velocity
c                 is close to zero

c----------------------------------------------------------------------
c
c OUTPUT:
c
c      jtl     -- jakobian matrix 5 by 5 - derivatives of the numerical
c                 flux function with respect to the conservative variables
c                 from the left cell;
c
c      jtr     -- jakobian matrix 5 by 5 - derivatives of the numerical
c                 flux function with respect to the conservative variables
c                 from the right cell.
c----------------------------------------------------------------------
      IMPLICIT INTEGER(I-N)
       real*8 wvec_l(5),wvec_r(5)
       real*8 nvect(3),tvec1(3),tvec2(3)
       real*8 jl(5,5),jr(5,5)
       real*8 wl(5,5),wr(5,5)
       real*8 jtl(5,5),jtr(5,5)
       real*8 alpha,beta,upr_l,upr_r,v_inf
       real*8 ga, gm1,temph
       real*8 n_x,n_y,n_z,t1_x,t1_y,t1_z,t2_x,t2_y,t2_z
       real*8 un_l,un_r,ut1_l,ut1_r,ut2_l,ut2_r
       real*8 ml,mr,Mplus,Mmin,mmid
       real*8 mpl_m, mmin_m,am
       real*8 rold_l,uold_l,vold_l,wold_l,pold_l,eold_l
       real*8 rold_r,uold_r,vold_r,wold_r,pold_r,eold_r
       real*8 Pplus,Pmin
       real*8 hr_l,hr_r
       real*8 br1,br2,br3,temp_l,temp_r,brac_l,brac_r
       real*8 aleft, arigh
       real*8 damr_l,damr_r,damu_l,damu_r
       real*8 damv_l,damv_r,damp_l,damp_r
       real*8 damw_l,damw_r
       real*8 dmlr_l,dmlr_r,dmlu_l,dmlu_r
       real*8 dmlv_l,dmlv_r,dmlp_l,dmlp_r
       real*8 dmlw_l,dmlw_r
       real*8 dmrr_l,dmrr_r,dmru_l,dmru_r
       real*8 dmrv_l,dmrv_r,dmrp_l,dmrp_r
       real*8 dmrw_l,dmrw_r
       real*8 dMpr_l,dMpr_r,dMpu_l,dMpu_r
       real*8 dMpv_l,dMpv_r,dMpp_l,dMpp_r
       real*8 dMpw_l,dMpw_r
       real*8 dMmr_l,dMmr_r,dMmu_l,dMmu_r
       real*8 dMmv_l,dMmv_r,dMmp_l,dMmp_r
       real*8 dMmw_l,dMmw_r
       real*8 dmir_l,dmir_r,dmiu_l,dmiu_r
       real*8 dmiv_l,dmiv_r,dmip_l,dmip_r
       real*8 dmiw_l,dmiw_r
       real*8 d3mr_l,d3mr_r,d3mu_l,d3mu_r
       real*8 d3mv_l,d3mv_r,d3mp_l,d3mp_r
       real*8 d3mw_l,d3mw_r
       real*8 d2mr_l,d2mr_r,d2mu_l,d2mu_r
       real*8 d2mv_l,d2mv_r,d2mp_l,d2mp_r
       real*8 d2mw_l,d2mw_r
       real*8 dPpr_l,dPpr_r,dPpu_l,dPpu_r
       real*8 dPpv_l,dPpv_r,dPpp_l,dPpp_r
       real*8 dPpw_l,dPpw_r
       real*8 dPmr_l,dPmr_r,dPmu_l,dPmu_r
       real*8 dPmv_l,dPmv_r,dPmp_l,dPmp_r
       real*8 dPmw_l,dPmw_r
       real*8 dpir_l,dpir_r,dpiu_l,dpiu_r
       real*8 dpiv_l,dpiv_r,dpip_l,dpip_r
       real*8 dpiw_l,dpiw_r
       real*8 epsil,qq,amw,Mmin1,Mplus1
       real*8 fmid,mlw,mrw,termp
       real*8 ur_r,ur_l,urm,mhalf,mhalfr
       real*8 durr_l,durr_r,duru_l,duru_r
       real*8 durv_l,durv_r,durp_l,durp_r
       real*8 durw_l,durw_r
       real*8 dmhr_l,dmhr_r,dmhu_l,dmhu_r
       real*8 dmhv_l,dmhv_r,dmhp_l,dmhp_r
       real*8 dmhw_l,dmhw_r
       real*8 dmfr_l,dmfr_r,dmfu_l,dmfu_r
       real*8 dmfv_l,dmfv_r,dmfp_l,dmfp_r
       real*8 dmfw_l,dmfw_r
       real*8 dfm_mf,dfm_mh
       real*8 dfmr_l,dfmr_r,dfmu_l,dfmu_r
       real*8 dfmv_l,dfmv_r,dfmp_l,dfmp_r
       real*8 dfmw_l,dfmw_r
       real*8 m1mr_l,m1mr_r,m1mu_l,m1mu_r
       real*8 m1mv_l,m1mv_r,m1mp_l,m1mp_r
       real*8 m1mw_l,m1mw_r
       real*8 m1pr_l,m1pr_r,m1pu_l,m1pu_r
       real*8 m1pv_l,m1pv_r,m1pp_l,m1pp_r
       real*8 m1pw_l,m1pw_r
       real*8 tmpr_l,tmpr_r,tmpu_l,tmpu_r
       real*8 tmpv_l,tmpv_r,tmpp_l,tmpp_r
       real*8 tmpw_l,tmpw_r,rum
       real*8 rumr_l,rumu_l,rumv_l,rumw_l,rump_l
       real*8 rumr_r,rumu_r,rumv_r,rumw_r,rump_r
       real*8 sw_l,sw_r,top,bot,bots,coef,canc
       real*8 sr_l,sr_r,su_l,su_r,sv_l,sv_r,sp_l,sp_r
       integer i,j,k
       parameter(alpha = 0.1875D0, beta = 0.125D0)
       parameter(epsil = 1.0d0)
       canc=1.0d0
       upr_l=0.0d0
       upr_r=0.0d0
c-----------------------
       gm1=ga-1.0d0
c-----------------------
       n_x=nvect(1)
       n_y=nvect(2)
       n_z=nvect(3)
c-------------------
       t1_x=tvec1(1)
       t1_y=tvec1(2)
       t1_z=tvec1(3)
c-------------------
       t2_x=tvec2(1)
       t2_y=tvec2(2)
       t2_z=tvec2(3)
c-------------------------------------
       rold_l=wvec_l(1)
       uold_l=wvec_l(2)
       vold_l=wvec_l(3)
       wold_l=wvec_l(4)
       pold_l=wvec_l(5)
c-----------------------
       rold_r=wvec_r(1)
       uold_r=wvec_r(2)
       vold_r=wvec_r(3)
       wold_r=wvec_r(4)
       pold_r=wvec_r(5)
c-----------------------
       eold_l=(uold_l*uold_l+vold_l*vold_l+wold_l*wold_l)/2.0d0
       eold_l=eold_l+pold_l/(gm1*rold_l)
       eold_r=(uold_r*uold_r+vold_r*vold_r+wold_r*wold_r)/2.0d0
       eold_r=eold_r+pold_r/(gm1*rold_r)
c------------------------------------------------------------------
c   Computing reference velocity and its derivatives
c   see Eq.(2) of the Ref.(2).
c------------------------------------------------------------------
       aleft=sqrt(ga*pold_l/rold_l)
       arigh=sqrt(ga*pold_r/rold_r)
       qq=sqrt(uold_l*uold_l+vold_l*vold_l+wold_l*wold_l)
       if(qq .lt. (epsil*v_inf)) then
          ur_l = epsil*v_inf
          durr_l=0.0d0
          duru_l=0.0d0
          durv_l=0.0d0
          durw_l=0.0d0
          durp_l=0.0d0
       else
          ur_l=qq
          durr_l=0.0d0
          duru_l=uold_l/qq
          durv_l=vold_l/qq
          durw_l=wold_l/qq
          durp_l=0.0d0
       endif
c-------------------------------------------------------------------
       if(ur_l .ge. aleft) then
            ur_l=aleft
            durr_l=-aleft/(2.0d0*rold_l)
            duru_l=0.0d0
            durv_l=0.0d0
            durw_l=0.0d0
            durp_l=ga/(2.0d0*aleft*rold_l)
       endif
c-------------------------------------------------------------------
       if(ur_l .lt. upr_l) then
          ur_l=upr_l
          durr_l=0.0d0
          duru_l=0.0d0
          durv_l=0.0d0
          durw_l=0.0d0
          durp_l=0.0d0
       endif
c-------------------------------------------------------------------
       qq=sqrt(uold_r*uold_r+vold_r*vold_r+wold_r*wold_r)
       if(qq .lt. (epsil*v_inf)) then
          ur_r = epsil*v_inf
          durr_r=0.0d0
          duru_r=0.0d0
          durv_r=0.0d0
          durw_r=0.0d0
          durp_r=0.0d0
       else
          ur_r=qq
          durr_r=0.0d0
          duru_r=uold_r/qq
          durv_r=vold_r/qq
          durw_r=wold_r/qq
          durp_r=0.0d0
       endif
c------------------------------------------------------------------
       if(ur_r .ge. arigh) then
            ur_r=arigh
            durr_r=-arigh/(2.0d0*rold_r)
            duru_r=0.0d0
            durv_r=0.0d0
            durw_r=0.0d0
            durp_r=ga/(2.0d0*arigh*rold_r)
       endif
c------------------------------------------------------------------
       if(ur_r .lt. upr_r) then
          ur_r=upr_r
          durr_r=0.0d0
          duru_r=0.0d0
          durv_r=0.0d0
          durw_r=0.0d0
          durp_r=0.0d0
       endif
c------------------------------------------------------------------
c  Reference velocity at the interface is taken as an average
c  of the reference velocities of the neighbouring cells
c-------------------------------------------------------------------
       urm=0.5d0*(ur_l+ur_r)
       durr_l=0.5d0*durr_l
       duru_l=0.5d0*duru_l
       durv_l=0.5d0*durv_l
       durw_l=0.5d0*durw_l
       durp_l=0.5d0*durp_l
c-------------------------
       durr_r=0.5d0*durr_r
       duru_r=0.5d0*duru_r
       durv_r=0.5d0*durv_r
       durw_r=0.5d0*durw_r
       durp_r=0.5d0*durp_r
c-------------------------------------------------------------------
c Computation of the speed of sound and its derivatives;
c numerical speed of sound at the interface is taken as an average
c of the speeds of sounds of the neighbouring cells
c-------------------------------------------------------------------
       am=0.5d0*(aleft+arigh)
c-------------------------------------------------------------------
       if(abs(urm/am-1.0d0).le.0.000001d0) then
         coef=0.0d0
       else
         coef=1.0d0
       endif
c-------------------------------------------------------------------
c Computation of the speed of sound and its derivatives;
c numerical speed of sound at the interface is taken as an average
c of the speeds of sounds of the neighbouring cells
c--------------------------------------------------------------------
       damr_r=-arigh/(4.0d0*rold_r)
       damu_r=0.0d0
       damv_r=0.0d0
       damw_r=0.0d0
       damp_r=ga/(4.0d0*arigh*rold_r)
c-----------------------
       damr_l=-aleft/(4.0d0*rold_l)
       damu_l=0.0d0
       damv_l=0.0d0
       damw_l=0.0d0
       damp_l=ga/(4.0d0*aleft*rold_l)
c----------------------------------------------------------------------
c  computing numerical Mach number and its derivatives
c----------------------------------------------------------------------
       un_l=uold_l*n_x+vold_l*n_y+wold_l*n_z
       un_r=uold_r*n_x+vold_r*n_y+wold_r*n_z
c----------
       ut1_l=uold_l*t1_x+vold_l*t1_y+wold_l*t1_z
       ut1_r=uold_r*t1_x+vold_r*t1_y+wold_r*t1_z
c----------
       ut2_l=uold_l*t2_x+vold_l*t2_y+wold_l*t2_z
       ut2_r=uold_r*t2_x+vold_r*t2_y+wold_r*t2_z
c----------------------------------------
       ml=un_l/am
       mr=un_r/am
       mhalf=0.5d0*(un_l+un_r)/am
c---------------------
       top=0.5d0*(un_l+un_r)/(am*am)
       dmhr_l=-top*damr_l
       dmhu_l=n_x/2.0d0/am-top*damu_l
       dmhv_l=n_y/2.0d0/am-top*damv_l
       dmhw_l=n_z/2.0d0/am-top*damw_l
       dmhp_l=-top*damp_l
c---------------------
       dmhr_r=-top*damr_r
       dmhu_r=n_x/2.0d0/am-top*damu_r
       dmhv_r=n_y/2.0d0/am-top*damv_r
       dmhw_r=n_z/2.0d0/am-top*damw_r
       dmhp_r=-top*damp_r
c--------------------------------
       mhalfr=urm/am
c--------------------------------
       top=urm/(am*am)
       dmfr_l=durr_l/am-top*damr_l
       dmfu_l=duru_l/am-top*damu_l
       dmfv_l=durv_l/am-top*damv_l
       dmfw_l=durw_l/am-top*damw_l
       dmfp_l=durp_l/am-top*damp_l
c---------------------
       dmfr_r=durr_r/am-top*damr_r
       dmfu_r=duru_r/am-top*damu_r
       dmfv_r=durv_r/am-top*damv_r
       dmfw_r=durw_r/am-top*damw_r
       dmfp_r=durp_r/am-top*damp_r
c-------------------------------------------------------------------
c Scaling function for the speed of sound and its derivatives
c see Eq.(32) of the Ref.2)
c-------------------------------------------------------------------
       top=(1.0d0-mhalfr*mhalfr)*(1.0d0-mhalfr*mhalfr)
       top=top*mhalf*mhalf+4.0d0*mhalfr*mhalfr
       bot=1.0d0+mhalfr*mhalfr
       if(abs(canc-0.0d0).lt.0.000001d0) then
         fmid=1.0d0
       else
         fmid=sqrt(top)/bot
       endif
c--------------------------
       temph=-4.0d0*(1.0d0-mhalfr*mhalfr)*mhalfr
       temph=temph*mhalf*mhalf+8.0d0*mhalfr
       dfm_mf=temph/(sqrt(top)*2.0d0*bot)
       dfm_mf=dfm_mf-sqrt(top)*2.0d0*mhalfr/(bot*bot)
c--------------------------
       temph=2.0d0*(1.0d0-mhalfr*mhalfr)*(1.0d0-mhalfr*mhalfr)*mhalf
       dfm_mh=temph/(2.0d0*bot*sqrt(top))
c--------------------------
       dfmr_l=dfm_mf*dmfr_l+dfm_mh*dmhr_l
       dfmu_l=dfm_mf*dmfu_l+dfm_mh*dmhu_l
       dfmv_l=dfm_mf*dmfv_l+dfm_mh*dmhv_l
       dfmw_l=dfm_mf*dmfw_l+dfm_mh*dmhw_l
       dfmp_l=dfm_mf*dmfp_l+dfm_mh*dmhp_l
c--------------------------
       dfmr_r=dfm_mf*dmfr_r+dfm_mh*dmhr_r
       dfmu_r=dfm_mf*dmfu_r+dfm_mh*dmhu_r
       dfmv_r=dfm_mf*dmfv_r+dfm_mh*dmhv_r
       dfmw_r=dfm_mf*dmfw_r+dfm_mh*dmhw_r
       dfmp_r=dfm_mf*dmfp_r+dfm_mh*dmhp_r
c------------------------------------------------------------------
c 'New' speed of sound 'amw' defined as a product of the scaling
c  function 'fmid' and the 'Old' speed of sound 'am'; see (31) of Ref.2)
c------------------------------------------------------------------
       amw=fmid*am
       mlw=un_l/amw
       mrw=un_r/amw
c--------------------------
       damr_l=canc*coef*dfmr_l*am+fmid*damr_l
       damu_l=canc*coef*dfmu_l*am+fmid*damu_l
       damv_l=canc*coef*dfmv_l*am+fmid*damv_l
       damw_l=canc*coef*dfmw_l*am+fmid*damw_l
       damp_l=canc*coef*dfmp_l*am+fmid*damp_l
c--------------------------
       damr_r=canc*coef*dfmr_r*am+fmid*damr_r
       damu_r=canc*coef*dfmu_r*am+fmid*damu_r
       damv_r=canc*coef*dfmv_r*am+fmid*damv_r
       damw_r=canc*coef*dfmw_r*am+fmid*damw_r
       damp_r=canc*coef*dfmp_r*am+fmid*damp_r
c-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
       am=amw
c-------------------------------------------------------------------
c  Redefinition of the numerical mach numbers;
c  see Eqs. (33) and (34) of the Ref.2)
c-------------------------------------------------------------------
       if(abs(canc-0.0d0).lt.0.000001d0) then
         top=2.0d0
         bot=0.0d0
       else
         top=1.0d0+mhalfr*mhalfr
         bot=1.0d0-mhalfr*mhalfr
       endif
       ml=0.5d0*(top*mlw+bot*mrw)
       mr=0.5d0*(top*mrw+bot*mlw)
c-------------------------------------------------------------------
c  Mplus and Mmin are calligraphic lettes M+ and M- from the paper,
c  see (19a) and (19b), p.367. of the Ref.1)
c-------------------------------------------------------------------
       if(abs(ml) .ge. 1.0d0) then
         Mplus=(ml+abs(ml))/2.0d0
       else
         Mplus=(ml+1.0d0)*(ml+1.0d0)/4.0d0
         Mplus=Mplus+beta*(ml*ml-1.0d0)*(ml*ml-1.0d0)
       endif
       Mplus1=(ml+abs(ml))/2.0d0
c-------------------------------------------------------------------
       if(abs(mr) .ge. 1.0d0) then
         Mmin=(mr-abs(mr))/2.0d0
       else
         Mmin=-(mr-1.0d0)*(mr-1.0d0)/4.0d0
         Mmin=Mmin-beta*(mr*mr-1.0d0)*(mr*mr-1.0d0)
       endif
       Mmin1=(mr-abs(mr))/2.0d0
c-------------------------------------------------------------------
c---------------------------------------
c Derivatives of ml and mr with respect
c to both sets of primitive variables:
c left  and right
c--------------------------------------
       temp_l=-un_l/(am*am)
       temp_r=-un_r/(am*am)
c--------
       dmlr_l=temp_l*damr_l
       dmlr_r=temp_l*damr_r
       dmrr_l=temp_r*damr_l
       dmrr_r=temp_r*damr_r
c--------
       dmlu_l=n_x/am+temp_l*damu_l
       dmlu_r=temp_l*damu_r
       dmru_l=temp_r*damu_l
       dmru_r=n_x/am+temp_r*damu_r
c--------
       dmlv_l=n_y/am+temp_l*damv_l
       dmlv_r=temp_l*damv_r
       dmrv_l=temp_r*damv_l
       dmrv_r=n_y/am+temp_r*damv_r
c--------
       dmlw_l=n_z/am+temp_l*damw_l
       dmlw_r=temp_l*damw_r
       dmrw_l=temp_r*damw_l
       dmrw_r=n_z/am+temp_r*damw_r
c--------
       dmlp_l=temp_l*damp_l
       dmlp_r=temp_l*damp_r
       dmrp_l=temp_r*damp_l
       dmrp_r=temp_r*damp_r
c-----------------------------
       sr_l=dmlr_l
       sr_r=dmlr_r
       su_l=dmlu_l
       su_r=dmlu_r
       sv_l=dmlv_l
       sv_r=dmlv_r
       sw_l=dmlw_l
       sw_r=dmlw_r
       sp_l=dmlp_l
       sp_r=dmlp_r
c-----------------------------------------------------------------
c   Redefinition of the derivatives of the ml & mr
c-----------------------------------------------------------------
       temp_l=(mlw-mrw)*mhalfr
       temp_r=-temp_l
c--------
       dmlr_l=0.5d0*(top*dmlr_l+bot*dmrr_l)+canc*coef*temp_l*dmfr_l
       dmlu_l=0.5d0*(top*dmlu_l+bot*dmru_l)+canc*coef*temp_l*dmfu_l
       dmlv_l=0.5d0*(top*dmlv_l+bot*dmrv_l)+canc*coef*temp_l*dmfv_l
       dmlw_l=0.5d0*(top*dmlw_l+bot*dmrw_l)+canc*coef*temp_l*dmfw_l
       dmlp_l=0.5d0*(top*dmlp_l+bot*dmrp_l)+canc*coef*temp_l*dmfp_l
c--------
       dmlr_r=0.5d0*(top*dmlr_r+bot*dmrr_r)+canc*coef*temp_l*dmfr_r
       dmlu_r=0.5d0*(top*dmlu_r+bot*dmru_r)+canc*coef*temp_l*dmfu_r
       dmlv_r=0.5d0*(top*dmlv_r+bot*dmrv_r)+canc*coef*temp_l*dmfv_r
       dmlw_r=0.5d0*(top*dmlw_r+bot*dmrw_r)+canc*coef*temp_l*dmfw_r
       dmlp_r=0.5d0*(top*dmlp_r+bot*dmrp_r)+canc*coef*temp_l*dmfp_r
c--------
       dmrr_l=0.5d0*(top*dmrr_l+bot*sr_l)+canc*coef*temp_r*dmfr_l
       dmru_l=0.5d0*(top*dmru_l+bot*su_l)+canc*coef*temp_r*dmfu_l
       dmrv_l=0.5d0*(top*dmrv_l+bot*sv_l)+canc*coef*temp_r*dmfv_l
       dmrw_l=0.5d0*(top*dmrw_l+bot*sw_l)+canc*coef*temp_r*dmfw_l
       dmrp_l=0.5d0*(top*dmrp_l+bot*sp_l)+canc*coef*temp_r*dmfp_l
c--------
       dmrr_r=0.5d0*(top*dmrr_r+bot*sr_r)+canc*coef*temp_r*dmfr_r
       dmru_r=0.5d0*(top*dmru_r+bot*su_r)+canc*coef*temp_r*dmfu_r
       dmrv_r=0.5d0*(top*dmrv_r+bot*sv_r)+canc*coef*temp_r*dmfv_r
       dmrw_r=0.5d0*(top*dmrw_r+bot*sw_r)+canc*coef*temp_r*dmfw_r
       dmrp_r=0.5d0*(top*dmrp_r+bot*sp_r)+canc*coef*temp_r*dmfp_r
c-----------------------------------------------------------
c mmid is m_{1/2} (notation as in the paper)
c see Eq.(13),p.366 of the Ref.1)
c----------------------------------------------------------
       mmid=Mplus+Mmin
c-----------------------------------------------------------
c Computing the derivatives of M+ and M-
c-----------------------------------------------------------
       if(ml .ge. 1.0d0) then
         dMpr_l=dmlr_l
         dMpu_l=dmlu_l
         dMpv_l=dmlv_l
         dMpw_l=dmlw_l
         dMpp_l=dmlp_l
c--------------------
         dMpr_r=dmlr_r
         dMpu_r=dmlu_r
         dMpv_r=dmlv_r
         dMpw_r=dmlw_r
         dMpp_r=dmlp_r
       else
        if((ml .gt. -1.0d0) .and. (ml .lt. 1.0d0)) then
         temph=(ml+1.0d0)/2.0d0
         dMpr_l=(temph+4.0d0*beta*ml*(ml*ml-1.0d0))*dmlr_l
         dMpu_l=(temph+4.0d0*beta*ml*(ml*ml-1.0d0))*dmlu_l
         dMpv_l=(temph+4.0d0*beta*ml*(ml*ml-1.0d0))*dmlv_l
         dMpw_l=(temph+4.0d0*beta*ml*(ml*ml-1.0d0))*dmlw_l
         dMpp_l=(temph+4.0d0*beta*ml*(ml*ml-1.0d0))*dmlp_l
c--------------------
           dMpr_r=(temph+4.0d0*beta*ml*(ml*ml-1.0d0))*dmlr_r
           dMpu_r=(temph+4.0d0*beta*ml*(ml*ml-1.0d0))*dmlu_r
           dMpv_r=(temph+4.0d0*beta*ml*(ml*ml-1.0d0))*dmlv_r
           dMpw_r=(temph+4.0d0*beta*ml*(ml*ml-1.0d0))*dmlw_r
           dMpp_r=(temph+4.0d0*beta*ml*(ml*ml-1.0d0))*dmlp_r
         else
           dMpr_l=0.0d0
           dMpu_l=0.0d0
           dMpv_l=0.0d0
           dMpw_l=0.0d0
           dMpp_l=0.0d0
c---------------------
           dMpr_r=0.0d0
           dMpu_r=0.0d0
           dMpv_r=0.0d0
           dMpw_r=0.0d0
           dMpp_r=0.0d0
         endif
       endif
c-----------------------------------------------------------
c   addition of low Mach number terms
c-----------------------------------------------------------
       if(ml .ge. 0.0d0) then
         m1pr_l=dmlr_l
         m1pu_l=dmlu_l
         m1pv_l=dmlv_l
         m1pw_l=dmlw_l
         m1pp_l=dmlp_l
c---------------------
         m1pr_r=dmlr_r
         m1pu_r=dmlu_r
         m1pv_r=dmlv_r
         m1pw_r=dmlw_r
         m1pp_r=dmlp_r
       else
         m1pr_l=0.0d0
         m1pu_l=0.0d0
         m1pv_l=0.0d0
         m1pw_l=0.0d0
         m1pp_l=0.0d0
c--------------------
         m1pr_r=0.0d0
         m1pu_r=0.0d0
         m1pv_r=0.0d0
         m1pw_r=0.0d0
         m1pp_r=0.0d0
       endif
c-----------------------------------------------------------
c-----------------------------------------------------------
       if(mr .ge. 1.0d0) then
         dMmr_l=0.0d0
         dMmu_l=0.0d0
         dMmv_l=0.0d0
         dMmw_l=0.0d0
         dMmp_l=0.0d0
c---------------------
         dMmr_r=0.0d0
         dMmu_r=0.0d0
         dMmv_r=0.0d0
         dMmw_r=0.0d0
         dMmp_r=0.0d0
       else
         if((mr .gt. -1.0d0) .and. (mr .lt. 1.0d0)) then
           temph=(-mr+1.0d0)/2.0d0
           dMmr_l=(temph-4.0d0*beta*mr*(mr*mr-1.0d0))*dmrr_l
           dMmu_l=(temph-4.0d0*beta*mr*(mr*mr-1.0d0))*dmru_l
           dMmv_l=(temph-4.0d0*beta*mr*(mr*mr-1.0d0))*dmrv_l
           dMmw_l=(temph-4.0d0*beta*mr*(mr*mr-1.0d0))*dmrw_l
           dMmp_l=(temph-4.0d0*beta*mr*(mr*mr-1.0d0))*dmrp_l
c--------------------
           dMmr_r=(temph-4.0d0*beta*mr*(mr*mr-1.0d0))*dmrr_r
           dMmu_r=(temph-4.0d0*beta*mr*(mr*mr-1.0d0))*dmru_r
           dMmv_r=(temph-4.0d0*beta*mr*(mr*mr-1.0d0))*dmrv_r
           dMmw_r=(temph-4.0d0*beta*mr*(mr*mr-1.0d0))*dmrw_r
           dMmp_r=(temph-4.0d0*beta*mr*(mr*mr-1.0d0))*dmrp_r
         else
           dMmr_l=dmrr_l
           dMmu_l=dmru_l
           dMmv_l=dmrv_l
           dMmw_l=dmrw_l
           dMmp_l=dmrp_l
c--------------------
           dMmr_r=dmrr_r
           dMmu_r=dmru_r
           dMmv_r=dmrv_r
           dMmw_r=dmrw_r
           dMmp_r=dmrp_r
         endif
       endif
c-----------------------------------------------------------
c   addition of low Mach number terms
c-----------------------------------------------------------
       if(mr .le. 0.0d0) then
         m1mr_l=dmrr_l
         m1mu_l=dmru_l
         m1mv_l=dmrv_l
         m1mw_l=dmrw_l
         m1mp_l=dmrp_l
c---------------------
         m1mr_r=dmrr_r
         m1mu_r=dmru_r
         m1mv_r=dmrv_r
         m1mw_r=dmrw_r
         m1mp_r=dmrp_r
       else
         m1mr_l=0.0d0
         m1mu_l=0.0d0
         m1mv_l=0.0d0
         m1mw_l=0.0d0
         m1mp_l=0.0d0
c--------------------
         m1mr_r=0.0d0
         m1mu_r=0.0d0
         m1mv_r=0.0d0
         m1mw_r=0.0d0
         m1mp_r=0.0d0
       endif
c-----------------------------------------------------------------
c computing the derivatives of m_{1/2} (notation as in the paper)
c-----------------------------------------------------------------
       dmir_l=dMpr_l+dMmr_l
       dmir_r=dMpr_r+dMmr_r
c-------------
       dmiu_l=dMpu_l+dMmu_l
       dmiu_r=dMpu_r+dMmu_r
c-------------
       dmiv_l=dMpv_l+dMmv_l
       dmiv_r=dMpv_r+dMmv_r
c-------------
       dmiw_l=dMpw_l+dMmw_l
       dmiw_r=dMpw_r+dMmw_r
c-------------
       dmip_l=dMpp_l+dMmp_l
       dmip_r=dMpp_r+dMmp_r
c-------------------------------------------------------------
c computing the main convective variables and their derivatives
c mpl_m is m^{+}_{1/2} (paper's notation) and
c mmin_m  is m^{-}_{1/2} (paper's notation),
c see Eq.(A2) on p.370 of the Ref.1)
c----------------------------------------------------------------
       termp=(Mmin1-Mmin+Mplus-Mplus1)*(1.0d0/(mhalfr*mhalfr)-1.0d0)
       termp=termp*(pold_l-pold_r)/(pold_l/rold_l+pold_r/rold_r)
c-------------------------------------------------------------
c    derivatives of the termp
c-------------------------------------------------------------
       top=(Mmin1-Mmin+Mplus-Mplus1)
       bots=1.0d0/(pold_l/rold_l+pold_r/rold_r)
       bot=(pold_l-pold_r)*bots
       temph=1.0d0/(mhalfr*mhalfr)-1.0d0
c---------------------------
       tmpr_l=(m1mr_l-dMmr_l+dMpr_l-m1pr_l)*bot*temph
       tmpr_l=tmpr_l-2.0d0*bot*top*dmfr_l/(mhalfr*mhalfr*mhalfr)
       tmpr_l=tmpr_l+temph*top*bot*bots*(pold_l/rold_l/rold_l)
c---------------------------
       tmpu_l=(m1mu_l-dMmu_l+dMpu_l-m1pu_l)*bot*temph
       tmpu_l=tmpu_l-2.0d0*bot*top*dmfu_l/(mhalfr*mhalfr*mhalfr)
c---------------------------
       tmpv_l=(m1mv_l-dMmv_l+dMpv_l-m1pv_l)*bot*temph
       tmpv_l=tmpv_l-2.0d0*bot*top*dmfv_l/(mhalfr*mhalfr*mhalfr)
c---------------------------
       tmpw_l=(m1mw_l-dMmw_l+dMpw_l-m1pw_l)*bot*temph
       tmpw_l=tmpw_l-2.0d0*bot*top*dmfw_l/(mhalfr*mhalfr*mhalfr)
c---------------------------
       tmpp_l=(m1mp_l-dMmp_l+dMpp_l-m1pp_l)*bot*temph
       tmpp_l=tmpp_l-2.0d0*bot*top*dmfp_l/(mhalfr*mhalfr*mhalfr)
       tmpp_l=tmpp_l+temph*top*bots*(1.0d0-bot/rold_l)
c------------rrrrrrrr-------
c------------rrrrrrrr-------
       tmpr_r=(m1mr_r-dMmr_r+dMpr_r-m1pr_r)*bot*temph
       tmpr_r=tmpr_r-2.0d0*bot*top*dmfr_r/(mhalfr*mhalfr*mhalfr)
       tmpr_r=tmpr_r+temph*top*bot*bots*(pold_r/rold_r/rold_r)
c---------------------------
       tmpu_r=(m1mu_r-dMmu_r+dMpu_r-m1pu_r)*bot*temph
       tmpu_r=tmpu_r-2.0d0*bot*top*dmfu_r/(mhalfr*mhalfr*mhalfr)
c---------------------------
       tmpv_r=(m1mv_r-dMmv_r+dMpv_r-m1pv_r)*bot*temph
       tmpv_r=tmpv_r-2.0d0*bot*top*dmfv_r/(mhalfr*mhalfr*mhalfr)
c---------------------------
       tmpw_r=(m1mw_r-dMmw_r+dMpw_r-m1pw_r)*bot*temph
       tmpw_r=tmpw_r-2.0d0*bot*top*dmfw_r/(mhalfr*mhalfr*mhalfr)
c---------------------------
       tmpp_r=(m1mp_r-dMmp_r+dMpp_r-m1pp_r)*bot*temph
       tmpp_r=tmpp_r-2.0d0*bot*top*dmfp_r/(mhalfr*mhalfr*mhalfr)
       tmpp_r=tmpp_r-temph*top*bots*(1.0d0+bot/rold_r)
c-------------------------------------------------------------
       if(mmid .ge. 0.0d0) then
         mpl_m = mmid
         d2mr_l=dmir_l
         d2mu_l=dmiu_l
         d2mv_l=dmiv_l
         d2mw_l=dmiw_l
         d2mp_l=dmip_l
c------------
         d2mr_r=dmir_r
         d2mu_r=dmiu_r
         d2mv_r=dmiv_r
         d2mw_r=dmiw_r
         d2mp_r=dmip_r
c------------
       else
         mpl_m = 0.0d0
         d2mr_l=0.0d0
         d2mu_l=0.0d0
         d2mv_l=0.0d0
         d2mw_l=0.0d0
         d2mp_l=0.0d0
c------------
         d2mr_r=0.0d0
         d2mu_r=0.0d0
         d2mv_r=0.0d0
         d2mw_r=0.0d0
         d2mp_r=0.0d0
       endif
c------------------------------------------------------------------
       if(mmid .le. 0.0d0) then
         mmin_m = mmid
         d3mr_l=dmir_l
         d3mu_l=dmiu_l
         d3mv_l=dmiv_l
         d3mw_l=dmiw_l
         d3mp_l=dmip_l
c------------
         d3mr_r=dmir_r
         d3mu_r=dmiu_r
         d3mv_r=dmiv_r
         d3mw_r=dmiw_r
         d3mp_r=dmip_r
c------------
       else
         mmin_m = 0.0d0
         d3mr_l=0.0d0
         d3mu_l=0.0d0
         d3mv_l=0.0d0
         d3mw_l=0.0d0
         d3mp_l=0.0d0
c------------
         d3mr_r=0.0d0
         d3mu_r=0.0d0
         d3mv_r=0.0d0
         d3mw_r=0.0d0
         d3mp_r=0.0d0
       endif
c---------------------------------------------------------------
c Computing the calligraphic P+ and P- with their derivatives
c---------------------------------------------------------------
       if(ml .ge. 1.0d0) then
         Pplus = 1.0d0
       else
         if((ml .gt. -1.0d0) .and. (ml .lt. 1.0d0)) then
           Pplus=(ml+1.0d0)*(ml+1.0d0)*(2.0d0-ml)/4.0d0
           Pplus=Pplus+alpha*ml*(ml*ml-1.0d0)*(ml*ml-1.0d0)
         else
           Pplus = 0.0d0
         endif
       endif
c---------------------------------------------------------------
       if(mr .ge. 1.0d0) then
         Pmin = 0.0d0
       else
         if((mr .gt. -1.0d0) .and. (mr .lt. 1.0d0)) then
           Pmin=(mr-1.0d0)*(mr-1.0d0)*(2.0d0+mr)/4.0d0
           Pmin=Pmin-alpha*mr*(mr*mr-1.0d0)*(mr*mr-1.0d0)
         else
           Pmin = 1.0d0
         endif
       endif
c---------------------------------------------------------------
       brac_l=(ml+1.0d0)*(2.0d0-ml)/2.0d0-(ml+1.0d0)*(ml+1.0d0)/4.0d0
       brac_l=brac_l+alpha*(ml*ml-1.0d0)*(ml*ml-1.0d0)
       brac_l=brac_l+4.0d0*alpha*ml*ml*(ml*ml-1.0d0)
c--------------
       brac_r=(mr-1.0d0)*(2.0d0+mr)/2.0d0+(mr-1.0d0)*(mr-1.0d0)/4.0d0
       brac_r=brac_r-alpha*(mr*mr-1.0d0)*(mr*mr-1.0d0)
       brac_r=brac_r-4.0d0*alpha*mr*mr*(mr*mr-1.0d0)
c---------------------------------------------------------------
       if((ml .gt. -1.0d0) .and. (ml .lt. 1.0d0)) then
         dPpr_l=brac_l*dmlr_l
         dPpr_r=brac_l*dmlr_r
c------------
         dPpu_l=brac_l*dmlu_l
         dPpu_r=brac_l*dmlu_r
c------------
         dPpv_l=brac_l*dmlv_l
         dPpv_r=brac_l*dmlv_r
c------------
         dPpw_l=brac_l*dmlw_l
         dPpw_r=brac_l*dmlw_r
c------------
         dPpp_l=brac_l*dmlp_l
         dPpp_r=brac_l*dmlp_r
c------------
       else
         dPpr_l=0.0d0
         dPpr_r=0.0d0
c-----------
         dPpu_l=0.0d0
         dPpu_r=0.0d0
c-----------
         dPpv_l=0.0d0
         dPpv_r=0.0d0
c-----------
         dPpw_l=0.0d0
         dPpw_r=0.0d0
c-----------
         dPpp_l=0.0d0
         dPpp_r=0.0d0
c-----------
       endif
c---------------------------------------------------------------
       if((mr .gt. -1.0d0) .and. (mr .lt. 1.0d0)) then
         dPmr_l=brac_r*dmrr_l
         dPmr_r=brac_r*dmrr_r
c------------
         dPmu_l=brac_r*dmru_l
         dPmu_r=brac_r*dmru_r
c------------
         dPmv_l=brac_r*dmrv_l
         dPmv_r=brac_r*dmrv_r
c------------
         dPmw_l=brac_r*dmrw_l
         dPmw_r=brac_r*dmrw_r
c------------
         dPmp_l=brac_r*dmrp_l
         dPmp_r=brac_r*dmrp_r
c------------
       else
         dPmr_l=0.0d0
         dPmr_r=0.0d0
c-----------
         dPmu_l=0.0d0
         dPmu_r=0.0d0
c-----------
         dPmv_l=0.0d0
         dPmv_r=0.0d0
c-----------
         dPmw_l=0.0d0
         dPmw_r=0.0d0
c-----------
         dPmp_l=0.0d0
         dPmp_r=0.0d0
c-----------
       endif
c---------------------------------------------------------------------
c computing pmid -- p_{1/2} and its derivatives
c---------------------------------------------------------------------
       dpir_l=dPpr_l*pold_l+dPmr_l*pold_r
       dpiu_l=dPpu_l*pold_l+dPmu_l*pold_r
       dpiv_l=dPpv_l*pold_l+dPmv_l*pold_r
       dpiw_l=dPpw_l*pold_l+dPmw_l*pold_r
       dpip_l=dPpp_l*pold_l+Pplus+dPmp_l*pold_r
c----------------------------
       dpir_r=dPpr_r*pold_l+dPmr_r*pold_r
       dpiu_r=dPpu_r*pold_l+dPmu_r*pold_r
       dpiv_r=dPpv_r*pold_l+dPmv_r*pold_r
       dpiw_r=dPpw_r*pold_l+dPmw_r*pold_r
       dpip_r=dPpp_r*pold_l+Pmin+dPmp_r*pold_r
c---------------------------------------------------------------------
c  !!!!!!!!!!!!!!!!!!  JACOBIAN  !!!!!!!!!!!!!!!!!!!!!!!!!!!!
c---------------------------------------------------------------------
       rum=am*(mpl_m*rold_l+mmin_m*rold_r)+canc*am*termp
c---------------------------------------------------------------------
       rumr_l=damr_l*(mpl_m*rold_l+mmin_m*rold_r)+
     &        am*(d2mr_l*rold_l+mpl_m+d3mr_l*rold_r)
       rumr_l=rumr_l+canc*coef*(damr_l*termp+am*tmpr_l)
       rumu_l=damu_l*(mpl_m*rold_l+mmin_m*rold_r)+
     &        am*(d2mu_l*rold_l+d3mu_l*rold_r)
       rumu_l=rumu_l+canc*coef*(damu_l*termp+am*tmpu_l)
       rumv_l=damv_l*(mpl_m*rold_l+mmin_m*rold_r)+
     &        am*(d2mv_l*rold_l+d3mv_l*rold_r)
       rumv_l=rumv_l+canc*coef*(damv_l*termp+am*tmpv_l)
       rumw_l=damw_l*(mpl_m*rold_l+mmin_m*rold_r)+
     &        am*(d2mw_l*rold_l+d3mw_l*rold_r)
       rumw_l=rumw_l+canc*coef*(damw_l*termp+am*tmpw_l)
       rump_l=damp_l*(mpl_m*rold_l+mmin_m*rold_r)+
     &        am*(d2mp_l*rold_l+d3mp_l*rold_r)
       rump_l=rump_l+canc*coef*(damp_l*termp+am*tmpp_l)
c-------------------------------------------------
       rumr_r=damr_r*(mpl_m*rold_l+mmin_m*rold_r)+
     &        am*(d2mr_r*rold_l+mmin_m+d3mr_r*rold_r)
       rumr_r=rumr_r+canc*coef*(damr_r*termp+am*tmpr_r)
       rumu_r=damu_r*(mpl_m*rold_l+mmin_m*rold_r)+
     &        am*(d2mu_r*rold_l+d3mu_r*rold_r)
       rumu_r=rumu_r+canc*coef*(damu_r*termp+am*tmpu_r)
       rumv_r=damv_r*(mpl_m*rold_l+mmin_m*rold_r)+
     &        am*(d2mv_r*rold_l+d3mv_r*rold_r)
       rumv_r=rumv_r+canc*coef*(damv_r*termp+am*tmpv_r)
       rumw_r=damw_r*(mpl_m*rold_l+mmin_m*rold_r)+
     &        am*(d2mw_r*rold_l+d3mw_r*rold_r)
       rumw_r=rumw_r+canc*coef*(damw_r*termp+am*tmpw_r)
       rump_r=damp_r*(mpl_m*rold_l+mmin_m*rold_r)+
     &        am*(d2mp_r*rold_l+d3mp_r*rold_r)
       rump_r=rump_r+canc*coef*(damp_r*termp+am*tmpp_r)
c---------------------------------------------------------------------
c---------------------------------------------------------------------
       jl(1,1)=rumr_l
       jl(1,2)=rumu_l
       jl(1,3)=rumv_l
       jl(1,4)=rumw_l
       jl(1,5)=rump_l
c------------------------------------
       jr(1,1)=rumr_r
       jr(1,2)=rumu_r
       jr(1,3)=rumv_r
       jr(1,4)=rumw_r
       jr(1,5)=rump_r
c------------------------------------
ccccc    f222222222222  -------------
c derivatives with respect to left set of
c primitive variables
c------------------------------------
       if(rum .ge. 0.0d0) then
         br1=rum*un_l
         br2=rum*ut1_l
         br3=rum*ut2_l
       else
         br1=rum*un_r
         br2=rum*ut1_r
         br3=rum*ut2_r
       endif
c------------------------------------
       if(rum .ge. 0.0d0) then
         br1=rumr_l*un_l
         br2=rumr_l*ut1_l
         br3=rumr_l*ut2_l
       else
         br1=rumr_l*un_r
         br2=rumr_l*ut1_r
         br3=rumr_l*ut2_r
       endif
       jl(2,1)=n_x*(br1+dpir_l)+br2*t1_x+br3*t2_x
       jl(3,1)=n_y*(br1+dpir_l)+br2*t1_y+br3*t2_y
       jl(4,1)=n_z*(br1+dpir_l)+br2*t1_z+br3*t2_z
c-------------------------------------------------------------------------
       if(rum .ge. 0.0d0) then
         br1=rumu_l*un_l+rum*n_x
         br2=rumu_l*ut1_l+rum*t1_x
         br3=rumu_l*ut2_l+rum*t2_x
       else
         br1=rumu_l*un_r
         br2=rumu_l*ut1_r
         br3=rumu_l*ut2_r
       endif
       jl(2,2)=n_x*(br1+dpiu_l)+br2*t1_x+br3*t2_x
       jl(3,2)=n_y*(br1+dpiu_l)+br2*t1_y+br3*t2_y
       jl(4,2)=n_z*(br1+dpiu_l)+br2*t1_z+br3*t2_z
c-------------------------------------------------------------------------
       if(rum .ge. 0.0d0) then
         br1=rumv_l*un_l+rum*n_y
         br2=rumv_l*ut1_l+rum*t1_y
         br3=rumv_l*ut2_l+rum*t2_y
       else
         br1=rumv_l*un_r
         br2=rumv_l*ut1_r
         br3=rumv_l*ut2_r
       endif
       jl(2,3)=n_x*(br1+dpiv_l)+br2*t1_x+br3*t2_x
       jl(3,3)=n_y*(br1+dpiv_l)+br2*t1_y+br3*t2_y
       jl(4,3)=n_z*(br1+dpiv_l)+br2*t1_z+br3*t2_z
c-------------------------------------------------------------------------
       if(rum .ge. 0.0d0) then
         br1=rumw_l*un_l+rum*n_z
         br2=rumw_l*ut1_l+rum*t1_z
         br3=rumw_l*ut2_l+rum*t2_z
       else
         br1=rumw_l*un_r
         br2=rumw_l*ut1_r
         br3=rumw_l*ut2_r
       endif
       jl(2,4)=n_x*(br1+dpiw_l)+br2*t1_x+br3*t2_x
       jl(3,4)=n_y*(br1+dpiw_l)+br2*t1_y+br3*t2_y
       jl(4,4)=n_z*(br1+dpiw_l)+br2*t1_z+br3*t2_z
c-------------------------------------------------------------------------
       if(rum .ge. 0.0d0) then
         br1=rump_l*un_l
         br2=rump_l*ut1_l
         br3=rump_l*ut2_l
       else
         br1=rump_l*un_r
         br2=rump_l*ut1_r
         br3=rump_l*ut2_r
       endif
       jl(2,5)=n_x*(br1+dpip_l)+br2*t1_x+br3*t2_x
       jl(3,5)=n_y*(br1+dpip_l)+br2*t1_y+br3*t2_y
       jl(4,5)=n_z*(br1+dpip_l)+br2*t1_z+br3*t2_z
c-------------------------------------------------------------------------
c        rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
c-------------------------------------------------------------------------
       if(rum .ge. 0.0d0) then
         br1=rumr_r*un_l
         br2=rumr_r*ut1_l
         br3=rumr_r*ut2_l
       else
         br1=rumr_r*un_r
         br2=rumr_r*ut1_r
         br3=rumr_r*ut2_r
       endif
       jr(2,1)=n_x*(br1+dpir_r)+br2*t1_x+br3*t2_x
       jr(3,1)=n_y*(br1+dpir_r)+br2*t1_y+br3*t2_y
       jr(4,1)=n_z*(br1+dpir_r)+br2*t1_z+br3*t2_z
c------------------------------------------------------------------------
       if(rum .ge. 0.0d0) then
         br1=rumu_r*un_l
         br2=rumu_r*ut1_l
         br3=rumu_r*ut2_l
       else
         br1=rumu_r*un_r+rum*n_x
         br2=rumu_r*ut1_r+rum*t1_x
         br3=rumu_r*ut2_r+rum*t2_x
       endif
       jr(2,2)=n_x*(br1+dpiu_r)+br2*t1_x+br3*t2_x
       jr(3,2)=n_y*(br1+dpiu_r)+br2*t1_y+br3*t2_y
       jr(4,2)=n_z*(br1+dpiu_r)+br2*t1_z+br3*t2_z
c------------------------------------------------------------------------
       if(rum .ge. 0.0d0) then
         br1=rumv_r*un_l
         br2=rumv_r*ut1_l
         br3=rumv_r*ut2_l
       else
         br1=rumv_r*un_r+rum*n_y
         br2=rumv_r*ut1_r+rum*t1_y
         br3=rumv_r*ut2_r+rum*t2_y
       endif
       jr(2,3)=n_x*(br1+dpiv_r)+br2*t1_x+br3*t2_x
       jr(3,3)=n_y*(br1+dpiv_r)+br2*t1_y+br3*t2_y
       jr(4,3)=n_z*(br1+dpiv_r)+br2*t1_z+br3*t2_z
c-----------------------------------------------------------------------
       if(rum .ge. 0.0d0) then
         br1=rumw_r*un_l
         br2=rumw_r*ut1_l
         br3=rumw_r*ut2_l
       else
         br1=rumw_r*un_r+rum*n_z
         br2=rumw_r*ut1_r+rum*t1_z
         br3=rumw_r*ut2_r+rum*t2_z
       endif
       jr(2,4)=n_x*(br1+dpiw_r)+br2*t1_x+br3*t2_x
       jr(3,4)=n_y*(br1+dpiw_r)+br2*t1_y+br3*t2_y
       jr(4,4)=n_z*(br1+dpiw_r)+br2*t1_z+br3*t2_z
c-----------------------------------------------------------------------
       if(rum .ge. 0.0d0) then
         br1=rump_r*un_l
         br2=rump_r*ut1_l
         br3=rump_r*ut2_l
       else
         br1=rump_r*un_r
         br2=rump_r*ut1_r
         br3=rump_r*ut2_r
       endif
       jr(2,5)=n_x*(br1+dpip_r)+br2*t1_x+br3*t2_x
       jr(3,5)=n_y*(br1+dpip_r)+br2*t1_y+br3*t2_y
       jr(4,5)=n_z*(br1+dpip_r)+br2*t1_z+br3*t2_z
c-------------------------------------------------------
c-------------------------------------------------------
       hr_l=(eold_l+pold_l/rold_l)
       hr_r=(eold_r+pold_r/rold_r)
c-------------------------------------------------
       if(rum .ge. 0.0d0) then
         br1=rumr_l*hr_l-rum*ga*pold_l/gm1/rold_l/rold_l
       else
         br1=rumr_l*hr_r
       endif
       jl(5,1)=br1
c-------------------------------------------------
       if(rum .ge. 0.0d0) then
         br1=rumu_l*hr_l+rum*uold_l
       else
         br1=rumu_l*hr_r
       endif
       jl(5,2)=br1
c-------------------------------------------------
       if(rum .ge. 0.0d0) then
         br1=rumv_l*hr_l+rum*vold_l
       else
         br1=rumv_l*hr_r
       endif
       jl(5,3)=br1
c-------------------------------------------------
       if(rum .ge. 0.0d0) then
         br1=rumw_l*hr_l+rum*wold_l
       else
         br1=rumw_l*hr_r
       endif
       jl(5,4)=br1
c-------------------------------------------------
       if(rum .ge. 0.0d0) then
         br1=rump_l*hr_l+rum*ga/gm1/rold_l
       else
         br1=rump_l*hr_r
       endif
       jl(5,5)=br1
c-------------------------------------------------
c-------------------------------------------------
       if(rum .ge. 0.0d0) then
         br1=rumr_r*hr_l
       else
         br1=rumr_r*hr_r-rum*ga*pold_r/gm1/rold_r/rold_r
       endif
       jr(5,1)=br1
c---------------------
       if(rum .ge. 0.0d0) then
         br1=rumu_r*hr_l
       else
         br1=rumu_r*hr_r+rum*uold_r
       endif
       jr(5,2)=br1
c---------------------
       if(rum .ge. 0.0d0) then
         br1=rumv_r*hr_l
       else
         br1=rumv_r*hr_r+rum*vold_r
       endif
       jr(5,3)=br1
c---------------------
       if(rum .ge. 0.0d0) then
         br1=rumw_r*hr_l
       else
         br1=rumw_r*hr_r+rum*wold_r
       endif
       jr(5,4)=br1
c---------------------
       if(rum .ge. 0.0d0) then
         br1=rump_r*hr_l
       else
         br1=rump_r*hr_r+rum*ga/gm1/rold_r
       endif
       jr(5,5)=br1
c---------------------------------------------------
c----------------------------------------------------------
c  matrixes wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
c----------------------------------------------------------
       wl(1,1)=1.0d0
       wl(1,2)=0.0d0
       wl(1,3)=0.0d0
       wl(1,4)=0.0d0
       wl(1,5)=0.0d0
c------------------------------
       wl(2,1)=-uold_l/rold_l
       wl(2,2)=1.0d0/rold_l
       wl(2,3)=0.0d0
       wl(2,4)=0.0d0
       wl(2,5)=0.0d0
c------------------------------
       wl(3,1)=-vold_l/rold_l
       wl(3,2)=0.0d0
       wl(3,3)=1.0d0/rold_l
       wl(3,4)=0.0d0
       wl(3,5)=0.0d0
c------------------------------
       wl(4,1)=-wold_l/rold_l
       wl(4,2)=0.0d0
       wl(4,3)=0.0d0
       wl(4,4)=1.0d0/rold_l
       wl(4,5)=0.0d0
c------------------------------
       wl(5,1)=gm1*(uold_l*uold_l+vold_l*vold_l+wold_l*wold_l)/2.0d0
       wl(5,2)=-uold_l*gm1
       wl(5,3)=-vold_l*gm1
       wl(5,4)=-wold_l*gm1
       wl(5,5)=gm1
c------------------------------
c------------------------------
       wr(1,1)=1.0d0
       wr(1,2)=0.0d0
       wr(1,3)=0.0d0
       wr(1,4)=0.0d0
       wr(1,5)=0.0d0
c------------------------------
       wr(2,1)=-uold_r/rold_r
       wr(2,2)=1.0d0/rold_r
       wr(2,3)=0.0d0
       wr(2,4)=0.0d0
       wr(2,5)=0.0d0
c------------------------------
       wr(3,1)=-vold_r/rold_r
       wr(3,2)=0.0d0
       wr(3,3)=1.0d0/rold_r
       wr(3,4)=0.0d0
       wr(3,5)=0.0d0
c------------------------------
       wr(4,1)=-wold_r/rold_r
       wr(4,2)=0.0d0
       wr(4,3)=0.0d0
       wr(4,4)=1.0d0/rold_r
       wr(4,5)=0.0d0
c------------------------------
       wr(5,1)=gm1*(uold_r*uold_r+vold_r*vold_r+wold_r*wold_r)/2.0d0
       wr(5,2)=-uold_r*gm1
       wr(5,3)=-vold_r*gm1
       wr(5,4)=-wold_r*gm1
       wr(5,5)=gm1
c----------------------------------------------
c----------------------------------------------
       do 1 i=1,5
        do 2 j=1,5
         jtl(i,j)=0.0d0
         jtr(i,j)=0.0d0
         do 3 k=1,5
          jtl(i,j)=jtl(i,j)+jl(i,k)*wl(k,j)
          jtr(i,j)=jtr(i,j)+jr(i,k)*wr(k,j)
 3       continue
 2      continue
 1     continue
c----------------------------------------------
       return
       end




















