/[lmdze]/trunk/phylmd/Mobidic/regr_pr_o3.f
ViewVC logotype

Annotation of /trunk/phylmd/Mobidic/regr_pr_o3.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 97 - (hide annotations)
Fri Apr 25 14:58:31 2014 UTC (10 years ago) by guez
File size: 4528 byte(s)
Module pressure_var is now only used in gcm. Created local variables
pls and p3d in etat0, added argument p3d to regr_pr_o3.

In leapfrog, moved computation of p3d and exner function immediately
after integrd, for clarity (does not change the execution).

Removed unused arguments: ntra, tra1 and tra of cv3_compress; ntra,
tra and traent of cv3_mixing; ntra, ftra, ftra1 of cv3_uncompress;
ntra, tra, trap of cv3_unsat; ntra, tra, trap, traent, ftra of
cv3_yield; tra, tvp, pbase, bbase, dtvpdt1, dtvpdq1, dplcldt,
dplcldr, ntra of concvl; ndp1, ntra, tra1 of cv_driver

Removed argument d_tra and computation of d_tra in concvl. Removed
argument ftra1 and computation of ftra1 in cv_driver. ftra1 was just
set to 0 in cv_driver, associated to d_tra in concvl, and set again to
zero in concvl.

1 guez 8 module regr_pr_o3_m
2    
3     implicit none
4    
5     contains
6    
7 guez 97 subroutine regr_pr_o3(p3d, o3_mob_regr)
8 guez 8
9     ! "regr_pr_o3" stands for "regrid pressure ozone".
10     ! This procedure reads Mobidic ozone mole fraction from
11     ! "coefoz_LMDZ.nc" at the initial day and regrids it in pressure.
12 guez 19 ! Ozone mole fraction from "coefoz_LMDZ.nc" is a 2D latitude --
13     ! pressure variable.
14     ! The target horizontal LMDZ grid is the "scalar" grid: "rlonv", "rlatu".
15     ! The target vertical LMDZ grid is the grid of layer boundaries.
16     ! We assume that the input variable is already on the LMDZ "rlatu"
17     ! latitude grid.
18     ! The input variable does not depend on longitude, but the
19     ! pressure at LMDZ layers does.
20     ! Therefore, the values on the LMDZ grid do depend on longitude.
21 guez 8 ! Regridding is by averaging, assuming a step function.
22 guez 19 ! We assume that, in the input file, the pressure levels are in
23     ! hPa and strictly increasing.
24 guez 8
25     use conf_gcm_m, only: dayref
26     use dimens_m, only: iim, jjm, llm
27     use netcdf95, only: nf95_open, nf95_close, nf95_inq_varid, handle_err, &
28 guez 22 nf95_gw_var
29 guez 8 use netcdf, only: nf90_nowrite, nf90_get_var
30 guez 36 use nr_util, only: assert
31 guez 19 use grid_change, only: dyn_phy
32 guez 61 use numer_rec_95, only: regr1_step_av
33 guez 8
34 guez 97 REAL, intent(in):: p3d(:, :, :) ! (iim + 1, jjm + 1, llm+1)
35     ! pressure at layer interfaces, in Pa
36     ! ("p3d(i, j, l)" is at longitude "rlonv(i)", latitude "rlatu(j)",
37     ! for interface "l")
38    
39 guez 8 real, intent(out):: o3_mob_regr(:, :, :) ! (iim + 1, jjm + 1, llm)
40     ! (ozone mole fraction from Mobidic adapted to the LMDZ grid)
41     ! ("o3_mob_regr(i, j, l)" is at longitude "rlonv(i)", latitude
42     ! "rlatu(j)" and pressure level "pls(i, j, l)")
43    
44     ! Variables local to the procedure:
45    
46     real, pointer:: plev(:)
47     ! (pressure levels of Mobidic data, in Pa, in strictly increasing order)
48    
49     real, allocatable:: press_in_edg(:)
50     ! (edges of pressure intervals for Mobidic data, in Pa, in strictly
51     ! increasing order)
52    
53     integer ncid, varid, ncerr ! for NetCDF
54     integer n_plev ! number of pressure levels in Mobidic data
55 guez 19 integer i, j
56 guez 8
57     real, allocatable:: r_mob(:, :)! (jjm + 1, n_plev)
58     ! (ozone mole fraction from Mobidic at day "dayref")
59     ! (r_mob(j, k) is at latitude "rlatu(j)" and pressure level "plev(k)".)
60    
61     !------------------------------------------------------------
62    
63 guez 10 print *, "Call sequence information: regr_pr_o3"
64 guez 8
65 guez 97 call assert(shape(o3_mob_regr) == (/iim + 1, jjm + 1, llm/), &
66     "regr_pr_o3 o3_mob_regr")
67     call assert(shape(p3d) == (/iim + 1, jjm + 1, llm + 1/), &
68     "regr_pr_o3 p3d")
69    
70 guez 8 call nf95_open("coefoz_LMDZ.nc", nf90_nowrite, ncid)
71    
72 guez 22 call nf95_inq_varid(ncid, "plev", varid)
73     call nf95_gw_var(ncid, varid, plev)
74 guez 8 ! Convert from hPa to Pa because "regr_pr_av" requires so:
75     plev = plev * 100.
76     n_plev = size(plev)
77    
78     ! Compute edges of pressure intervals:
79     allocate(press_in_edg(n_plev + 1))
80     press_in_edg(1) = 0.
81     ! We choose edges halfway in logarithm:
82     forall (j = 2:n_plev) press_in_edg(j) = sqrt(plev(j - 1) * plev(j))
83     press_in_edg(n_plev + 1) = huge(0.)
84     ! (infinity, but any value guaranteed to be greater than the
85     ! surface pressure would do)
86    
87     deallocate(plev) ! pointer
88    
89     call nf95_inq_varid(ncid, "r_Mob", varid)
90     allocate(r_mob(jjm + 1, n_plev))
91    
92     ! Get data at the right day from the input file:
93     ncerr = nf90_get_var(ncid, varid, r_mob, start=(/1, 1, dayref/))
94     call handle_err("nf90_get_var r_Mob", ncerr)
95     ! Latitudes are in increasing order in the input file while
96     ! "rlatu" is in decreasing order so we need to invert order:
97     r_mob = r_mob(jjm+1:1:-1, :)
98    
99     call nf95_close(ncid)
100    
101 guez 20 ! Regrid in pressure by averaging a step function of pressure:
102 guez 19 do j = 1, jjm + 1
103     do i = 1, iim
104     if (dyn_phy(i, j)) then
105     o3_mob_regr(i, j, llm:1:-1) &
106     = regr1_step_av(r_mob(j, :), press_in_edg, &
107     p3d(i, j, llm+1:1:-1))
108     ! (invert order of indices because "p3d" is decreasing)
109     end if
110     end do
111     end do
112 guez 8
113 guez 19 ! Duplicate pole values on all longitudes:
114     o3_mob_regr(2:, 1, :) = spread(o3_mob_regr(1, 1, :), dim=1, ncopies=iim)
115     o3_mob_regr(2:, jjm + 1, :) &
116     = spread(o3_mob_regr(1, jjm + 1, :), dim=1, ncopies=iim)
117    
118     ! Duplicate first longitude to last longitude:
119     o3_mob_regr(iim + 1, 2:jjm, :) = o3_mob_regr(1, 2:jjm, :)
120    
121 guez 8 end subroutine regr_pr_o3
122    
123     end module regr_pr_o3_m

  ViewVC Help
Powered by ViewVC 1.1.21