 
! The utm_obs program calculates the UTM coordinates of high resolution
! (5km x 5km) observational database created by AEMET (Peral et al., 2017).
!
SUBROUTINE utm_obs(obspath,xcand,ycand)

USE MOD_CSTS
USE MOD_FUNCS, ONLY : geoutm

      Implicit none

      CHARACTER(LEN=*), INTENT(IN) :: obspath
      REAL, INTENT(OUT) :: xcand(nptos)
      REAL, INTENT(OUT) :: ycand(nptos)

      integer n
      integer igrad,imin,rseg,igrad1,imin1,i
      real*8 rlat,rlon
      real*8 r1,r2,r3,r4,r5,r6,rad,rad1,xint,yint
      character pathin*100
      
      print*,"program 5: UTM coordinates high resolution observational database"

      n=nptos
      pathin=obspath
!
       open (1,file=trim(pathin)//'maestro_red_hr')

        do i=1,n
         read(1,200) rlon,rlat
       rad1=rlon
       rad=rlat
!    Calculation of UTM coordinates
       call geoutm(rad1,rad,huso,xint,yint)

       xcand(i)=xint
       ycand(i)=yint
 
         enddo

200    format(14x,f6.3,4x,f6.3)

      close(1)
!  
!Peral, C., Navascués, B. and Ramos, P.: Serie de precipitación diaria en
!rejilla con fines climáticos. Nota Técnica nº 24, AEMET,
!http://hdl.handle.net/20.500.11765/7573, 2017.

END SUBROUTINE utm_obs
