Ignore:
Timestamp:
Jan 5, 2021 11:21:41 AM (3 years ago)
Author:
Giersch
Message:

Copyright updated to year 2021, interface pmc_sort removed to accelarate the nesting code

File:
1 edited

Legend:

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

    r4649 r4828  
    1414! <http://www.gnu.org/licenses/>.
    1515!
    16 ! Copyright 1997-2020 Leibniz Universitaet Hannover
     16! Copyright 1997-2021 Leibniz Universitaet Hannover
    1717!--------------------------------------------------------------------------------------------------!
    1818!
     
    2525! -----------------
    2626! $Id$
     27! pmc_s_set_2d_index_list revised for accelerating the code. Subroutine
     28! description added.
     29!
     30! 4649 2020-08-25 12:11:17Z raasch
    2731! File re-formatted to follow the PALM coding standard
    2832!
     
    7074              pmc_g_setname,                                                                       &
    7175              pmc_max_array,                                                                       &
    72               pmc_max_models,                                                                      &
    73               pmc_sort
     76              pmc_max_models
    7477
    7578    USE pmc_handle_communicator,                                                                   &
     
    166169! ------------
    167170!
    168 !> @Todo: Missing subroutine description.
     171!> If this thread is intended as parent, initialize parent part of parent-client data transfer
    169172!--------------------------------------------------------------------------------------------------!
    170173 SUBROUTINE pmc_parentinit
     
    214217! ------------
    215218!
    216 !> @Todo: Missing subroutine description.
     219!> thread 0 transfers the index list, which contains all parent grid cells involved in
     220!> parent client data transfer to the thread, on which this grid cell is located
    217221!--------------------------------------------------------------------------------------------------!
    218222 SUBROUTINE pmc_s_set_2d_index_list( childid, index_list )
     
    220224     IMPLICIT NONE
    221225
     226     INTEGER(iwp), INTENT(IN) ::  childid  !<
     227     INTEGER(iwp), DIMENSION(:,:), INTENT(INOUT) ::  index_list   !<
     228
    222229     INTEGER(iwp) ::  ian    !<
    223      INTEGER(iwp) ::  ie     !<
     230     INTEGER(iwp) ::  i      !<
    224231     INTEGER(iwp) ::  ip     !<
    225      INTEGER(iwp) ::  is     !<
    226232     INTEGER(iwp) ::  istat  !<
    227 
    228      INTEGER(iwp), INTENT(IN) ::  childid  !<
    229 
    230      INTEGER(iwp), DIMENSION(:,:), INTENT(INOUT) ::  index_list  !<
     233     INTEGER(iwp) ::  max_cells  !<
     234
     235     INTEGER(iwp), DIMENSION(:), ALLOCATABLE     ::  cells_on_pe  !<
     236     INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE   ::  lo_ind_list  !<
    231237
    232238
    233239     IF ( m_model_rank == 0 )  THEN
    234240!
    235 !--     Sort to ascending parent process order
    236         CALL pmc_sort( index_list, 6 )
    237         is = 1
     241!--     Compute maximum number of grid cells located on one parent thread
     242
     243        ALLOCATE(cells_on_pe(0:m_model_npes-1))
     244        cells_on_pe = 0
     245
     246        DO i=1,SIZE( index_list, 2 )
     247           cells_on_pe(index_list(6,i )) = cells_on_pe(index_list(6,i ))+1
     248        END DO
     249
     250        max_cells = MAXVAL(cells_on_pe)
     251!
     252!--     Allocate temp array for thread dependent transfer of index_list
     253
     254        ALLOCATE(lo_ind_list(SIZE(index_list,1),max_cells))
     255
    238256        DO  ip = 0, m_model_npes-1
    239257!
    240258!--        Split into parent processes
    241            ie = is - 1
    242 !
    243 !--        There may be no entry for this process
    244            IF ( is <= SIZE( index_list, 2 )  .AND.  ie >= 0 )  THEN
    245               DO WHILE ( index_list(6,ie+1 ) == ip )
    246                  ie = ie + 1
    247                  IF ( ie == SIZE( index_list, 2 ) )  EXIT
    248               ENDDO
    249               ian = ie - is + 1
    250            ELSE
    251               is  = -1
    252               ie  = -2
    253               ian =  0
    254            ENDIF
     259
     260           ian = 0
     261
     262           DO i=1,SIZE( index_list, 2 )
     263              IF(index_list(6,i ) == ip )   THEN
     264                 ian = ian+1
     265                 lo_ind_list(:,ian) = index_list(:,i)
     266              END IF
     267           END DO
    255268!
    256269!--        Send data to other parent processes
     
    262275              ALLOCATE( indchildren(childid)%index_list_2d(6,1:ian) )
    263276              IF ( ian > 0)  THEN
    264                   indchildren(childid)%index_list_2d(:,1:ian) = index_list(:,is:ie)
     277                  indchildren(childid)%index_list_2d(:,1:ian) = lo_ind_list(:,1:ian)
    265278              ENDIF
    266279           ELSE
    267280              CALL MPI_SEND( ian, 1, MPI_INTEGER, ip, 1000, m_model_comm, istat )
    268281              IF ( ian > 0)  THEN
    269                   CALL MPI_SEND( index_list(1,is), 6*ian, MPI_INTEGER, ip, 1001, m_model_comm,     &
    270                                  istat )
     282                  CALL MPI_SEND( lo_ind_list, 6*ian, MPI_INTEGER, ip, 1001, m_model_comm, istat )
    271283              ENDIF
    272284           ENDIF
    273            is = ie + 1
    274285        ENDDO
     286
     287        DEALLOCATE(lo_ind_list)
     288        DEALLOCATE(cells_on_pe)
    275289     ELSE
    276290        CALL MPI_RECV( indchildren(childid)%nrpoints, 1, MPI_INTEGER, 0, 1000, m_model_comm,       &
     
    296310! ------------
    297311!
    298 !> @Todo: Missing subroutine description.
    299 !--------------------------------------------------------------------------------------------------!
     312!> Before creating an array list with arrays schedule for parent client transfer
     313!> make sure that the list is empty
     314!--------------------------------------------------------------------------------------------------!
     315
    300316 SUBROUTINE pmc_s_clear_next_array_list
    301317
     
    306322
    307323 END SUBROUTINE pmc_s_clear_next_array_list
    308 
    309324
    310325
     
    348363! ------------
    349364!
    350 !> @Todo: Missing subroutine description.
     365!> add 2D real array to list of arrays scheduled for parent-client transfer
    351366!--------------------------------------------------------------------------------------------------!
    352367 SUBROUTINE pmc_s_set_dataarray_2d( childid, array, array_2 )
     
    388403! ------------
    389404!
    390 !> @Todo: Missing subroutine description.
     405!> add 2D integer array to list of arrays scheduled for parent-client transfer
    391406!--------------------------------------------------------------------------------------------------!
    392407 SUBROUTINE pmc_s_set_dataarray_ip2d( childid, array )
     
    420435! ------------
    421436!
    422 !> @Todo: Missing subroutine description.
     437!> add 3D real array to list of arrays scheduled for parent-client transfer
    423438!--------------------------------------------------------------------------------------------------!
    424439 SUBROUTINE pmc_s_set_dataarray_3d( childid, array, nz_cl, nz, array_2 )
     
    645660! ------------
    646661!
    647 !> @Todo: Missing subroutine description.
     662!> Fill buffer in RMA window to enable the client to fetch the dat with MPI_Get
    648663!--------------------------------------------------------------------------------------------------!
    649664 SUBROUTINE pmc_s_fillbuffer( childid, waittime, particle_transfer )
     
    747762! ------------
    748763!
    749 !> @Todo: Missing subroutine description.
     764!> Get client data from RMM window
    750765!--------------------------------------------------------------------------------------------------!
    751766 SUBROUTINE pmc_s_getdata_from_buffer( childid, waittime , particle_transfer, child_process_nr )
     
    896911! ------------
    897912!
    898 !> @Todo: Missing subroutine description.
     913!> broadcast name of transfer arrays from child thread 0 to parent threads
    899914!--------------------------------------------------------------------------------------------------!
    900915 SUBROUTINE get_da_names_from_child( childid )
Note: See TracChangeset for help on using the changeset viewer.