1 |
module regr_pr_coefoz |
module regr_pr_av_m |
|
|
|
|
! Both procedures of this module read a single Mobidic ozone |
|
|
! coefficient from "coefoz_LMDZ.nc", at the current day, regrid this |
|
|
! coefficient in pressure to the LMDZ vertical grid and pack it to the LMDZ |
|
|
! horizontal "physics" grid. |
|
|
! The input data is a 2D latitude -- pressure field. |
|
|
! The target horizontal LMDZ grid is the "scalar" grid: "rlonv", "rlatu". |
|
|
! We assume that the input data is already on the LMDZ "rlatu" |
|
|
! latitude grid. |
|
2 |
|
|
3 |
implicit none |
implicit none |
4 |
|
|
5 |
contains |
contains |
6 |
|
|
7 |
subroutine regr_pr_av_coefoz(ncid, name, julien, v3) |
subroutine regr_pr_av(ncid, name, julien, v3) |
8 |
|
|
9 |
|
! "regr_pr_av" stands for "regrid pressure averaging". |
10 |
|
|
11 |
|
! This procedure reads a 2D latitude-pressure field from a NetCDF |
12 |
|
! file, at a given day, regrids this field in pressure to the LMDZ |
13 |
|
! vertical grid and packs it to the LMDZ horizontal "physics" |
14 |
|
! grid. |
15 |
|
|
16 |
|
! We assume that, in the input file, the field has 3 dimensions: |
17 |
|
! latitude, pressure, julian day. |
18 |
|
|
19 |
|
! We assume that the input field is already on the LMDZ "rlatu" |
20 |
|
! latitudes, except that latitudes are in ascending order in the |
21 |
|
! input file. |
22 |
|
|
|
! "regr_pr_av_coefoz" stands for "regrid pressure averaging |
|
|
! coefficient ozone". |
|
23 |
! The target vertical LMDZ grid is the grid of layer boundaries. |
! The target vertical LMDZ grid is the grid of layer boundaries. |
|
! The input data does not depend on longitude, but the pressure |
|
|
! at LMDZ layers does. |
|
|
! Therefore, the values on the LMDZ grid do depend on longitude. |
|
24 |
! Regridding in pressure is done by averaging a step function of pressure. |
! Regridding in pressure is done by averaging a step function of pressure. |
25 |
|
|
26 |
use dimens_m, only: iim, jjm, llm |
use dimens_m, only: iim, jjm, llm |
27 |
use dimphy, only: klon |
use dimphy, only: klon |
|
use netcdf95, only: nf95_inq_varid, handle_err |
|
|
use netcdf, only: nf90_get_var |
|
28 |
use grid_change, only: dyn_phy |
use grid_change, only: dyn_phy |
29 |
|
use netcdf95, only: nf95_inq_varid, nf95_get_var |
30 |
use nr_util, only: assert |
use nr_util, only: assert |
31 |
|
use numer_rec_95, only: regr1_step_av |
32 |
use press_coefoz_m, only: press_in_edg |
use press_coefoz_m, only: press_in_edg |
|
use l_util, only: regr1_step_av |
|
33 |
use pressure_var, only: p3d |
use pressure_var, only: p3d |
34 |
|
|
35 |
integer, intent(in):: ncid ! NetCDF ID of the file |
integer, intent(in):: ncid ! NetCDF ID of the file |
37 |
integer, intent(in):: julien ! jour julien, 1 <= julien <= 360 |
integer, intent(in):: julien ! jour julien, 1 <= julien <= 360 |
38 |
|
|
39 |
real, intent(out):: v3(:, :) ! (klon, llm) |
real, intent(out):: v3(:, :) ! (klon, llm) |
40 |
! (ozone coefficient from Mobidic on the "physics" grid) |
! regridded field on the partial "physics" grid |
41 |
! ("v3(i, k)" is at longitude "xlon(i)", latitude |
! "v3(i, k)" is at longitude "xlon(i)", latitude "xlat(i)", in |
42 |
! "xlat(i)", in layer "k".) |
! layer "k". |
43 |
|
|
44 |
! Variables local to the procedure: |
! Variables local to the procedure: |
45 |
|
|
46 |
integer varid, ncerr ! for NetCDF |
integer varid ! for NetCDF |
47 |
|
|
48 |
real v1(jjm + 1, size(press_in_edg) - 1) |
real v1(jjm + 1, size(press_in_edg) - 1) |
49 |
! (ozone coefficient from "coefoz_LMDZ.nc" at day "julien") |
! input field at day "julien" |
50 |
! ("v1(j, k)" is at latitude "rlatu(j)" and for |
! "v1(j, k)" is at latitude "rlatu(j)" and for |
51 |
! pressure interval "[press_in_edg(k), press_in_edg(k+1)]".) |
! pressure interval "[press_in_edg(k), press_in_edg(k+1)]". |
52 |
|
|
53 |
real v2(iim + 1, jjm + 1, llm) |
real v2(iim + 1, jjm + 1, llm) |
54 |
! (ozone coefficient on the "dynamics" grid) |
! regridded field on the "dynamics" grid |
55 |
! ("v2(i, j, k)" is at longitude "rlonv(i)", latitude |
! ("v2(i, j, k)" is at longitude "rlonv(i)", latitude |
56 |
! "rlatu(j)" and for pressure interval "[p3d(i, j, k+1), p3d(i, j, k)]".) |
! "rlatu(j)" and for pressure interval "[p3d(i, j, k+1), p3d(i, j, k)]".) |
57 |
|
|
59 |
|
|
60 |
!-------------------------------------------- |
!-------------------------------------------- |
61 |
|
|
62 |
call assert(shape(v3) == (/klon, llm/), "regr_pr_av_coefoz") |
call assert(shape(v3) == (/klon, llm/), "regr_pr_av") |
63 |
|
|
64 |
call nf95_inq_varid(ncid, name, varid) |
call nf95_inq_varid(ncid, name, varid) |
65 |
|
|
66 |
! Get data at the right day from the input file: |
! Get data at the right day from the input file: |
67 |
ncerr = nf90_get_var(ncid, varid, v1, start=(/1, 1, julien/)) |
call nf95_get_var(ncid, varid, v1, start=(/1, 1, julien/)) |
|
call handle_err("regr_pr_av_coefoz nf90_get_var " // name, ncerr, ncid) |
|
68 |
! Latitudes are in ascending order in the input file while |
! Latitudes are in ascending order in the input file while |
69 |
! "rlatu" is in descending order so we need to invert order: |
! "rlatu" is in descending order so we need to invert order: |
70 |
v1 = v1(jjm+1:1:-1, :) |
v1 = v1(jjm+1:1:-1, :) |
83 |
|
|
84 |
forall (k = 1:llm) v3(:, k) = pack(v2(:, :, k), dyn_phy) |
forall (k = 1:llm) v3(:, k) = pack(v2(:, :, k), dyn_phy) |
85 |
|
|
86 |
end subroutine regr_pr_av_coefoz |
end subroutine regr_pr_av |
|
|
|
|
!*************************************************************** |
|
|
|
|
|
subroutine regr_pr_int_coefoz(ncid, name, julien, top_value, v3) |
|
|
|
|
|
! "regr_pr_int_coefoz" stands for "regrid pressure interpolation |
|
|
! coefficient ozone". |
|
|
! The target vertical LMDZ grid is the grid of mid-layers. |
|
|
! The input data does not depend on longitude, but the pressure |
|
|
! at LMDZ mid-layers does. |
|
|
! Therefore, the values on the LMDZ grid do depend on longitude. |
|
|
! Regridding is by linear interpolation. |
|
|
|
|
|
use dimens_m, only: iim, jjm, llm |
|
|
use dimphy, only: klon |
|
|
use netcdf95, only: nf95_inq_varid, handle_err |
|
|
use netcdf, only: nf90_get_var |
|
|
use grid_change, only: dyn_phy |
|
|
use nr_util, only: assert |
|
|
use press_coefoz_m, only: plev |
|
|
use l_util, only: regr1_lint |
|
|
use pressure_var, only: pls |
|
|
|
|
|
integer, intent(in):: ncid ! NetCDF ID of the file |
|
|
character(len=*), intent(in):: name ! of the NetCDF variable |
|
|
integer, intent(in):: julien ! jour julien, 1 <= julien <= 360 |
|
|
|
|
|
real, intent(in):: top_value |
|
|
! (extra value of ozone coefficient at 0 pressure) |
|
|
|
|
|
real, intent(out):: v3(:, :) ! (klon, llm) |
|
|
! (ozone coefficient from Mobidic on the "physics" grid) |
|
|
! ("v3(i, k)" is at longitude "xlon(i)", latitude |
|
|
! "xlat(i)", middle of layer "k".) |
|
|
|
|
|
! Variables local to the procedure: |
|
|
|
|
|
integer varid, ncerr ! for NetCDF |
|
|
|
|
|
real v1(jjm + 1, 0:size(plev)) |
|
|
! (ozone coefficient from "coefoz_LMDZ.nc" at day "julien") |
|
|
! ("v1(j, k >=1)" is at latitude "rlatu(j)" and pressure "plev(k)".) |
|
|
|
|
|
real v2(iim + 1, jjm + 1, llm) |
|
|
! (ozone coefficient on the "dynamics" grid) |
|
|
! "v2(i, j, k)" is at longitude "rlonv(i)", latitude |
|
|
! "rlatu(j)" and pressure "pls(i, j, k)".) |
|
|
|
|
|
integer i, j, k |
|
|
|
|
|
!-------------------------------------------- |
|
|
|
|
|
call assert(shape(v3) == (/klon, llm/), "regr_pr_int_coefoz") |
|
|
|
|
|
call nf95_inq_varid(ncid, name, varid) |
|
|
|
|
|
! Get data at the right day from the input file: |
|
|
ncerr = nf90_get_var(ncid, varid, v1(:, 1:), start=(/1, 1, julien/)) |
|
|
call handle_err("regr_pr_int_coefoz nf90_get_var " // name, ncerr, ncid) |
|
|
! Latitudes are in ascending order in the input file while |
|
|
! "rlatu" is in descending order so we need to invert order: |
|
|
v1(:, 1:) = v1(jjm+1:1:-1, 1:) |
|
|
|
|
|
! Complete "v1" with the value at 0 pressure: |
|
|
v1(:, 0) = top_value |
|
|
|
|
|
! Regrid in pressure at each horizontal position: |
|
|
do j = 1, jjm + 1 |
|
|
do i = 1, iim |
|
|
if (dyn_phy(i, j)) then |
|
|
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 |
|
|
end do |
|
|
|
|
|
forall (k = 1:llm) v3(:, k) = pack(v2(:, :, k), dyn_phy) |
|
|
|
|
|
end subroutine regr_pr_int_coefoz |
|
87 |
|
|
88 |
end module regr_pr_coefoz |
end module regr_pr_av_m |