SURFEX v8.1
General documentation of Surfex
get_near_meshes_cartesian.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_cartesian(KGRID_PAR,KL,PGRID_PAR,KNEAR_NBR,KNEAR)
7 ! ##############################################################
8 !
9 !!**** *GET_NEAR_MESHES_CARTESIAN* 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 INTEGER :: IIMAX, IJMAX
57 INTEGER :: JI, JJ
58 INTEGER :: JX, JY
59 INTEGER :: JL
60 INTEGER :: IDIST
61 INTEGER :: ICOUNT
62 REAL(KIND=JPRB) :: ZHOOK_HANDLE
63 !----------------------------------------------------------------------------
64 !
65 IF (lhook) CALL dr_hook('GET_NEAR_MESHES_CARTESIAN',0,zhook_handle)
66  CALL get_gridtype_cartesian(pgrid_par,kimax=iimax,kjmax=ijmax)
67 !
68 knear(:,:) = 0
69 !
70 idist = int(sqrt(float(knear_nbr)))
71 !
72 IF (iimax*ijmax==kl) THEN
73  DO jj=1,ijmax
74  DO ji=1,iimax
75  icount = 0
76  jl = ji + iimax * (jj-1)
77  IF (nindex(jl)==nrank) THEN
78  knear(nnum(jl),:) = 0
79  DO jx=-(idist-1)/2,idist/2
80  DO jy=-(idist-1)/2,idist/2
81  IF (ji+jx>0 .AND. ji+jx<iimax+1 .AND. jj+jy>0 .AND. jj+jy<ijmax+1) THEN
82  icount = icount + 1
83  knear(nnum(jl),icount) = (ji+jx) + iimax * (jj+jy-1)
84  END IF
85  END DO
86  END DO
87  ENDIF
88  ENDDO
89  END DO
90 END IF
91 IF (lhook) CALL dr_hook('GET_NEAR_MESHES_CARTESIAN',1,zhook_handle)
92 !
93 !-------------------------------------------------------------------------------
94 !
95 END SUBROUTINE get_near_meshes_cartesian
subroutine get_near_meshes_cartesian(KGRID_PAR, KL, PGRID_PAR, KNEAR_
integer, dimension(:), allocatable nnum
integer, parameter jprb
Definition: parkind1.F90:32
logical lhook
Definition: yomhook.F90:15
subroutine get_gridtype_cartesian(PGRID_PAR, PLAT0, PLON0,
integer, dimension(:), allocatable nindex