!     !!!!!!!!!!!!!!!
      subroutine training(Rvar,pathSI,Sidim,pathLR,LRdim,obspath,obsdim,&
                         pathsig,sigdim,nanx,neni,ngridd,nlat,nlon,ic,&
                         nlatt,nlont,id,slat,slon,rlat,rlon,slatt,slont,&
                         nd) 
!     !!!!!!!!!!!!!!!
!*       0.   DECLARATIONS
!             ------------
!

! MODULES with constants and functions
use mod_csts
use mod_funcs

implicit none

!!!!!!!!!!!!!!!!!!!!!!!!
! INPUT ARGUMENTS
!!!!!!!!!!!!!!!!!!!!!!!!
! VARIABLE and input data PATHS 
character(len=4), intent(in) :: Rvar 
integer, intent(in) :: SIdim
integer, intent(in) :: LRdim
integer, intent(in) :: obsdim
integer, intent(in) :: sigdim
character(SIdim), intent(in) :: pathSI 
character(LRdim), intent(in) :: pathLR 
character(obsdim), intent(in) :: obspath
character(sigdim), intent(in) :: pathsig 
!***********************************************
integer, intent(in) :: nanx
integer, intent(in) :: neni
integer, intent(in) :: ngridd
!***********************************************
! DOMAIN variables
!************************************************
! sinoptic grid
integer, intent(in) :: nlat
integer, intent(in) :: nlon
integer, intent(in) :: ic
!-----------------------------------------------
! low resolution grid
integer, intent(in) :: nlatt
integer, intent(in) :: nlont
integer, intent(in) :: id
!------------------------------------------------
double precision, intent(in) :: slat
double precision, intent(in) :: slon
double precision, intent(in) :: rlat
double precision, intent(in) :: rlon
!------------------------------------------------
double precision, intent(in) :: slatt
double precision, intent(in) :: slont
!------------------------------------------------
!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!
! TIME variables
integer, intent(in) :: nd
!integer, intent(in) :: nm
!------------------------------------------------
integer :: nger
!------------------------------------------------
real :: den(nd,ic)
!------------------------------------------------
real :: um(nd,ic)
real :: vm(nd,ic)
!------------------------------------------------
real :: gu92(nd,ic)
real :: gv92(nd,ic)
real :: gu52(nd,ic)
real :: gv52(nd,ic)
!------------------------------------------------
real :: x(ic)
real :: y(ic)
!------------------------------------------------
real :: xcand(nptos)
real :: ycand(nptos)
!------------------------------------------------
integer :: iri(nptos)
!------------------------------------------------
real :: dmin(nptos)
!------------------------------------------------

print*,"*** TRAINING PROCESS ***"
print*,""
print*," Downscaled variable... ", Rvar

!print*,"nlat =",nlat
!print*,"nlon =",nlon
!print*,"ic =",ic
!print*,"nlatt =",nlatt
!print*,"nlont =",nlont
!print*,"id =",id
!print*,"slat =",slat
!print*,"slon =",slon
!print*,"rlat =",rlat
!print*,"rlon =",rlon
!print*,"slatt =",slatt
!print*,"slont =",slont

call calc_tempes_densi_sealev(ic,nd,pathSI,den)
call geos(ic,nd,id,slatt,slont,slat,slon,rlat,&
                rlon,rlat,rlon,nlatt,nlont,nlat,nlon,den,pathLR,ngridd,&
                um,vm)
call clasif(ic,nd,nlon,nlat,slat,slon,rlat,rlon,um,vm,pathSI,nger,&
            gu92,gv92,gu52,gv52)
call utm_ERA(ic,nlat,nlon,slat,slon,rlat,rlon,x,y)
call utm_obs(obspath,xcand,ycand)
call ptos_ref(ic,x,y,xcand,ycand,iri,dmin)
call sig_predic(nlat,nlon,nlatt,nlont,slat,slon,rlat,rlon,slatt, &
                      slont,nd,ic,id,obspath,nger,&
                      um,vm,gu92,gv92,gu52,gv52,iri,pathSI,pathsig,nanx,&
                      neni)
stop
end subroutine

