Changeset 4832 for palm/trunk/SOURCE/poismg_mod.f90
- Timestamp:
- Jan 7, 2021 7:15:12 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SOURCE/poismg_mod.f90
r4828 r4832 25 25 ! ----------------- 26 26 ! $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 27 31 ! File re-formatted to follow the PALM coding standard 28 32 ! … … 742 746 INTEGER(iwp) :: l !< grid level 743 747 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 747 755 748 756 REAL(wp), DIMENSION(nzb:nzt_mg(grid_level)+1,nys_mg(grid_level)-1:nyn_mg(grid_level)+1, & … … 751 759 nxl_mg(grid_level)-1:nxr_mg(grid_level)+1) :: p_mg !< perturbation pressure 752 760 761 753 762 l = grid_level 754 763 755 764 unroll = ( MOD( nyn_mg(l)-nys_mg(l)+1, 4 ) == 0 .AND. MOD( nxr_mg(l)-nxl_mg(l)+1, 2 ) == 0 ) 756 765 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 757 784 DO n = 1, ngsrb 758 785 … … 762 789 763 790 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 764 803 ! 765 804 !-- Without unrolling of loops, no cache optimization … … 784 823 ENDDO 785 824 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 786 837 !$OMP DO 787 838 DO i = nxl_mg(l)+1, nxr_mg(l), 2 … … 803 854 ENDDO 804 855 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 805 868 !$OMP DO 806 869 DO i = nxl_mg(l), nxr_mg(l), 2 … … 821 884 ENDDO 822 885 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 823 898 824 899 !$OMP DO … … 1013 1088 ENDDO 1014 1089 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 1015 1101 END SUBROUTINE redblack 1016 1102
Note: See TracChangeset
for help on using the changeset viewer.