!
!  Copyright 2017 SALMON developers
!
!  Licensed under the Apache License, Version 2.0 (the "License");
!  you may not use this file except in compliance with the License.
!  You may obtain a copy of the License at
!
!      http://www.apache.org/licenses/LICENSE-2.0
!
!  Unless required by applicable law or agreed to in writing, software
!  distributed under the License is distributed on an "AS IS" BASIS,
!  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
!  See the License for the specific language governing permissions and
!  limitations under the License.
!
!This file is "current.f90"
!This file contain one subroutine.
!SUBROUTINE current
!--------10--------20--------30--------40--------50--------60--------70--------80--------90--------100-------110-------120-------130
#ifdef ARTED_USE_NVTX
#define NVTX_BEG(name,id)  call nvtxStartRange(name,id)
#define NVTX_END()         call nvtxEndRange()
#else
#define NVTX_BEG(name,id)
#define NVTX_END()
#endif

#ifdef ARTED_CURRENT_PREPROCESSING
subroutine current_RT_preconditioner(ib,ik,A)
  use Global_Variables
  use opt_variables
  implicit none
  integer,intent(in)    :: ib,ik
  complex(8),intent(in) :: A(0:NL-1)
  real(8) :: nabt(12),zx,zy,zz

  nabt( 1: 4) = nabx(1:4)
  nabt( 5: 8) = naby(1:4)
  nabt( 9:12) = nabz(1:4)

  zx = 0.d0
  zy = 0.d0
  zz = 0.d0
  call current_stencil(nabt,A,zx,zy,zz)

  zcx(ib,ik)=zx
  zcy(ib,ik)=zy
  zcz(ib,ik)=zz
end subroutine
#endif

subroutine current0
  use Global_Variables, only: NBoccmax,zu_t
  implicit none
  call current('ZE',NBoccmax,zu_t)
end subroutine

subroutine current_GS
  use Global_Variables, only: NB,zu_GS
  implicit none
  call current('GS',NB,zu_GS)
end subroutine

subroutine current_RT
  use Global_Variables, only: NBoccmax,zu_t
  implicit none
  call current('RT',NBoccmax,zu_t)
end subroutine

subroutine current_RT_MS(ixy_m)
  use Global_Variables, only: NBoccmax,zu_m
  implicit none
  integer,intent(in) :: ixy_m
  call current('RT',NBoccmax,zu_m(:,:,:,ixy_m))
end subroutine

subroutine current(mode,NBtmp,zutmp)
  use Global_Variables, only: NL,NK_s,NK_e
  use timer
#ifdef ARTED_USE_NVTX
  use nvtx
#endif
  implicit none
  character(2), intent(in) :: mode
  integer,intent(in)       :: NBtmp
  complex(8),intent(in)    :: zutmp(NL,NBtmp,NK_s:NK_e)
  real(8) :: jx,jy,jz

  NVTX_BEG('current_RT()',2)
  call timer_begin(LOG_CURRENT)
#ifdef _OPENACC
  if (mode == 'RT') then
    call current_acc_impl(zutmp,jx,jy,jz)
  else
    call impl(mode,NBtmp,zutmp,jx,jy,jz)
  end if
#else
  call impl(mode,NBtmp,zutmp,jx,jy,jz)
#endif
  call summation(jx,jy,jz)
  call timer_end(LOG_CURRENT)
  NVTX_END()

contains
  subroutine impl(mode, NBtmp, zutmp, jxs, jys, jzs)
    use Global_Variables
    use projector
    implicit none
    character(2),intent(in) :: mode
    integer,intent(in)      :: NBtmp
    complex(8),intent(in)   :: zutmp(0:NL-1,NBtmp,NK_s:NK_e)
    real(8),intent(out)     :: jxs,jys,jzs

    integer :: ikb,ib,ik
    real(8) :: jx,jy,jz,IaLxyz
    real(8) :: nabt(12)

    nabt( 1: 4) = nabx(1:4)
    nabt( 5: 8) = naby(1:4)
    nabt( 9:12) = nabz(1:4)

    IaLxyz = 1.0 / aLxyz

    call update_projector(kac)

    jxs=0.d0
    jys=0.d0
    jzs=0.d0
!$omp parallel reduction(+:jxs,jys,jzs)

    if (mode == 'ZE' .or. mode == 'GS') then
!$omp do private(ikb,ik,ib,jx,jy,jz)
      do ikb=1,NKB
        ik=ik_table(ikb)
        ib=ib_table(ikb)

        call init(ik,ib,zutmp(:,ib,ik),jx,jy,jz)
        call stencil(ik,ib,zutmp(:,ib,ik),nabt,jx,jy,jz)
        call pseudo_pt(ik,ib,zutmp(:,ib,ik),IaLxyz,jx,jy,jz)

        jxs=jxs+jx
        jys=jys+jy
        jzs=jzs+jz
      end do
!$omp end do
    else if (mode == 'RT') then
!$omp do private(ikb,ik,ib,jx,jy,jz)
      do ikb=1,NKB
        ik=ik_table(ikb)
        ib=ib_table(ikb)

        call init(ik,ib,zutmp(:,ib,ik),jx,jy,jz)
#ifdef ARTED_CURRENT_PREPROCESSING
        call preconditioned_stencil(ik,ib,jx,jy,jz)
#else
        call stencil(ik,ib,zutmp(:,ib,ik),nabt,jx,jy,jz)
#endif
        call pseudo_pt(ik,ib,zutmp(:,ib,ik),IaLxyz,jx,jy,jz)

        jxs=jxs+jx
        jys=jys+jy
        jzs=jzs+jz
      end do
!$omp end do
    else
      call err_finalize('ERROR: current mode')
    end if
!$omp end parallel
  end subroutine

  subroutine init(ik,ib,zutmp,jx,jy,jz)
    use Global_Variables
    implicit none
    integer,intent(in)    :: ik,ib
    complex(8),intent(in) :: zutmp(0:NL-1)
    real(8),intent(out)   :: jx,jy,jz

    integer :: i
    real(8) :: jt

    jt=0.d0
!dir$ vector aligned
    do i=0,NL-1
      jt=jt+real(zutmp(i))**2+aimag(zutmp(i))**2
    end do

    jx=occ(ib,ik)*kAc(ik,1)*jt
    jy=occ(ib,ik)*kAc(ik,2)*jt
    jz=occ(ib,ik)*kAc(ik,3)*jt
  end subroutine

  subroutine stencil(ik,ib,zutmp,nabt,jx,jy,jz)
    use Global_Variables
    use opt_variables
    implicit none
    integer,intent(in)    :: ik,ib
    complex(8),intent(in) :: zutmp(0:NL-1)
    real(8),intent(in)    :: nabt(12)
    real(8),intent(inout) :: jx,jy,jz
    real(8) :: jxt,jyt,jzt

    jxt=0.d0
    jyt=0.d0
    jzt=0.d0
    call current_stencil(nabt,zutmp,jxt,jyt,jzt)

    jx=jx+jxt*occ(ib,ik)
    jy=jy+jyt*occ(ib,ik)
    jz=jz+jzt*occ(ib,ik)
  end subroutine

#ifdef ARTED_CURRENT_PREPROCESSING
  subroutine preconditioned_stencil(ik,ib,jx,jy,jz)
    use Global_Variables
    use opt_variables
    implicit none
    integer,intent(in)    :: ik,ib
    real(8),intent(inout) :: jx,jy,jz

    jx=jx+zcx(ib,ik)*occ(ib,ik)
    jy=jy+zcy(ib,ik)*occ(ib,ik)
    jz=jz+zcz(ib,ik)*occ(ib,ik)
  end subroutine
#endif

  subroutine pseudo_pt(ik,ib,zutmp,IaLxyz,jx,jy,jz)
    use Global_Variables
    use omp_lib
    use opt_variables
    use timer
    implicit none
    integer,intent(in)    :: ik,ib
    complex(8),intent(in) :: zutmp(NL)
    real(8),intent(in)    :: IaLxyz
    real(8),intent(out)   :: jx,jy,jz

    integer    :: ilma,ia,j,i,ix,iy,iz
    real(8)    :: x,y,z
    real(8)    :: jxt,jyt,jzt
    complex(8) :: uVpsi,uVpsix,uVpsiy,uVpsiz

    jxt=0d0
    jyt=0d0
    jzt=0d0

    do ilma=1,Nlma
      ia=a_tbl(ilma)
      uVpsi=0.d0; uVpsix=0.d0; uVpsiy=0.d0; uVpsiz=0.d0
      do j=1,Mps(ia)
        i=Jxyz(j,ia)

        ix=Jxx(j,ia); x=Lx(i)*Hx-ix*aLx
        iy=Jyy(j,ia); y=Ly(i)*Hy-iy*aLy
        iz=Jzz(j,ia); z=Lz(i)*Hz-iz*aLz

        uVpsi =uVpsi +conjg(zproj(j,ilma,ik))  *zutmp(i)
        uVpsix=uVpsix+conjg(zproj(j,ilma,ik))*x*zutmp(i)
        uVpsiy=uVpsiy+conjg(zproj(j,ilma,ik))*y*zutmp(i)
        uVpsiz=uVpsiz+conjg(zproj(j,ilma,ik))*z*zutmp(i)
      end do
      uVpsi =uVpsi *Hxyz*iuV(ilma)
      uVpsix=uVpsix*Hxyz
      uVpsiy=uVpsiy*Hxyz
      uVpsiz=uVpsiz*Hxyz
      jxt=jxt+occ(ib,ik)*IaLxyz*2*aimag(conjg(uVpsix)*uVpsi)
      jyt=jyt+occ(ib,ik)*IaLxyz*2*aimag(conjg(uVpsiy)*uVpsi)
      jzt=jzt+occ(ib,ik)*IaLxyz*2*aimag(conjg(uVpsiz)*uVpsi)
    end do

    jx=jx*Hxyz*IaLxyz+jxt
    jy=jy*Hxyz*IaLxyz+jyt
    jz=jz*Hxyz*IaLxyz+jzt
  end subroutine

  subroutine summation(jx,jy,jz)
    use Global_Variables, only: jav
    use salmon_parallel, only: nproc_group_tdks
    use salmon_communication, only: comm_summation
    use timer
    implicit none
    real(8),intent(in) :: jx,jy,jz
    real(8) :: jav_l(3)

    call timer_begin(LOG_ALLREDUCE)
    jav_l(1)=jx
    jav_l(2)=jy
    jav_l(3)=jz
    call comm_summation(jav_l,jav,3,nproc_group_tdks)
    call timer_end(LOG_ALLREDUCE)
  end subroutine
end subroutine


