SURFEX v8.1
General documentation of Surfex
get_near_meshes_lonlat_reg.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_lonlat_reg(KGRID_PAR,KL,PGRID_PAR,KNEAR_NBR,KNEAR)
7 ! ##############################################################
8 !
9 !!**** *GET_NEAR_MESHES_LONLAT_REG* 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 USE modd_surfex_mpi, ONLY : nindex, nrank, nnum
36 !
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 INTEGER :: ILON ! number of points in longitude
57 INTEGER :: ILAT ! number of points in latitude
58 INTEGER :: JLAT, JLON
59 INTEGER :: JL
60 INTEGER :: JX, JY
61 INTEGER :: IDIST
62 INTEGER :: ICOUNT
63 REAL(KIND=JPRB) :: ZHOOK_HANDLE
64 !----------------------------------------------------------------------------
65 !
66 IF (lhook) CALL dr_hook('GET_NEAR_MESHES_LONLAT_REG',0,zhook_handle)
67  CALL get_gridtype_lonlat_reg(pgrid_par,klon=ilon,klat=ilat)
68 !
69 knear(:,:) = 0
70 !
71 idist = int(sqrt(float(knear_nbr)))
72 !
73 IF (ilon*ilat==kl) THEN
74  DO jlat=1,ilat
75  DO jlon=1,ilon
76  icount = 0
77  jl = jlon + ilon * (jlat-1)
78  IF (nindex(jl)==nrank) THEN
79  knear(nnum(jl),:) = 0
80  DO jx=-(idist-1)/2,idist/2
81  DO jy=-(idist-1)/2,idist/2
82  IF (jlon+jx>0 .AND. jlon+jx<ilon+1 .AND. jlat+jy>0 .AND. jlat+jy<ilat+1) THEN
83  icount = icount + 1
84  knear(nnum(jl),icount) = (jlon+jx) + ilon * (jlat+jy-1)
85  END IF
86  END DO
87  END DO
88  ENDIF
89  END DO
90  END DO
91 END IF
92 IF (lhook) CALL dr_hook('GET_NEAR_MESHES_LONLAT_REG',1,zhook_handle)
93 !
94 !-------------------------------------------------------------------------------
95 !
96 END SUBROUTINE get_near_meshes_lonlat_reg
integer, dimension(:), allocatable nnum
integer, parameter jprb
Definition: parkind1.F90:32
subroutine get_gridtype_lonlat_reg(PGRID_PAR, PLONMIN, PLONMAX, PLATMIN, PLATMAX, KLON, KLAT, KL, PLON, PLAT)
subroutine get_near_meshes_lonlat_reg(KGRID_PAR, KL, PGRID_PAR, KNEAR
logical lhook
Definition: yomhook.F90:15
integer, dimension(:), allocatable nindex