!--------------------------------------------------------------------------------------------------
!  DOXYGEN
!> @brief Inserir Brief de DASSIM2
!> @details Inserir Details de DASSIM2 
!> @author ORIGINATOR - ????? 
!> @date ??-??-?? \n
!> @author LUCCI 
!> @date 18-03-20 \n
!> @version V1.1.0
!> @details MODERNIZATION OF THE CODE, INCLUDING:
!!                      * F77 TO F90/F95
!!                      * INDENTATION & UNIFORMIZATION CODE
!!                      * REPLACEMENT OF COMMONS BLOCK FOR MODULES
!!                      * DOCUMENTATION WITH DOXYGEN
!!                      * OPENMP FUNCTIONALITY 
!<
!> @details <b>Use Module:</b>
!! @arg @c CTLBLK 
!! @arg @c F77KINDS
!! @arg @c MPPSTAFF
!! @arg @c PARMETA
!! @arg @c VRBLS
!> @details <b>Driver:</b> 
!<
!> @details <b>Calls:</b>
!! @arg @c BOCOHMPI
!! @arg @c BOCOVMPI
!--------------------------------------------------------------------------------------------------
    SUBROUTINE DASSIM2
!--------------------------------------------------------------------------------------------------
! SUBROUTINE DASSIM2
!
! SUBPROGRAM: DASSIM2 - ?????
! PROGRAMMER: ?????
! ORG: W/NP2 
! DATE: ??-??-??
!
! ABSTRACT:
! ?????
!
! PROGRAM HISTORY LOG:
! ??-??-??  ?????     - ORIGINATOR
! 18-01-15  LUCCI     - MODERNIZATION OF THE CODE, INCLUDING:
!                       * F77 TO F90/F95
!                       * INDENTATION & UNIFORMIZATION CODE
!                       * REPLACEMENT OF COMMONS BLOCK FOR MODULES
!                       * DOCUMENTATION WITH DOXYGEN
!                       * OPENMP FUNCTIONALITY 
!
! INPUT ARGUMENT LIST:
! NONE
!
! OUTPUT ARGUMENT LIST:
! NONE
!
! INPUT/OUTPUT ARGUMENT LIST:
! NONE 
!
! USE MODULES: CTLBLK
!              F77KINDS
!              MPPSTAFF
!              PARMETA
!              VRBLS
!  
! DRIVER     : -----
!
! CALLS      : BOCOHMPI
!              BOCOVMPI             
!--------------------------------------------------------------------------------------------------
    USE CTLBLK
    USE F77KINDS
    USE MPPSTAFF
    USE PARMETA
    USE VRBLS
!
    IMPLICIT NONE
!
    INTEGER(KIND=I4)                                                                            ::&
    & K       , I       , J       , K2
!
    CHARACTER(LEN=2)                                                                            ::&
    & C_K     , C_K2
!
    CHARACTER(LEN=256)                                                                          ::&
    & FNAME   , FNAME2
!
    REAL   (KIND=R4)    , DIMENSION(:,:)                        , ALLOCATABLE                   ::&
    & DUM1    , DUM12
!
    REAL   (KIND=R4)    , DIMENSION(:,:,:)                      , ALLOCATABLE                   ::&
    & DUM2    , DUM22
!
    REAL   (KIND=R4)    , PARAMETER :: W1 = 0.
!
    REAL   (KIND=R4)                                                                            ::&
    & TIME    , DTA     , XSI     , DTOTAO
!
    DTOTAO = DT * 1.E-5
    DTA    =  6 * 3600.
!
    TIME = NTSD * DT
    K    = TIME / DTA + 1
    K2   = K + 1
    XSI  = TIME / DTA + 1 - K
!
    ALLOCATE ( DUM1(0:IM+1, 0:JM+1))
    ALLOCATE (DUM12(0:IM+1, 0:JM+1))
    ALLOCATE ( DUM2(0:IM+1, 0:JM+1, LM))
    ALLOCATE (DUM22(0:IM+1, 0:JM+1, LM))
!
    WRITE(C_K ,'(I2.2)') K
    WRITE(C_K2,'(I2.2)') K2
!
    FNAME  = "../data/data_in/vrbls"//C_K //"."//C_MYPE
    FNAME2 = "../data/data_in/vrbls"//C_K2//"."//C_MYPE

    IF (MYPE == 0) THEN
         PRINT *, 'DATA ASSIM,', FNAME, FNAME2, XSI
    END IF
!
    OPEN(51, FILE=TRIM(FNAME), FORM='UNFORMATTED')
    OPEN(52, FILE=TRIM(FNAME), FORM='UNFORMATTED')
!
    READ(51)DUM1
    READ(52)DUM12
!
    PD = PD + ((1-XSI) * DUM1 + XSI * DUM12 - PD) * DTOTAO
!
    READ(51) DUM2
    READ(52) DUM22
!
    T = T  + ((1 - XSI) * DUM2 + XSI * DUM22 - T) * DTOTAO
!
    READ(51) DUM2
    READ(52) DUM22
!
    Q = Q  + ((1 - XSI) * DUM2 + XSI * DUM22 - Q) * DTOTAO
!
    READ(51) DUM2
    READ(52) DUM22
!
    U = U  + ((1 - XSI) * DUM2 + XSI * DUM22 - U) * DTOTAO
!
    READ(51) DUM2
    READ(52) DUM22
!
    V = V  + ((1 - XSI) * DUM2 + XSI * DUM22 - V) * DTOTAO
!
    CLOSE(51)
    CLOSE(52)
!
    CALL BOCOHMPI(PD,  1)
    CALL BOCOHMPI(T , LM)
    CALL BOCOHMPI(Q , LM)
!
    CALL BOCOVMPI(U , V ,LM)
!
    DEALLOCATE (DUM1, DUM2, DUM12, DUM22)
!
    END SUBROUTINE DASSIM2
