Changeset 4233


Ignore:
Timestamp:
Sep 20, 2019 9:55:54 AM (5 years ago)
Author:
knoop
Message:

OpenACC support added to global_min_max.f90

Location:
palm/trunk/SOURCE
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/global_min_max.f90

    r4182 r4233  
    2525! -----------------
    2626! $Id$
     27! OpenACC support added
     28!
     29! 4182 2019-08-22 15:20:23Z scharf
    2730! Corrected "Former revisions" section
    2831!
     
    8992    REAL(wp) ::  fmin_l(2)  !<
    9093#endif
     94#if defined( _OPENACC )
     95    REAL(wp)     ::  red        !< scalar for reduction with OpenACC
     96    INTEGER(iwp) ::  count_eq   !< counter for locations of maximum
     97#endif
    9198    REAL(wp), OPTIONAL ::  value1  !<
    9299
     
    177184!-- Determine absolute array maximum
    178185    IF ( mode == 'abs' )  THEN
     186
     187#if defined( _OPENACC )
     188       red = 0.0_wp
     189       !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) &
     190       !$ACC PRESENT(ar) COPY(red) REDUCTION(MAX: red)
     191       DO  k = k1, k2
     192          DO  j = j1, j2
     193             DO  i = i1, i2
     194                IF ( ABS( ar(i,j,k) ) > red )  THEN
     195                   red = ABS( ar(i,j,k) )
     196                ENDIF
     197             ENDDO
     198          ENDDO
     199       ENDDO
     200       fmax_l(1) = red
     201
     202!
     203!--    Determine the maximum's position and count how often it is found.
     204       count_eq = 0
     205       !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) &
     206       !$ACC PRESENT(ar) COPY(fmax_ijk_l(1:3), count_eq) &
     207       !$ACC REDUCTION(+:count_eq)
     208       DO  k = k1, k2
     209          DO  j = j1, j2
     210             DO  i = i1, i2
     211                IF ( ABS( ar(i,j,k) ) == red )  THEN
     212                   fmax_ijk_l(1) = i
     213                   fmax_ijk_l(2) = j
     214                   fmax_ijk_l(3) = k
     215                   count_eq = count_eq + 1
     216                ENDIF
     217             ENDDO
     218          ENDDO
     219       ENDDO
     220
     221       IF ( count_eq == 1 ) THEN
     222!
     223!--       We found a single maximum element and correctly got its position. Transfer its
     224!--       value to handle the negative case correctly.
     225          !$ACC UPDATE HOST(ar(fmax_ijk_l(1):fmax_ijk_l(1),fmax_ijk_l(2),fmax_ijk_l(3)))
     226       ELSE
     227!
     228!--       We found no maximum element (?) or multiple, so the position is not correct.
     229!--       Copy the full array to the host and determine the maximum sequentially...
     230          !$ACC UPDATE HOST(ar(i1:i2,j1:j2,k1:k2))
     231#endif
    179232
    180233!
     
    197250       ENDDO
    198251
     252#if defined( _OPENACC )
     253!
     254!--       Close ELSE case from above
     255       ENDIF
     256#endif
     257
    199258!
    200259!--    Set a flag in case that the determined value is negative.
  • palm/trunk/SOURCE/timestep.f90

    r4182 r4233  
    2525! -----------------
    2626! $Id$
     27! OpenACC data update host removed
     28!
     29! 4182 2019-08-22 15:20:23Z scharf
    2730! Corrected "Former revisions" section
    2831!
     
    119122    CALL cpu_log( log_point(12), 'calculate_timestep', 'start' )
    120123
    121     !$ACC UPDATE &
    122     !$ACC HOST(u(nzb:nzt+1,nysg:nyng,nxlg:nxrg)) &
    123     !$ACC HOST(v(nzb:nzt+1,nysg:nyng,nxlg:nxrg)) &
    124     !$ACC HOST(w(nzb:nzt+1,nysg:nyng,nxlg:nxrg)) &
    125     !$ACC HOST(kh(nzb:nzt+1,nysg:nyng,nxlg:nxrg)) &
    126     !$ACC HOST(km(nzb:nzt+1,nysg:nyng,nxlg:nxrg))
    127 
    128124!
    129125!-- In case of Galilei-transform not using the geostrophic wind as translation
Note: See TracChangeset for help on using the changeset viewer.