!!****h* ariane/mod_input_data_seq
!! NAME
!!   mod_input_data_seq (mod_input_data_seq.f90 - Fortran90 module)
!!
!! USAGE
!!   Include 'USE mod_input_data_seq' in the header of your Fortran 90 source 
!!   code.
!!   Then you'll have access to the subroutine:
!!      - sub_input_data_seq
!!      - sub_input_data_seq_main
!!      - sub_transp_alloc_seq
!!      - sub_transp_dealloc_seq
!!      - sub_tracer_alloc_seq
!!      - sub_tracer_dealloc_seq
!!
!! FUNCTION
!!   Read input data: tracers and currents (compute transport).
!!   File format is netcdf (netcdf version 3.6.0 or newer is required).
!!
!! AUTHOR
!!   * Origin  : Nicolas Grima (April-May 2005)
!! 
!! CREATION DATE
!!   * April-May 2005
!!
!! HISTORY
!!   Date (dd/mm/yyyy/) - Modification(s)
!!
!! RESULT
!!   
!!
!! EXAMPLES
!!   * USE mod_input_data_seq
!!
!! NOTES
!!   ROBODoc header style.
!!
!! TODO
!!   
!!
!! PORTABILITY
!!         Machine-OS    - Fortran90/95 compiler
!!   * i686-pc-linux-gnu -         ifort
!!   * i686-pc-linux-gnu -          g95
!!
!! SEE ALSO
!!   
!!
!! USES
!!   * USE mod_precision
!!   * USE mod_namelist
!!   * USE mod_input_grid
!!   * USE mod_w_comput
!!   * USE mod_rhostp
!!   * USE mod_netcdf
!!   * USE reducmem
!!
!! USED BY
!!   * posini
!!   * trajec
!!
!! SOURCE
!!=========================================================================

MODULE mod_input_data_seq,7

  !------------------!
  ! USE ASSOCIAITION !
  !------------------!
  USE mod_precision
  USE mod_namelist
  USE mod_input_grid
  USE mod_w_comput
  USE mod_rhostp
  USE mod_netcdf
  USE mod_reducmem
  USE netcdf

  !-------------!
  ! DECLARATION !
  !-------------!
  IMPLICIT NONE

  !- Global variables -!
  REAL(kind=rprec), DIMENSION(:,:,:,:), ALLOCATABLE :: &
       uu      , & ! Zonal Transport
       vv      , & ! Meridional transport
       ww          ! Vertical transport

  REAL(kind=rprec), DIMENSION(:,:,:,:), ALLOCATABLE :: &
       tt      , & ! Temperature
       ss      , & ! Salinity
       rr          ! Density

  LOGICAL :: id_comments = .FALSE.

