subroutine ustssc &
 ( nvar   , nscal  , ncepdp , ncesmp ,                            &
   iscal  ,                                                       &
   icepdc , icetsm , itypsm ,                                     &
   dt     ,                                                       &
   ckupdc , smacel ,                                              &
   crvexp , crvimp )

!===============================================================================
! Module files
!===============================================================================

use paramx
use numvar
use entsor
use optcal
use cstphy
use parall
use period
use mesh
use field

!===============================================================================

implicit none

! Arguments

integer          nvar   , nscal
integer          ncepdp , ncesmp
integer          iscal  , iflmas

integer          icepdc(ncepdp)
integer          icetsm(ncesmp), itypsm(ncesmp,nvar)

double precision dt(ncelet)
double precision ckupdc(ncepdp,6), smacel(ncesmp,nvar)
double precision crvexp(ncelet), crvimp(ncelet)

! Local variables

character*80     chaine
integer          ivar, iiscvr,  iel
integer          ilelt, nlelt

double precision tauf, prodf, wallheatflux, plength, totalmassflow, celldensity, zvelocity

integer, allocatable, dimension(:) :: lstelt
double precision, dimension(:), pointer ::  cpro_rom, cvar_vel, imasfl ,  cpro_crom

!===============================================================================



!===============================================================================
! 1. Initialization
!===============================================================================

! Allocate a temporary array for cells selection
allocate(lstelt(ncel))

! --- Index number of the variable associated to scalar iscal
ivar = isca(iscal)

! --- Name of the the variable associated to scalar iscal
call field_get_label(ivarfl(ivar), chaine)

! --- Indicateur of variance scalars
!         If iscavr(iscal) = 0:
!           the scalar iscal is not a variance
!         If iscavr(iscal) > 0 and iscavr(iscal) < nscal + 1 :
!           the scalar iscal is the variance of the scalar iscavr(iscal)
iiscvr = iscavr(iscal)

! --- Density
call field_get_val_s(icrom, cpro_rom)

if (iwarni(ivar).ge.1) then
  write(nfecra,1000) chaine(1:8)
endif

!===============================================================================
! 1. Impose Heat Source
!===============================================================================


wallheatflux=200000                       !constant wall heat flux
plength=0.03104                           !circum length of the channel
totalmassflow=6.7649491533992830E-003     !channel mass flow rate

call getcel('fluid', nlelt, lstelt)

call field_get_val_s(icrom, cpro_crom) 
call field_get_val_v(ivarfl(iw), cvar_vel) 


call field_get_key_int(ivarfl(ivar), kimasf, iflmas)
call field_get_val_s(iflmas, imasfl)


do ilelt = 1, nlelt
  iel = lstelt(ilelt)
  celldensity=cpro_crom(iel)
  zvelocity=cvar_vel(iel)
  ! Explicit source term
  crvexp(iel) = volume(iel)*celldensity*zvelocity*((wallheatflux*plength)/totalmassflow)
      
enddo



do ilelt = 1, nlelt
  iel = lstelt(ilelt)
! No implicit source term
  crvimp(iel) = 0.d0

  
enddo

!--------
! Formats
!--------

 1000 format(' User source terms for variable ',A8,/)

!----
! End
!----

! Deallocate the temporary array
deallocate(lstelt)

return
end subroutine ustssc