text:
!**********************************************************************!
SUBROUTINE SEDZLJ_MAIN

  !**********************************************************************!
  !
  ! **  SUBROUTINE CALSED CALCULATES COHESIVE SEDIMENT SETTLING,
  ! **  DEPOSITION AND RESUSPENSION According to SEDZLJ MODEL
  !
  ! ORIGINAL DATE :  May 24, 2006
  !  Craig Jones and Scott James
  ! REVISED: SIGMA-ZED AND OMP - 2016-11-07
  !  Paul M. Craig

  !**********************************************************************!

  USE GLOBAL
  IMPLICIT NONE

  REAL(RKD) :: CRNUM,SEDAVG,GRADSED,CLEFT,CRIGHT,WVEL,SMASSD,SMASSU,SMASS
  REAL(RKD),SAVE :: LASTTIME=-9999.
  REAL(RKD),DIMENSION(NSCM) :: BLFLUXU,BLFLUXD
  REAL    :: T1TMP
  INTEGER :: L,K,NS,ND,LL,LF,LP,LUTMP,LDTMP,NSB

  ! *** ENFORCE STARTUP FOR ENTIRE SEDIMENT PROCESS
  IF( LASTTIME == -9999. ) LASTTIME = TIMEDAY
  T1TMP=SECNDS(0.0)

  SSGI(1:NSCM)=1.0/(1.0E6*SSG(1:NSCM))

  ! *** INITIALIZE CURRENT TIME STEP VARIABLES FOR SEDZLJ
  !$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(ND,LF,LL,LP,L)
  DO ND=1,NDM
    LF=(ND-1)*LDMWET+1
    LL=MIN(LF+LDMWET-1,LAWET)
    DO LP=LF,LL
      L=LWET(LP)
      HPCM(L) = 100.0*HP(L)
    ENDDO
  ENDDO
  !$OMP END PARALLEL DO

  ! *** Calculates the shear stresses from the velocity output of the hydraulic model.
  CALL SEDZLJ_SHEAR

  IF( ISSLOPE ) CALL SEDZLJ_SLOPE

  ! *** Calling bed load calculation.  BEDLOADJ subroutine provides CBL, the sediment concentration load.
  IF( NCALC_BL > 0 )THEN
    CALL BEDLOADJ
  ENDIF

  ! *** Calls the sedflume transport. NOTE: ISEDTIME is the time difference between when sediment
  ! *** transport begins versus the beginning of hydraulic transport.
  IF( NSEDFLUME == 1 )THEN

    !*************************************************************************************!
    !   SEDZLJ Sediment Transport
    !
    !$OMP PARALLEL DEFAULT(SHARED)

    !$OMP DO PRIVATE(ND,NS,K,LP,L,WVEL,CLEFT,CRIGHT)
    DO ND=1,NDM
      ! *** ZERO LAYER FLUXES, INCLUDING BOTTOM LAYER
      DO NS=1,NSCM
        DO K=1,KS
          DO LP=1,LLWET(K,ND)
            L=LKWET(LP,K,ND)
            SEDF(L,K,NS) = 0.0
            WSETA(L,K,NS) = WSEDO(NS)
          ENDDO

          ! *** ZERO BED/WATER INTERFACE FLUX
          IF( K == KS )THEN
            DO LP=1,LLWET(KC,ND)
              L=LKWET(LP,KC,ND)
              SEDF(L,0,NS) = 0.0
            ENDDO
          ENDIF
        ENDDO
      ENDDO

      !-----------------------------------------------------------------------------------!
      !
      ! *** HORIZONTAL LOOPS
      ! *** These loops account for sediment flux between the water layers due to settling.
      IF( KC /= 1 )THEN
        DO NS=1,NSCM
          DO LP=1,LLWET(KC,ND)
            L=LKWET(LP,KC,ND)
            WVEL = DTSEDJ*HPKI(L,KC)
            CLEFT = 1.0 + WSETA(L,KC-1,NS)*WVEL
            CRIGHT = MAX(SED(L,KC,NS),0.0)
            SED(L,KC,NS) = CRIGHT/CLEFT
            SEDF(L,KC-1,NS) = -WSETA(L,KC-1,NS)*SED(L,KC,NS)
          ENDDO

          IF( KC /= 2 )THEN
            DO K=KS,2,-1
              DO LP=1,LLWET(K-1,ND)
                L=LKWET(LP,K-1,ND)
                WVEL = DTSEDJ*HPKI(L,K)
                CLEFT = 1.0+WSETA(L,K-1,NS)*WVEL
                CRIGHT = MAX(SED(L,K,NS),0.0) - SEDF(L,K,NS)*WVEL
                SED(L,K,NS) = CRIGHT/CLEFT
                SEDF(L,K-1,NS) = -WSETA(L,K-1,NS)*SED(L,K,NS)
              ENDDO
            ENDDO
          ENDIF
        ENDDO
      ENDIF
    ENDDO
    !$OMP END DO

    ! **********************************************************************************
    ! *** Erosion/Deposition Loop
    !$OMP DO PRIVATE(ND,LF,LL,LP,L)
    DO ND=1,NDM
      LF=(ND-1)*LDMWET+1
      LL=MIN(LF+LDMWET-1,LAWET)
      DO LP=LF,LL
        L=LWET(LP)

        ! *** Calculate total flux from bed and determine if
        ! *** there is enough sediment to erode from SEDZLJ
        CALL SEDZLJ(L)

      ENDDO
    ENDDO
    !$OMP END DO

    ! **********************************************************************************
    ! *** Compute cell centered bedload fluxes for outflow or recirculation boundary
    !$OMP SINGLE
    IF( NSBDLDBC > 0 )THEN
      BLFLUXU = 0.0
      BLFLUXD = 0.0
      DO NSB=1,NSBDLDBC
        LUTMP = LSBLBCU(NSB)
        LDTMP = LSBLBCD(NSB)

        SMASSU = TSED(1,LUTMP)
        DO NS=NNONCO,NSCM
          BLFLUXU(NS) = ( DBL(LUTMP,NS) - EBL(LUTMP,NS) )/10000.             ! *** Flux in/out of bedload CBL                   (g/cm^2)
          TSED(1,LUTMP) = TSED(1,LUTMP) - BLFLUXU(NS)                        ! *** Back out erosion/depostion due to bedload    (g/cm^2)
          QBLFLUX(LUTMP,NS)  = -DBL(LUTMP,NS)/10000.                         ! *** Flux out of bed for bedload                  (g/cm^2)
          QSBDLDOT(LUTMP,NS) =  DBL(LUTMP,NS)*DXYP(LUTMP)/DTSEDJ             ! *** Sediment flux from upstream cell             (g/s)
          EBL(LUTMP,NS) = 0.0
        ENDDO

        ! *** UPDATE PERSED WITH MACHINE PRECISION A CONSIDERATION: UPSTREAM
        SMASS = 0.0
        DO NS=1,NSCM
          SMASS = SMASS + MAX(PERSED(NS,1,LUTMP)*SMASSU - BLFLUXU(NS),0.0)
        ENDDO
        IF( SMASS > 0.0 )THEN
          DO NS=1,NSCM
            PERSED(NS,1,LUTMP) = MAX(PERSED(NS,1,LUTMP)*SMASSU - BLFLUXU(NS),0.0)/SMASS
          ENDDO
          TSED(1,LUTMP) = SMASS
        ELSE
          TSED(1,LUTMP) = 0.0
          PERSED(1:NSCM,1,LUTMP) = 0.0
        ENDIF

        ! *** Update EFDC variables
        SEDDIA50(LUTMP,1) = SUM(PERSED(1:NSCM,1,LUTMP)*D50(1:NSCM))
        HBED(LUTMP,1)  = 0.01_8*TSED(1,LUTMP)/BULKDENS(1,LUTMP)
        SEDBT(LUTMP,1) = TSED(1,LUTMP)*10000.
        SEDB(LUTMP,1,1:NSCM)  = SEDBT(LUTMP,1)*PERSED(1:NSCM,1,LUTMP)

        IF( LDTMP > 0 )THEN
          ! *** The flow is returning.  Add to downstream cell
          SMASSD = TSED(1,LDTMP)
          DO NS=NNONCO,NSCM
            BLFLUXD(NS)    = DBL(LUTMP,NS)/10000.*DXYP(LUTMP)*DXYIP(LDTMP)     ! *** Depostion due to bedload from upstream cell  (g/cm^2)
            TSED(1,LDTMP) = TSED(1,LDTMP) + BLFLUXD(NS)                        ! *** Add mass to downstream cell                  (g/cm^2)
          ENDDO

          ! *** UPDATE PERSED WITH MACHINE PRECISION A CONSIDERATION: DOWNSTREAM
          SMASS = 0.0
          DO NS=1,NSCM
            SMASS = SMASS + MAX(PERSED(NS,1,LDTMP)*SMASSD + BLFLUXD(NS),0.0)
          ENDDO
          IF( SMASS > 0.0 )THEN
            DO NS=1,NSCM
              PERSED(NS,1,LDTMP) = MAX(PERSED(NS,1,LDTMP)*SMASSD + BLFLUXD(NS),0.0)/SMASS
            ENDDO
            TSED(1,LDTMP) = SMASS
          ELSE
            TSED(1,LUTMP) = 0.0
            PERSED(1:NSCM,1,LUTMP) = 0.0
          ENDIF

          ! *** Update EFDC variables
          SEDDIA50(LDTMP,1) = SUM(PERSED(1:NSCM,1,LDTMP)*D50(1:NSCM))
          HBED(LDTMP,1)  = 0.01_8*TSED(1,LDTMP)/BULKDENS(1,LDTMP)
          SEDBT(LDTMP,1) = TSED(1,LDTMP)*10000.
          SEDB(LDTMP,1,1:NSCM)  = SEDBT(LDTMP,1)*PERSED(1:NSCM,1,LDTMP)
        ENDIF

      ENDDO
    ENDIF
    !$OMP END SINGLE

    ! **********************************************************************************
    ! ***  ANTI-DIFFUSION AND FINAL BED/WATER FLUX FOR SEDIMENTS WHEN KC > 1
    IF( KC > 1 .AND. ISTOPT(6) > 0 )THEN
      !$OMP DO PRIVATE(ND,LF,LL,NS,K,LP,L,CRNUM,GRADSED,SEDAVG)
      DO ND=1,NDM
        LF=(ND-1)*LDMWET+1
        LL=MIN(LF+LDMWET-1,LAWET)

        DO NS=1,NSCM
          ! ***  ANTI-DIFFUSION OF SEDIMENT FOR KC > 1
          DO K=1,KS
            DO LP=1,LLWET(K,ND)
              L = LKWET(LP,K,ND)
              CRNUM = 1.+DTSEDJ*WSETA(L,K,NS)*HPKI(L,K+1)
              GRADSED = ( SED(L,K+1,NS) - SED(L,K,NS) )/(DZC(L,K+1)+DZC(L,K))
              SEDAVG = 0.5*( SED(L,K+1,NS) + SED(L,K,NS) + 1.E-16 )
              WSETA(L,K,NS) = -CRNUM*DZC(L,K+1)*WSETA(L,K,NS)*GRADSED/SEDAVG
            ENDDO
          ENDDO

          ! *** TVAR1S=LOWER DIAGONAL
          DO LP=LF,LL
            L  =LWET(LP)
            TVAR1S(L,KSZ(L)) = 0.
          ENDDO
          DO K=2,KC
            DO LP=1,LLWET(K,ND)
              L = LKWET(LP,K,ND)
              TVAR1S(L,K) = MIN(WSETA(L,K-1,NS),0.)
            ENDDO
          ENDDO

          ! *** TVAR1N=UPPER DIAGONAL
          DO LP=LF,LL
            L = LWET(LP)
            TVAR1N(L,KC) = 0.
          ENDDO
          DO K=1,KS
            DO LP=1,LLWET(K,ND)
              L = LKWET(LP,K,ND)
              TVAR1N(L,K) = -MAX(WSETA(L,K,NS),0.)
            ENDDO
          ENDDO

          ! *** TVAR1W=MAIN DIAGONAL
          DO LP=LF,LL
            L=LWET(LP)
            TVAR1W(L,KSZ(L)) = DELTI*HPK(L,KSZ(L)) - MIN(WSETA(L,1,NS),0.)
            TVAR1W(L,KC)     = DELTI*HPK(L,KC)     + MAX(WSETA(L,KC-1,NS),0.)
          ENDDO
          DO K=2,KS
            DO LP=1,LLWET(K-1,ND)
              L = LKWET(LP,K-1,ND)
              TVAR1W(L,K) = DELTI*HPK(L,K) + MAX(WSETA(L,K-1,NS),0.) - MIN(WSETA(L,K,NS),0.)
            ENDDO
          ENDDO

          ! *** TVAR1E=RIGHT HAND SIDE
          DO K=1,KC
            DO LP=1,LLWET(K,ND)
              L=LKWET(LP,K,ND)
              TVAR1E(L,K) = DELTI*HPK(L,K)*SED(L,K,NS)
            ENDDO
          ENDDO

          ! *** TVAR3S=BET,TVAR2N=U,TVAR2S=GAM ARE WORKING ARRAYS
          DO LP=LF,LL
            L=LWET(LP)
            TVAR3S(L) =TVAR1W(L,KSZ(L))
          ENDDO
          DO LP=LF,LL
            L=LWET(LP)
            TVAR2N(L,KSZ(L)) = TVAR1E(L,KSZ(L))/TVAR3S(L)
          ENDDO
          DO K=2,KC
            DO LP=1,LLWET(K-1,ND)
              L = LKWET(LP,K-1,ND)
              TVAR2S(L,K) = TVAR1N(L,K-1)/TVAR3S(L)
              TVAR3S(L)   = TVAR1W(L,K)  - TVAR1S(L,K)*TVAR2S(L,K)
              TVAR2N(L,K) = (TVAR1E(L,K) - TVAR1S(L,K)*TVAR2N(L,K-1))/TVAR3S(L)
            ENDDO
          ENDDO
          DO K=KS,1,-1
            DO LP=1,LLWET(K,ND)
              L = LKWET(LP,K,ND)
              TVAR2N(L,K) = TVAR2N(L,K)-TVAR2S(L,K+1)*TVAR2N(L,K+1)
            ENDDO
          ENDDO
          DO K=1,KC
            DO LP=1,LLWET(K,ND)
              L = LKWET(LP,K,ND)
              SED(L,K,NS) = TVAR2N(L,K)
            ENDDO
          ENDDO
          ! *** END OF ANTI-DIFFUSION CALCULATIONS

          ! *** RECOMPUTE FLUXES FROM FINAL SED: KC-1 LAYER
          DO LP=LF,LL
            L=LWET(LP)
            SEDF(L,KS,NS) = DELTI*HPK(L,KC)*( SED(L,KC,NS) - SEDS(L,KC,NS) )
          ENDDO

          ! *** RECOMPUTE FLUXES FROM FINAL SED: MIDDLE LAYERS
          DO K=KS-1,1,-1
            DO LP=1,LLWET(K+1,ND)
              L=LKWET(LP,K+1,ND)
              SEDF(L,K,NS) = DELTI*HPK(L,K+1)*( SED(L,K+1,NS)-SEDS(L,K+1,NS) ) + SEDF(L,K+1,NS)
            ENDDO
          ENDDO
        ENDDO   ! *** End do of NS=1,NSCM loop

      ENDDO  ! *** End of Domain Loop
      !$OMP END DO
    ENDIF    ! *** END OF KC > 1 ANTI-DIFFUSION BLOCK

    !$OMP END PARALLEL

  ELSEIF( NSEDFLUME == 2 )THEN
    ! **********************************************************************************
    ! *** SEDZLJ Sediment and Contaminant Transport model
    ! *** PMC - 2017-08 - Deprecated as toxic transport is handled by CALTOX and CALTOXB
    STOP 'NSEDFLUME=2 Deprecated (EE8.3) as toxic transport is handled by CALTOX and CALTOXB'
  ENDIF
  ! *** End of condition  NSEDFLUME == 1 .AND. N >= ISEDTIME
  ! ************************************************************************************

  ! *** PMC deleted the MORPHJ routine as it was redundant and not as complete as the morphology update in SSEDTOX  (2016-12)

  ! *** Mass balance routine will be called every X minutes divided by 1440
  IF( ISBAL > 0 .AND. ( NDYCOUNT == 0 .OR. ( TIMEDAY >= LASTTIME+5./1440. ) ) ) THEN
    CALL MASS_BALANCE
    LASTTIME = TIMEDAY
  END IF
  NDYCOUNT=NDYCOUNT+1

  TSSEDZLJ = TSSEDZLJ+SECNDS(T1TMP)

  RETURN

