SURFEX v8.1
General documentation of Surfex
horibl_surf_extrap.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 horibl_surf_extrap(PILA1,PILO1,PILA2,PILO2,KINLA,KINLO,KILEN,PARIN, &
7  KOLEN,KP,PXOUT,PYOUT,PAROUT,KLUOUT,OINTERP,PILATARRAY )
8 ! ###########################################################################
9 !
10 !!**** *HORIBL_SURF_EXTRAP* - horitontal bilinear interpolation
11 !!
12 !! PURPOSE
13 !! -------
14 !!
15 !! Interpolates a field, supports masks.
16 !!
17 !! METHOD
18 !! ------
19 !!
20 !! This routine performs a bilinear interpolation based on the 12 surrounding
21 !! points. It begins with an interpolation along the latitudes (with third order
22 !! polynoms interpolation with 4 points and linear interpolation for 2 points)
23 !! and then a second along the longitude (third order polynoms interpolation).
24 !! Two interpolations are performed : first along the parallels then between the
25 !! four resulting points.
26 !!
27 !! The disposition of the points is the following :
28 !!
29 !!
30 !! N 1 2
31 !!
32 !! ^ 3 4 5 6
33 !! | x
34 !! | 7 8 9 10
35 !! |
36 !! 11 12
37 !! S
38 !! W ---------------> E
39 !!
40 !! Note : the name 'south', 'north', may not be exact if the last data point is
41 !! to the south of first (delta latitude < 0). This does not affect computations.
42 !!
43 !! The formula used to compute the weight is :
44 !! (Lon - Lon.i) . (Lon - Lon.i) . (Lon - Lon.i)
45 !! Wi = ---------------------------------------------------
46 !! (Lon.i - Lon.j) . (Lon.i - Lon.k) . (Lon.i - Lon.l)
47 !! Where j,k,l are the other points of the line.
48 !!
49 !! When masks are used, points with different types than the output points are
50 !! not taken in account (in the formula, the corresponding coefficient is set
51 !! to 1). If no points of the same nature are available, the interpolation is
52 !! performed anyway with the 12 points. It is the task of the calling program
53 !! to react to this situation.
54 !!
55 !! When the inputs parameters define a circular map (or global), the inputs data
56 !! are extended. The value of the parameter ODVECT is used to know if the datas
57 !! are vectorial or scalar (this affects the sign of extended values).
58 !!
59 !! EXTERNAL
60 !! --------
61 !!
62 !! subroutine FMLOOK_ll : to retrieve the logical unit number of the listing file
63 !!
64 !! IMPLICIT ARGUMENTS
65 !! ------------------
66 !!
67 !! REFERENCE
68 !! ---------
69 !!
70 !! This routine is based on the one used by the software FULL-POS from Meteo France.
71 !! More informations may be found in 'Book 1'
72 !!
73 !! AUTHOR
74 !! ------
75 !!
76 !! J.Pettre & V.Bousquet
77 !!
78 !! MODIFICATIONS
79 !! -------------
80 !!
81 !! Original 07/01/1999
82 !! 21/04/1999 (V. Masson) set correct prefixes and bug in
83 !! a logical definition
84 !! 21/04/1999 (V. Masson) bug in north and south poles
85 !! extension for input map land-sea mask
86 !! 27/05/1999 (V. Masson) bug in 'grib south pole'
87 !! extrapolation (number of point per parallel)
88 !! 27/05/1999 (V. Masson) bug in 'grib pole' extrapolation
89 !! extra latitudes are now computed symetrically
90 !! to the poles.
91 !! 17/03/2010 (P. LeMoigne) bug in weights computations
92 !! 16/06/2010 (G. Tanguy) bug in 'grib north pole"
93 !! extrapolation (tabular ZARIN not totaly filled)
94 !!
95 !------------------------------------------------------------------------------
96 !
97 !
98 !* 0. DECLARATIONS
99 ! ---------------
100 !
101 USE modi_hor_extrapol_surf
102 !
103 USE modd_surfex_mpi, ONLY : nrank, npio, ncomm, nproc
104 USE modd_surf_par, ONLY : xundef
105 !
106 USE yomhook ,ONLY : lhook, dr_hook
107 USE parkind1 ,ONLY : jprb
108 !
109 IMPLICIT NONE
110 !
111 #ifdef SFX_MPI
112 include "mpif.h"
113 #endif
114 !
115 !* 0.1. Declaration of arguments
116 !
117 REAL, INTENT(IN) :: PILA1 ! Lat. (y) of first input point KDGSA
118 REAL, INTENT(IN) :: PILO1 ! Lon. (x) of first input point
119 REAL, INTENT(IN) :: PILA2 ! Lat. (y) of last input point KDGEN
120 REAL, INTENT(IN) :: PILO2 ! Lon. (x) of last input point
121 INTEGER, INTENT(IN) :: KINLA ! Number of parallels
122 INTEGER, DIMENSION(:), INTENT(IN) :: KINLO ! Number of point along a parallel
123 INTEGER, INTENT(IN) :: KILEN ! size of input arrays
124 REAL, DIMENSION(:,:), INTENT(IN) :: PARIN ! input array
125 INTEGER, INTENT(IN) :: KOLEN ! size of output array
126 INTEGER, DIMENSION(:,:), INTENT(IN) :: KP
127 REAL, DIMENSION(:), INTENT(IN) :: PXOUT ! X (lon.) of output points
128 REAL, DIMENSION(:), INTENT(IN) :: PYOUT ! Y (lat.) of output points
129 REAL, DIMENSION(:,:), INTENT(INOUT) :: PAROUT ! output array
130 LOGICAL, DIMENSION(:), INTENT(IN) :: OINTERP ! .true. where physical value is needed
131 INTEGER, INTENT(IN) :: KLUOUT ! output listing logical unit
132 REAL, DIMENSION(:), INTENT(IN), OPTIONAL :: PILATARRAY
133 !
134 !* 0.2. Declaration of local variables
135 !
136 #ifdef SFX_MPI
137 INTEGER, DIMENSION(MPI_STATUS_SIZE) :: ISTATUS
138 #endif
139  ! Variables implied in the extension procedure
140 INTEGER :: ICOUNT, JL, INL
141  ! Loop counters
142 INTEGER :: INFOMPI, J, ICPT
143 !------------------------------------------------------------------------------
144 REAL(KIND=JPRB) :: ZHOOK_HANDLE, ZHOOK_HANDLE_OMP
145 !------------------------------------------------------------------------------
146 !
147 !* 1. DETERMINATION of the latitude of the poles (depending of the latitude
148 ! ------------- of the first data point)
149 !
150 !------------------------------------------------------------------------------
151 !
152 IF (lhook) CALL dr_hook('HORIBL_SURF_EXTRAP_2',0,zhook_handle)
153 
154 inl = SIZE(parout,2)
155 
156 !* no data point
157 IF (nrank==npio) icount = count(parin(:,:)/=xundef)
158 IF (nproc>1) THEN
159 #ifdef SFX_MPI
160  CALL mpi_bcast(icount,kind(icount)/4,mpi_integer,npio,ncomm,infompi)
161 #endif
162 ENDIF
163 IF (icount==0 .AND. lhook) CALL dr_hook('HORIBL_SURF_EXTRAP_2',1,zhook_handle)
164 IF (icount==0) RETURN
165 !
166 IF (lhook) CALL dr_hook('HORIBL_SURF_EXTRAP_2',1,zhook_handle)
167 IF (lhook) CALL dr_hook('HORIBL_SURF_EXTRAP_3',0,zhook_handle)
168 !
169 DO jl=1,inl
170 WRITE(kluout,*) ' Remaining horizontal extrapolations'
171 WRITE(kluout,*) ' Total number of input data : ',icount
172 WRITE(kluout,*) ' Number of points to interpolate: ',count(parout(:,jl)==xundef .AND. ointerp(:))
173 ENDDO
174 !
175 IF (lhook) CALL dr_hook('HORIBL_SURF_EXTRAP_3',1,zhook_handle)
176 IF (lhook) CALL dr_hook('HORIBL_SURF_EXTRAP_4',0,zhook_handle)
177 
178 !* input grid coordinates
179 !
180 !
181 IF (PRESENT(pilatarray)) THEN
182  CALL hor_extrapol_surf(kluout,'LALO',kilen,pila1,pila2,pilo1,pilo2,kinla,kinlo,&
183  kp,parin,pyout,pxout,parout,ointerp,pilatarray)
184 ELSE
185  CALL hor_extrapol_surf(kluout,'LALO',kilen,pila1,pila2,pilo1,pilo2,kinla,kinlo,&
186  kp,parin,pyout,pxout,parout,ointerp)
187 ENDIF
188 !
189 IF (lhook) CALL dr_hook('HORIBL_SURF_EXTRAP_4',1,zhook_handle)
190 !
191 !------------------------------------------------------------------------------
192 !
193 !
194 END SUBROUTINE horibl_surf_extrap
subroutine hor_extrapol_surf(KLUOUT, HCOORTYPE, KILEN, PILA1, PILA2, PI
real, parameter xundef
integer, parameter jprb
Definition: parkind1.F90:32
logical lhook
Definition: yomhook.F90:15
subroutine horibl_surf_extrap(PILA1, PILO1, PILA2, PILO2, KINLA, KINLO, KILEN, PARIN, KOLEN, KP, PXOUT, PYOUT, PAROUT, KLUOUT, OINTERP, PILATARRAY)
static int count
Definition: memory_hook.c:21