1 |
module regr_lat_time_coefoz_m |
module regr_lat_time_coefoz_m |
2 |
|
|
|
! This module is clean: no C preprocessor directive, no include line. |
|
3 |
! Author: Lionel GUEZ |
! Author: Lionel GUEZ |
4 |
|
|
5 |
implicit none |
implicit none |
36 |
! -- time increases from January to December (even though we do |
! -- time increases from January to December (even though we do |
37 |
! not use values of the input time coordinate). |
! not use values of the input time coordinate). |
38 |
|
|
39 |
use dimens_m, only: jjm |
use dimensions, only: jjm |
40 |
use comgeom, only: rlatv |
use dynetat0_m, only: rlatv |
41 |
use nr_util, only: pi |
use nr_util, only: pi |
42 |
use l_util, only: regr1_step_av, regr3_lint |
use numer_rec_95, only: regr3_lint, regr1_conserv, slopes |
43 |
use netcdf95, only: nf95_open, nf95_gw_var, nf95_close, & |
use netcdf95, only: nf95_open, nf95_gw_var, nf95_close, & |
44 |
nf95_inq_varid, handle_err, nf95_put_var |
nf95_inq_varid, handle_err, nf95_put_var |
45 |
use netcdf, only: nf90_nowrite, nf90_get_var |
use netcdf, only: nf90_nowrite, nf90_get_var |
50 |
integer n_plev ! number of pressure levels in the input data |
integer n_plev ! number of pressure levels in the input data |
51 |
integer n_lat! number of latitudes in the input data |
integer n_lat! number of latitudes in the input data |
52 |
|
|
53 |
real, pointer:: latitude(:) |
real, allocatable:: latitude(:) |
54 |
! (of input data, converted to rad, sorted in strictly increasing order) |
! (of input data, converted to rad, sorted in strictly increasing order) |
55 |
|
|
56 |
real, allocatable:: lat_in_edg(:) |
real, allocatable:: lat_in_edg(:) |
57 |
! (edges of latitude intervals for input data, in rad, in strictly |
! (edges of latitude intervals for input data, in rad, in strictly |
58 |
! increasing order) |
! increasing order) |
59 |
|
|
60 |
real, pointer:: plev(:) ! pressure level of input data |
real, allocatable:: plev(:) ! pressure level of input data |
61 |
logical decr_lat ! decreasing latitude in the input file |
logical decr_lat ! decreasing latitude in the input file |
62 |
|
|
63 |
real, allocatable:: o3_par_in(:, :, :) ! (n_lat, n_plev, 12) |
real, allocatable:: o3_par_in(:, :, :) ! (n_lat, n_plev, 12) |
167 |
lat_in_edg(1) = - pi / 2 |
lat_in_edg(1) = - pi / 2 |
168 |
forall (j = 2:n_lat) lat_in_edg(j) = (latitude(j - 1) + latitude(j)) / 2 |
forall (j = 2:n_lat) lat_in_edg(j) = (latitude(j - 1) + latitude(j)) / 2 |
169 |
lat_in_edg(n_lat + 1) = pi / 2 |
lat_in_edg(n_lat + 1) = pi / 2 |
|
deallocate(latitude) ! pointer |
|
170 |
|
|
171 |
call nf95_inq_varid(ncid_in, "plev", varid) |
call nf95_inq_varid(ncid_in, "plev", varid) |
172 |
call nf95_gw_var(ncid_in, varid, plev) |
call nf95_gw_var(ncid_in, varid, plev) |
186 |
call nf95_put_var(ncid_out, varid_time, tmidday) |
call nf95_put_var(ncid_out, varid_time, tmidday) |
187 |
call nf95_put_var(ncid_out, varid_plev, plev) |
call nf95_put_var(ncid_out, varid_plev, plev) |
188 |
|
|
|
deallocate(plev) ! pointer |
|
|
|
|
189 |
allocate(o3_par_in(n_lat, n_plev, 12)) |
allocate(o3_par_in(n_lat, n_plev, 12)) |
190 |
allocate(v_regr_lat(jjm + 1, n_plev, 0:13)) |
allocate(v_regr_lat(jjm + 1, n_plev, 0:13)) |
191 |
allocate(o3_par_out(jjm + 1, n_plev, 360)) |
allocate(o3_par_out(jjm + 1, n_plev, 360)) |
201 |
! Regrid in latitude: |
! Regrid in latitude: |
202 |
! We average with respect to sine of latitude, which is |
! We average with respect to sine of latitude, which is |
203 |
! equivalent to weighting by cosine of latitude: |
! equivalent to weighting by cosine of latitude: |
204 |
v_regr_lat(jjm+1:1:-1, :, 1:12) = regr1_step_av(o3_par_in, & |
call regr1_conserv(o3_par_in, & |
205 |
xs=sin(lat_in_edg), xt=sin((/- pi / 2, rlatv(jjm:1:-1), pi / 2/))) |
xs = sin(lat_in_edg), xt = (/- 1., sin(rlatv(jjm:1:-1)), 1./), & |
206 |
|
slope = slopes(o3_par_in, sin(lat_in_edg)), & |
207 |
|
vt = v_regr_lat(jjm + 1:1:- 1, :, 1:12)) |
208 |
! (invert order of indices in "v_regr_lat" because "rlatu" is |
! (invert order of indices in "v_regr_lat" because "rlatu" is |
209 |
! decreasing) |
! decreasing) |
210 |
|
|
235 |
! This subroutine creates the NetCDF output file, defines |
! This subroutine creates the NetCDF output file, defines |
236 |
! dimensions and variables, and writes one of the coordinate variables. |
! dimensions and variables, and writes one of the coordinate variables. |
237 |
|
|
238 |
use dimens_m, only: jjm |
use dimensions, only: jjm |
239 |
use comgeom, only: rlatu |
use dynetat0_m, only: rlatu |
240 |
use nr_util, only: assert_eq, pi |
use netcdf, only: nf90_clobber, nf90_float, nf90_copy_att, nf90_global |
|
|
|
241 |
use netcdf95, only: nf95_create, nf95_def_dim, nf95_def_var, & |
use netcdf95, only: nf95_create, nf95_def_dim, nf95_def_var, & |
242 |
nf95_put_att, nf95_enddef, nf95_copy_att, nf95_put_var |
nf95_put_att, nf95_enddef, nf95_copy_att, nf95_put_var |
243 |
use netcdf, only: nf90_clobber, nf90_float, nf90_copy_att, nf90_global |
use nr_util, only: assert_eq, pi |
244 |
|
|
245 |
integer, intent(in):: ncid_in, varid_in(:), n_plev |
integer, intent(in):: ncid_in, varid_in(:), n_plev |
246 |
character(len=*), intent(in):: name_out(:) ! of NetCDF variables |
character(len=*), intent(in):: name_out(:) ! of NetCDF variables |