END SUBROUTINE SEDZLJ_MAIN

max_stars_repo_name: dsi-llc/EFDCPlus

max_forks_repo_name: dsi-llc/EFDCPlus


text:
      program unstr
c     To verify the test is not restructured
c     (the entry node has a fan in of 2)
      integer a, b

c     10 j = 3
 10   j = 3
      goto 20
c     20 a = 2
 20   a = 2

c     if:
      if (b .eq. 0) goto 20
      goto 10

      end

ext: f


text:
      subroutine distance_field_signed
     &   (imsgin,xmsgin,cmsgin,msgtype,nwds,ierror)
C
C######################################################################
C
C     PURPOSE -
C
C       Compute the signed distance field, dist, between the nodes of one
C       mesh object, mo_source, and another mesh object, mo_sink. The
C       attribute dist will contain the minimum distance from each node
C       of mo_sink to the nearest node in mo_source.
C
C     NOTES -
C
C      Syntax for this command:
C      compute / signed_distance_field / mo_sink / mo_source / distance_field_attribute
C
C
C######################################################################
C
      implicit none
C
C     Subroutine Input Variables
C
      integer       nwds, ierror, imesh_type, ilen , itype
      integer       ndt, ndg
      character*(*) cmsgin(nwds)
      integer       imsgin(nwds), msgtype(nwds)
      real*8        xmsgin(nwds)
C
C     Name Variables and Message Variables
C
      character*32  mesh_type
      character*32  isubname
      character*32  mo_sink
      character*32  mo_src
      character*32  cattribute
      character*132 logmess
      character*256 cmdmess
C
C     Function variable
      integer icharlnf
C
C######################################################################
C
      isubname = 'distance_field'
C
C
C     Check input mesh objects
C
C     If we get this far, syntax of argument 1 and 2 is ok. Move on to
C     arguments 3, 4, 5
C
      if(nwds .ne. 5) then
         write(logmess,'(a)')
     &    'ERROR distance_field: Command requires 5 arguments.'
         call writloga('default',0,logmess,0,ierror)
         ierror = -2
         goto 9999
      endif
      if(msgtype(3) .ne. 3) then
         write(logmess,'(a)')
     &    'ERROR distance_field: Argument 3 must be of type character.'
         call writloga('default',0,logmess,0,ierror)
         ierror = -2
         goto 9999
      endif
      if(msgtype(4) .ne. 3) then
         write(logmess,'(a)')
     &    'ERROR distance_field: Argument 4 must be of type character.'
         call writloga('default',0,logmess,0,ierror)
         ierror = -2
         goto 9999
      endif
      if(msgtype(5) .ne. 3) then
         write(logmess,'(a)')
     &    'ERROR distance_field: Argument 5 must be of type character.'
         call writloga('default',0,logmess,0,ierror)
         ierror = -2
         goto 9999
      endif
C
      mo_sink = cmsgin(3)
      mo_src  = cmsgin(4)
      cattribute = cmsgin(5)
      print *, mo_sink, mo_src, cattribute
C
      call cmo_exist(mo_sink,ierror)
      if(ierror.ne.0) then
         write(logmess,'(a)')
     &    'ERROR distance_field: sink mesh object does not exist.'
         call writloga('default',0,logmess,0,ierror)
         ierror = -1
         go to 9999
      endif
      call cmo_exist(mo_src,ierror)
      if(ierror.ne.0) then
         write(logmess,'(a)')
     &    'ERROR distance_field: source mesh object does not exist.'
         call writloga('default',0,logmess,0,ierror)
         ierror = -1
         go to 9999
      endif
C
C     For the signed distance field, the only valid source mesh object is a a quad or tri sheet.
C
C    dimensions geometry =         3
C    element type =                qua
C    dimensions topology =         2
C   or
C    dimensions geometry =         3
C    element type =                tri
C    dimensions topology =         2
      call cmo_get_info('ndimensions_geom',mo_src,ndg,ilen,itype,ierror)
      call cmo_get_info('ndimensions_topo',mo_src,ndt,ilen,itype,ierror)
      call cmo_get_mesh_type(mo_src,mesh_type,imesh_type,ierror)
      if(((ndg.eq.3).and.(ndt.eq.2).and.(mesh_type(1:3).eq.'qua')) .or.
     1   ((ndg.eq.3).and.(ndt.eq.2).and.(mesh_type(1:3).eq.'tri'))) then
         continue
      else
         write(logmess,'(a)')
     & 'ERROR distance_field: source MO must be tri or quad'
         call writloga('default',0,logmess,0,ierror)
         write(logmess,'(a)')
     & 'ERROR distance_field: source MO must be in 3 dimensions'
         call writloga('default',0,logmess,0,ierror)
         write(logmess,'(a)')
     & 'ERROR distance_field: source MO must be topologically 2d'
         call writloga('default',0,logmess,0,ierror)
      cmdmess = 'cmo/status/'// mo_src(1:icharlnf(mo_src)) //
     &     '/brief;finish'
      call dotask(cmdmess,ierror)
         ierror = -1
         go to 9999
      endif
C
C     Now execute a series of dotask operations that compute the signed distance field.
C
C     The general strategy is to compute two regions, one on either side of the source
C     mesh object and change the sign of the distance field attribute for nodes below (le)
C     the source mesh object.
C
      cmdmess = 'surface/s1_signed_distance_s1/reflect/sheet/'//
     &   mo_src(1:icharlnf(mo_src)) // ';finish'
      call dotask(cmdmess,ierror)

      cmdmess = 'cmo/select/'// mo_sink(1:icharlnf(mo_sink))
     &  // ';finish'
      call dotask(cmdmess,ierror)

      cmdmess = 'region/r2_signed_distance_r2/le s1_signed_distance_s1'
     &  // ';finish'
      call dotask(cmdmess,ierror)

      cmdmess='pset/p2_signed_distance_p2/region/r2_signed_distance_r2'
     &  // ';finish'
      call dotask(cmdmess,ierror)

      cmdmess = 'compute / distance_field /' //
     &  mo_sink(1:icharlnf(mo_sink)) // '/' //
     &  mo_src(1:icharlnf(mo_src)) // '/' //
     &  cattribute(1:icharlnf(cattribute)) // '/'
     &  // ';finish'
      call dotask(cmdmess,ierror)

      cmdmess = 'math/multiply/' //
     &  mo_sink(1:icharlnf(mo_sink))// '/' //
     &  cattribute(1:icharlnf(cattribute)) // '/' //
     &  'pset/get/p2_signed_distance_p2/' //
     &  mo_sink(1:icharlnf(mo_sink))// '/' //
     &  cattribute(1:icharlnf(cattribute)) // '/'
     &  // '-1.0; finish'
      call dotask(cmdmess,ierror)

      cmdmess = 'pset/p2_signed_distance_p2/delete'
     &  // ';finish'
      call dotask(cmdmess,ierror)

      cmdmess = 'region/r2_signed_distance_r2/delete'
     &  // ';finish'
      call dotask(cmdmess,ierror)

      cmdmess = 'surface/s1_signed_distance_s1/delete'
     &  // ';finish'
      call dotask(cmdmess,ierror)

      cmdmess = 'cmo/delete/s1_signed_distance_s1'
     &  // ';finish'
      call dotask(cmdmess,ierror)

      cmdmess = 'cmo/select/'// mo_sink(1:icharlnf(mo_sink))
     &  // ';finish'
      call dotask(cmdmess,ierror)
C
C     All done
C
      ierror = 0
 9999 continue
      return
      end

max_forks_repo_name: daniellivingston/LaGriT


text:
C
C
C  Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
C
C  This program is free software; you can redistribute it and/or modify it
C  under the terms of version 2 of the GNU General Public License as
C  published by the Free Software Foundation.
C
C  This program is distributed in the hope that it would be useful, but
C  WITHOUT ANY WARRANTY; without even the implied warranty of
C  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
C
C  Further, this software is distributed without any warranty that it is
C  free of the rightful claim of any third person regarding infringement
C  or the like.  Any license provided herein, whether implied or
C  otherwise, applies only to this software file.  Patent licenses, if
C  any, provided herein do not apply to combinations of this program with
C  other software, or any other product whatsoever.
C
C  You should have received a copy of the GNU General Public License along
C  with this program; if not, write the Free Software Foundation, Inc., 59
C  Temple Place - Suite 330, Boston MA 02111-1307, USA.
C
C  Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
C  Mountain View, CA 94043, or:
C
C  http://www.sgi.com
C
C  For further information regarding this notice, see:
C
C  http://oss.sgi.com/projects/GenInfo/NoticeExplan
C
C

