SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
hor_interpol_conf_proj.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_conf_proj(KLUOUT,PFIELDIN,PFIELDOUT)
7 ! #################################################################################
8 !!
9 !! PURPOSE
10 !! -------
11 !!
12 !! METHOD
13 !! ------
14 !!
15 !! EXTERNAL
16 !! --------
17 !!
18 !! IMPLICIT ARGUMENTS
19 !! ------------------
20 !!
21 !! REFERENCE
22 !! ---------
23 !!
24 !! AUTHOR
25 !! ------
26 !!
27 !! MODIFICATION
28 !! ------------
29 !!
30 !! 02/04/12 M. Tomasini Add an index in the second dimension of the ISBA
31 !! array variables for BILIN interpolation routine to
32 !! not bug in case 2D (this is not the more beautiful
33 !! method; the BILIN routine should better be adapted)
34 !! Search ! Ajout MT
35 !-------------------------------------------------------------------------------
36 !
37 !
38 USE modd_prep, ONLY : xlat_out, xlon_out, linterp
39 USE modd_grid_conf_proj, ONLY : xx, xy, nx, ny, xlat0, xlon0, xlatori, &
40  xlonori, xrpk, xbeta
41 USE modd_surf_par, ONLY : xundef
42 !
44 USE modi_bilin
45 !
46 !
47 USE yomhook ,ONLY : lhook, dr_hook
48 USE parkind1 ,ONLY : jprb
49 !
50 IMPLICIT NONE
51 !
52 !* 0.1 declarations of arguments
53 !
54 INTEGER, INTENT(IN) :: kluout ! logical unit of output listing
55 REAL, DIMENSION(:,:), INTENT(IN) :: pfieldin ! field to interpolate horizontally
56 REAL, DIMENSION(:,:), INTENT(OUT) :: pfieldout ! interpolated field
57 !
58 !* 0.2 declarations of local variables
59 !
60 REAL, DIMENSION(:), ALLOCATABLE :: zx,zy ! coordinate of the output field
61 REAL, DIMENSION(:), ALLOCATABLE :: zx_duplique ! X coordinate of the output field ! Ajout MT
62 REAL, DIMENSION(:), ALLOCATABLE :: zy_duplique ! Y coordinate of the output field ! Ajout MT
63 REAL, DIMENSION(:), ALLOCATABLE :: zxy_duplique ! Y coordinate of the input field ! Ajout MT
64 REAL, DIMENSION(:,:,:), ALLOCATABLE :: zfieldin ! input field
65 REAL, DIMENSION(:,:,:), ALLOCATABLE :: zfieldin_duplique ! input field ! Ajout MT
66 REAL, DIMENSION(:,:), ALLOCATABLE :: zfieldout_duplique ! interpolated output field ! Ajout MT
67 !
68 INTEGER :: ino ! output number of points
69 INTEGER :: ji,jj,jl ! loop index
70 !
71 REAL(KIND=JPRB) :: zhook_handle
72 !
73 LOGICAL, DIMENSION(:), ALLOCATABLE :: ginterp_duplique ! .true. where physical value is needed ! Ajout MT
74 !-------------------------------------------------------------------------------------
75 !
76 !* 1. Allocations
77 !
78 IF (lhook) CALL dr_hook('HOR_INTERPOL_CONF_PROJ',0,zhook_handle)
79 ino = SIZE(xlat_out)
80 !
81 ALLOCATE(zx(ino))
82 ALLOCATE(zy(ino))
83 !
84 IF (ny==1) THEN ! Ajout MT
85  ALLOCATE(zxy_duplique(2),zfieldin_duplique(nx,2,SIZE(pfieldin,2)))
86  ALLOCATE(zx_duplique(2*ino),zy_duplique(2*ino),zfieldout_duplique(2*ino,SIZE(pfieldin,2)))
87  ALLOCATE(ginterp_duplique(SIZE(zfieldout_duplique,1)))
88 END IF
89 !
90 !* 2. Transformation of latitudes/longitudes into metric coordinates of output grid
91 !
92  CALL xy_conf_proj(xlat0,xlon0,xrpk,xbeta,xlatori,xlonori, &
93  zx,zy,xlat_out,xlon_out )
94 !
95 !* 3. Put input field on its squared grid
96 !
97 ALLOCATE(zfieldin(nx,ny,SIZE(pfieldin,2)))
98 !
99 DO jj=1,ny
100  DO ji=1,nx
101  zfieldin(ji,jj,:) = pfieldin(ji+nx*(jj-1),:)
102  END DO
103 END DO
104 !
105 IF (ny==1) THEN ! Ajout MT
106  zfieldin_duplique(:,1,:)=zfieldin(:,1,:)
107  zfieldin_duplique(:,2,:)=zfieldin(:,1,:)
108  zxy_duplique(1)=xy(1)
109  zxy_duplique(2)=xy(1)+10000.
110  zx_duplique(1:ino) =zx(:)
111  zx_duplique(ino+1:2*ino)=zx(:)
112  zy_duplique(1:ino) =zy(:)
113  zy_duplique(ino+1:2*ino)=zy(:)+10000.
114  ginterp_duplique(1:ino) =linterp(1:ino)
115  ginterp_duplique(ino+1:2*ino)=linterp(1:ino)
116 END IF
117 !
118 !* 4. Interpolation with bilinear
119 !
120 IF (ny==1) THEN ! Ajout MT
121  DO jl=1,SIZE(pfieldin,2)
122  CALL bilin(kluout,xx,zxy_duplique,zfieldin_duplique(:,:,jl), &
123  zx_duplique,zy_duplique,zfieldout_duplique(:,jl),ginterp_duplique)
124 
125  pfieldout(1:ino,jl)=zfieldout_duplique(1:ino,jl)
126  END DO
127 ELSE
128  DO jl=1,SIZE(pfieldin,2)
129  CALL bilin(kluout,xx,xy,zfieldin(:,:,jl),zx,zy,pfieldout(:,jl),linterp)
130  END DO
131 END IF
132 !
133 !
134 !* 5. Deallocations
135 !
136 !
137 DEALLOCATE(zx,zy)
138 DEALLOCATE(zfieldin)
139 IF (ny==1) DEALLOCATE(zxy_duplique,zx_duplique,zy_duplique, &
140  zfieldin_duplique,zfieldout_duplique,ginterp_duplique) ! Ajout MT
141 !
142 IF (lhook) CALL dr_hook('HOR_INTERPOL_CONF_PROJ',1,zhook_handle)
143 !
144 !-------------------------------------------------------------------------------------
145 END SUBROUTINE hor_interpol_conf_proj
subroutine bilin(KLUOUT, PX1, PY1, PFIELD1, PX2, PY2, PFIELD2, OINTERP)
Definition: bilin.F90:6
subroutine hor_interpol_conf_proj(KLUOUT, PFIELDIN, PFIELDOUT)
subroutine xy_conf_proj(PLAT0, PLON0, PRPK, PBETA, PLATOR, PLONOR, PX, PY, PLAT, PLON)