Ignore:
Timestamp:
Jan 7, 2021 7:15:12 AM (4 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_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
    2832!
     
    742746    INTEGER(iwp) ::  l      !< grid level
    743747    INTEGER(iwp) ::  n      !< loop variable Gauß-Seidel iterations
    744 
    745 
    746     LOGICAL ::  unroll  !< flag indicating whether loop unrolling is possible
     748    INTEGER(iwp) ::  save_nxl_mg  !< to save nxl_mg on coarsest level 1
     749    INTEGER(iwp) ::  save_nys_mg  !< to save nys_mg on coarsest level 1
     750
     751
     752    LOGICAL ::  adjust_lower_i_index  !< adjust lower limit of i loop in case of odd number of grid points
     753    LOGICAL ::  adjust_lower_j_index  !< adjust lower limit of j loop in case of odd number of grid points
     754    LOGICAL ::  unroll                !< flag indicating whether loop unrolling is possible
    747755
    748756    REAL(wp), DIMENSION(nzb:nzt_mg(grid_level)+1,nys_mg(grid_level)-1:nyn_mg(grid_level)+1,        &
     
    751759                        nxl_mg(grid_level)-1:nxr_mg(grid_level)+1) ::  p_mg  !< perturbation pressure
    752760
     761
    753762    l = grid_level
    754763
    755764    unroll = ( MOD( nyn_mg(l)-nys_mg(l)+1, 4 ) == 0  .AND.  MOD( nxr_mg(l)-nxl_mg(l)+1, 2 ) == 0 )
    756765
     766!
     767!-- The red/black decomposition requires that on the lower i,j indices need to start alternatively with an
     768!-- even or odd value on the coarsest grid level, depending on the core-id, and if the subdomain has an
     769!-- uneven number of gridpoints along x/y. Set the respective steering switches here.
     770    IF ( l == 1  .AND.  MOD( myidx, 2 ) /= 0  .AND.  MOD( nxl_mg(l) - nxr_mg(l), 2 ) == 0 )  THEN
     771       adjust_lower_i_index = .TRUE.
     772       save_nxl_mg = nxl_mg(1)
     773    ELSE
     774       adjust_lower_i_index = .FALSE.
     775    ENDIF
     776    IF ( l == 1  .AND.  MOD( myidy, 2 ) /= 0  .AND.  MOD( nyn_mg(l) - nys_mg(l), 2 ) == 0 )  THEN
     777       adjust_lower_j_index = .TRUE.
     778       save_nys_mg = nys_mg(l)
     779    ELSE
     780       adjust_lower_j_index = .FALSE.
     781    ENDIF
     782
     783
    757784    DO  n = 1, ngsrb
    758785
     
    762789
    763790             CALL cpu_log( log_point_s(36), 'redblack_no_unroll_f', 'start' )
     791
     792             IF ( adjust_lower_i_index )  THEN
     793                nxl_mg(l) = save_nxl_mg + 1
     794             ENDIF
     795
     796             IF ( adjust_lower_j_index )  THEN
     797                IF ( color == 1 )  THEN
     798                  nys_mg(l) = save_nys_mg - 1
     799                ELSE
     800                  nys_mg(l) = save_nys_mg + 1
     801                ENDIF
     802             ENDIF
    764803!
    765804!--          Without unrolling of loops, no cache optimization
     
    784823             ENDDO
    785824
     825             IF ( adjust_lower_i_index )  THEN
     826                nxl_mg(l) = save_nxl_mg - 1
     827             ENDIF
     828
     829             IF ( adjust_lower_j_index )  THEN
     830                IF ( color == 1 )  THEN
     831                  nys_mg(l) = save_nys_mg + 1
     832                ELSE
     833                  nys_mg(l) = save_nys_mg - 1
     834                ENDIF
     835             ENDIF
     836
    786837             !$OMP DO
    787838             DO  i = nxl_mg(l)+1, nxr_mg(l), 2
     
    803854             ENDDO
    804855
     856             IF ( adjust_lower_i_index )  THEN
     857                nxl_mg(l) = save_nxl_mg + 1
     858             ENDIF
     859
     860             IF ( adjust_lower_j_index )  THEN
     861                IF ( color == 1 )  THEN
     862                  nys_mg(l) = save_nys_mg + 1
     863                ELSE
     864                  nys_mg(l) = save_nys_mg - 1
     865                ENDIF
     866             ENDIF
     867
    805868             !$OMP DO
    806869             DO  i = nxl_mg(l), nxr_mg(l), 2
     
    821884                ENDDO
    822885             ENDDO
     886
     887             IF ( adjust_lower_i_index )  THEN
     888                nxl_mg(l) = save_nxl_mg - 1
     889             ENDIF
     890
     891             IF ( adjust_lower_j_index )  THEN
     892                IF ( color == 1 )  THEN
     893                  nys_mg(l) = save_nys_mg - 1
     894                ELSE
     895                  nys_mg(l) = save_nys_mg + 1
     896                ENDIF
     897             ENDIF
    823898
    824899             !$OMP DO
     
    10131088    ENDDO
    10141089
     1090!
     1091!-- Reset lower index limits to their standard values (may happen on coarsest levels only)
     1092    IF ( adjust_lower_i_index )  THEN
     1093       nxl_mg(l) = save_nxl_mg
     1094    ENDIF
     1095
     1096    IF ( adjust_lower_j_index )  THEN
     1097       nys_mg(l) = save_nys_mg
     1098    ENDIF
     1099
     1100
    10151101 END SUBROUTINE redblack
    10161102
Note: See TracChangeset for help on using the changeset viewer.