1 |
module press_coefoz_m |
2 |
|
3 |
implicit none |
4 |
|
5 |
real, pointer, save:: plev(:) |
6 |
! (pressure level of Mobidic input data, converted to Pa, in |
7 |
! ascending order) |
8 |
|
9 |
real, allocatable, save:: press_in_edg(:) |
10 |
! (edges of pressure intervals for Mobidic input data, in Pa, in |
11 |
! ascending order) |
12 |
|
13 |
contains |
14 |
|
15 |
subroutine press_coefoz |
16 |
|
17 |
! This procedure is called once per run. |
18 |
! It reads the pressure levels from "coefoz_LMDZ.nc". |
19 |
! We assume that, in "coefoz_LMDZ.nc", the pressure levels are in hPa |
20 |
! and strictly increasing. |
21 |
|
22 |
use netcdf95, only: nf95_open, nf95_close, nf95_inq_varid, nf95_gw_var |
23 |
use netcdf, only: nf90_nowrite |
24 |
|
25 |
! Variables local to the procedure: |
26 |
integer ncid, varid ! for NetCDF |
27 |
integer n_plev ! number of pressure levels in the input data |
28 |
integer k |
29 |
|
30 |
!--------------------------------------- |
31 |
|
32 |
print *, "Call sequence information: press_coefoz" |
33 |
|
34 |
call nf95_open("coefoz_LMDZ.nc", nf90_nowrite, ncid) |
35 |
|
36 |
call nf95_inq_varid(ncid, "plev", varid) |
37 |
call nf95_gw_var(ncid, varid, plev) |
38 |
! Convert from hPa to Pa because "regr_pr_av" and "regr_pr_int" |
39 |
! require so: |
40 |
plev = plev * 100. |
41 |
n_plev = size(plev) |
42 |
|
43 |
call nf95_close(ncid) |
44 |
|
45 |
! Compute edges of pressure intervals: |
46 |
allocate(press_in_edg(n_plev + 1)) |
47 |
press_in_edg(1) = 0. |
48 |
! We choose edges halfway in logarithm: |
49 |
forall (k = 2:n_plev) press_in_edg(k) = sqrt(plev(k - 1) * plev(k)) |
50 |
press_in_edg(n_plev + 1) = huge(0.) |
51 |
! (infinity, but any value guaranteed to be greater than the |
52 |
! surface pressure would do) |
53 |
|
54 |
end subroutine press_coefoz |
55 |
|
56 |
end module press_coefoz_m |