Changeset 1414 for LMDZ4/trunk/libf/cosp/cosp_stats.F90
- Timestamp:
- Jul 15, 2010, 5:21:22 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
LMDZ4/trunk/libf/cosp/cosp_stats.F90
r1396 r1414 1 1 ! (c) British Crown Copyright 2008, the Met Office. 2 2 ! All rights reserved. 3 ! 4 ! Redistribution and use in source and binary forms, with or without modification, are permitted 3 ! 4 ! Redistribution and use in source and binary forms, with or without modification, are permitted 5 5 ! provided that the following conditions are met: 6 ! 7 ! * Redistributions of source code must retain the above copyright notice, this list 6 ! 7 ! * Redistributions of source code must retain the above copyright notice, this list 8 8 ! of conditions and the following disclaimer. 9 9 ! * Redistributions in binary form must reproduce the above copyright notice, this list 10 ! of conditions and the following disclaimer in the documentation and/or other materials 10 ! of conditions and the following disclaimer in the documentation and/or other materials 11 11 ! provided with the distribution. 12 ! * Neither the name of the Met Office nor the names of its contributors may be used 13 ! to endorse or promote products derived from this software without specific prior written 12 ! * Neither the name of the Met Office nor the names of its contributors may be used 13 ! to endorse or promote products derived from this software without specific prior written 14 14 ! permission. 15 ! 16 ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 17 ! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 ! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 19 ! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 ! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 ! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 22 ! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 15 ! 16 ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 17 ! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 ! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 19 ! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 ! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 ! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 22 ! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 23 23 ! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 … … 29 29 ! Oct 2008 - J.-L. Dufresne - Bug fixed. Assignment of Npoints,Nlevels,Nhydro,Ncolumns in COSP_STATS 30 30 ! Oct 2008 - H. Chepfer - Added PARASOL reflectance arguments 31 ! May 2010 - L. Fairhead - Optimisation of COSP_CHANGE_VERTICAL_GRID routine for NEC SX8 computer32 ! 33 ! 31 ! Jun 2010 - T. Yokohata, T. Nishimura and K. Ogochi - Added NEC SXs optimisations 32 ! 33 ! 34 34 MODULE MOD_COSP_STATS 35 35 USE MOD_COSP_CONSTANTS … … 45 45 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 46 46 SUBROUTINE COSP_STATS(gbx,sgx,cfg,sgradar,sglidar,vgrid,stradar,stlidar) 47 47 48 48 ! Input arguments 49 49 type(cosp_gridbox),intent(in) :: gbx … … 55 55 ! Output arguments 56 56 type(cosp_radarstats),intent(inout) :: stradar ! Summary statistics for radar 57 type(cosp_lidarstats),intent(inout) :: stlidar ! Summary statistics for lidar 58 59 ! Local variables 57 type(cosp_lidarstats),intent(inout) :: stlidar ! Summary statistics for lidar 58 59 ! Local variables 60 60 integer :: Npoints !# of grid points 61 61 integer :: Nlevels !# of levels … … 66 66 real,dimension(:,:,:),allocatable :: Ze_out,betatot_out,betamol_in,betamol_out,ph_in,ph_out 67 67 real,dimension(:,:),allocatable :: ph_c,betamol_c 68 68 69 69 Npoints = gbx%Npoints 70 70 Nlevels = gbx%Nlevels … … 73 73 Nlr = vgrid%Nlvgrid 74 74 75 if (cfg%Lcfad_ lidarsr532) ok_lidar_cfad=.true.75 if (cfg%Lcfad_Lidarsr532) ok_lidar_cfad=.true. 76 76 77 77 if (vgrid%use_vgrid) then ! Statistics in a different vertical grid … … 81 81 Ze_out = 0.0 82 82 betatot_out = 0.0 83 betamol_in(:,1,:) = sglidar%beta_mol(:,:)84 83 betamol_out= 0.0 85 84 betamol_c = 0.0 … … 89 88 !++++++++++++ Radar CFAD ++++++++++++++++ 90 89 if (cfg%Lradar_sim) then 91 call cosp_change_vertical_grid(Npoints,Ncolumns,Nlevels,gbx%zlev,gbx%zlev_half,sgradar%Ze_tot, &90 call cosp_change_vertical_grid(Npoints,Ncolumns,Nlevels,gbx%zlev,gbx%zlev_half,sgradar%Ze_tot, & 92 91 Nlr,vgrid%zl,vgrid%zu,Ze_out,log_units=.true.) 93 92 stradar%cfad_ze = cosp_cfad(Npoints,Ncolumns,Nlr,DBZE_BINS,Ze_out, & … … 96 95 !++++++++++++ Lidar CFAD ++++++++++++++++ 97 96 if (cfg%Llidar_sim) then 97 betamol_in(:,1,:) = sglidar%beta_mol(:,:) 98 98 call cosp_change_vertical_grid(Npoints,1,Nlevels,gbx%zlev,gbx%zlev_half,betamol_in, & 99 99 Nlr,vgrid%zl,vgrid%zu,betamol_out) … … 114 114 if (cfg%Lradar_sim.and.cfg%Llidar_sim) call cosp_lidar_only_cloud(Npoints,Ncolumns,Nlr, & 115 115 betatot_out,betamol_c,Ze_out, & 116 stradar%lidar_only_freq_cloud,stradar%radar_lidar_tcc) 116 stradar%lidar_only_freq_cloud,stradar%radar_lidar_tcc) 117 117 ! Deallocate arrays at coarse resolution 118 118 deallocate(Ze_out,betatot_out,betamol_in,betamol_out,betamol_c,ph_in,ph_out,ph_c) … … 131 131 if (cfg%Lradar_sim.and.cfg%Llidar_sim) call cosp_lidar_only_cloud(Npoints,Ncolumns,Nlr, & 132 132 sglidar%beta_tot,sglidar%beta_mol,sgradar%Ze_tot, & 133 stradar%lidar_only_freq_cloud,stradar%radar_lidar_tcc) 133 stradar%lidar_only_freq_cloud,stradar%radar_lidar_tcc) 134 134 endif 135 135 ! Replace undef 136 where (stlidar%cfad_sr == LIDAR_UNDEF) stlidar%cfad_sr = R_UNDEF 137 where (stlidar%lidarcld == LIDAR_UNDEF) stlidar%lidarcld = R_UNDEF 138 where (stlidar%cldlayer == LIDAR_UNDEF) stlidar%cldlayer = R_UNDEF 139 where (stlidar%parasolrefl == LIDAR_UNDEF) stlidar%parasolrefl = R_UNDEF 136 where (stlidar%cfad_sr == LIDAR_UNDEF) stlidar%cfad_sr = R_UNDEF 137 where (stlidar%lidarcld == LIDAR_UNDEF) stlidar%lidarcld = R_UNDEF 138 where (stlidar%cldlayer == LIDAR_UNDEF) stlidar%cldlayer = R_UNDEF 139 where (stlidar%parasolrefl == LIDAR_UNDEF) stlidar%parasolrefl = R_UNDEF 140 140 141 141 END SUBROUTINE COSP_STATS … … 162 162 163 163 ! Local variables 164 integer :: i,j,k ,c164 integer :: i,j,k 165 165 logical :: lunits 166 real :: ws(Npoints,M), ws_temp(Npoints,M) 167 real,dimension(Npoints,Nlevels) :: xl, xu ! Lower and upper boundaries of model grid 168 real,dimension(M) :: dz ! Layer depth 169 real,dimension(Npoints,Nlevels,M) :: w ! Weights to do the mean at each point 170 real,dimension(Npoints,Ncolumns,Nlevels) :: yp ! Variable to be changed to a different grid. 171 ! Local copy at a particular point. 172 ! This allows for change of units. 173 166 167 integer :: l 168 real,dimension(Npoints) :: ws,sumwyp 169 real,dimension(Npoints,Nlevels) :: xl,xu 170 real,dimension(Npoints,Nlevels) :: w 171 real,dimension(Npoints,Ncolumns,Nlevels) :: yp 174 172 175 173 lunits=.false. 176 174 if (present(log_units)) lunits=log_units 177 175 178 r(:,:,:) = 0.0 179 yp(:,:,:) = y(:,:,:) 180 w(:,:,:) = 0.0 181 ws(:,:) = 0.0 182 ws_temp(:,:) = 0.0 183 dz = zu - zl 184 176 r(:,:,:) = R_GROUND 177 ! Vertical grid at that point 178 xl(:,:) = zhalf(:,:) 179 xu(:,1:Nlevels-1) = xl(:,2:Nlevels) 180 xu(:,Nlevels) = zfull(:,Nlevels) + zfull(:,Nlevels) - zhalf(:,Nlevels) ! Top level symmetric 181 yp(:,:,:) = y(:,:,:) ! Temporary variable to regrid 185 182 ! Check for dBZ and change if necessary 186 183 if (lunits) then 187 184 where (y /= R_UNDEF) 188 yp = 10.0**(y/10.0) 185 yp = 10.0**(y/10.0) 186 elsewhere 187 yp = 0.0 189 188 end where 190 189 endif 191 192 ! Vertical grids 193 xl(:,:) = zhalf(:,:) 194 xu(:,1:Nlevels-1) = zhalf(:,2:Nlevels) 195 xu(:,Nlevels) = zfull(:,Nlevels) + zfull(:,Nlevels) - zhalf(:,Nlevels) ! Top level symmetric 196 ! Find weights 197 do k=1, M 198 do j=1, Nlevels 199 do i=1, Npoints 190 do k=1,M 191 ! Find weights 192 w(:,:) = 0.0 193 do j=1,Nlevels 194 do i=1,Npoints 200 195 if ((xl(i,j) < zl(k)).and.(xu(i,j) > zl(k)).and.(xu(i,j) <= zu(k))) then 201 196 !xl(j)-----------------xu(j) 202 197 ! zl(k)------------------------------zu(k) 203 w(i,j ,k) = xu(i,j) - zl(k)198 w(i,j) = xu(i,j) - zl(k) 204 199 else if ((xl(i,j) >= zl(k)).and.(xu(i,j) <= zu(k))) then 205 200 ! xl(j)-----------------xu(j) 206 201 ! zl(k)------------------------------zu(k) 207 w(i,j ,k) = xl(i,j+1) - xl(i,j)202 w(i,j) = xu(i,j) - xl(i,j) 208 203 else if ((xl(i,j) >= zl(k)).and.(xl(i,j) < zu(k)).and.(xu(i,j) >= zu(k))) then 209 204 ! xl(j)-----------------xu(j) 210 205 ! zl(k)------------------------------zu(k) 211 w(i,j ,k) = zu(k) - xl(i,j)206 w(i,j) = zu(k) - xl(i,j) 212 207 else if ((xl(i,j) <= zl(k)).and.(xu(i,j) >= zu(k))) then 213 208 ! xl(j)---------------------------xu(j) 214 209 ! zl(k)--------------zu(k) 215 w(i,j,k) = dz(j) 210 w(i,j) = zu(k) - zl(k) 211 endif 212 enddo 213 enddo 214 ! Do the weighted mean 215 do j=1,Ncolumns 216 ws (:) = 0.0 217 sumwyp(:) = 0.0 218 do l=1,Nlevels 219 do i=1,Npoints 220 if (zu(k) > zhalf(i,1)) then ! Level above model bottom level 221 ws (i) = ws (i) + w(i,l) 222 sumwyp(i) = sumwyp(i) + w(i,l)*yp(i,j,l) 223 endif 224 enddo 225 enddo 226 do i=1,Npoints 227 if (zu(k) > zhalf(i,1)) then ! Level above model bottom level 228 if (ws(i) > 0.0) r(i,j,k) = sumwyp(i)/ws(i) 216 229 endif 217 230 enddo 218 231 enddo 219 232 enddo 220 221 ! Do the weighted mean222 do k=1,M223 do i = 1, Npoints224 ws(i,k) = sum(w(i,:,k))225 enddo226 enddo227 228 ws_temp = 1.229 where (ws(:,:) > 0.0) ws_temp(:,:)=ws(:,:)230 231 do c=1,Ncolumns232 do k=1,M233 do i = 1, Npoints234 r(i,c,k) = sum(w(i,:,k)*yp(i,c,:))/ws_temp(i,k)235 enddo236 enddo237 enddo238 239 do k=1,M240 do i = 1, Npoints241 if (ws(i,k) <= 0.0) r(i,:,k)=0.0242 enddo243 enddo244 245 233 ! Check for dBZ and change if necessary 246 234 if (lunits) then 247 where (r(:,:,:) <= 0.0) 248 r(:,:,:) = R_UNDEF 249 elsewhere 250 r(:,:,:) = 10.0*log10(r(:,:,:)) 251 end where 235 do k=1,M 236 do j=1,Ncolumns 237 do i=1,Npoints 238 if (zu(k) > zhalf(i,1)) then ! Level above model bottom level 239 if (r(i,j,k) <= 0.0) then 240 r(i,j,k) = R_UNDEF 241 else 242 r(i,j,k) = 10.0*log10(r(i,j,k)) 243 endif 244 endif 245 enddo 246 enddo 247 enddo 252 248 endif 253 254 END SUBROUTINE COSP_CHANGE_VERTICAL_GRID 249 250 251 252 END SUBROUTINE COSP_CHANGE_VERTICAL_GRID 255 253 256 254 END MODULE MOD_COSP_STATS
Note: See TracChangeset
for help on using the changeset viewer.