Ignore:
Timestamp:
May 18, 2024, 8:07:34 PM (2 weeks ago)
Author:
idelkadi
Message:

The addition of explicit loops with the "omp simd reduction" directive to solve the slowness problem linked to the "sum" command (svn4938 revesion) led to non-reproducibility in MPI and mixed MPI-OMP modes in the case of Tripleclouds and Mcica solvers.
We return to the svn4848 versions of the radiation_tripleclouds_*w.F90 and radiation_mcica_*w.F90 routines.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/trunk/libf/phylmd/ecrad/radiation/radiation_mcica_lw.F90

    r4853 r4946  
    1818!   2017-07-12  R. Hogan  Call fast adding method if only clouds scatter
    1919!   2017-10-23  R. Hogan  Renamed single-character variables
    20 
    21 #include "ecrad_config.h"
    2220
    2321module radiation_mcica_lw
     
    126124    ! Identify clear-sky layers
    127125    logical :: is_clear_sky_layer(nlev)
    128 
    129     ! Temporary storage for more efficient summation
    130 #ifdef DWD_REDUCTION_OPTIMIZATIONS
    131     real(jprb), dimension(nlev+1,2) :: sum_aux
    132 #else
    133     real(jprb) :: sum_up, sum_dn
    134 #endif
    135126
    136127    ! Index of the highest cloudy layer
     
    188179
    189180      ! Sum over g-points to compute broadband fluxes
    190 #ifdef DWD_REDUCTION_OPTIMIZATIONS
    191       sum_aux(:,:) = 0.0_jprb
    192       do jg = 1,ng
    193         do jlev = 1,nlev+1
    194           sum_aux(jlev,1) = sum_aux(jlev,1) + flux_up_clear(jg,jlev)
    195           sum_aux(jlev,2) = sum_aux(jlev,2) + flux_dn_clear(jg,jlev)
    196         end do
    197       end do
    198       flux%lw_up_clear(jcol,:) = sum_aux(:,1)
    199       flux%lw_dn_clear(jcol,:) = sum_aux(:,2)
    200 #else
    201       do jlev = 1,nlev+1
    202         sum_up = 0.0_jprb
    203         sum_dn = 0.0_jprb
    204         !$omp simd reduction(+:sum_up, sum_dn)
    205         do jg = 1,ng
    206           sum_up = sum_up + flux_up_clear(jg,jlev)
    207           sum_dn = sum_dn + flux_dn_clear(jg,jlev)
    208         end do
    209         flux%lw_up_clear(jcol,jlev) = sum_up
    210         flux%lw_dn_clear(jcol,jlev) = sum_dn
    211       end do
    212 #endif
    213 
     181      flux%lw_up_clear(jcol,:) = sum(flux_up_clear,1)
     182      flux%lw_dn_clear(jcol,:) = sum(flux_dn_clear,1)
    214183      ! Store surface spectral downwelling fluxes
    215184      flux%lw_dn_surf_clear_g(:,jcol) = flux_dn_clear(:,nlev+1)
     
    310279          else
    311280            ! Clear-sky layer: copy over clear-sky values
    312             do jg = 1,ng
    313               reflectance(jg,jlev) = ref_clear(jg,jlev)
    314               transmittance(jg,jlev) = trans_clear(jg,jlev)
    315               source_up(jg,jlev) = source_up_clear(jg,jlev)
    316               source_dn(jg,jlev) = source_dn_clear(jg,jlev)
    317             end do
     281            reflectance(:,jlev) = ref_clear(:,jlev)
     282            transmittance(:,jlev) = trans_clear(:,jlev)
     283            source_up(:,jlev) = source_up_clear(:,jlev)
     284            source_dn(:,jlev) = source_dn_clear(:,jlev)
    318285          end if
    319286        end do
     
    340307       
    341308        ! Store overcast broadband fluxes
    342 #ifdef DWD_REDUCTION_OPTIMIZATIONS
    343         sum_aux(:,:) = 0._jprb
    344         do jg = 1, ng
    345           do jlev = 1, nlev+1
    346             sum_aux(jlev,1) = sum_aux(jlev,1) + flux_up(jg,jlev)
    347             sum_aux(jlev,2) = sum_aux(jlev,2) + flux_dn(jg,jlev)
    348           end do
    349         end do
    350         flux%lw_up(jcol,:) = sum_aux(:,1)
    351         flux%lw_dn(jcol,:) = sum_aux(:,2)
    352 #else
    353         do jlev = 1,nlev+1
    354           sum_up = 0.0_jprb
    355           sum_dn = 0.0_jprb
    356           !$omp simd reduction(+:sum_up, sum_dn)
    357           do jg = 1,ng
    358             sum_up = sum_up + flux_up(jg,jlev)
    359             sum_dn = sum_dn + flux_dn(jg,jlev)
    360           end do
    361           flux%lw_up(jcol,jlev) = sum_up
    362           flux%lw_dn(jcol,jlev) = sum_dn
    363         end do
    364 #endif
     309        flux%lw_up(jcol,:) = sum(flux_up,1)
     310        flux%lw_dn(jcol,:) = sum(flux_dn,1)
    365311
    366312        ! Cloudy flux profiles currently assume completely overcast
    367313        ! skies; perform weighted average with clear-sky profile
    368         do jlev = 1,nlev+1
    369           flux%lw_up(jcol,jlev) =  total_cloud_cover *flux%lw_up(jcol,jlev) &
    370              &       + (1.0_jprb - total_cloud_cover)*flux%lw_up_clear(jcol,jlev)
    371           flux%lw_dn(jcol,jlev) =  total_cloud_cover *flux%lw_dn(jcol,jlev) &
    372              &       + (1.0_jprb - total_cloud_cover)*flux%lw_dn_clear(jcol,jlev)
    373         end do
     314        flux%lw_up(jcol,:) =  total_cloud_cover *flux%lw_up(jcol,:) &
     315             &  + (1.0_jprb - total_cloud_cover)*flux%lw_up_clear(jcol,:)
     316        flux%lw_dn(jcol,:) =  total_cloud_cover *flux%lw_dn(jcol,:) &
     317             &  + (1.0_jprb - total_cloud_cover)*flux%lw_dn_clear(jcol,:)
    374318        ! Store surface spectral downwelling fluxes
    375319        flux%lw_dn_surf_g(:,jcol) = total_cloud_cover*flux_dn(:,nlev+1) &
     
    391335        ! No cloud in profile and clear-sky fluxes already
    392336        ! calculated: copy them over
    393         do jlev = 1,nlev+1
    394           flux%lw_up(jcol,jlev) = flux%lw_up_clear(jcol,jlev)
    395           flux%lw_dn(jcol,jlev) = flux%lw_dn_clear(jcol,jlev)
    396         end do
     337        flux%lw_up(jcol,:) = flux%lw_up_clear(jcol,:)
     338        flux%lw_dn(jcol,:) = flux%lw_dn_clear(jcol,:)
    397339        flux%lw_dn_surf_g(:,jcol) = flux%lw_dn_surf_clear_g(:,jcol)
    398340        if (config%do_lw_derivatives) then
Note: See TracChangeset for help on using the changeset viewer.