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_tripleclouds_lw.F90

    r4853 r4946  
    170170    logical :: is_clear_sky_layer(0:nlev+1)
    171171
    172     ! Temporaries to speed up summations
    173     real(jprb) :: sum_dn, sum_up
    174    
    175172    ! Index of the highest cloudy layer
    176173    integer :: i_cloud_top
     
    264261      if (config%do_clear) then
    265262        ! Sum over g-points to compute broadband fluxes
    266         do jlev = 1,nlev+1
    267           sum_up = 0.0_jprb
    268           sum_dn = 0.0_jprb
    269           !$omp simd reduction(+:sum_up, sum_dn)
    270           do jg = 1,ng
    271             sum_up = sum_up + flux_up_clear(jg,jlev)
    272             sum_dn = sum_dn + flux_dn_clear(jg,jlev)
    273           end do
    274           flux%lw_up_clear(jcol,jlev) = sum_up
    275           flux%lw_dn_clear(jcol,jlev) = sum_dn
    276         end do
    277 
     263        flux%lw_up_clear(jcol,:) = sum(flux_up_clear,1)
     264        flux%lw_dn_clear(jcol,:) = sum(flux_dn_clear,1)
    278265        ! Store surface spectral downwelling fluxes / TOA upwelling
    279         do jg = 1,ng
    280           flux%lw_dn_surf_clear_g(jg,jcol) = flux_dn_clear(jg,nlev+1)
    281           flux%lw_up_toa_clear_g (jg,jcol) = flux_up_clear(jg,1)
    282         end do
     266        flux%lw_dn_surf_clear_g(:,jcol) = flux_dn_clear(:,nlev+1)
     267        flux%lw_up_toa_clear_g (:,jcol) = flux_up_clear(:,1)
    283268        ! Save the spectral fluxes if required
    284269        if (config%do_save_spectral_flux) then
     
    468453          end if
    469454        else
    470           sum_dn = 0.0_jprb
    471           !$omp simd reduction(+:sum_dn)
    472           do jg = 1,ng
    473             sum_dn = sum_dn + flux_dn_clear(jg,jlev)
    474           end do
    475           flux%lw_dn(jcol,jlev) = sum_dn
     455          flux%lw_dn(jcol,:) = sum(flux_dn_clear(:,jlev))
    476456          if (config%do_save_spectral_flux) then
    477457            call indexed_sum(flux_dn_clear(:,jlev), &
     
    490470           &  + total_albedo(:,1,i_cloud_top)*flux_dn_clear(:,i_cloud_top)
    491471      flux_up(:,2:) = 0.0_jprb
    492 
    493       sum_up = 0.0_jprb
    494       !$omp simd reduction(+:sum_up)
    495       do jg = 1,ng
    496         sum_up = sum_up + flux_up(jg,1)
    497       end do
    498       flux%lw_up(jcol,i_cloud_top) = sum_up
    499 
     472      flux%lw_up(jcol,i_cloud_top) = sum(flux_up(:,1))
    500473      if (config%do_save_spectral_flux) then
    501474        call indexed_sum(flux_up(:,1), &
     
    505478      do jlev = i_cloud_top-1,1,-1
    506479        flux_up(:,1) = trans_clear(:,jlev)*flux_up(:,1) + source_up_clear(:,jlev)
    507         sum_up = 0.0_jprb
    508         !$omp simd reduction(+:sum_up)
    509         do jg = 1,ng
    510           sum_up = sum_up + flux_up(jg,1)
    511         end do
    512         flux%lw_up(jcol,jlev) = sum_up
     480        flux%lw_up(jcol,jlev) = sum(flux_up(:,1))
    513481        if (config%do_save_spectral_flux) then
    514482          call indexed_sum(flux_up(:,1), &
     
    560528
    561529        ! Store the broadband fluxes
    562         sum_up = 0.0_jprb
    563         sum_dn = 0.0_jprb
    564         do jreg = 1,nregions
    565           !$omp simd reduction(+:sum_up, sum_dn)
    566           do jg = 1,ng
    567             sum_up = sum_up + flux_up(jg,jreg)
    568             sum_dn = sum_dn + flux_dn(jg,jreg)
    569           end do
    570         end do
    571         flux%lw_up(jcol,jlev+1) = sum_up
    572         flux%lw_dn(jcol,jlev+1) = sum_dn
     530        flux%lw_up(jcol,jlev+1) = sum(sum(flux_up,1))
     531        flux%lw_dn(jcol,jlev+1) = sum(sum(flux_dn,1))
    573532
    574533        ! Save the spectral fluxes if required
Note: See TracChangeset for help on using the changeset viewer.