!$$$      integer function f90_verify(string,set,back)
!$$$      character*(*) string,set
!$$$      logical back
!$$$      f90_verify = verify(string,set,back)
!$$$      end
!$$$
!$$$      integer function f90_scan(string,set,back)
!$$$      character*(*) string,set
!$$$      logical back
!$$$      f90_scan = scan(string,set,back)
!$$$      end
!$$$
!$$$      integer function f90_index(string,substring,back)
!$$$      character*(*) string,substring
!$$$      logical back
!$$$      f90_index = index(string,substring,back)
!$$$      end

      SUBROUTINE ARCDIV(R, X, Y)
      END

      SUBROUTINE ARCDDIV(R, X, Y)
      END

      SUBROUTINE ARCXDDIV(R, X, Y)
      END

      SUBROUTINE ARCABS (R, X)
      END

      SUBROUTINE ARSQRT (R, X)
      END

      SUBROUTINE ARDSQRT (R, X)
      END

      SUBROUTINE ARXDSQRT (R, X)
      END

      SUBROUTINE ARCSQRT (R, X)
      END

      SUBROUTINE ARLOG (R, X)
      END

      SUBROUTINE ARDLOG (R, X)
      END

      SUBROUTINE ARXDLOG (R, X)
      END

      SUBROUTINE ARCLOG (R, X)
      END

      SUBROUTINE AREXP (R, X)
      END

      SUBROUTINE ARDEXP (R, X)
      END

      SUBROUTINE ARXDEXP (R, X)
      END

      SUBROUTINE ARCEXP (R, X)
      END

      SUBROUTINE ARPOWII (IR, I, J)
      END

      SUBROUTINE ARPOWJJ (IR, I, J)
      END

      SUBROUTINE ARPOWRI (R, X, I)
      END

      SUBROUTINE ARPOWRJ (R, X, J)
      END

      SUBROUTINE ARPOWDI (R, D, I)
      END

      SUBROUTINE ARPOWDJ (R, D, J)
      END

      SUBROUTINE ARPOWXDI (R, D, I)
      END

      SUBROUTINE ARPOWXDJ (R, D, J)
      END

      SUBROUTINE ARPOWCI (R, C, I)
      END

      SUBROUTINE ARPOWCJ (R, C, J)
      END

      SUBROUTINE ARPOWIR (R, I, X)
      END

      SUBROUTINE ARPOWJR (R, J, X)
      END

      SUBROUTINE ARPOWRR (R, X, Y)
      END

      SUBROUTINE ARPOWDR (R, X, Y)
      END

      SUBROUTINE ARPOWXDR (R, X, Y)
      END

      SUBROUTINE ARPOWCR (R, X, Y)
      END

      SUBROUTINE ARPOWDD (R, X, Y)
      END

      SUBROUTINE ARPOWXDXD (R, X, Y)
      END

      SUBROUTINE ARPOWCC (R, X, Y)
      END

      SUBROUTINE ARMODI (R, I, M)
      END

      SUBROUTINE ARMODJ (R, J, M)
      END

      SUBROUTINE ARMOD (R, X, Y)
      END

      SUBROUTINE ARMODD (R, X, Y)
      END

      SUBROUTINE ARMODXD (R, X, Y)
      END

      SUBROUTINE ARSELRK (K, P, R)
      END

max_stars_repo_name: sharugupta/OpenUH

max_issues_repo_name: sharugupta/OpenUH

max_forks_repo_name: sharugupta/OpenUH


text:
cc ------------ dpmjet3.4 - authors: S.Roesler, R.Engel, J.Ranft -------
cc -------- phojet1.12-40 - authors: S.Roesler, R.Engel, J.Ranft -------
cc                                                      - oct'13 -------
cc ----------- pythia-6.4 - authors: Torbjorn Sjostrand, Lund'10 -------
cc ---------------------------------------------------------------------
cc                                  converted for use with FLUKA -------
cc                                                      - oct'13 -------

C...PYDUMP
C...Dumps histogram contents on file for reading by other program.
C...Can also read back own dump.

      SUBROUTINE PYDUMP(MDUMP,LFN,NHI,IHI)

C...Double precision declaration.
      IMPLICIT DOUBLE PRECISION(A-H, O-Z)
      IMPLICIT INTEGER(I-N)
C...Commonblock.
      include 'inc/pybins'
C...Local arrays and character variables.
      DIMENSION IHI(*),ISS(100),VAL(5)
      CHARACTER TITLE*60,FORMAT*13

C...Dump all histograms that have been booked,
C...including titles and ranges, one after the other.
      IF(MDUMP.EQ.1) THEN

C...Loop over histograms and find which are wanted and booked.
        IF(NHI.LE.0) THEN
          NW=IHIST(1)
        ELSE
          NW=NHI
        ENDIF
        DO 130 IW=1,NW
          IF(NHI.EQ.0) THEN
            ID=IW
          ELSE
            ID=IHI(IW)
          ENDIF
          IS=INDX(ID)
          IF(IS.NE.0) THEN

C...Write title, histogram size, filling statistics.
            NX=NINT(BIN(IS+1))
            DO 100 IT=1,20
              IEQ=NINT(BIN(IS+8+NX+IT))
              TITLE(3*IT-2:3*IT)=CHAR(IEQ/256**2)//
     &        CHAR(MOD(IEQ,256**2)/256)//CHAR(MOD(IEQ,256))
  100       CONTINUE
            WRITE(LFN,5100) ID,TITLE
            WRITE(LFN,5200) NX,BIN(IS+2),BIN(IS+3)
            WRITE(LFN,5300) NINT(BIN(IS+5)),BIN(IS+6),BIN(IS+7),
     &      BIN(IS+8)

C...Write histogram contents, in groups of five.
            DO 120 IXG=1,(NX+4)/5
              DO 110 IXV=1,5
                IX=5*IXG+IXV-5
                IF(IX.LE.NX) THEN
                  VAL(IXV)=BIN(IS+8+IX)
                ELSE
                  VAL(IXV)=0D0
                ENDIF
  110         CONTINUE
              WRITE(LFN,5400) (VAL(IXV),IXV=1,5)
  120       CONTINUE

C...Go to next histogram; finish.
          ELSEIF(NHI.GT.0) THEN
            CALL PYERRM(8,'(PYDUMP:) unknown histogram number')
          ENDIF
  130   CONTINUE

C...Read back in histograms dumped MDUMP=1.
      ELSEIF(MDUMP.EQ.2) THEN

C...Read histogram number, title and range, and book.
  140   READ(LFN,5100,END=170) ID,TITLE
        READ(LFN,5200) NX,XL,XU
        CALL PYBOOK(ID,TITLE,NX,XL,XU)
        IS=INDX(ID)

C...Read filling statistics.
        READ(LFN,5300) NENTRY,BIN(IS+6),BIN(IS+7),BIN(IS+8)
        BIN(IS+5)=DBLE(NENTRY)

C...Read histogram contents, in groups of five.
        DO 160 IXG=1,(NX+4)/5
          READ(LFN,5400) (VAL(IXV),IXV=1,5)
          DO 150 IXV=1,5
            IX=5*IXG+IXV-5
            IF(IX.LE.NX) BIN(IS+8+IX)=VAL(IXV)
  150     CONTINUE
  160   CONTINUE

C...Go to next histogram; finish.
        GOTO 140
  170   CONTINUE

C...Write histogram contents in column format,
C...convenient e.g. for GNUPLOT input.
      ELSEIF(MDUMP.EQ.3) THEN

C...Find addresses to wanted histograms.
        NSS=0
        IF(NHI.LE.0) THEN
          NW=IHIST(1)
        ELSE
          NW=NHI
        ENDIF
        DO 180 IW=1,NW
          IF(NHI.EQ.0) THEN
            ID=IW
          ELSE
            ID=IHI(IW)
          ENDIF
          IS=INDX(ID)
          IF(IS.NE.0.AND.NSS.LT.100) THEN
            NSS=NSS+1
            ISS(NSS)=IS
          ELSEIF(NSS.GE.100) THEN
            CALL PYERRM(8,'(PYDUMP:) too many histograms requested')
          ELSEIF(NHI.GT.0) THEN
            CALL PYERRM(8,'(PYDUMP:) unknown histogram number')
          ENDIF
  180   CONTINUE

C...Check that they have common number of x bins. Fix format.
        NX=NINT(BIN(ISS(1)+1))
        DO 190 IW=2,NSS
          IF(NINT(BIN(ISS(IW)+1)).NE.NX) THEN
            CALL PYERRM(8,'(PYDUMP:) different number of bins')
            RETURN
          ENDIF
  190   CONTINUE
        FORMAT='(1P,000E12.4)'
        WRITE(FORMAT(5:7),'(I3)') NSS+1

C...Write histogram contents; first column x values.
        DO 200 IX=1,NX
          X=BIN(ISS(1)+2)+(IX-0.5D0)*BIN(ISS(1)+4)
          WRITE(LFN,FORMAT) X, (BIN(ISS(IW)+8+IX),IW=1,NSS)
  200   CONTINUE

      ENDIF

C...Formats for output.
 5100 FORMAT(I5,5X,A60)
 5200 FORMAT(I5,1P,2D12.4)
 5300 FORMAT(I12,1P,3D12.4)
 5400 FORMAT(1P,5D12.4)

      RETURN
      END

max_stars_repo_name: pzhristov/DPMJET

max_issues_repo_name: pzhristov/DPMJET

max_forks_repo_name: pzhristov/DPMJET


text:
Davisville Express Lube provides oil changes, radiator/transmission flushing, and other services for your automobile. They have had $7 off Discounts and Freebies coupons in the California Aggie as well a $10 off coupon in the Little Green Coupon Machine Green Machine, so look for discounts.  Come for the coupon but return for the fast, honest service.  As of 2008, their full service oil change was listed at $36.99 ($31.99 with the coupon). Davisville now has a mechanic (Andres LopezASE Cert.) They do tuneups, brake, and mechanical work. Air conditioner service is also now available.Locally Owned

Davisville has gone Green with installation of SOLAR!!!!!!!!

They have added namebrand tires to their line up of services. They stock or will order almost all brandsGoodyear, Michelin, Bridgestone, Pirelli, Dunlop, Riken, Kumho, Goodrich, Continental, Uniroyal, Firestorne, and many more. They will match a competitors price. They mount and balance the tires and also offer free tire rotations and flat repair for the life of the tires when you buy two or more tires.

All year long, they offer a free car wash with an oil change (currently, this is at Planet Wash). An added bonusStarbucks is located next door.

To locate other places to get your car fixed in Davis, please visit our Automobile Repair page.

Very clean inside and Ron, one of the coowners, was very helpful and professional. Users/BrettCoder

20060307 11:46:14 nbsp excellent Users/GregoryChang

20060307 11:47:15 nbsp pleasant, efficient, clean and modern waiting room.  Highly recommended Users/GregoryChang

20060611 18:41:36 nbsp did a coolant flush, great and cheap Users/HaiYu

20060919 02:31:44 nbsp The first and last time I was here for an oil change, the service was slow. There was only one car in each of the two bays (one of which was mine) and it took at least 30 minutes. And when they were finished, they left streaks of motor in three different places on the body of my car. I had to go into their bathroom to get paper towels to wipe it all off. Users/JaneNguyen

For the record...When Jane wrote this she had not been to our shop in about a year..I checked our records. In addition, if you look at her writeup history...she wrote this and minutes later wrote a glowing report on a competitor. You decide?? Ronowner

20060929 23:54:41 nbsp I went today for an oil change. I went for the highend $60 oil change that included full synthetic oil and filter, nitrogen in the tires, and a free car wash. Two for two of the other people were suggested to change their air filter, but I was told everything was OK (I replaced the air filter an hour beforehand). The service didnt take too long considering the hand car wash and there was no appointment necessary. Users/JustinCummins

20061102 23:28:29 nbsp We are a locally owned and operated business.  Weve got a great staff who are knowledgeable, responsive to our customers and efficient.  No appointments are necessary and our customer service area is very clean and comfortable.  Se habla espanol tambien!

