SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
mode_gltools_interp.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 !GLT_LIC The GELATO model is a seaice model used in stand-alone or embedded mode.
6 !GLT_LIC It has been developed by Meteo-France. The holder of GELATO is Meteo-France.
7 !GLT_LIC
8 !GLT_LIC This software is governed by the CeCILL-C license under French law and biding
9 !GLT_LIC by the rules of distribution of free software. See the CeCILL-C_V1-en.txt
10 !GLT_LIC (English) and CeCILL-C_V1-fr.txt (French) for details. The CeCILL is a free
11 !GLT_LIC software license, explicitly compatible with the GNU GPL
12 !GLT_LIC (see http://www.gnu.org/licenses/license-list.en.html#CeCILL)
13 !GLT_LIC
14 !GLT_LIC The CeCILL-C licence agreement grants users the right to modify and re-use the
15 !GLT_LIC software governed by this free software license. The exercising of this right
16 !GLT_LIC is conditional upon the obligation to make available to the community the
17 !GLT_LIC modifications made to the source code of the software so as to contribute to
18 !GLT_LIC its evolution.
19 !GLT_LIC
20 !GLT_LIC In consideration of access to the source code and the rights to copy, modify
21 !GLT_LIC and redistribute granted by the license, users are provided only with a limited
22 !GLT_LIC warranty and the software's author, the holder of the economic rights, and the
23 !GLT_LIC successive licensors only have limited liability. In this respect, the risks
24 !GLT_LIC associated with loading, using, modifying and/or developing or reproducing the
25 !GLT_LIC software by the user are brought to the user's attention, given its Free
26 !GLT_LIC Software status, which may make it complicated to use, with the result that its
27 !GLT_LIC use is reserved for developers and experienced professionals having in-depth
28 !GLT_LIC computer knowledge. Users are therefore encouraged to load and test the
29 !GLT_LIC suitability of the software as regards their requirements in conditions enabling
30 !GLT_LIC the security of their systems and/or data to be ensured and, more generally, to
31 !GLT_LIC use and operate it in the same conditions of security.
32 !GLT_LIC
33 !GLT_LIC The GELATO sofware is cureently distibuted with the SURFEX software, available at
34 !GLT_LIC http://www.cnrm.meteo.fr/surfex. The fact that you download the software deemed that
35 !GLT_LIC you had knowledge of the CeCILL-C license and that you accept its terms.
36 !GLT_LIC Attempts to use this software in a way not complying with CeCILL-C license
37 !GLT_LIC may lead to prosecution.
38 !GLT_LIC
39 ! =======================================================================
40 ! ======================== MODULE mode_gltools_interp =====================
41 ! =======================================================================
42 !
43 !
44 ! -------------------- BEGIN MODULE mode_gltools_interp -------------------
45 !
47 INTERFACE
48 !
49 FUNCTION glt_interpz(plevn,pvtpo,plevo) RESULT(tab_interp)
50  USE modd_glt_param, only : nilay
51  REAL, DIMENSION(nilay+1), INTENT(in) :: &
52  plevn
53  REAL, DIMENSION(:), INTENT(in) :: &
54  pvtpo
55  REAL, DIMENSION(:), INTENT(in) :: &
56  plevo
57  REAL, DIMENSION(nilay) :: &
58  tab_interp
59 END FUNCTION glt_interpz
60 !
61 #if ! defined in_surfex
62 SUBROUTINE glt_c2b(pcu,pcv,pbu,pbv)
64 REAL, DIMENSION(nx,ny),INTENT(in) :: &
65  pcu,pcv
66 REAL, DIMENSION(nx,ny),INTENT(out) :: &
67  pbu,pbv
68 END SUBROUTINE glt_c2b
69 !
70 SUBROUTINE glt_b2c(pbu,pbv,pcu,pcv)
72 REAL, DIMENSION(nx,ny),INTENT(in) :: &
73  pbu,pbv
74 REAL, DIMENSION(ilo:ihi,jlo:jhi), INTENT(out) :: &
75  pcu,pcv
76 END SUBROUTINE glt_b2c
77 !
78 #endif
79 END INTERFACE
80 END MODULE mode_gltools_interp
81 !
82 ! -------------------- END MODULE mode_gltools_interp ---------------------
83 !
84 !
85 ! -----------------------------------------------------------------------
86 ! --------------------------- FUNCTION glt_interpz --------------------------
87 !
88 ! Goal: Interpolate a vertical tracer profile, pvtpo (dimension n),
89 ! defined on a vertical, normalized grid :
90 ! [ plevo(1)=1, plevo(2), ..., plevo(n), plevo(n+1)=1 ],
91 ! where plevo(jl),plevo(jl+1) define the height (from ice/water bottom
92 ! interface) of respectively the lower and upper boundaries of layer jl.
93 ! Note that n can be any number.
94 !
95 ! The glt_output is delivered on the model's standard vertical levels.
96 !
97 FUNCTION glt_interpz(plevn,pvtpo,plevo) RESULT(tab_interp)
98 !
99  USE modd_glt_param , only: nilay
100  USE mode_glt_stats
101 !
102  IMPLICIT NONE
103 !
104  REAL, DIMENSION(nilay+1), INTENT(in) :: &
105  plevn
106  REAL, DIMENSION(:), INTENT(in) :: &
107  pvtpo
108  REAL, DIMENSION(:), INTENT(in) :: &
109  plevo
110  REAL, DIMENSION(nilay) :: &
111  tab_interp
112 !
113  INTEGER :: jl
114 !
115  DO jl=1,nilay
116  tab_interp(jl) = &
117  ( glt_vtpint(plevn(jl+1),pvtpo,plevo)- &
118  glt_vtpint(plevn(jl),pvtpo,plevo) ) / &
119  ( plevn(jl+1)-plevn(jl) )
120  END DO
121 !
122 END FUNCTION glt_interpz
123 !
124 ! ------------------------- END FUNCTION glt_interpz ------------------------
125 ! -----------------------------------------------------------------------
126 !
127 #if ! defined in_surfex
128 !
129 ! ----------------------------------------------------------------------
130 ! --------------------------- SUBROUTINE glt_c2b ---------------------------
131 !
132 ! .. Interpolates a vector field defined by two components on a C-grid
133 ! to the EVP grid (both components defined at the top right corner of
134 ! the grid cell). Note the interpolated fields must be bounded
135 ! afterwards.
136 !
137 SUBROUTINE glt_c2b(pcu,pcv,pbu,pbv)
138 !
139 USE modd_glt_param
140 !
141 IMPLICIT NONE
142 !
143 REAL, DIMENSION(nx,ny),INTENT(in) :: &
144  pcu,pcv
145 REAL, DIMENSION(nx,ny),INTENT(out) :: &
146  pbu,pbv
147 INTEGER :: &
148  ji,jj
149 !
150 !
151 !
152 ! 1. Initializations
153 ! ==================
154 !
155  pbu(:,:) = 0.
156  pbv(:,:) = 0.
157 !
158 !
159 !
160 ! 2. Interpolate
161 ! ===============
162 !
163 ! Here it is assumed that the input C-grid velocities (u,v) are
164 ! respectively defined at the middle of the East and North edges
165 ! of the grid cell
166 ! B-grid velocities (u,v) are both defined at the northeast corner
167 ! of the grid cell
168 !
169  DO jj = 2,ny-1
170  DO ji = 2,nx/2-1
171  pbu(ji,jj) = .5*( pcu(ji,jj)+pcu(ji,jj+1) )
172  pbv(ji,jj) = .5*( pcv(ji,jj)+pcv(ji+1,jj) )
173  END DO
174 ! Not sure that a special operation has to be done for ji=nx/2
175  pbu(nx/2,jj) = .5*( pcu(nx/2,jj)+pcu(nx/2,jj+1) )
176  pbv(nx/2,jj) = .5*( pcv(nx/2,jj)+pcv(nx/2+1,jj) )
177  DO ji = nx/2+1,nx-1
178  pbu(ji,jj) = .5*( pcu(ji,jj)+pcu(ji,jj+1) )
179  pbv(ji,jj) = .5*( pcv(ji,jj)+pcv(ji+1,jj) )
180  END DO
181  END DO
182 !
183 END SUBROUTINE glt_c2b
184 !
185 ! ------------------------ END SUBROUTINE glt_c2b --------------------------
186 ! ----------------------------------------------------------------------
187 !
188 !
189 ! ----------------------------------------------------------------------
190 ! --------------------------- SUBROUTINE glt_b2c ---------------------------
191 !
192 ! .. Interpolates a vector field defined by two components on a B-grid
193 ! (or EVP grid, both components defined at the top right corner of
194 ! the grid cell) to the C-grid (OPA type: u and v are respectively
195 ! defined at the middle of the Eastern and Northern edges of the grid
196 ! cell.
197 !
198 SUBROUTINE glt_b2c(pbu,pbv,pcu,pcv)
199 !
200 USE modd_glt_param
201 USE mode_gltools_bound
202 !
203 IMPLICIT NONE
204 !
205 REAL, DIMENSION(nx,ny),INTENT(in) :: &
206  pbu,pbv
207 REAL, DIMENSION(ilo:ihi,jlo:jhi), INTENT(out) :: &
208  pcu,pcv
209 !
210 INTEGER :: &
211  ji,jj
212 !
213 !
214 !
215 ! 1.1. Define ancillary arrays
216 ! -----------------------------
217 !
218 ! ...
219 !
220 !
221 ! 1.2. Compute velocity components
222 ! ---------------------------------
223 !
224  DO jj=jlo,jhi
225  DO ji=ilo,ihi
226  pcu(ji,jj) = 0.5*( pbu(ji,jj)+pbu(ji,jj-1) )
227  pcv(ji,jj) = 0.5*( pbv(ji,jj)+pbv(ji-1,jj) )
228  END DO
229  END DO
230 !
231 END SUBROUTINE glt_b2c
232 !
233 ! ------------------------ END SUBROUTINE glt_b2c --------------------------
234 ! ----------------------------------------------------------------------
235 #endif
subroutine glt_c2b(pcu, pcv, pbu, pbv)
real function, dimension(nilay) glt_interpz(plevn, pvtpo, plevo)
subroutine glt_b2c(pbu, pbv, pcu, pcv)