/[lmdze]/trunk/Sources/phylmd/Mobidic/regr_pr_av.f
ViewVC logotype

Diff of /trunk/Sources/phylmd/Mobidic/regr_pr_av.f

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/libf/phylmd/o3_mob_ph_m.f90 revision 3 by guez, Wed Feb 27 13:16:39 2008 UTC trunk/libf/phylmd/Mobidic/regr_pr_coefoz.f90 revision 17 by guez, Tue Aug 5 13:31:32 2008 UTC
# Line 1  Line 1 
1  module o3_Mob_ph_m  module regr_pr_coefoz
2    
3    implicit none    implicit none
4    
5  contains  contains
6    
7    function o3_Mob_ph(ncid, name)    subroutine regr_pr_av_coefoz(ncid, name, julien, v3)
8    
9      ! This function reads a single Mobidic ozone parameter from a file and      ! "regr_pr_av_coefoz" stands for "regrid pressure averaging
10      ! packs it on the "physics" grid.      ! coefficient ozone".
11        ! This procedure reads a single Mobidic ozone coefficient from
12        ! "coefoz_LMDZ.nc", at the current day, regrids this parameter in
13        ! pressure to the LMDZ vertical grid and packs it to the LMDZ
14        ! horizontal "physics" grid.
15        ! Regridding in pressure is done by averaging a step function.
16    
17      use dimens_m, only: iim, jjm, llm      use dimens_m, only: iim, jjm, llm
18      use dimphy, only: klon      use dimphy, only: klon
19      use netcdf95, only: nf95_inq_varid, nf90_get_var, handle_err      use netcdf95, only: nf95_inq_varid, handle_err
20        use netcdf, only: nf90_get_var
21      use grid_change, only: dyn_phy      use grid_change, only: dyn_phy
22        use regr_pr, only: regr_pr_av
23        use numer_rec, only: assert
24        use press_coefoz_m, only: press_in_edg
25    
26      integer, intent(in):: ncid ! NetCDF ID of the file      integer, intent(in):: ncid ! NetCDF ID of the file
27      character(len=*), intent(in):: name ! of the NetCDF variable      character(len=*), intent(in):: name ! of the NetCDF variable
28        integer, intent(in):: julien ! jour julien, 1 <= julien <= 360
29    
30      real o3_Mob_ph(klon, llm, 12)      real, intent(out):: v3(:, :) ! (klon, llm)
31        ! (ozone coefficient from Mobidic on the "physics" grid)
32        ! ("v3(i, k)" is at longitude "xlon(i)", latitude
33        ! "xlat(i)", middle of layer "k".)
34    
35        ! Variables local to the procedure:
36        integer varid, ncerr
37        integer k
38    
39        real  v1(jjm + 1, size(press_in_edg) - 1)
40        ! (ozone coefficient from "coefoz_LMDZ.nc" at day "julien")
41        ! ("v1(j, k)" is at latitude "rlatu(j)" and for
42        ! pressure interval "[press_in_edg(k), press_in_edg(k+1)]".)
43    
44        real v2(iim + 1, jjm + 1, llm)
45        ! (ozone parameter from Mobidic on the "dynamics" grid)
46        ! "v2(i, j, k)" is at longitude "rlonv(i)", latitude
47        ! "rlatu(j)", middle of layer "k".)
48    
49        !--------------------------------------------
50    
51        call assert(shape(v3) == (/klon, llm/), "regr_pr_av_coefoz")
52    
53        call nf95_inq_varid(ncid, name, varid)
54    
55        ! Get data at the right day from the input file:
56        ncerr = nf90_get_var(ncid, varid, v1, start=(/1, 1, julien/))
57        call handle_err("regr_pr_av_coefoz nf90_get_var " // name, ncerr, ncid)
58        ! Latitudes are in increasing order in the input file while
59        ! "rlatu" is in decreasing order so we need to invert order:
60        v1 = v1(jjm+1:1:-1, :)
61    
62        ! Regrid in pressure at each horizontal position:
63        v2 = regr_pr_av(v1, press_in_edg)
64    
65        forall (k = 1:llm) v3(:, k) = pack(v2(:, :, k), dyn_phy)
66    
67      end subroutine regr_pr_av_coefoz
68    
69      !***************************************************************
70    
71      subroutine regr_pr_int_coefoz(ncid, name, julien, top_value, v3)
72    
73        ! This procedure reads a single Mobidic ozone coefficient from
74        !"coefoz_LMDZ.nc", at the current day, regrids this parameter in
75        ! pressure to the LMDZ vertical grid and packs it to the LMDZ
76        ! horizontal "physics" grid.
77        ! Regridding is by linear interpolation.
78    
79        use dimens_m, only: iim, jjm, llm
80        use dimphy, only: klon
81        use netcdf95, only: nf95_inq_varid, handle_err
82        use netcdf, only: nf90_get_var
83        use grid_change, only: dyn_phy
84        use regr_pr, only: regr_pr_int
85        use numer_rec, only: assert
86        use press_coefoz_m, only: plev
87    
88        integer, intent(in):: ncid ! NetCDF ID of the file
89        character(len=*), intent(in):: name ! of the NetCDF variable
90        integer, intent(in):: julien ! jour julien, 1 <= julien <= 360
91    
92        real, intent(in):: top_value
93        ! (extra value of ozone coefficient at 0 pressure)
94    
95        real, intent(out):: v3(:, :) ! (klon, llm)
96      ! (ozone parameter from Mobidic on the "physics" grid)      ! (ozone parameter from Mobidic on the "physics" grid)
97      ! (Third dimension is the number of the month in the year.      ! ("v3(i, k)" is at longitude "xlon(i)", latitude
     ! "o3_Mob_ph(i, k, month)" is at longitude "xlon(i)", latitude  
98      ! "xlat(i)", middle of layer "k".)      ! "xlat(i)", middle of layer "k".)
99    
100      ! Variables local to the procedure:      ! Variables local to the procedure:
101      integer varid, ncerr      integer varid, ncerr
102      integer k, month      integer k
103    
104        real  v1(jjm + 1, 0:size(plev))
105        ! (ozone coefficient from "coefoz_LMDZ.nc" at day "julien")
106        ! ("v1(j, k >=1)" is at latitude "rlatu(j)" and pressure "plev(k)".)
107    
108      real o3_Mob_dyn(iim + 1, jjm + 1, llm, 12)      real v2(iim + 1, jjm + 1, llm)
109      ! (ozone parameter from Mobidic on the "dynamics" grid)      ! (ozone parameter from Mobidic on the "dynamics" grid)
110      ! Fourth dimension is the number of the month in the year.      ! "v2(i, j, k)" is at longitude "rlonv(i)", latitude
     ! "o3_Mob_dyn(i, j, k, month)" is at longitude "rlonv(i)", latitude  
111      ! "rlatu(j)", middle of layer "k".)      ! "rlatu(j)", middle of layer "k".)
112    
113      !--------------------------------------------      !--------------------------------------------
114    
115        call assert(shape(v3) == (/klon, llm/), "regr_pr_int_coefoz")
116    
117      call nf95_inq_varid(ncid, name, varid)      call nf95_inq_varid(ncid, name, varid)
     ncerr = nf90_get_var(ncid, varid, o3_Mob_dyn)  
     call handle_err("o3_Mob_ph nf90_get_var " // name, ncerr, ncid)  
118    
119        ! Get data at the right day from the input file:
120        ncerr = nf90_get_var(ncid, varid, v1(:, 1:), start=(/1, 1, julien/))
121        call handle_err("regr_pr_int_coefoz nf90_get_var " // name, ncerr, ncid)
122      ! Latitudes are in increasing order in the input file while      ! Latitudes are in increasing order in the input file while
123      ! "rlatu" is in decreasing order, so invert:      ! "rlatu" is in decreasing order so we need to invert order:
124      o3_Mob_dyn = o3_Mob_dyn(:, jjm+1:1:-1, :, :)      v1(:, 1:) = v1(jjm+1:1:-1, 1:)
125      forall (k = 1:llm, month = 1:12) &  
126           o3_Mob_ph(:, k, month) = pack(o3_Mob_dyn(:, :, k, month), dyn_phy)      ! Complete "v1" with the value at 0 pressure:
127        v1(:, 0) = top_value
128    
129        ! Regrid in pressure at each horizontal position:
130        v2 = regr_pr_int(v1, (/0., plev/))
131    
132        forall (k = 1:llm) v3(:, k) = pack(v2(:, :, k), dyn_phy)
133    
134    end function o3_Mob_ph    end subroutine regr_pr_int_coefoz
135    
136  end module o3_Mob_ph_m  end module regr_pr_coefoz

Legend:
Removed from v.3  
changed lines
  Added in v.17

  ViewVC Help
Powered by ViewVC 1.1.21