Ignore:
Timestamp:
Jul 15, 2010, 5:21:22 PM (14 years ago)
Author:
idelkadi
Message:

Passage a la version cosp.v1.3 pour le Lidar et ISCCP
Corrections de bugs pour ISCCP et optimisation pour le Lidar

File:
1 edited

Legend:

Unmodified
Added
Removed
  • LMDZ4/trunk/libf/cosp/cosp_stats.F90

    r1396 r1414  
    11! (c) British Crown Copyright 2008, the Met Office.
    22! 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
    55! 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
    88!       of conditions and the following disclaimer.
    99!     * 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
    1111!       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
    1414!       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
    2323! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2424
     
    2929! Oct 2008 - J.-L. Dufresne   - Bug fixed. Assignment of Npoints,Nlevels,Nhydro,Ncolumns in COSP_STATS
    3030! Oct 2008 - H. Chepfer       - Added PARASOL reflectance arguments
    31 ! May 2010 - L. Fairhead      - Optimisation of COSP_CHANGE_VERTICAL_GRID routine for NEC SX8 computer
    32 !
    33 ! 
     31! Jun 2010 - T. Yokohata, T. Nishimura and K. Ogochi - Added NEC SXs optimisations
     32!
     33!
    3434MODULE MOD_COSP_STATS
    3535  USE MOD_COSP_CONSTANTS
     
    4545!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    4646SUBROUTINE COSP_STATS(gbx,sgx,cfg,sgradar,sglidar,vgrid,stradar,stlidar)
    47  
     47
    4848   ! Input arguments
    4949   type(cosp_gridbox),intent(in) :: gbx
     
    5555   ! Output arguments
    5656   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
    6060   integer :: Npoints  !# of grid points
    6161   integer :: Nlevels  !# of levels
     
    6666   real,dimension(:,:,:),allocatable :: Ze_out,betatot_out,betamol_in,betamol_out,ph_in,ph_out
    6767   real,dimension(:,:),allocatable :: ph_c,betamol_c
    68  
     68
    6969   Npoints  = gbx%Npoints
    7070   Nlevels  = gbx%Nlevels
     
    7373   Nlr      = vgrid%Nlvgrid
    7474
    75    if (cfg%Lcfad_lidarsr532) ok_lidar_cfad=.true.
     75   if (cfg%Lcfad_Lidarsr532) ok_lidar_cfad=.true.
    7676
    7777   if (vgrid%use_vgrid) then ! Statistics in a different vertical grid
     
    8181        Ze_out = 0.0
    8282        betatot_out  = 0.0
    83         betamol_in(:,1,:) = sglidar%beta_mol(:,:)
    8483        betamol_out= 0.0
    8584        betamol_c  = 0.0
     
    8988        !++++++++++++ Radar CFAD ++++++++++++++++
    9089        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, &
    9291                                           Nlr,vgrid%zl,vgrid%zu,Ze_out,log_units=.true.)
    9392            stradar%cfad_ze = cosp_cfad(Npoints,Ncolumns,Nlr,DBZE_BINS,Ze_out, &
     
    9695        !++++++++++++ Lidar CFAD ++++++++++++++++
    9796        if (cfg%Llidar_sim) then
     97            betamol_in(:,1,:) = sglidar%beta_mol(:,:)
    9898            call cosp_change_vertical_grid(Npoints,1,Nlevels,gbx%zlev,gbx%zlev_half,betamol_in, &
    9999                                           Nlr,vgrid%zl,vgrid%zu,betamol_out)
     
    114114        if (cfg%Lradar_sim.and.cfg%Llidar_sim) call cosp_lidar_only_cloud(Npoints,Ncolumns,Nlr, &
    115115                                    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)
    117117        ! Deallocate arrays at coarse resolution
    118118        deallocate(Ze_out,betatot_out,betamol_in,betamol_out,betamol_c,ph_in,ph_out,ph_c)
     
    131131        if (cfg%Lradar_sim.and.cfg%Llidar_sim) call cosp_lidar_only_cloud(Npoints,Ncolumns,Nlr, &
    132132                                    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)
    134134   endif
    135135   ! 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
    140140
    141141END SUBROUTINE COSP_STATS
     
    162162
    163163   ! Local variables
    164    integer :: i,j,k,c
     164   integer :: i,j,k
    165165   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
    174172
    175173   lunits=.false.
    176174   if (present(log_units)) lunits=log_units
    177175
    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
    185182   ! Check for dBZ and change if necessary
    186183   if (lunits) then
    187184     where (y /= R_UNDEF)
    188         yp = 10.0**(y/10.0)
     185       yp = 10.0**(y/10.0)
     186     elsewhere
     187       yp = 0.0
    189188     end where
    190189   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
    200195         if ((xl(i,j) < zl(k)).and.(xu(i,j) > zl(k)).and.(xu(i,j) <= zu(k))) then
    201196           !xl(j)-----------------xu(j)
    202197           !      zl(k)------------------------------zu(k)
    203            w(i,j,k) = xu(i,j) - zl(k)
     198           w(i,j) = xu(i,j) - zl(k)
    204199         else if ((xl(i,j) >= zl(k)).and.(xu(i,j) <= zu(k))) then
    205200           !           xl(j)-----------------xu(j)
    206201           !      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)
    208203         else if ((xl(i,j) >= zl(k)).and.(xl(i,j) < zu(k)).and.(xu(i,j) >= zu(k))) then
    209204           !                           xl(j)-----------------xu(j)
    210205           !      zl(k)------------------------------zu(k)
    211            w(i,j,k) = zu(k) - xl(i,j)
     206           w(i,j) = zu(k) - xl(i,j)
    212207         else if ((xl(i,j) <= zl(k)).and.(xu(i,j) >= zu(k))) then
    213208           !  xl(j)---------------------------xu(j)
    214209           !        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)
    216229         endif
    217230       enddo
    218231     enddo
    219232   enddo
    220 
    221    ! Do the weighted mean
    222    do k=1,M
    223      do i = 1, Npoints
    224         ws(i,k) = sum(w(i,:,k))
    225      enddo
    226    enddo
    227 
    228    ws_temp = 1.
    229    where (ws(:,:) > 0.0) ws_temp(:,:)=ws(:,:)
    230 
    231    do c=1,Ncolumns
    232      do k=1,M
    233        do i = 1, Npoints
    234           r(i,c,k) = sum(w(i,:,k)*yp(i,c,:))/ws_temp(i,k)
    235        enddo
    236      enddo
    237    enddo
    238 
    239    do k=1,M
    240      do i = 1, Npoints
    241         if (ws(i,k) <= 0.0) r(i,:,k)=0.0
    242      enddo
    243    enddo
    244  
    245233   ! Check for dBZ and change if necessary
    246234   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
    252248   endif
    253    
    254 END SUBROUTINE COSP_CHANGE_VERTICAL_GRID
     249
     250
     251
     252END SUBROUTINE COSP_CHANGE_VERTICAL_GRID
    255253
    256254END MODULE MOD_COSP_STATS
Note: See TracChangeset for help on using the changeset viewer.