Ignore:
Timestamp:
Jan 7, 2021 7:15:12 AM (3 years ago)
Author:
raasch
Message:

bugfix in redblack algorithm: lower i,j indices need to start alternatively with even or odd value on the coarsest grid level, if the subdomain has an uneven number of gridpoints along x/y; some debug output flushed

File:
1 edited

Legend:

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

    r4828 r4832  
    2525! -----------------
    2626! $Id$
     27! bugfix in redblack algorithm: lower i,j indices need to start alternatively with even or odd
     28! value on the coarsest grid level, if the subdomain has an uneven number of gridpoints along x/y
     29!
     30! 4828 2021-01-05 11:21:41Z Giersch
    2731! File re-formatted to follow the PALM coding standard
    28 !
    2932!
    3033! 4457 2020-03-11 14:20:43Z raasch
     
    801804    IMPLICIT NONE
    802805
    803     INTEGER(iwp) :: color  !<
    804     INTEGER(iwp) :: i      !<
    805     INTEGER(iwp) :: ic     !<
    806     INTEGER(iwp) :: j      !<
    807     INTEGER(iwp) :: jc     !<
    808     INTEGER(iwp) :: jj     !<
    809     INTEGER(iwp) :: k      !<
    810     INTEGER(iwp) :: l      !<
    811     INTEGER(iwp) :: n      !<
    812 
     806    INTEGER(iwp) ::  color  !<
     807    INTEGER(iwp) ::  i      !<
     808    INTEGER(iwp) ::  ic     !<
     809    INTEGER(iwp) ::  j      !<
     810    INTEGER(iwp) ::  jc     !<
     811    INTEGER(iwp) ::  jj     !<
     812    INTEGER(iwp) ::  k      !<
     813    INTEGER(iwp) ::  l      !<
     814    INTEGER(iwp) ::  n      !<
     815    INTEGER(iwp) ::  save_nxl_mg  !< to save nxl_mg on coarsest level 1
     816    INTEGER(iwp) ::  save_nys_mg  !< to save nys_mg on coarsest level 1
     817
     818    LOGICAL ::  adjust_lower_i_index  !< adjust lower limit of i loop in case of odd number of grid points
     819    LOGICAL ::  adjust_lower_j_index  !< adjust lower limit of j loop in case of odd number of grid points
    813820    LOGICAL ::  unroll  !<
    814821
     
    855862               MOD( nxr_mg(l)-nxl_mg(l)+1, 2 ) == 0 )
    856863
     864!
     865!-- The red/black decomposition requires that on the lower i,j indices need to start alternatively with an
     866!-- even or odd value on the coarsest grid level, depending on the core-id, and if the subdomain has an
     867!-- uneven number of gridpoints along x/y. Set the respective steering switches here.
     868    IF ( l == 1  .AND.  MOD( myidx, 2 ) /= 0  .AND.  MOD( nxl_mg(l) - nxr_mg(l), 2 ) == 0 )  THEN
     869       adjust_lower_i_index = .TRUE.
     870       save_nxl_mg = nxl_mg(1)
     871    ELSE
     872       adjust_lower_i_index = .FALSE.
     873    ENDIF
     874    IF ( l == 1  .AND.  MOD( myidy, 2 ) /= 0  .AND.  MOD( nyn_mg(l) - nys_mg(l), 2 ) == 0 )  THEN
     875       adjust_lower_j_index = .TRUE.
     876       save_nys_mg = nys_mg(l)
     877    ELSE
     878       adjust_lower_j_index = .FALSE.
     879    ENDIF
     880
     881
    857882    DO  n = 1, ngsrb
    858883
     
    863888             CALL cpu_log( log_point_s(36), 'redblack_no_unroll_noopt', 'start' )
    864889
     890             IF ( adjust_lower_i_index )  THEN
     891                nxl_mg(l) = save_nxl_mg + 1
     892             ENDIF
     893
     894             IF ( adjust_lower_j_index )  THEN
     895                IF ( color == 1 )  THEN
     896                  nys_mg(l) = save_nys_mg - 1
     897                ELSE
     898                  nys_mg(l) = save_nys_mg + 1
     899                ENDIF
     900             ENDIF
    865901!
    866902!--          Without unrolling of loops, no cache optimization
     
    897933                ENDDO
    898934             ENDDO
     935
     936             IF ( adjust_lower_i_index )  THEN
     937                nxl_mg(l) = save_nxl_mg - 1
     938             ENDIF
     939
     940             IF ( adjust_lower_j_index )  THEN
     941                IF ( color == 1 )  THEN
     942                  nys_mg(l) = save_nys_mg + 1
     943                ELSE
     944                  nys_mg(l) = save_nys_mg - 1
     945                ENDIF
     946             ENDIF
    899947
    900948             DO  i = nxl_mg(l)+1, nxr_mg(l), 2
     
    924972             ENDDO
    925973
     974             IF ( adjust_lower_i_index )  THEN
     975                nxl_mg(l) = save_nxl_mg + 1
     976             ENDIF
     977
     978             IF ( adjust_lower_j_index )  THEN
     979                IF ( color == 1 )  THEN
     980                  nys_mg(l) = save_nys_mg + 1
     981                ELSE
     982                  nys_mg(l) = save_nys_mg - 1
     983                ENDIF
     984             ENDIF
     985
    926986             DO  i = nxl_mg(l), nxr_mg(l), 2
    927987                DO  j = nys_mg(l) + (color-1), nyn_mg(l), 2
     
    9491009                ENDDO
    9501010             ENDDO
     1011
     1012             IF ( adjust_lower_i_index )  THEN
     1013                nxl_mg(l) = save_nxl_mg - 1
     1014             ENDIF
     1015
     1016             IF ( adjust_lower_j_index )  THEN
     1017                IF ( color == 1 )  THEN
     1018                  nys_mg(l) = save_nys_mg - 1
     1019                ELSE
     1020                  nys_mg(l) = save_nys_mg + 1
     1021                ENDIF
     1022             ENDIF
    9511023
    9521024             DO  i = nxl_mg(l)+1, nxr_mg(l), 2
     
    12151287
    12161288!
    1217 !--    Set pressure within topography and at the topography surfaces
     1289!-- Reset lower index limits to their standard values (may happen on coarsest levels only)
     1290    IF ( adjust_lower_i_index )  THEN
     1291       nxl_mg(l) = save_nxl_mg
     1292    ENDIF
     1293
     1294    IF ( adjust_lower_j_index )  THEN
     1295       nys_mg(l) = save_nys_mg
     1296    ENDIF
     1297
     1298!
     1299!-- Set pressure within topography and at the topography surfaces
    12181300!$OMP PARALLEL PRIVATE (i,j,k,wall_left,wall_north,wall_right,wall_south,wall_top,wall_total)
    12191301!$OMP DO
Note: See TracChangeset for help on using the changeset viewer.