SURFEX v8.1
General documentation of Surfex
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 USE modd_surfex_mpi, ONLY : nindex, nrank, nnum
38 !
39 USE yomhook ,ONLY : lhook, dr_hook
40 USE parkind1 ,ONLY : jprb
41 !
42 IMPLICIT NONE
43 !
44 !* 0.1 Declaration of arguments
45 ! ------------------------
46 !
47 INTEGER, INTENT(IN) :: KGRID_PAR ! size of PGRID_PAR
48 INTEGER, INTENT(IN) :: KL ! number of points
49 INTEGER, INTENT(IN) :: KNEAR_NBR ! number of nearest points wanted
50 REAL, DIMENSION(KGRID_PAR), INTENT(IN) :: PGRID_PAR ! grid parameters
51 INTEGER, DIMENSION(:,:),POINTER :: KNEAR ! near mesh indices
52 !
53 !* 0.2 Declaration of other local variables
54 ! ------------------------------------
55 !
56 REAL, DIMENSION(KL) :: ZDIS
57 REAL,DIMENSION(KL) :: ZX
58 REAL,DIMENSION(KL) :: ZY
59 REAL,DIMENSION(KL) :: ZDX
60 REAL,DIMENSION(KL) :: ZDY
61 REAL :: ZDMAX
62 INTEGER :: ID0
63 INTEGER :: JP1, JP2, JN, IL
64 REAL(KIND=JPRB) :: ZHOOK_HANDLE
65 !
66 !----------------------------------------------------------------------------
67 !
68 IF (lhook) CALL dr_hook('GET_NEAR_MESHES_LONLATVAL',0,zhook_handle)
69 !
70  CALL get_gridtype_lonlatval(pgrid_par,il,zx,zy,zdx,zdy)
71 !
72 knear(:,:) = 0
73 !
74 ! calcul de la distance de tous les points 2 à 2
75 !
76 zdis = 1.e20
77 !
78 DO jp1=1,kl
79  !
80  IF (nindex(jp1)==nrank) THEN
81  !
82  DO jp2=1,kl
83  zdis(jp2) = sqrt((zx(jp1)-zx(jp2))**2+(zy(jp1)-zy(jp2))**2)
84  ENDDO
85  zdmax = maxval(zdis(:)) + 1.
86  zdis(jp1) = zdmax
87  !
88  ! on prend les knear_nbr premiers, pour chaque
89  !
90  DO jn=1,min(kl-1,knear_nbr)
91  !
92  id0 = maxval(minloc(zdis(:)))
93  !
94  knear(nnum(jp1),jn) = id0
95  zdis(id0) = zdmax
96  !
97  ENDDO
98  !
99  ENDIF
100  !
101 ENDDO
102 !
103 IF (lhook) CALL dr_hook('GET_NEAR_MESHES_LONLATVAL',1,zhook_handle)
104 !
105 !-------------------------------------------------------------------------------
106 !
107 END SUBROUTINE get_near_meshes_lonlatval
subroutine get_near_meshes_lonlatval(KGRID_PAR, KL, PGRID_PAR, KNEAR_
subroutine get_gridtype_lonlatval(PGRID_PAR, KL, PX, PY, PDX, PDY)
integer, dimension(:), allocatable nnum
integer, parameter jprb
Definition: parkind1.F90:32
logical lhook
Definition: yomhook.F90:15
integer, dimension(:), allocatable nindex