20061122 11:52:38 nbsp This place rocks!!!  They got me in/out on the cheap without that pressure to buy any extra crap I didnt really want.  Having just moved here, I gotta say its nice to have these guys local because now I dont have to make that trip over the causeway and back.  Thanks!!!  Users/RossBenitti

20070309 16:32:06 nbsp Excellent, quick, and VERY friendly! They even offer student discounts.  Users/AliPezeshkpour

20070505 00:04:03 nbsp Our extremely popular Free Car Wash with Oil Change is back for the summer season.  This is a hand car wash performed by some great local guys.  The hours vary a bit but are typically 105 MSat & weather dependant.  Wed like our guys to wash lots of cars this summer so check it out!  ThanksTom Corcoran, Owner Users/ThomasCorcoran

20070521 14:04:37 nbsp We have taken our two cars to Davisville several times and have been extremely happy with their services. Although we never wait for long (20 minutes max), the waiting room is clean, comfortable and there is a Starbucks on the same street! The people there are very knowledgeable, efficient and courteous.  Last time we took a car there, Roger (the manager), noticed differential fluid leakage and recommended we take the car to our Toyota dealer. The dealer found the leak and fixed it (the car is still under warranty)....thanks, Roger! We highly recommend Davisville Express Lube! Users/Naomi

20070530 18:52:38 nbsp kind of expensive in my opinion, using the same type of oil they use and buying your own oil filter would only cost 15 bucks at most and they charge an extra 15 bucks for Techron which only cost 6 bucks to buy at other stores. for the prices they charge they could at least use higher quality oil and you dont even get a discount for bringing in you own oil, shows you how much their oil is worth. Users/Billy

20070716 17:01:21 nbsp I would definitely recommend this place for oil changes.  I used to go to Speedee, but noticed they kept trying to tackon (questionable) repairs; you can always find something to repair on an older car.  Ive been getting oil changes with them for over a year now and never had this issue with Davisville ... two thumbs up. Users/VladLoscutoff

20070721 19:53:14 nbsp i usually go to Speedee Oil Change & Tune Up speedee to get my oil changed.  However i was driving down covell and i forgot where that do it yourself carwash was.  Then i noticed a sign for Davisville Express Lube that said free car wash with oil change.  Since i was going to get my oil changed this week i thought why not?  Funny thing is i noticed that the usual mechanic i have had at speedee now works for this place.  Interesting.  Both places are pretty similar.  Speedy tops off more stuff for free, but this place has the modern waiting room and the free carwash.  They are both about the same price its a toss up. Users/MattHh

20070729 13:39:44 nbsp This place was great.  The waiting room is clean and they didnt try to sell me anything extra (except windshield wipers, which I actually do need).  There was no wait  I drove right in and it only took about 15 minutes, including a window cleaning.  Unfortunately they no longer offer the car wash (there was a sign about Davis city regulations so this might be temporary).  Theres also a $5 coupon on their website. Users/rachelss

20070904 16:50:56 nbsp Clean, very fast, very polite. I had just driven to Davis from Florida and wanted an oil change...they didnt try to sell me anything I didnt need and the experience was very pleasant. Will go again.  Users/CStevens

20070927 09:37:20 nbsp I have gone to Davisville Lube several times.  I have always received great service.  The prices are excellent, the staff accomodating to your needs, the place is clean and comfortable.  The owners are great and the manager Roger is awesome.  If you have a problem, go to him.  Users/Debbi

20071109 19:04:26 nbsp I used to go to speedy cause it was close to my house, but they always left my car dirty and wouldnt vacuum, clean my windows or top stuff off like their invoice said.  And they were always trying to get me to replace things unecessarily.  Davisville lube has been fast every time I have come in and they are not more expensive.  Plus the mechanics are honest, friendly and not sleezy which is a big plus.  Dont go to speedy, go to davisville. Users/cfm

20071230 10:46:57 nbsp This is the only place in town that will perform an oil change for my VW Golf diesel with inhouse oil (Chevron Delo). They always have it in stock. Every other place either does not do diesel oil changes, I have to bring my own oil, or they have to special order the oil. I have had the typical suggested maintenance and the riduculous come back in 3,000 miles BS but they are not hard sell like some other places. I highly recommend them. Users/Rsronce

20080210 12:22:48 nbsp I would like to say good luck to the new manager of Davisville Express Lube.  Miguel.  This is a very good shop and they do excellent work.  I would like to thank all the customers over the past two years who I have had the pleasure of serving.  Thank you all so much.  And good luck to the new manager and team.   Users/roger

20080211 15:09:17 nbsp I really like the quality of work done here.  The staff does a good job and Jacob provided me with fantastic customer care.  I go here and only here and get package #3 whenever my car needs servicing. :) Users/EmilyBlake

20080317 13:50:12 nbsp Pricing and facilities are well thought out although you can tell that they need to have better training standards for better consistancy throughout their employee base. They all seem to do things differently each time. If I dont stand over them there is usually oil spilled or smeared somewhere on the car. It would be nice if you could really enjoy the waiting area without having to be involved in making sure your car wasnt getting oil spilled on it. All being said, the long time employees do a decent job getting things done.  Users/MikeDimone

20080613 10:32:30 nbsp Mike
Ron here one of the owners of Davisville Express Lube. Thanks so much for your feedback. Finding top notch employees is one of the most difficult aspects of running a small business. You are absolutely correct our long time employees are terrific! MiguelJacobFrankieCraigRyanJamesKevin
We did have a few issues with a couple of our new hires but Im happy to report that we have taken corrective action.  Users/RonLautzenheiser

20080613 10:38:37 nbsp Davisville Express Lube has retained the services of:
Ryan James (ASE Cetified Mechanic)
Davisville EXL Automotive..............Now offering Brake Service/TuneUP/Belts/Mechanical
Call 530 7537543 or just stop by!! Users/RonLautzenheiser

20080613 10:41:00 nbsp The Davisville Express Lube

FREE CAR WASH with Oil Change

Is back in Action for the Summer!!!!!!!!!!!!!!! Users/RonLautzenheiser

20080719 13:12:07 nbsp Got my oil changed here about a month ago. Service was quick and honest. I was asked if I wanted a new air filter and shown how dirty the old one was, so I agreed, and the cost was only a few dollars more than if Id bought one and done it myself. Other than that (which was a legitimate suggestion) I agree with the comments above that theyre not too aggressive about trying to upsell you, which made for a pleasant experience.  Users/OscarSabino

20080724 21:21:07 nbsp Excellent, polite, lowpressure serviceand an unusually good assortment of reading material in the waiting area. Users/DavidRobinson

20080904 15:08:03 nbsp How much is it for just a standard oil change? Users/patrick82

20080911 10:31:56 nbsp I couldnt find prices anywhere, so drove by and found that the full service oil change was listed at $39.99 ($34.99 with the coupon). I had a coupon for a $20 oil change somewhere else, so I went there instead. No car wash at the place I went, though.  Users/dhsandler

20080911 11:33:09 nbsp thank you very much for the info. Users/patrick82

20080911 17:20:03 nbsp Just a quick note: Our oil change base price is $33.99. We have a $5 Off coupon on our web site www.davislube.com and we are in the Green Machine coupone book as well. We also offer a FREE CAR WASH
with the oil change (or other service).
NEW CAR WASH INFO:
Davisville has established a relationship with Planet Wash (Lake&Covell...behind Circle K) a new high techeco friendly touchless wash in Davis. We provide you with a code to get your vehicle washed at your convience.

Ronone of the owners Users/RonLautzenheiser

20080911 17:25:40 nbsp Price info:
We recently recieved a rather substantial price increase from our oil supplier (CHEVRON). So we are considering a price increase unfortunately. Ill keep everyone posted when we make a decision.
Rowner  Users/RonLautzenheiser

20080911 17:29:11 nbsp I dont know how to edit the price listed at the top of our page?? Can someone fix the price listed. 39.99 is not correct...it is 33.99..thanks Users/RonLautzenheiser
   Howdy Ron... I wrote about that on Users/RonLautzenheiser your editor entry awhile ago:  If you click Edit at the top of the entry, you can edit the whole thing (and that applies to everybody and every entry on the entire wiki).  You arent just limited to adding comments.  Feel free to edit anything on the wiki, remembering that its a community resource, so other people will edit as well.  One place to get started is the community written (informal) Welcome to the Wiki/Business Owner tips for business owners. Users/JabberWokky Evan JabberWokky Edwards

20080912 08:29:01 nbsp EvanThanks...got it! Users/RonLautzenheiser

20080921 14:29:16 nbsp Because of a substantial increase in pricing from our supplier (Chevron) we were forced to raise the base price on our oil change from 33.99 to 36.99
Ronowner Users/RonLautzenheiser
  The price increase for an oil change sucks (this place is already on the high end to begin with), but Ill keep coming back because the service is good, reliable and honest. Thats worth a lot in the auto service industry. Users/OscarSabino

20081125 15:26:16 nbsp Fast and friendly. I was impressed. And the free car wash is from Planet Wash, too, not just their employees doing a slapdash car wash after they change your oil. :) (You have 10 days to redeem the car wash to boot, which is great for me, since Im traveling for Thanksgiving this week.) Definitely recommended. Users/RobertM525

20090109 10:38:17 nbsp Great experience.  I brought my G35 for service.  Service was done quickly with a recommendation of air filter replacement. (it was a reasonable offer).  Nice waiting room.  It was my first time here.  Will be back again. Users/HaiyongLi

20090318 16:48:18 nbsp These guys are great. ALL of the people who work here are friendly and honest (and Ive worked with about four or five of them). Ryan, the mechanic, gave me a half hour off labor because the part I had to pay for was so expensive, and he fixed my tail light at no extra cost. And Ive noticed that whenever theyre recommending that people get a particular service done, they tell them to go home and check their records to see if its been done recently. That is admirable. This is a small, locally owned business worth supporting! Users/jsogul

20090421 23:04:25 nbsp I take my car here for oil changes and its great! The service is fast and competitively priced, plus the wash your windows and vacuum your car! Last time I went the mechanic suggested I have the transmission fluid changed; he told me how much it would be to change it there, but there was no pressure to have it done right then. This was great because Ive been semibullied into car services I probably didnt even need at other repair places. The waiting room is really clean and comfortable. HIGHLY recommended!!! Users/CParker

20090514 18:55:12 nbsp These guys are great. First time Ive been there. Very courteous, and I have to say, patient, as I asked a lot of questions, and the person helping me answered all of my questions. Ive worked on cars some in the past, and I feel these guys are honest, and do a good job. They took the time to look over everything and do a thorough job. Highly recommended. Oh and very comfy waiting room, super clean, professional, excellent.   Users/KeithJose

20090527 12:03:41 nbsp TIRES TIRES TIRES TIRES

Hi
Ron here, one of the owners. Just wanted to let everyone know that we have added TIRES to our lineup of services. We carry almost all major brands: Michelin, GoodYear, Bridgestone, Pirelli, Firestone, BFGoodrich, Dunlop, General, Riken, Kumho, and more. We mount and balance the tires. When you purchase 2 or more tires we include FREE TIRE ROTATIONS and FREE FLAT REPAIR (life of the tires).

We have competitive prices and great fast service!! Users/RonLautzenheiser

20090527 12:08:13 nbsp We also, as always, offer a FREE CAR WASH with your service Oil Change, Tires, Mechanical

This is year round and the Wash is done by PLANET WASH our environmentally friendly H2o recycle, reverse osmosisenviro friendly soaps
 Users/RonLautzenheiser

20090629 13:41:14 nbsp The service is great. I enjoyed the free car wash and the vacuum of the interior of my car. They never forced other services on me but would just simply recommend them. I thought that the price was a bit much compared to what Im used to but the great service and car wash makes up for it. Users/FlowerCindy

   This is a drive by review from an account created http://daviswiki.org/Users/MikeWhitmier?actionuserinfo just to leave this negative review, created right after an employee was fired.  It should be read with suspicion... or the author should establish an identity.

