!-------------------------------------------------------------------------------

!                      Code_Saturne version 3.0.1
!                      --------------------------
! This file is part of Code_Saturne, a general-purpose CFD tool.
!
! Copyright (C) 1998-2013 EDF S.A.
!
! This program is free software; you can redistribute it and/or modify it under
! the terms of the GNU General Public License as published by the Free Software
! Foundation; either version 2 of the License, or (at your option) any later
! version.
!
! This program is distributed in the hope that it will be useful, but WITHOUT
! ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
! FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
! details.
!
! You should have received a copy of the GNU General Public License along with
! this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
! Street, Fifth Floor, Boston, MA 02110-1301, USA.

!-------------------------------------------------------------------------------

!===============================================================================
! Purpose:
! -------

!> \file cs_user_modules.f90
!>
!> \brief User-defined module: it allows to create any user array.
!>
!> This file is compiled before all other user Fortran files.
!> To ensure this, it must not be renamed.
!>
!> The user may define an arbitrary number of modules here, even though
!> only one is defined in the example.
!
!-------------------------------------------------------------------------------

module user_module

  ! Example: allocatable user arrays

  !integer,          dimension(:), allocatable :: iwork
  !double precision, dimension(:,:), allocatable :: rwork
  double precision, allocatable, dimension(:) :: usertau, userutau
contains

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

  ! Allocate arrays

  subroutine init_user_module(nfac)

    ! Arguments

    integer, intent(in) :: nfac

    ! Local variables

    integer :: err = 0

    allocate(usertau(nfac)) 
    allocate(userutau(nfac))

    if (.not.allocated(usertau) .or. .not.allocated(userutau)) then
      allocate(usertau(ncelet), stat=err)
      allocate(userutau(ncelet), stat=err)
    endif

    if (err /= 0) then
      write (*, *) "Error allocating array."
      call csexit(err)
    endif

    return

  end subroutine init_user_module

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

  ! Free related arrays

  subroutine finalize_user_module

  end subroutine finalize_user_module

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

end module user_module
