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