20090819 15:54:00 nbsp I was at Davisville Lube about 3 weeks ago..they took forever! the bathroom was repulsive! my car leaked oil and i had to go to speedys shop to get it cleaned up and my oil top off! ( it was a half a quart low after I had it changed)The manager was trying to sell me everything under the sun and I over heard a employee saying he got ripped off on his pay check and they were paying him under the table I could tell he was upset! I was appalled! I will NEVER go there again! The poor guy looked like he needed the money, I felt like paying him myself! Users/MikeWhitmier

Ron The owner here. After a review of our computer record....we show no roecord of a Mike Whitmier ever having his vehicle serviced at Davisville.

20090826 08:13:27 nbsp This is Ron one of the owners of Davisville. I am writing in response to the post written by Mike Whitmier on the 19th of August. If one were to read our posts going back to the begining of our wiki page (2006) one would be hard pressed to find a negative comment on Davisville. I find it interesting that Mike had such an awful experience.
    My business partners and I live in Davis and are very involved in the community. Our reputation is on the line and we run an EXCELLENT business(dont take it from me take it from all of our other WIKI posts).

For the record.... Oh and very comfy waiting room, super clean, professional, excellent. —KeithJose 20090514

                They never forced other services on me but would just simply recommend them.  —FlowerCindy 20090629

              Excellent, quick, and VERY friendly! They even offer student discounts. —AliPezeshkpour 20070309

     This place was great. The waiting room is clean and they didnt try to sell me anything extra —rachelss 20070729

    We have taken our two cars to Davisville several times and have been extremely happy with their services. Although  we never wait for long (20 minutes max), the waiting room is clean, comfortable and there is a Starbucks on the same street!—Naomi 20070521

 And Ive noticed that whenever theyre recommending that people get a particular service done, they tell them to go home and check their records to see if its been done recently. That is admirable. This is a small, locally owned business worth supporting! —jsogul 20090318

 Users/RonLautzenheiser

20090901 10:26:42 nbsp I cant get the website to work. Is it just me? Users/BrookeB

20090902 07:51:18 nbsp Sorry about the web site. We are in the process of redoing the site. Davislube.com should be up soon.
In the mean time use Davislube.net

Cheers
R Users/RonLautzenheiser

20090902 22:25:14 nbsp I normally avoid lube places, having had bad experiences with Jiffy Lube long ago.  But I thought Id give this place a try, since (I think) they are an independent outfit.  I was in and out quickly.  All the employees I saw were polite and professional.  They didnt try to pressure me into getting a more expensive service or try to claim that I needed service that I didnt.  What more could I ask for?  Ill be back there for my next oil change. Users/CovertProfessor

20091103 13:50:44 nbsp I came in for an oil change in my aging, ailing car and they were great.  Friendly, fast service. Ill be back. Users/ZeldaKPotsdam

20091109 17:04:27 nbsp I went here for the first time after browsing through Daviswiki for oil change places and seeing that Davisville had received the best reviews.  I was not disappointed.  It was right before closing when I arrived, but they still serviced my car and did an excellent job even though it took them until past closing time.  They did forgot to turn the indicator light off, but it was simple enough to bring it back, and there was no additional charge for the visit. My second experience was just as good.  Fast service, nice waiting room, staff is helpful, informative, and not pushy.   Users/cmwhit

20100218 22:39:05 nbsp I POSTED THE COMMENT (BEHIND THE SCENES) JUST TOO INFORM PEOPLE OF WHAT HAPPEN TO ME AS A EMPLOYEE NOT TO SLAM THE SERVICE OF THE SHOP. ALL I DID IS TELL MY EXPERIENCE LIKE IT SAYS TO DO ABOVE! EVERYTHING I SAID IS TRUE! IF IT WERE NOT THERE WOULD BE NO REASON TO DELETE IT OR FOR ME TO WRITE ON YOUR PAGE...I DID CALL THE SHOP BEFORE I POSTED IT AND GOT NO RESPONCE!!THEN I POSTED A NOTE ON HERE FOR RON TO GET A HOLD OF ME (THAT WAS DELETED AS WELL) BEFORE I POSTED WHAT HAPPEN.... AGAIN TRYING TO HANDLE THE MATTER WITHOUT MAKING A BIG DEAL. IF THERE IS A WAY TO POST AUDIO ON HERE I WOULD LIKE TO KNOW SO I COULD SHOW YOU ALL THE PROOF! I DONT NORMALLY POST ON WIKI BECAUSE EVERY BUSINESS IN DAVIS I HAVE GONE TO I HAVE HAD A GREAT EXPERIENCE AT. IF I HAD RECEIVED A W2 WITH THE CORRECT INFORMATION I WOULD NEVER HAVE COMMENTED ON THE PAGE. ALL I WANT IS TO GET THE PROBLEM FIXED (AGAIN NOTICED I NEVER SLAMMED THE SERVICES PERFORMED AT THE SHOP IN ANY WAY!) I STATED ON THE LAST POST THAT IT WOULD GET DELETED..LIKE THIS ONE WILL WHICH MAKES THE PAGE A PLACE FOR GOOD COMMENTS ONLY DUE TO THE EDITING! THANKS FOR ALL THE COMMENTS IN RESPONCE AS WELL! I WILL CERTAINLY HANDLE THE MATTER IN A DIFFERENT WAY. I WROTE THE LAST POST IN 5 MINUTES OUT OF ANGER AND WONT DO IT AGAIN! Users/ANOTHERRIPPEDOFFEMPLOYEE2
  Actually, slamming the business for bad service is fine.  It was the bizarre threats and the way you were using the wiki as a blunt weapon for blackmail that was probably the reason that your comment was removed.  Honestly, there are plenty of comments all over the wiki about how utterly horrible any given business is.  Seldom, however, do people leave messages calling out the owner by name and making personal demands, using the wiki as a blackmail tool.  That  quite simply  makes you a bad person who is abusing a public space as a personal tool for selfish gain.  It wasnt Ron who has been deleting your posts, they are being deleted by your neighbors, volunteers who see threats like, Hey Ron before I go on here and paste our text conversations (WITH YOU AND THE MANAGER MIGUEL)Im gonna give you the chance to give me a call and fix the W2 I recently picked up from the shop as detrimental to civil discourse.  Somebody stepped in (because anybody can edit anything on the wiki), and removed your threat, just the same as if you were trying to threaten somebody or screaming at somebody at the Farmers Market, a stranger might step in and tell you to back off and calm down.  Several people have been trying to contact you, but you keep changing accounts. If you havent noticed, most people here go by their real name (we are, after all, neighbors), and youre using an alias created for the sole purpose of harassing somebody.  Once again, Ron is not deleting your comments  the people around you, your neighbors, are watching these nasty threats and removing them to keep this space civil and free of personal attacks.  Calm down, sign up under your real name (or at least what you introduce yourself to people by), and explain your grievance without making threats or writing a long rant in all capital letters (which reads as coming from either somebody screaming or a crazy person).  There is no problem with you airing your issues, as Ron does not own this entry, and the volunteers from the community of Davis who help maintain the wiki wouldnt let him delete a reasonable complaint.  But you keep running in, using a different name each time, loudly making threats, screaming in an semicomprehensible paranoid rant and then running off.  What the heck would you do if you saw somebody doing that in a public place?  The wiki is run by and for the community, and youre part of it: you are an equal editor, the same as anybody else.  Dont be an ass to other people, stop screaming in all caps, introduce yourself under a real name rather than a single purpose account designed to attack somebody, and nobody will have a problem with your comments.  Cmon  do you act like this in all public places?  Just calm down, be reasonable, and itll be okay.  Users/JabberWokky Evan JabberWokky Edwards

20100505 18:33:25 nbsp Extremely pleased with the staff and service here. A week ago I came in to see why my engine check light was onmy front oxygen sensor was burnt out. They only charged for the half hour it took for the diagnostics, and gave me a quote on replacing the part. I called many of the auto repair shop that Daviswiki lists (10 places!), and Davisville had the lowest price.

So, I came back today to get the sensor fixed. They were swamped with cars, so it took a bit longer than they said they would, but not unreasonably so. Andres was informative and easy to talk to. In addition to fixing my car and showing me where he replaced the old sensor, he also showed me where oil was leaking from a cracked valve (an expensive fix). He took the time to explain the relevant parts of the engine involved and patiently answered all my questionsvery much appreciated. He printed out a quote, and encouraged me to go home and check with other places for the best price.

With fixing my car, I am much more comfortable returning to a place I know will do a good job and be honest with me. I will look around for fixing the valve, but I dont expect I will find a much better quote, if I do at all. I will likely return to Davisville for any servicing I need while Im still in Davis.  Users/victoria.ngo
  And when I came for the diagnostic (a half hour procedure), it was 5:05 but they squeezed me in anyway.  Users/victoria.ngo

20100606 16:14:32 nbsp tires were running a little wonky... figured it was a tire pressure issue. very few auto places open on sundays. pulled up here 10 mins before closing, explained my situation, and the tech was super nice and had me pull the car around and fixed the issue. didnt charge me a dime, but certainly earned some future business from me. sweet! Users/KevinWan

20100617 15:37:39 nbsp Ive been taking my car to Davisville Lube for about 3 years for regular oil changes and Ive been overall pretty happy with them.  The turnaround is quick, and they dont try and sell you a ton of additional services like many other places do.  However, I had a less than stellar experience with them in February and now Im not so sure.  I had my oil changed on my 2002 accord, no problems.  The next day, I drove out to Walnut Creek, and on the return trip, my oil warning light came on.  Not the check engine light, but the your car is out of oil light.  I checked the oil level, and it was fine, but the light would not turn off.  After much back and forth with a local service shop and the Walnut Creek Honda dealer, it turns out that Davisville Lube had put the wrong oil filter on the car (it was the filer for a civic, which is a slightly different size).  After getting the proper filter put on, the light went off.  The dealer (who didnt charge me anything) told me that having the wrong size filter on the car can affect the oil pressure and give me the indication light I had.

While there was no damage to my car, I was more than annoyed because I had to spend hours running around trying to get my car fixed in an unfamiliar town.  When I returned to Davis, I went to Davisville Lube to complain and get a refund.  I explained the situation to the manager on duty (Im not sure of his name).  He spent about 510 minutes looking up the part number of the filter Davisville had put on, looking up the part number of the filter that should have been put in my car, and explaining to me that there is really no difference between the two.  I am not a car person my any stretch of the imagination, but first of all, if there was no difference between the two parts, then why would two different parts be made?  Second, I saw the two filters sidebyside, and they are different sizes.

I explained to him that while that may be true, part of the service that I pay for at Davisville Lube is to replace the oil filter with the proper part, and they did not do that.  He did agree to refund the cost of my oil change (by check in the mail), but added that he thought the oil warning light often comes on when the sensor is going bad, and to do him a favor and let him know if the sensor needed to be replaced in the next few months.  He definitely made me feel like he was doing me a favor by refunding the cost of the oil change, when it was likely something wrong with my car.  This was beyond annoying because even if the sensor was going bad, they still put the WRONG filter on my car.  Also, four months later, the sensor is still working fine.

Im not going to say that Im never going to Davisville Lube again, because aside from this, my experiences have been very positive, but I am certainly not going to recommend them like I once would have.   Users/GrdStudentT

GrdStudentT
Hi, Ron here the owner of Davisville. I would like to offer our sincere apology for your trouble. One of our very experienced techs made an error and installed the incorrect oil filter..causing the oil light to illuminate. There are two very similar Honda oil filters and it is our job to get it right! We didnt....

We have an excellent reputation in Davis and almost always get things right. I have reviewed all of our crosscheck and safety procedures with our crew!!I hope you give us another opportunity to earn your trust.

I definitely understand how valuable your time is! If you contact Miguel our manager (7537543) we would be happy to copensate you for your time and trouble.

Sincerely
Ron

