SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
hor_interpol_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 hor_interpol_cartesian(KLUOUT,PFIELDIN,PFIELDOUT)
7 ! #################################################################################
8 !
9 !
10 USE modd_prep, ONLY : xlat_out, xlon_out, xx_out, xy_out, linterp
11 USE modd_grid_cartesian, ONLY : xx, xy, nx, ny
12 USE modd_surf_par, ONLY : xundef
13 !
15 USE modi_bilin
16 !
17 !
18 USE yomhook ,ONLY : lhook, dr_hook
19 USE parkind1 ,ONLY : jprb
20 !
21 IMPLICIT NONE
22 !
23 !* 0.1 declarations of arguments
24 !
25 INTEGER, INTENT(IN) :: kluout ! logical unit of output listing
26 REAL, DIMENSION(:,:), INTENT(IN) :: pfieldin ! field to interpolate horizontally
27 REAL, DIMENSION(:,:), INTENT(OUT) :: pfieldout ! interpolated field
28 !
29 !* 0.2 declarations of local variables
30 !
31 REAL, DIMENSION(:), ALLOCATABLE :: zx ! X coordinate
32 REAL, DIMENSION(:), ALLOCATABLE :: zy ! Y coordinate
33 INTEGER :: ino ! output number of points
34 REAL, DIMENSION(:,:,:), ALLOCATABLE :: zfieldin ! input field
35 !
36 INTEGER :: ji ! loop index
37 INTEGER :: jj ! loop index
38 INTEGER :: jl ! loop index
39 REAL(KIND=JPRB) :: zhook_handle
40 
41 !-------------------------------------------------------------------------------------
42 !
43 !* 1. Allocations
44 !
45 IF (lhook) CALL dr_hook('HOR_INTERPOL_CARTESIAN',0,zhook_handle)
46 ino = SIZE(xx_out)
47 !
48 ALLOCATE(zx(ino))
49 ALLOCATE(zy(ino))
50 !
51 !* 2. Transformation of latitudes/longitudes into metric coordinates of output grid
52 !
53 !* WARNING : here, because the input grid is not geographic, one assumes that
54 ! coordinates are coherent between input and output grid, but without
55 ! any way to check it.
56 !
57 zx = xx_out
58 zy = xy_out
59 !
60 !
61 !* 3. Put input field on its squared grid
62 !
63 ALLOCATE(zfieldin(nx,ny,SIZE(pfieldin,2)))
64 !
65 DO jj=1,ny
66  DO ji=1,nx
67  zfieldin(ji,jj,:) = pfieldin(ji+nx*(jj-1),:)
68  END DO
69 END DO
70 !
71 !* 4. Interpolation with bilinear
72 !
73 DO jl=1,SIZE(pfieldin,2)
74  CALL bilin(kluout,xx,xy,zfieldin(:,:,jl),zx,zy,pfieldout(:,jl),linterp)
75 END DO
76 !
77 !
78 !* 5. Deallocations
79 !
80 !
81 DEALLOCATE(zx)
82 DEALLOCATE(zy)
83 DEALLOCATE(zfieldin)
84 IF (lhook) CALL dr_hook('HOR_INTERPOL_CARTESIAN',1,zhook_handle)
85 !
86 !-------------------------------------------------------------------------------------
87 END SUBROUTINE hor_interpol_cartesian
subroutine bilin(KLUOUT, PX1, PY1, PFIELD1, PX2, PY2, PFIELD2, OINTERP)
Definition: bilin.F90:6
subroutine hor_interpol_cartesian(KLUOUT, PFIELDIN, PFIELDOUT)