SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
get_near_meshes_lonlatval.F90
Go to the documentation of this file.
1 !SFX_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
2 !SFX_LIC This is part of the SURFEX software governed by the CeCILL-C licence
3 !SFX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SFX_LIC for details. version 1.
5 ! #########
6  SUBROUTINE get_near_meshes_lonlatval(KGRID_PAR,KL,PGRID_PAR,KNEAR_NBR,KNEAR)
7 ! ##############################################################
8 !
9 !!**** *GET_NEAR_MESHES_LONLATVAL* get the near grid mesh indices
10 !!
11 !! PURPOSE
12 !! -------
13 !!
14 !! METHOD
15 !! ------
16 !!
17 !! REFERENCE
18 !! ---------
19 !!
20 !! AUTHOR
21 !! ------
22 !!
23 !! V. Masson Meteo-France
24 !!
25 !! MODIFICATION
26 !! ------------
27 !!
28 !! Original 03/2004
29 !!
30 !----------------------------------------------------------------------------
31 !
32 !* 0. DECLARATION
33 ! -----------
34 !
36 !
37 !
38 USE yomhook ,ONLY : lhook, dr_hook
39 USE parkind1 ,ONLY : jprb
40 !
41 IMPLICIT NONE
42 !
43 !* 0.1 Declaration of arguments
44 ! ------------------------
45 !
46 INTEGER, INTENT(IN) :: kgrid_par ! size of PGRID_PAR
47 INTEGER, INTENT(IN) :: kl ! number of points
48 INTEGER, INTENT(IN) :: knear_nbr ! number of nearest points wanted
49 REAL, DIMENSION(KGRID_PAR), INTENT(IN) :: pgrid_par ! grid parameters
50 INTEGER, DIMENSION(:,:),POINTER :: knear ! near mesh indices
51 !
52 !* 0.2 Declaration of other local variables
53 ! ------------------------------------
54 !
55 REAL, DIMENSION(KL) :: zdis
56 REAL,DIMENSION(KL) :: zx
57 REAL,DIMENSION(KL) :: zy
58 REAL,DIMENSION(KL) :: zdx
59 REAL,DIMENSION(KL) :: zdy
60 REAL :: zdmax
61 INTEGER :: id0
62 INTEGER :: jp1, jp2, jn, il
63 REAL(KIND=JPRB) :: zhook_handle
64 !
65 !----------------------------------------------------------------------------
66 !
67 IF (lhook) CALL dr_hook('GET_NEAR_MESHES_LONLATVAL',0,zhook_handle)
68 !
69  CALL get_gridtype_lonlatval(pgrid_par,il,zx,zy,zdx,zdy)
70 !
71 knear(:,:) = 0
72 !
73 ! calcul de la distance de tous les points 2 à 2
74 !
75 zdis = 1.e20
76 !
77 DO jp1=1,kl
78  !
79  DO jp2=1,kl
80  zdis(jp2) = sqrt((zx(jp1)-zx(jp2))**2+(zy(jp1)-zy(jp2))**2)
81  ENDDO
82  zdmax = maxval(zdis(:)) + 1.
83  zdis(jp1) = zdmax
84  !
85  ! on prend les knear_nbr premiers, pour chaque
86  !
87  DO jn=1,min(kl-1,knear_nbr)
88  !
89  id0 = maxval(minloc(zdis(:)))
90  !
91  knear(jp1,jn) = id0
92  zdis(id0) = zdmax
93  !
94  ENDDO
95  !
96 ENDDO
97 !
98 IF (lhook) CALL dr_hook('GET_NEAR_MESHES_LONLATVAL',1,zhook_handle)
99 !
100 !-------------------------------------------------------------------------------
101 !
102 END SUBROUTINE get_near_meshes_lonlatval
subroutine get_near_meshes_lonlatval(KGRID_PAR, KL, PGRID_PAR, KNEAR_NBR, KNEAR)
subroutine get_gridtype_lonlatval(PGRID_PAR, KL, PX, PY, PDX, PDY)