20100626 14:30:45 nbsp I have been coming here for almost 2 years and can say I am pleased. I love all the coupons this place offers and the free car wash. I think this place offers fair prices and the owner and employees are extremely helpful. One example is the first time I met Ron the owner. I had brought a coupon for 5 dollars off and he traded me for a 10 dollar coupon.By the way if you dont have a coupon for this place, print one out using their guest computer while you wait. I also expressed my opinions about the business and he made sure my issues were resolved. Make sure you ask the guys for your free vacuuming interior and washing the windows. I get the synthetic oil change for my car, Ron was extremely knowledgeable and explained the major differences to me, extremely helpful. I have also purchased tires here and been happy with them. The service is quick and reliable. Highly recommend this place. Users/ElizabethBarthel

20100627 09:49:40 nbsp I really like this place; I get my oil changed here for all three of my vehicles. Its clean, theyre courteous, theyre fast, and they offer free wifi. However, they have tried to sell me filters and other replacement items I dont think I needed. Here is an actual exchange I overheard:

Guy from under my car shouts up: He needs a new oil plug!
Guy on the deck shouts back down, No he doesnt! He comes here a lot!

At the time, I took this exchange to mean that since I came there a lot, they wouldnt try to scam me by telling me that I needed a replacement oil plug. However, in the comments below, the shop owner explains that this is simply because new plugs are provided to repeat customers for free.

So long as you come in to the shop for an ordinary change without any bells and whistles or replacement filters and whatnot, its the best lube shop in town! Users/EdwardNiemand
  Potential other meaning: You go there often enough that you will be back in time to replace the oil plug without a problem. My experience with them is that even firsttimers get advice on replacing parts as well. Users/hankim

Hi Ron the owner.
Thanks for the feedback!
Not entirely sure on the context of the plug conversation. The oil plug is something we replace free for repeat customers and just a couple of bucks for nonrepeats.
They can get worn after numerous oil changes.

A word on our business model. I live in Davis as does most of our crew and mechanic. We value our personal and business reputation. We are upfront,straight forward and honest  with our customers. We do our best to tell them about their vehicle and any issues that might need addressedour customers rely on us to keep their vehicles safe and in good working order. We recommend services based on milage from the vehicle manufacture. We never want to be that shopthe one that is pushy and/or not straight up with their customers not a good way to build a great busiess.

Thanks
R

20100627 22:24:05 nbsp Ron,

Brilliant. Thanks for the feedback. That completely explains the exchange. Ive modified my original comment to reflect your explanation. As I said, I really like your shop, its run splendidly... I guess I just came to expect the upsell, and that tinted my interpretation of that exchange. Users/EdwardNiemand

20100822 15:01:27 nbsp Ive been bringing my cars here for years. They do great work quick, clean, thorough, reasonably priced. I had a few (apparently unfounded) concerns about the transmission flush they performed, they answered all my questions and doublechecked everything to make sure it was done correctly. Great folks. Highly recommend them.  Users/bpwhite

20100830 00:24:45 nbsp Recently, I had an interesting experience here.
I changed my brake fluid just before going to a long trip. Nothing was wrong but since the last change of the brake fluid was two yeas ago, I changed it as a part of regular maintenance.
When I was driving on a highway at 65 miles per hour, suddenly my brake lost the function. When I push the brake pedal, I heard only the sound of air.
The highway was very crowded because of summer holiday. Anyway, I had to stop my car. I hold the wheel with my left hand and the parking brake with my right hand. After a couple of minutes, I could manage and stop my car by the roadside.
This accident could kill me. I have never had this kind of experience in my real life. I saw this kind of situation only in movies.
Fortunately, I had AAA membership and called AAA. A policeman also stopped by to see if I am OK. AAA towed my car to a local auto repair shop.
What they found is simply the screw of the brake bleeder was loosened. They did not have to change any parts. What they did is putting new brake fluid and tightening the screw.
After this trip, I explained what happened and how I was scared and how it spoiled my trip because I had some plans and online reservations which I couldn’t use at this time. I also explained it could cost several thousands to million dollar if I hit some car or some person.
The manager told me he will discuss with the owner of the shop and send the compensation. Recently, I received it. What they sent was refund of the repair and three oil change coupons which I can use at this shop. Users/davisdriver

davisdriver
Our sincere apology for your trouble and distress. As an airline pilot, I take our maintenance work at Davisville with the utmost seriousness. I understand the gravity of what a mistake can mean. Our entire crew and mechanic carry this same attitde and commitment. Andreas, our mechanic, performed the work on your vehicle. I just wanted to assure you that he is ASE (Automotive Service Excellence) Certified and is a topnotch mechanic who does very good work. Clearly there was an issue with the work that could have resulted in a very serious situation ...and for this there really are no words that can convey how terrible we feel. If you could please contact the shop (ask for Miguel 530 7537543) we would be happy to discuss what we could do to further compensate you for your time and trouble.
Sincerely
Ron (owner)

I also just wanted to add a quick note on brake systems. I in no way want to minimize the the dismay you experienced while driving.
Brake systems are typically designed so that a single failure in the system will not reslut to total brake failure:

3. Brake Problems:

All modern brake systems use a split hydraulic system. The system is split in the master cylinder (Diagram) and this prevents the complete loss of brakes if a leak develops on one side of the system. Complete loss of brakes is therefore very unlikely except for unusual problems with the master cylinder. However, if the front brakes are lost, the vehicle will be down to 30% to 40% of normal braking capacity and it may feel to the operator as though there is a complete loss of brakes.

Thanks
R

20100908 23:14:00 nbsp I got an oil change from Davisville today and I was very pleased with their service. The guys at the shop were polite and got my car in and out in about 25 minutes, even with a few cars ahead of me.

A huge plus was that no one tried to sell me any extra crap I didnt neednew oil filter, new wipers, tire rotation, etc. Every other place Ive been to has always bombarded me with the usual oh, you should check this... or for just a little extra we can do this for you... This place didnt do any of that. In fact, the guy at the counter gave me $10 off (in addition to the free car wash that is always offered with their oil changes) just because!

In total the oil change cost me $32, and it included the change, air in my tires, wiper fluid refill, the usual car checkup, and a car wash. Id say it was a great deal. Id DEFINITELY go back again! Users/AshleyMatson

20101005 13:05:08 nbsp I went in to Davisville yesterday to get my radiator checked out  its a radiator they installed over six months ago. I performed some routine maintenance on the car and noticed a faint radiator fluid smell and hissing sound, along with some small dried fluid patches. Andres (sorry if I misspelled his name) took my car in, checked the hoses, connections, pressure tested the system, checked for fluid pools, odd sounds and all. When I asked his coworker in the shop if I could go over and talk with Andres about my specific concerns, the guy was friendly and accommodating. Andres answered all my questions completely and helped me understand my car better  especially the air intake system, as he explained away the slight hissing sound I was worried about. Andres recommended a couple services that I could have done there at their shop, which is to be expected  they need to make money, but the whole situation was professional and low pressure. Ive dealt with two mechanics and a couple other Davisville employees over the last couple years and have found only one guy who was sleazy and seemed a little too eager to sell me extras. Andres and his coworker from Monday morning, 10/04/2010 (sorry I didnt write down his name), were spot on perfect in the customer service department. My radiator was inspected to my satisfaction and Im now comfortable that the things not leaking. I rode out of there feeling good about giving Davisville my business  and they didnt charge me a dime for the followup.   Users/millerabgj

Nice, quick service, but dont rely on these guys to give you accurate advice about whats leaking in your engine. They told me I had a front engine seal leak and I took it to two other shops, and both told me its a completely different problem.  If youre going to give engine advice, fine, but make damned sure its accurate. If you dont know what youre doing, dont give the advice. Users/DavisLurker

Davislurker
We really do our very best to give an acurate analysis. This is not always that straight forward....especially on older vehicles. I dont think you had the analysis done by our mechanic (Andres)?? Andres is ASE certified and very good.

Ron

Roger.  Shops said one might think it was front engine seal if they hadnt bothered to search for the source of the leak. Users/DavisLurker

Davislurker
Thanks for the feedback. Our techs are very knowledgabe ...however they are not mechanics. I think Roger was trying to be helpful in identifying the problem. Andres is our ASE certified mechanic and would be the one to evaluate your vehicle and provide a written quote..I think this occured on a weekend and Andres is on MF. Sorry for any trouble this might have caused. (mention this wiki to Miguel our manager and your next service is on the house)
Cheers
Ron

I think I will pass, but thank you for your concern, Ron.  Users/DavisLurker

20101021 13:26:07 nbsp I just wanted to add that these guys give great lube jobs. I brought my car in recently and they took care of it wonderfully. I have a greater piece of mind, which I didnt have before, while driving down the road.  Users/JonCantrell

20101102 17:36:14 nbsp Ive been using Davisville for a year now and Im always impressed with the friendliness, integrity and overall great service they provide. Their prices are reasonable (free car wash with oil change coupon!) and they work quickly plus their waiting area is much nicer than most auto places. I cant say enough good things about them!  Users/CailinHeinze

20101107 23:17:25 nbsp My experience with this shop. I went in for a fluid change and then i was pressured into getting new brake pads and left spending 300!! Yeah i was there for two hours they were waiting for the parts to come in and then the wrong parts came so i had to wait even longer. there was no sorry or any thing. I even had to beg for a discount for my troubles. I am very displeased and I tell everyone. OH and the skinny mexican guy who works there i wish i remembered his name but any way he is a rude SCAMMER!!!!!!! they just want your money.. Dont go there.  Users/ESepe

After doing some homework....I believe this writeup to be some type of personal attack. I do no think this customer was ever at our shop or received service. I base this on a review of our records and discussions with my crew. The behavior described by this person is TOTALLY out of character for our mechanic. It is not credible that he would behave in this manner.
Ron

ESepe
Very surprised at this writeup. I am very sorry if you had a bad experience. We really do try very hard to provide great service and we are very straight forward with our customers. I think if you look at the vast majority of the writeups on wiki we do not pressure customers and we provide good service. I own this shop and I live in Davis. This is absolutely not how we do business. Andy (our mechanic) is a very friendly, mildmannered guy. I cant imagine him being pushy or rude. Again several wiki writeups support my view of our mechanic.
We have an excellent reputation in town! We build our business on excellent customer service and doing competent work! We have great customers who we respectwe would never pressure anyone for any reasonbad business!!
I will talk with Andy and I will try to reach you by phone to discuss the matter.

Sincerely,
Ron

20101107 23:24:37 nbsp Went here for an oil change. Decent service, although a bit pricier for a few things than this place I go to back in Campbell.  Users/hankim

20101109 13:10:29 nbsp I went there for oil change on a Sunday afternoon. Their service is smooth, taking only 20 min. The staff looks nice. The price is right, about 30$ with coupon, including a free car wash. Users/Jia

20110113 10:23:10 nbsp I recently changed to this shop from SpeeDee. The guy who helped us was named Ryan he was super helpful and professional. Users/YesItsMe

20110316 17:30:25 nbsp I was planning on using Davisville Express Lube as my main routine maintenance shop; unfortunately I have a life.  I took my car in once for a big service and one guy was super helpful and professional.  The service is reasonably priced and quick.  I wanted to bring my car back in but when I called I was told that they couldnt tell me how busy it was since they dont schedule oil changes.  He couldnt even guess at whether they would be able to get it done.  Unfortunately, I cant risk wasting a whole day waiting for an oil change that might not even happen.  This place would be great if I didnt have to drive across town to figure out whether I can get my car serviced. Users/WillODonnell

Will
Thanks for the feedback. Sorry for any inconvenience. Ill work with our staff on communication skills/clarity. Typically, our service is very fast...2030 minutes. A bit longer at peak times (preHoliday/Weekend).
Thanks
RonOwner

20110320 18:00:15
Please understand we cant predict how many cars will be in line by the time a vehicle arrives( Express/No Appointment required), but I will make sure to let my crew know we need to be more helpful about how we explain it over the phone. Our peak hours vary: early morning(8:3010) , Lunch time(111) and 4pm til closing time. On Holiday weekends I recommend not to wait to last minute, a week early will get you in and out of our shop faster.
Miguel(manager)

