source: LMDZ4/branches/LMDZ4-dev-20091210/libf/phylmd/regr_pr_int_m.F90 @ 1381

Last change on this file since 1381 was 1263, checked in by lguez, 15 years ago

1) Reactivated ability to read ozone (that was deactivated because of
dependency on version of IOIPSL). Added ability to read a pressure
coordinate in Pa in "regr_lat_time_climoz".

2) Added the ability to read a second ozone climatology, corresponding to
daylight ozone:

-- "read_climoz" is now an integer variable, instead of a logical
variable.

-- Added argument "read_climoz" to "phys_state_var_init",
"phys_output_open" and "regr_lat_time_climoz".

-- Created new variable "ozone_daylight" for "hist*.nc" output files.

-- Added a third dimension to variable "wo" in module
"phys_state_var_mod" and variable "POZON" in "radlwsw": index 1 for
average day-night ozone, index 2 for daylight ozone.

-- Added a fourth dimension to variables "o3_in", "o3_regr_lat" and
"o3_out" in "regr_lat_time_climoz": index 1 for average day-night
ozone, index 2 for daylight ozone.

-- In "physiq", moved call to "conf_phys" before call to
"phys_state_var_init". Thus, "conf_phys" is now inside the block "if
(first)" instead of "IF (debut)". There were definitions of "bl95_b0"
and "bl95_b1" that were useless because the variables were overwritten
by "conf_phys". Removed those definitions.

-- In "radlwsw", we pass the average day-night ozone to "LW_LMDAR4"
and the daylight ozone, if we have it, to "SW_LMDAR4" or
"SW_AEROAR4". If we do not have a specific field for daylight ozone
then "SW_LMDAR4" or "SW_AEROAR4" just get the average day-night ozone.

-- "regr_lat_time_climoz" now manages latitudes where the input ozone
field is missing at all levels (polar night).

-- Encapsulated "radlwsw" in a module.

3) Modifications to make sequential and parallel versions of
"create_etat0_limit" almost identical:

-- In "dyn3dpar/create_etat0_limit.F". No need to call
"phys_state_var_init", removed "use phys_state_var_mod" statement. No
need for "clesphys.h", removed "include" statement.

-- In "dyn3dpar/etat0_netcdf.F". Added argument "tau_ratqs" in call to
"conf_phys" (this bug was already corrected in "dyn3d"). Moved call to
"inifilr" after call to "infotrac_init" (as in "dyn3d").

4) Other peripheral modifications:

-- Added procedures "nf95_get_att" and "nf95_def_var_scalar" in
NetCDF95 interface. Overloaded "nf95_put_var" with three more
procedures: "nf95_put_var_FourByteReal", "nf95_put_var_FourByteInt",
"nf95_put_var_1D_FourByteInt".

-- Overloaded "regr1_step_av" with one more procedure:
"regr14_step_av". Overloaded "regr3_lint" with one more procedure:
"regr34_lint".

-- Corrected call to "Init_Phys_lmdz" in "dyn3d/create_etat0_limit.F":
the last argument should be an array, not a scalar.

-- Encapsulated "conf_phys" in a module.

-- Splitted module "regr_pr" into "regr_pr_av_m" and "regr_pr_int_m".

5) Tests:

This revision was compared to revision 1259, with optimization options
"debug" and "dev", parallelization options "none", "mpi", "omp" and
"mpi_omp", 1 and 2 MPI processes, 1 and 2 OpenMP threads, with the
compiler "FORTRAN90/SX Version 2.0 for SX-8". Both programs
"create_etat0_limit" and "gcm" were tested. In all cases,
parallelization does not change the results. With "read_climoz = 0" in
the ".def" files, the results of revision 1259 and of this revision
are the same.