CONTAINS






  !!****f* mod_input_data_seq/sub_transp_alloc_seq()
  !! NAME
  !!   sub_transp_alloc_seq()
  !!
  !! FUNCTION
  !!   Dynamic allocation of the transport arrays (uu, vv, ww)
  !!
  !! AUTHOR
  !!   * Origin  : Nicolas Grima (April-May 2005)
  !! 
  !! CREATION DATE
  !!   * April-May 2005
  !!
  !! HISTORY
  !!   Date (dd/mm/yyyy/) - Modification(s)
  !!
  !! ARGUMENTS
  !!   * dim1: dimension 1, or x, or i
  !!   * dim1: dimension 2, or y, or j
  !!   * dim1: dimension 3, or z, or k
  !!   * dim1: dimension 4, or t, or l
  !!
  !! TODO
  !!   
  !!
  !! USED BY
  !!   * mod_input_data_seq (Private)
  !!
  !! SOURCE
  !!=======================================================================

  SUBROUTINE sub_transp_alloc_seq(dim1, dim2, dim3, dim4)

    !-------------!
    ! Declaration !
    !-------------!
    !- arguments -!
    INTEGER(kind=iprec), INTENT(in) :: dim1, dim2, dim3, dim4

    !-------------!
    ! Code begins !
    !-------------!
    !- Dynamic allocation -!
    ALLOCATE(uu(dim1, dim2, dim3, dim4))
    ALLOCATE(vv(dim1, dim2, dim3, dim4))
    ALLOCATE(ww(dim1, dim2, dim3, dim4))

  END SUBROUTINE sub_transp_alloc_seq
  !!***

  !!****f* mod_input_data_seq/sub_transp_dealloc_seq()
  !! NAME
  !!   sub_transp_dealloc_seq()
  !!
  !! FUNCTION
  !!   Deallocate memory of the transport arrays (uu, vv, ww)
  !!
  !! AUTHOR
  !!   * Origin  : Nicolas Grima (April-May 2005)
  !! 
  !! CREATION DATE
  !!   * April-May 2005
  !!
  !! HISTORY
  !!   Date (dd/mm/yyyy/) - Modification(s)
  !!
  !! ARGUMENTS
  !!   * No argument
  !!
  !! TODO
  !!   
  !!
  !! USED BY
  !!   * trajec
  !!
  !! SOURCE
  !!=======================================================================

  SUBROUTINE sub_transp_dealloc_seq()

    !-------------!
    ! Code begins !
    !-------------!
    !- Deallocate arrays memory -!
    IF (ALLOCATED(uu)) DEALLOCATE(uu)
    IF (ALLOCATED(vv)) DEALLOCATE(vv)
    IF (ALLOCATED(ww)) DEALLOCATE(ww)

  END SUBROUTINE sub_transp_dealloc_seq
  !!***
  !=========================================================================
  !!****f* mod_input_data_seq/sub_tracer_alloc_seq()
  !! NAME
  !!   sub_tracer_alloc_seq()
  !!
  !! FUNCTION
  !!   Dynamic allocation of the tracer arrays (tt, ss, rr)
  !!
  !! AUTHOR
  !!   * Origin  : Nicolas Grima (April-May 2005)
  !! 
  !! CREATION DATE
  !!   * April-May 2005
  !!
  !! HISTORY
  !!   Date (dd/mm/yyyy/) - Modification(s)
  !!
  !! ARGUMENTS
  !!   * dim1: dimension 1, or x, or i
  !!   * dim1: dimension 2, or y, or j
  !!   * dim1: dimension 3, or z, or k
  !!   * dim1: dimension 4, or t, or l
  !!
  !! TODO
  !!   
  !!
  !! USED BY
  !!   * mod_input_data_seq (Private)
  !!
  !! SOURCE
  !!=======================================================================

  SUBROUTINE sub_tracer_alloc_seq(dim1, dim2, dim3, dim4)

    !-------------!
    ! Declaration !
    !-------------!
    !- arguments -!
    INTEGER(kind=iprec), INTENT(in) :: dim1, dim2, dim3, dim4

    !-------------!
    ! Code begins !
    !-------------!
    !- Dynamic allocation -!
    ALLOCATE(tt(dim1, dim2, dim3, dim4))
    ALLOCATE(ss(dim1, dim2, dim3, dim4))
    ALLOCATE(rr(dim1, dim2, dim3, dim4))

  END SUBROUTINE sub_tracer_alloc_seq
  !!***

  !!****f* mod_input_data_seq/sub_tracer_dealloc_seq()
  !! NAME
  !!   sub_tracer_dealloc_seq()
  !!
  !! FUNCTION
  !!   Deallocate memory of the tracer arrays (tt, ss, rr)
  !!
  !! AUTHOR
  !!   * Origin  : Nicolas Grima (April-May 2005)
  !! 
  !! CREATION DATE
  !!   * April-May 2005
  !!
  !! HISTORY
  !!   Date (dd/mm/yyyy/) - Modification(s)
  !!
  !! ARGUMENTS
  !!   * No argument
  !!
  !! TODO
  !!   
  !!
  !! USED BY
  !!   * trajec
  !!
  !! SOURCE
  !!=======================================================================

  SUBROUTINE sub_tracer_dealloc_seq()

    !-------------!
    ! Code begins !
    !-------------!
    !- Deallocate arrays -!
    IF (ALLOCATED(tt)) DEALLOCATE(tt)
    IF (ALLOCATED(ss)) DEALLOCATE(ss)
    IF (ALLOCATED(rr)) DEALLOCATE(rr)

  END SUBROUTINE sub_tracer_dealloc_seq
  !!***
END MODULE mod_input_data_seq