20110609 20:01:06 nbsp The guys who work here are super nice.  I suspect thats because theyre competent, treated as such by the management and are paid well.  This is not a throwaway quick lube jointthey are local.  While I have not had any major repairs here, I have trusted these guys to do a great job changing oil, filters, mounting, balancing and rotating tires.  The promotions they run make their services competitively affordable.  It is a pleasant and predictable experience dealing with this establishment and thus they have become my goto for oil changes and tire purchases.  Lastly, they have a supercomfortable waiting lobby with a complimentary coffee machine.  I do wish they provided complimentary wifi.   Users/bartbart
  They do provide complimentary wifi  or at least they used to  did you ask?   Users/CovertProfessor

We do provide free wifi..(davisville)
Cheers
Ron

20110711 12:18:27 nbsp My wife and i have been taking our vehicles to Davisville Express Lube since they first opened their doors.  Until recently, our experiences have always been great.

Due to some health problems in my family, my sisterinlaw had to use one of my vehicles to travel back and forth from Esparto to Davis to watch my young son.  I asked that she please get the oil service done at Davisville.

As usual, my vehicle needed to be toppedoff about 1500 miles later.  Thanks to Davisvilles free topoff policy, I was always able to just pull in, get it topped off, then be on my way.  That is, until about 6 months ago, when they charged my sisterinlaw $5.00 cash(had to be cash for some reason  no credit) for the quart of oil it took to top off the vehicle.

So, I took the vehicle there myself for another oil change to see what had changed.  Answer: nothing.  Same manager, owners, policy and prices.  Then, like clockwork, my vehicle (91 Aerostar) needed to be topped off.  I asked my wife to please take it to Davisville, but told her:  do not let them charge you for topping it off.  Sadly, the manager tried to charge her $5.00 cash for the quart of oil.  She told him:  my husband told you not to let you charge me for the topoff.  Fortunately, they did not charge her.

Maybe their policy has changed and they dont topoff for free any more.  They always have, except for when my wife or sisterinlaw try to have it done.
Even so, my van only takes 4 quarts, and 5 are included in the price of the service.

Im not looking for an apology or even free stuff, refunds, etc.  Ive met two of the three owners shortly after they opened their doors.  They were kind, courteous and willing to talk to me.  Ive always been impressed and exceptionally pleased with the level of service at Davisville.  But, until Im sure they arent charging for cash only topoffs, then my wife and I wont be returning. Users/BruceCampopiano
 Bruce Thanks for the feedback.

 Sorry for any confusion. We recently made some minor changes to our free topoff policy due to the ever increasing price of oil. We will continue to offer (1) free topoff between service on our bulk oil products.   Since our cost is considerably higher on bottled oil we decided to charge $5.00 for the bottled oil topoff to defray some of the cost. However due to your feedback we are going to reexamine this policy. If this is something important to our customers we want to know. Thanks!

 As far as Miguel (our manager) asking for cash...well, it is kind of an inside baseball thing. We always track our vehicles serviced (car count) so we can do business planning and make comparisons to previous years numbers. On some small items (like a topoff) if you run a credit card our computer system counts it as a vehicle serviced...which can skew our numbers a bit. If he does cash...he would just add that to a normal service ticket keeping our numbers more accurate. Ive actually ask that he not do this in the future. Again thanks!

 Cheers
 Ron
 owner

20110803 21:36:36 nbsp I really like this place.  I switched a little over a year ago from a chain lube place in Davis and my experience with Davisville thus far has been awesome.  I was in today and my oil was changed in under 20 minutes.  They even scraped the bug guts off my windshield.  I have never had any of the guys here try to sell me crazy things, and the waiting room is super classy.  Love that its within walking distance of Starbucks too :) Users/AynReyes

20110903 07:29:29 nbsp im proud of the work they did on my old car. they replaced the tires, did the tune up/oil change, recharged my a/c. unfortunately, this is where my car would die. my car kept overheating and needed the head gasket fixed. its an expensive job and i had already paid a few hundred for them to do the work they did. they tried to help me as best they could, it took all day when i was there. i ended up having to get a new car. I dont knock their work, but its unfortunate what happened to my car.  Users/Sandlot3

20110917 20:41:19 nbsp Just got 4 tires replaced here and was happy with the genuine and friendly staff.  What I was even more thrilled with (and frankly, surprised by) was when they caught a billing error they had made the next day and sent me a check to cover it.  I would have never noticed the difference, and because of this, Ill be coming here for my oil changes.  Users/AndrewWalker

20111118 09:15:12 nbsp Have a Great Tire Deal Going right now!!

Buy 3 Get 1 Free

(Kumho TiresCapital TiresNexen Tires...and a number of other brands)

 Users/RonLautzenheiser

20111118 09:18:49 nbsp TireRack.com

If you choose to order tires from tirerack.com you can have the tires shipped directly to our shop and we can handle the installation.
 Users/RonLautzenheiser

20111208 16:42:55 nbsp I went today, based on comments closest to this date. They were busy and their computer was being slow, which is no fault of theirs, Im sure. I live only a mile away and my hood flew up on the way home, because they didnt shut it all the way. That was fun. They didnt take any info or my name or anything, which I thought was odd, since the owner is on here to discredit people according to their file, so maybe they changed procedure? Id go back, but only because it is so close to my house and I will be checking my hood before I leave as well. I did like the $5 coupon and it was reasonably priced.  Users/MichelleCain

Hi Michell
Ron here the owner. I am so very sorry about your hood situation. I am at a loss on how this could happen. This has NEVER happened to a customer of ours in the thousands and thousdand of vehicles we have services. All vehicles have a safety so even if the hood does not latch the hood will not come up. Of course, we take our service very seriously and we are very careful to make sure all hoods are closed and latched. It is possible that the hood latch or safety is faulty. Please have the hood latch and safety checked. We would be happy to check it.

Also I talked with the crew. Yes it was quit busy that day our cashier neglected to get your information...our fault. It is always our normal procedure to put customer information into
our customer data base. We do this to send a reminder to the customer about their next service date and to contact the customer if there were an issue with their vehicle.

As a side note: I try to respond to all customer comments. I do this in an open and honest way. I live in Davis as does most of the crew. We try our very best to run a great business and be honest and straight forward with our customers. We are not perfect....we try our very best and when things arnt right we try to make them right.

Thanks
Ron

20111208 16:44:31 nbsp p.s. I never got my free car wash.... Users/MichelleCain

Please feel free to stop by and well give you the code for your free wash.
Thanks
Ron

20120113 15:31:35 nbsp Great service. In and out in less than 15 minutes for an oil change and a (free) tire pressure check. They also noticed something was wrong with my airintake hose, and fixed it right away, no extra charge. Thanks! Users/JeroenPost

20120131 18:06:37 nbsp Great, fast oil change service. I went to University Honda for oil change before but UH wanted to rape me for 80 dollars for a simple oil change but I made them take 20 dollars off (still a good rapage for UH, btw). This time, I tried Davisville and they just charged their base price without trying to up charge me or saying the oil Im using is rare so they dont stock it, etc. Great service, fast turn around and even gave out free car wash! Will come here again for sure.  Users/C.Ling

20120301 18:09:09 nbsp Ive had nothing but good experiences here. Professional and friendly at the same time, great waiting room, fast service. My truck was making an awful creaking/cracking sound whenever I turned the wheel all the way and I was afraid it was going to be something that cost me a ton. I brought it to Davisville Lube because of my previous experience getting oil changes there and Andres looked it over, test drove it, and figured out that all it needed was some grease on the inside of the wheels. It totally fixed the problem AND he didnt charge me at all. Love this place! Users/bwana

20120507 13:24:54 nbsp Davisville has gone GREEN with the installation of SOLAR!!!!!

Our Solar company recently completed the install and hookup of solar panels on our roof. This covers about 90% of our electrical power requirements!!
Were off the grid about going GREEN!!!

Cheers
Ron Users/RonLautzenheiser

20120803 10:07:48 nbsp I have had nothing but positive experiences here. The staff is friendly and professional. Not only have I had oil changes done here, but the guys have been happy to help me with things not included in their standard list of services. For example, I just had a front mount installed for my cars license plate that required drilling into the bumper. They were happy to do it, and the best part is that they charged me next to nothing for the work. Fantastic! Users/TylerPark

20120825 07:19:57 nbsp bad experience here. my car died here. before it died, they thought it was cool to sell me tires, they claimed that it was urgent and the most important thing when i secretly feel that they knew that there was something bigger wrong. so, i bought the tires because i dont know much about cars and they had my car for a number of hours. they also did a much needed oil change. when i picked up my car, i drove over a city and on my way back home, i ended up stranded and in the middle of nowhere. had to call a tow truck and it was just horrible and hot that day. took it back to this place after giving them a call and telling them what happened. they offered to look at my car again without cost. I was told that repairs would cost thousands of dollars, so i was basically screwed out of my car. fortunately, i got a new car which wont ever be serviced by this place. just beware of what they try to sell you, always get a 2nd opinion as well, maybe bring someone along with you who knows a thing about cars.  Users/Sandlot3

Sandlot3
So sorry for your bad experience. To be clear,for other wiki users.... My understanding, from talking with my crew, is that your cars demise was
 unrelated to any service that we provided (tires/oil change). Your vehicle was an older model with significant mileage
Ill just say this If one were to review our wiki or Yelp page....We would never do business in this manner! We are honest and upfront with our customers. Most of us here live in Davis and we value our customers and our reputation.

20121212 12:47:15 nbsp Brought my car here for an oil change for the second time, these guys are thorough, pleasant, and as helpful as any place Ive ever been to. I wont bring my car anywhere else.  Users/sba

20130212 18:09:55 nbsp My car had a engine problem, there was oil leaking into the engine and the sparks were misfiring. This problem was initially detected by SpedeeMidas in Davis, and they told me basically that repairing my car would be something between 1700 to 2700$ depending if I wanted to fix the plugs and valves, or to replace the whole engine.
When I took it to this place, the manager checked my car and he told me all the parts and changes that he would have to do, as well as the approximate cost. I agreed, and they fixed my car for a fraction of the price that was quoted in the other place and in less than 2 hours my car was ready to go and working without problems.
I would definitely recommend this places for oil changes and mechanical repairs, I like that they consult you first before they do any work and the price is really down to earth. Costumer service was excellent and fast. Users/KalaiLam

20140708 15:21:40 nbsp Cannot say enough great things about this place! I have been taking my car here for oil changes and basic maintenance for several years. Prices are reasonable, super quick service, and they really go above and beyond to make sure you are getting great service. Love this place! Users/JessDawn

max_stars_repo_name: voflo/Search

max_issues_repo_name: voflo/Search

max_forks_repo_name: voflo/Search


text:
<%
def element0(var):
    """find the first element array"""
    parts = ["lbound(s%%%s, %d)" % (var["name"], i+1) for i in range(var["rank"])]
    if var["rank"] > 0:
        txt = "(" + ",".join(parts) + ")"
    else:
        txt = ""
    return txt
%>
subroutine get_var(c_var_name, x) bind(C, name="get_var")
  !DEC$ ATTRIBUTES DLLEXPORT :: get_var

  ! Return a pointer to the variable

  character(kind=c_char), intent(in) :: c_var_name(*)
  type(c_ptr), intent(inout) :: x

  character(len=strlen(c_var_name)) :: var_name
  ! Store the name
  ! The real array
  integer :: index
  type(arraytype) :: array

  var_name = char_array_to_string(c_var_name)

  index =  chartoindex(var_name)
  if (index .eq. -1) return
  call indextos(s,index,array)

  select case(var_name)
%for variable in variables:
   case ('${variable["name"]}')
      ! if you want to reference a pointer variable
      ! you have to point to the first element
      x = c_loc(s%${variable["name"]}${element0(variable)})
%endfor
  end select

end subroutine get_var

max_stars_repo_name: liujiamingustc/phd

max_issues_repo_name: liujiamingustc/phd

max_forks_repo_name: liujiamingustc/phd