File size: 3.6 KB
Line 
1! $Id$
2module regr_pr_int_m
3
4  ! Author: Lionel GUEZ
5
6  implicit none
7
8contains
9
10  subroutine regr_pr_int(ncid, name, julien, plev, pplay, top_value, v3)
11
12    ! "regr_pr_int" stands for "regrid pressure interpolation".
13    ! In this procedure:
14    ! -- the root process reads a 2D latitude-pressure field from a
15    !    NetCDF file, at a given day.
16    ! -- the field is packed to the LMDZ horizontal "physics"
17    !    grid and scattered to all threads of all processes;
18    ! -- in all the threads of all the processes, the field is regridded in
19    !    pressure to the LMDZ vertical grid.
20    ! We assume that, in the input file, the field has 3 dimensions:
21    ! latitude, pressure, julian day.
22    ! We assume that latitudes are in ascending order in the input file.
23    ! The target vertical LMDZ grid is the grid of mid-layers.
24    ! Regridding is by linear interpolation.
25
26    use dimphy, only: klon
27    use netcdf95, only: nf95_inq_varid, handle_err
28    use netcdf, only: nf90_get_var
29    use assert_m, only: assert
30    use regr1_lint_m, only: regr1_lint
31    use mod_phys_lmdz_mpi_data, only: is_mpi_root
32
33    use mod_phys_lmdz_transfert_para, only: scatter2d
34    ! (pack to the LMDZ horizontal "physics" grid and scatter)
35
36    integer, intent(in):: ncid ! NetCDF ID of the file
37    character(len=*), intent(in):: name ! of the NetCDF variable
38    integer, intent(in):: julien ! jour julien, 1 <= julien <= 360
39
40    real, intent(in):: plev(:)
41    ! (pressure level of input data, in Pa, in strictly ascending order)
42
43    real, intent(in):: pplay(:, :) ! (klon, llm)
44    ! (pression pour le mileu de chaque couche, en Pa)
45
46    real, intent(in):: top_value
47    ! (extra value of field at 0 pressure)
48
49    real, intent(out):: v3(:, :) ! (klon, llm)
50    ! (regridded field on the partial "physics" grid)
51    ! ("v3(i, k)" is at longitude "xlon(i)", latitude
52    ! "xlat(i)", middle of layer "k".)
53
54    ! Variables local to the procedure:
55
56    include "dimensions.h"
57    integer varid, ncerr ! for NetCDF
58
59    real  v1(iim, jjm + 1, 0:size(plev))
60    ! (input field at day "julien", on the global "dynamics" horizontal grid)
61    ! (First dimension is for longitude.
62    ! The value is the same for all longitudes.
63    ! "v1(:, j, k >=1)" is at latitude "rlatu(j)" and pressure "plev(k)".)
64
65    real v2(klon, 0:size(plev))
66    ! (field scattered to the partial "physics" horizontal grid)
67    ! "v2(i, k >= 1)" is at longitude "xlon(i)", latitude "xlat(i)"
68    ! and pressure "plev(k)".)
69
70    integer i
71
72    !--------------------------------------------
73
74    call assert(shape(v3) == (/klon, llm/), "regr_pr_int v3")
75    call assert(shape(pplay) == (/klon, llm/), "regr_pr_int pplay")
76
77    !$omp master
78    if (is_mpi_root) then
79       call nf95_inq_varid(ncid, name, varid)
80
81       ! Get data at the right day from the input file:
82       ncerr = nf90_get_var(ncid, varid, v1(1, :, 1:), start=(/1, 1, julien/))
83       call handle_err("regr_pr_int nf90_get_var " // name, ncerr, ncid)
84       ! Latitudes are in ascending order in the input file while
85       ! "rlatu" is in descending order so we need to invert order:
86       v1(1, :, 1:) = v1(1, jjm+1:1:-1, 1:)
87
88       ! Complete "v1" with the value at 0 pressure:
89       v1(1, :, 0) = top_value
90
91       ! Duplicate on all longitudes:
92       v1(2:, :, :) = spread(v1(1, :, :), dim=1, ncopies=iim-1)
93    end if
94    !$omp end master
95
96    call scatter2d(v1, v2)
97
98    ! Regrid in pressure at each horizontal position:
99    do i = 1, klon
100       v3(i, llm:1:-1) = regr1_lint(v2(i, :), (/0., plev/), pplay(i, llm:1:-1))
101       ! (invert order of indices because "pplay" is in descending order)
102    end do
103
104  end subroutine regr_pr_int
105
106end module regr_pr_int_m
Note: See TracBrowser for help on using the repository browser.