1 |
module regr_pr_int_m |
module regr_pr_int_m |
2 |
|
|
3 |
|
! Author: Lionel GUEZ |
4 |
|
|
5 |
implicit none |
implicit none |
6 |
|
|
7 |
contains |
contains |
8 |
|
|
9 |
subroutine regr_pr_int(ncid, name, julien, top_value, v3) |
subroutine regr_pr_int(ncid, name, julien, pplay, top_value, v3) |
10 |
|
|
11 |
! "regr_pr_int" stands for "regrid pressure interpolation". |
! "regr_pr_int" stands for "regrid pressure interpolation". |
12 |
|
|
19 |
! that the input data is already on the LMDZ "rlatu" latitude |
! that the input data is already on the LMDZ "rlatu" latitude |
20 |
! grid. |
! grid. |
21 |
|
|
22 |
! The target vertical LMDZ grid is the grid of mid-layers. |
! The target vertical LMDZ grid is the grid of mid-layers. The |
23 |
! The input data does not depend on longitude, but the pressure |
! input data does not depend on longitude, but the pressure at |
24 |
! at LMDZ mid-layers does. |
! LMDZ mid-layers does. Therefore, the values on the LMDZ grid do |
25 |
! Therefore, the values on the LMDZ grid do depend on longitude. |
! depend on longitude. Regridding is by linear interpolation. |
|
! Regridding is by linear interpolation. |
|
26 |
|
|
27 |
use dimens_m, only: iim, jjm, llm |
use dimensions, only: iim, jjm, llm |
28 |
use dimphy, only: klon |
use dimphy, only: klon |
29 |
use grid_change, only: dyn_phy |
use grid_change, only: gr_dyn_phy |
30 |
use netcdf95, only: nf95_inq_varid, nf95_get_var |
use netcdf95, only: nf95_inq_varid, nf95_get_var |
31 |
use nr_util, only: assert |
use nr_util, only: assert |
32 |
use numer_rec_95, only: regr1_lint |
use numer_rec_95, only: regr1_lint |
33 |
use press_coefoz_m, only: plev |
use press_coefoz_m, only: plev |
|
use pressure_var, only: pls |
|
34 |
|
|
35 |
integer, intent(in):: ncid ! NetCDF ID of the file |
integer, intent(in):: ncid ! NetCDF ID of the file |
36 |
character(len=*), intent(in):: name ! of the NetCDF variable |
character(len=*), intent(in):: name ! of the NetCDF variable |
37 |
integer, intent(in):: julien ! jour julien, 1 <= julien <= 360 |
integer, intent(in):: julien ! jour julien, 1 <= julien <= 360 |
38 |
|
|
39 |
|
real, intent(in):: pplay(:, :) ! (klon, llm) |
40 |
|
! (pression pour le mileu de chaque couche, en Pa) |
41 |
|
|
42 |
real, intent(in):: top_value |
real, intent(in):: top_value |
43 |
! (extra value of field at 0 pressure) |
! (extra value of field at 0 pressure) |
44 |
|
|
50 |
|
|
51 |
integer varid ! for NetCDF |
integer varid ! for NetCDF |
52 |
|
|
53 |
real v1(jjm + 1, 0:size(plev)) |
real v1(jjm + 1, 0:size(plev)) |
54 |
! Input field at day "julien". "v1(j, k >=1)" is at latitude |
! Input field at day "julien". "v1(j, k >=1)" is at latitude |
55 |
! "rlatu(j)" and pressure "plev(k)". |
! "rlatu(j)" and pressure "plev(k)". |
56 |
|
|
57 |
real v2(iim + 1, jjm + 1, llm) |
real v2(klon, 0:size(plev)) |
58 |
! Regridded field on the "dynamics" horizontal grid. "v2(i, j, k)" |
! Field on the "physics" horizontal grid. "v2(i, k >= 1)" is at |
59 |
! is at longitude "rlonv(i)", latitude "rlatu(j)" and pressure |
! longitude "xlon(i)", latitude "xlat(i)" and pressure "plev(k)".) |
|
! "pls(i, j, k)". |
|
60 |
|
|
61 |
integer i, j, k |
integer i |
62 |
|
|
63 |
!-------------------------------------------- |
!-------------------------------------------- |
64 |
|
|
75 |
! Complete "v1" with the value at 0 pressure: |
! Complete "v1" with the value at 0 pressure: |
76 |
v1(:, 0) = top_value |
v1(:, 0) = top_value |
77 |
|
|
78 |
|
v2 = gr_dyn_phy(spread(v1, dim = 1, ncopies = iim + 1)) |
79 |
|
|
80 |
! Regrid in pressure at each horizontal position: |
! Regrid in pressure at each horizontal position: |
81 |
do j = 1, jjm + 1 |
do i = 1, klon |
82 |
do i = 1, iim |
v3(i, llm:1:-1) = regr1_lint(v2(i, :), (/0., plev/), pplay(i, llm:1:-1)) |
83 |
if (dyn_phy(i, j)) then |
! (invert order of indices because "pplay" is in descending order) |
|
v2(i, j, llm:1:-1) & |
|
|
= regr1_lint(v1(j, :), (/0., plev/), pls(i, j, llm:1:-1)) |
|
|
! (invert order of indices because "pls" is in descending order) |
|
|
end if |
|
|
end do |
|
84 |
end do |
end do |
85 |
|
|
|
forall (k = 1:llm) v3(:, k) = pack(v2(:, :, k), dyn_phy) |
|
|
|
|
86 |
end subroutine regr_pr_int |
end subroutine regr_pr_int |
87 |
|
|
88 |
end module regr_pr_int_m |
end module regr_pr_int_m |