Changeset 4830
- Timestamp:
- Jan 6, 2021 11:25:45 AM (4 years ago)
- Location:
- palm/trunk/SOURCE
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SOURCE/pmc_general_mod.f90
r4828 r4830 1 MODULE pmc_general 2 1 !> @file pmc_general_mod.f90 3 2 !--------------------------------------------------------------------------------------------------! 4 3 ! This file is part of the PALM model system. … … 18 17 !--------------------------------------------------------------------------------------------------! 19 18 ! 20 !21 19 ! Current revisions: 22 20 ! ----------------- … … 26 24 ! ----------------- 27 25 ! $Id$ 26 ! Reformatted to follow PALM coding standard 27 ! 28 ! 4828 2021-01-05 11:21:41Z Giersch 28 29 ! Interface pmc_sort removed. Subroutine description added. 29 30 ! … … 48 49 ! Initial revision by K. Ketelsen 49 50 ! 51 ! Authors: 52 ! -------- 53 !> @author Klaus Ketelsen (no affiliation) 54 ! 50 55 ! Description: 51 56 ! ------------ 52 ! 53 ! Structure definition and utilities of Palm Model Coupler 57 !> Structure definition and utilities of Palm Model Coupler 54 58 !--------------------------------------------------------------------------------------------------! 59 MODULE pmc_general 55 60 56 61 #if defined( __parallel ) … … 61 66 USE MPI 62 67 68 63 69 IMPLICIT NONE 64 70 65 66 PRIVATE 67 SAVE 68 69 INTEGER(iwp), PARAMETER, PUBLIC :: da_desclen = 8 !< 70 INTEGER(iwp), PARAMETER, PUBLIC :: da_namelen = 16 !< 71 INTEGER(iwp), PARAMETER, PUBLIC :: pmc_da_name_err = 10 !< 72 INTEGER(iwp), PARAMETER, PUBLIC :: pmc_max_models = 64 !< 73 INTEGER(iwp), PARAMETER, PUBLIC :: pmc_status_ok = 0 !< 74 INTEGER(iwp), PARAMETER, PUBLIC :: pmc_status_error = -1 !< 75 76 INTEGER(iwp), PUBLIC :: pmc_max_array !< max # of arrays which can be coupled 77 !< - will be determined dynamically in pmc_interface 78 79 80 TYPE, PUBLIC :: xy_ind !< pair of indices in horizontal plane 81 INTEGER(iwp) :: i 82 INTEGER(iwp) :: j 71 INTEGER(iwp) :: pmc_max_array !< max # of arrays which can be coupled 72 !< - will be determined dynamically in pmc_interface 73 74 INTEGER(iwp), PARAMETER :: da_desclen = 8 !< 75 INTEGER(iwp), PARAMETER :: da_namelen = 16 !< 76 INTEGER(iwp), PARAMETER :: pmc_da_name_err = 10 !< 77 INTEGER(iwp), PARAMETER :: pmc_max_models = 64 !< 78 INTEGER(iwp), PARAMETER :: pmc_status_ok = 0 !< 79 INTEGER(iwp), PARAMETER :: pmc_status_error = -1 !< 80 81 TYPE :: xy_ind !< pair of indices in horizontal plane 82 INTEGER(iwp) :: i !< 83 INTEGER(iwp) :: j !< 83 84 END TYPE 84 85 85 TYPE , PUBLIC:: arraydef86 TYPE :: arraydef 86 87 CHARACTER(LEN=da_namelen) :: Name !< name of array 87 88 … … 91 92 INTEGER(iwp) :: RecvSize !< size in receive buffer 92 93 INTEGER(iwp) :: SendSize !< size in send buffer 93 94 INTEGER(idp) :: RecvIndex !< index in receive buffer 95 INTEGER(idp) :: SendIndex !< index in send buffer 94 INTEGER(idp) :: RecvIndex !< index in receive buffer 95 INTEGER(idp) :: SendIndex !< index in send buffer 96 96 97 97 INTEGER(iwp), DIMENSION(4) :: a_dim !< size of dimensions … … 107 107 END TYPE arraydef 108 108 109 110 TYPE(arraydef), PUBLIC, POINTER :: next !< 111 112 113 TYPE, PUBLIC :: pedef 114 INTEGER(iwp) :: nr_arrays = 0 !< number of arrays which will be transfered 115 INTEGER(iwp) :: nrele !< number of elements, same for all arrays 109 TYPE :: pedef 110 INTEGER(iwp) :: nr_arrays = 0 !< number of arrays which will be transfered 111 INTEGER(iwp) :: nrele !< number of elements, same for all arrays 116 112 117 113 TYPE(arraydef), POINTER, DIMENSION(:) :: array_list !< list of data arrays to be transfered 118 TYPE(xy_ind), POINTER, DIMENSION(:) :: locInd !< xy index local array for remote PE 114 115 TYPE(xy_ind), POINTER, DIMENSION(:) :: locInd !< xy index local array for remote PE 119 116 END TYPE pedef 120 117 121 122 TYPE, PUBLIC :: childdef123 INTEGER(iwp) :: inter_ comm !< inter communicator model and child124 INTEGER(iwp) :: int er_npes !< number of PEs child model125 INTEGER(iwp) :: intra_ comm !< intra communicator model and child126 INTEGER(iwp) :: intra_rank !< rank within intra_comm127 INTEGER(iwp) :: model_ comm !< communicator ofthis model128 INTEGER(iwp) :: model_ npes !< number of PEsthis model129 INTEGER(i wp) :: model_rank !< rank of this model130 INTEGER(i dp) :: totalbuffersize !<131 INTEGER(iwp) :: win_parent_child !< MPI RMA for preparing data on parent AND child side 118 TYPE :: childdef 119 INTEGER(iwp) :: inter_comm !< inter communicator model and child 120 INTEGER(iwp) :: inter_npes !< number of PEs child model 121 INTEGER(iwp) :: intra_comm !< intra communicator model and child 122 INTEGER(iwp) :: intra_rank !< rank within intra_comm 123 INTEGER(iwp) :: model_comm !< communicator of this model 124 INTEGER(iwp) :: model_npes !< number of PEs this model 125 INTEGER(iwp) :: model_rank !< rank of this model 126 INTEGER(idp) :: totalbuffersize !< 127 INTEGER(iwp) :: win_parent_child !< MPI RMA for preparing data on parent AND child side 128 132 129 TYPE(pedef), DIMENSION(:), POINTER :: pes !< list of all child PEs 133 130 END TYPE childdef 134 131 135 136 TYPE, PUBLIC :: da_namedef !< data array name definition 132 TYPE :: da_namedef !< data array name definition 137 133 CHARACTER(LEN=da_desclen) :: childdesc !< child array description 138 134 CHARACTER(LEN=da_namelen) :: nameonchild !< name of array within child 139 135 CHARACTER(LEN=da_namelen) :: nameonparent !< name of array within parent 140 136 CHARACTER(LEN=da_desclen) :: parentdesc !< parent array description 141 INTEGER(iwp) :: couple_index !< unique number of array 137 138 INTEGER(iwp) :: couple_index !< unique number of array 142 139 END TYPE da_namedef 140 141 TYPE(arraydef), POINTER :: next !< 142 143 SAVE 144 145 PRIVATE 146 147 ! 148 !-- Public functions 149 PUBLIC pmc_g_setname 150 151 ! 152 !-- Public variables, constants and types 153 PUBLIC arraydef, & 154 childdef, & 155 da_desclen, & 156 da_namedef, & 157 da_namelen, & 158 next, & 159 pedef, & 160 pmc_da_name_err, & 161 pmc_max_array, & 162 pmc_max_models, & 163 pmc_status_error, & 164 pmc_status_ok, & 165 xy_ind 143 166 144 167 INTERFACE pmc_g_setname … … 146 169 END INTERFACE pmc_g_setname 147 170 148 PUBLIC pmc_g_setname149 171 150 172 CONTAINS 173 151 174 152 175 !---------------------------------------------------------------------------------------------------! … … 157 180 SUBROUTINE pmc_g_setname( mychild, couple_index, aname ) 158 181 159 IMPLICIT NONE 160 161 CHARACTER(LEN=*) :: aname !< 162 163 INTEGER(iwp), INTENT(IN) :: couple_index !< 182 CHARACTER(LEN=*), INTENT(IN) :: aname !< 164 183 165 184 INTEGER(iwp) :: i !< 166 185 167 TYPE(childdef), INTENT(INOUT) :: mychild !< 168 169 TYPE(pedef), POINTER :: ape !< 186 INTEGER(iwp), INTENT(IN) :: couple_index !< 187 188 TYPE(childdef), INTENT(INOUT) :: mychild !< 189 190 TYPE(pedef), POINTER :: ape !< 191 170 192 171 193 ! … … 180 202 181 203 END SUBROUTINE pmc_g_setname 182 183 204 #endif 205 206 184 207 END MODULE pmc_general -
palm/trunk/SOURCE/pmc_parent_mod.f90
r4828 r4830 1 MODULE pmc_parent 1 !> @file pmc_parent_mod.f90 2 2 !--------------------------------------------------------------------------------------------------! 3 3 ! This file is part of the PALM model system. … … 25 25 ! ----------------- 26 26 ! $Id$ 27 ! pmc_s_set_2d_index_list revised for accelerating the code. Subroutine 27 ! Reformatted to follow PALM coding standard 28 ! 29 ! 4828 2021-01-05 11:21:41Z Giersch 30 ! pmc_s_set_2d_index_list revised for accelerating the code. Subroutine 28 31 ! description added. 29 32 ! … … 54 57 ! Initial revision by K. Ketelsen 55 58 ! 56 !--------------------------------------------------------------------------------------------------! 59 ! Authors: 60 ! -------- 61 !> @author Klaus Ketelsen (no affiliation) 62 ! 57 63 ! Description: 58 64 ! ------------ 59 65 !> Parent part of Palm Model Coupler 60 66 !--------------------------------------------------------------------------------------------------! 67 MODULE pmc_parent 61 68 62 69 #if defined( __parallel ) … … 66 73 67 74 USE kinds 75 68 76 USE pmc_general, & 69 77 ONLY: arraydef, & … … 89 97 pmc_time 90 98 91 IMPLICIT NONE 92 93 94 PRIVATE 95 SAVE 96 97 INTEGER :: next_array_in_list = 0 !< 98 99 TYPE childindexdef 100 INTEGER :: nrpoints !< 101 INTEGER, DIMENSION(:,:), ALLOCATABLE :: index_list_2d !< 102 END TYPE childindexdef 103 104 TYPE(childdef), DIMENSION(pmc_max_models),PUBLIC :: children !< 105 TYPE(childindexdef), DIMENSION(pmc_max_models) :: indchildren !< 106 107 108 PUBLIC pmc_parent_for_child 109 110 111 INTERFACE pmc_parentinit 112 MODULE PROCEDURE pmc_parentinit 113 END INTERFACE pmc_parentinit 114 115 INTERFACE pmc_s_set_2d_index_list 116 MODULE PROCEDURE pmc_s_set_2d_index_list 117 END INTERFACE pmc_s_set_2d_index_list 118 119 INTERFACE pmc_s_clear_next_array_list 120 MODULE PROCEDURE pmc_s_clear_next_array_list 121 END INTERFACE pmc_s_clear_next_array_list 122 123 INTERFACE pmc_s_getnextarray 124 MODULE PROCEDURE pmc_s_getnextarray 125 END INTERFACE pmc_s_getnextarray 126 127 INTERFACE pmc_s_set_dataarray 128 MODULE PROCEDURE pmc_s_set_dataarray_2d 129 MODULE PROCEDURE pmc_s_set_dataarray_3d 130 MODULE PROCEDURE pmc_s_set_dataarray_ip2d 131 END INTERFACE pmc_s_set_dataarray 132 133 INTERFACE pmc_s_setind_and_allocmem 134 MODULE PROCEDURE pmc_s_setind_and_allocmem 135 END INTERFACE pmc_s_setind_and_allocmem 136 137 INTERFACE pmc_s_fillbuffer 138 MODULE PROCEDURE pmc_s_fillbuffer 139 END INTERFACE pmc_s_fillbuffer 140 141 INTERFACE pmc_s_getdata_from_buffer 142 MODULE PROCEDURE pmc_s_getdata_from_buffer 143 END INTERFACE pmc_s_getdata_from_buffer 144 145 INTERFACE pmc_s_set_active_data_array 146 MODULE PROCEDURE pmc_s_set_active_data_array 147 END INTERFACE pmc_s_set_active_data_array 148 149 INTERFACE pmc_s_get_child_npes 150 MODULE PROCEDURE pmc_s_get_child_npes 151 END INTERFACE pmc_s_get_child_npes 152 153 PUBLIC pmc_parentinit, & 99 100 IMPLICIT NONE 101 102 INTEGER :: next_array_in_list = 0 !< 103 104 TYPE childindexdef 105 INTEGER :: nrpoints !< 106 107 INTEGER, DIMENSION(:,:), ALLOCATABLE :: index_list_2d !< 108 END TYPE childindexdef 109 110 TYPE(childdef), DIMENSION(pmc_max_models) :: children !< 111 112 TYPE(childindexdef), DIMENSION(pmc_max_models) :: indchildren !< 113 114 SAVE 115 116 PRIVATE 117 118 ! 119 !-- Public functions 120 PUBLIC pmc_parent_for_child 121 122 ! 123 !-- Public variables, constants and types 124 PUBLIC children, & 125 pmc_parentinit, & 154 126 pmc_s_clear_next_array_list, & 155 127 pmc_s_fillbuffer, & … … 162 134 pmc_s_get_child_npes 163 135 136 INTERFACE pmc_parentinit 137 MODULE PROCEDURE pmc_parentinit 138 END INTERFACE pmc_parentinit 139 140 INTERFACE pmc_s_set_2d_index_list 141 MODULE PROCEDURE pmc_s_set_2d_index_list 142 END INTERFACE pmc_s_set_2d_index_list 143 144 INTERFACE pmc_s_clear_next_array_list 145 MODULE PROCEDURE pmc_s_clear_next_array_list 146 END INTERFACE pmc_s_clear_next_array_list 147 148 INTERFACE pmc_s_getnextarray 149 MODULE PROCEDURE pmc_s_getnextarray 150 END INTERFACE pmc_s_getnextarray 151 152 INTERFACE pmc_s_set_dataarray 153 MODULE PROCEDURE pmc_s_set_dataarray_2d 154 MODULE PROCEDURE pmc_s_set_dataarray_3d 155 MODULE PROCEDURE pmc_s_set_dataarray_ip2d 156 END INTERFACE pmc_s_set_dataarray 157 158 INTERFACE pmc_s_setind_and_allocmem 159 MODULE PROCEDURE pmc_s_setind_and_allocmem 160 END INTERFACE pmc_s_setind_and_allocmem 161 162 INTERFACE pmc_s_fillbuffer 163 MODULE PROCEDURE pmc_s_fillbuffer 164 END INTERFACE pmc_s_fillbuffer 165 166 INTERFACE pmc_s_getdata_from_buffer 167 MODULE PROCEDURE pmc_s_getdata_from_buffer 168 END INTERFACE pmc_s_getdata_from_buffer 169 170 INTERFACE pmc_s_set_active_data_array 171 MODULE PROCEDURE pmc_s_set_active_data_array 172 END INTERFACE pmc_s_set_active_data_array 173 174 INTERFACE pmc_s_get_child_npes 175 MODULE PROCEDURE pmc_s_get_child_npes 176 END INTERFACE pmc_s_get_child_npes 177 178 164 179 CONTAINS 165 180 … … 168 183 ! Description: 169 184 ! ------------ 170 !171 185 !> If this thread is intended as parent, initialize parent part of parent-client data transfer 172 186 !--------------------------------------------------------------------------------------------------! 173 187 SUBROUTINE pmc_parentinit 174 175 IMPLICIT NONE176 188 177 189 INTEGER(iwp) :: childid !< … … 182 194 183 195 DO i = 1, SIZE( pmc_parent_for_child ) - 1 184 185 196 childid = pmc_parent_for_child( i ) 186 197 … … 194 205 CALL MPI_COMM_REMOTE_SIZE( children(childid)%inter_comm, children(childid)%inter_npes, & 195 206 istat ) 207 196 208 ! 197 209 !-- Intra communicator is used for MPI_GET … … 201 213 202 214 ALLOCATE( children(childid)%pes(children(childid)%inter_npes) ) 215 203 216 ! 204 217 !-- Allocate array of TYPE arraydef for all child PEs to store information of the transfer array … … 208 221 209 222 CALL get_da_names_from_child( childid ) 210 211 223 ENDDO 212 224 213 225 END SUBROUTINE pmc_parentinit 214 226 215 !--------------------------------------------------------------------------------------------------! 216 ! Description:217 ! ------------218 ! 227 228 !--------------------------------------------------------------------------------------------------! 229 ! Description: 230 ! ------------ 219 231 !> thread 0 transfers the index list, which contains all parent grid cells involved in 220 232 !> parent client data transfer to the thread, on which this grid cell is located … … 222 234 SUBROUTINE pmc_s_set_2d_index_list( childid, index_list ) 223 235 224 IMPLICIT NONE 236 INTEGER(iwp) :: ian !< 237 INTEGER(iwp) :: i !< 238 INTEGER(iwp) :: ip !< 239 INTEGER(iwp) :: istat !< 240 INTEGER(iwp) :: max_cells !< 225 241 226 242 INTEGER(iwp), INTENT(IN) :: childid !< 227 INTEGER(iwp), DIMENSION(:,:), INTENT(INOUT) :: index_list !< 228 229 INTEGER(iwp) :: ian !< 230 INTEGER(iwp) :: i !< 231 INTEGER(iwp) :: ip !< 232 INTEGER(iwp) :: istat !< 233 INTEGER(iwp) :: max_cells !< 234 235 INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: cells_on_pe !< 236 INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: lo_ind_list !< 243 244 INTEGER(iwp), DIMENSION(:,:), INTENT(INOUT) :: index_list !< 245 246 INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: cells_on_pe !< 247 248 INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: lo_ind_list !< 237 249 238 250 … … 240 252 ! 241 253 !-- Compute maximum number of grid cells located on one parent thread 242 243 ALLOCATE(cells_on_pe(0:m_model_npes-1)) 254 ALLOCATE( cells_on_pe(0:m_model_npes-1) ) 244 255 cells_on_pe = 0 245 256 246 DO i=1,SIZE( index_list, 2 )257 DO i = 1, SIZE( index_list, 2 ) 247 258 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) 259 ENDDO 260 261 max_cells = MAXVAL( cells_on_pe ) 262 251 263 ! 252 264 !-- Allocate temp array for thread dependent transfer of index_list 253 254 ALLOCATE(lo_ind_list(SIZE(index_list,1),max_cells)) 265 ALLOCATE( lo_ind_list(SIZE( index_list,1 ),max_cells) ) 255 266 256 267 DO ip = 0, m_model_npes-1 257 268 ! 258 269 !-- Split into parent processes 259 260 270 ian = 0 261 271 262 DO i=1,SIZE( index_list, 2 )263 IF (index_list(6,i ) == ip )THEN272 DO i = 1, SIZE( index_list, 2 ) 273 IF ( index_list(6,i) == ip ) THEN 264 274 ian = ian+1 265 275 lo_ind_list(:,ian) = index_list(:,i) 266 END IF 267 END DO 276 ENDIF 277 ENDDO 278 268 279 ! 269 280 !-- Send data to other parent processes … … 274 285 !-- ian = 0, in order to avoid errors when array bounds are checked. 275 286 ALLOCATE( indchildren(childid)%index_list_2d(6,1:ian) ) 276 IF ( ian > 0 ) THEN287 IF ( ian > 0 ) THEN 277 288 indchildren(childid)%index_list_2d(:,1:ian) = lo_ind_list(:,1:ian) 278 289 ENDIF 279 290 ELSE 280 291 CALL MPI_SEND( ian, 1, MPI_INTEGER, ip, 1000, m_model_comm, istat ) 281 IF ( ian > 0 ) THEN292 IF ( ian > 0 ) THEN 282 293 CALL MPI_SEND( lo_ind_list, 6*ian, MPI_INTEGER, ip, 1001, m_model_comm, istat ) 283 294 ENDIF … … 285 296 ENDDO 286 297 287 DEALLOCATE( lo_ind_list)288 DEALLOCATE( cells_on_pe)298 DEALLOCATE( lo_ind_list ) 299 DEALLOCATE( cells_on_pe ) 289 300 ELSE 290 301 CALL MPI_RECV( indchildren(childid)%nrpoints, 1, MPI_INTEGER, 0, 1000, m_model_comm, & … … 300 311 ENDIF 301 312 ENDIF 313 302 314 CALL set_pe_index_list( children(childid), indchildren(childid)%index_list_2d, & 303 315 indchildren(childid)%nrpoints ) … … 309 321 ! Description: 310 322 ! ------------ 311 !312 323 !> Before creating an array list with arrays schedule for parent client transfer 313 324 !> make sure that the list is empty 314 325 !--------------------------------------------------------------------------------------------------! 315 316 326 SUBROUTINE pmc_s_clear_next_array_list 317 327 318 319 IMPLICIT NONE320 321 328 next_array_in_list = 0 322 329 … … 328 335 ! 329 336 !-- Althoug there are no linked lists any more in PMC, this call still looks like working with a list 330 331 337 CHARACTER(LEN=*), INTENT(OUT) :: myname !< 332 338 … … 334 340 335 341 TYPE(pedef), POINTER :: ape !< 336 TYPE(arraydef), POINTER :: ar !< 342 343 TYPE(arraydef), POINTER :: ar !< 344 337 345 338 346 next_array_in_list = next_array_in_list + 1 347 339 348 ! 340 349 !-- Array names are the same on all children processes, so take first process to get the name … … 350 359 ar => ape%array_list(next_array_in_list) 351 360 myname = ar%name 361 352 362 ! 353 363 !-- Return true if there is still an array in the list 354 355 364 pmc_s_getnextarray = .TRUE. 356 365 … … 358 367 359 368 360 361 !--------------------------------------------------------------------------------------------------! 362 ! Description: 363 ! ------------ 364 ! 369 !--------------------------------------------------------------------------------------------------! 370 ! Description: 371 ! ------------ 365 372 !> add 2D real array to list of arrays scheduled for parent-client transfer 366 373 !--------------------------------------------------------------------------------------------------! 367 374 SUBROUTINE pmc_s_set_dataarray_2d( childid, array, array_2 ) 368 375 369 IMPLICIT NONE370 371 376 INTEGER(iwp) :: nrdims !< 372 377 373 378 INTEGER(iwp), INTENT(IN) :: childid !< 374 379 375 INTEGER(iwp), DIMENSION(4) :: dims !<380 INTEGER(iwp), DIMENSION(4) :: dims !< 376 381 377 382 REAL(wp), INTENT(IN), DIMENSION(:,:), POINTER :: array !< … … 402 407 ! Description: 403 408 ! ------------ 404 !405 409 !> add 2D integer array to list of arrays scheduled for parent-client transfer 406 410 !--------------------------------------------------------------------------------------------------! 407 411 SUBROUTINE pmc_s_set_dataarray_ip2d( childid, array ) 408 412 409 IMPLICIT NONE410 411 413 INTEGER(iwp) :: nrdims !< 412 414 413 INTEGER(iwp),INTENT(IN) :: childid !< 415 INTEGER(iwp), DIMENSION(4) :: dims !< 416 417 INTEGER(iwp), INTENT(IN) :: childid !< 414 418 415 419 INTEGER(idp), INTENT(IN), DIMENSION(:,:), POINTER :: array !< 416 417 INTEGER(iwp), DIMENSION(4) :: dims !<418 420 419 421 TYPE(C_PTR) :: array_adr !< … … 434 436 ! Description: 435 437 ! ------------ 436 !437 438 !> add 3D real array to list of arrays scheduled for parent-client transfer 438 439 !--------------------------------------------------------------------------------------------------! 439 440 SUBROUTINE pmc_s_set_dataarray_3d( childid, array, nz_cl, nz, array_2 ) 440 441 IMPLICIT NONE442 441 443 442 INTEGER(iwp) :: nrdims !< … … 455 454 TYPE(C_PTR) :: array_adr !< 456 455 TYPE(C_PTR) :: second_adr !< 456 457 457 458 458 nrdims = 3 … … 479 479 ! Description: 480 480 ! ------------ 481 ! 482 !> @Todo: Missing subroutine description. 481 !> Naming convention for appendices: _pc -> parent to child transfer 482 !> _cp -> child to parent transfer 483 !> send -> parent to child transfer 484 !> recv -> child to parent transfer 485 !> 486 !> @todo: Missing subroutine description. 483 487 !--------------------------------------------------------------------------------------------------! 484 488 SUBROUTINE pmc_s_setind_and_allocmem( childid ) … … 486 490 USE control_parameters, & 487 491 ONLY: message_string 488 489 IMPLICIT NONE490 491 !492 !-- Naming convention for appendices: _pc -> parent to child transfer493 !-- _cp -> child to parent transfer494 !-- send -> parent to child transfer495 !-- recv -> child to parent transfer496 492 497 493 INTEGER(iwp) :: arlen !< … … 502 498 INTEGER(iwp) :: myindex !< 503 499 INTEGER(iwp) :: total_npes !< Total Number of PEs Parent and Child 504 505 500 INTEGER(idp) :: bufsize !< size of MPI data window 506 501 … … 517 512 TYPE(C_PTR) :: base_ptr !< 518 513 519 TYPE(pedef), POINTER :: ape !< 514 TYPE(pedef), POINTER :: ape !< 515 520 516 TYPE(arraydef), POINTER :: ar !< 521 517 … … 526 522 myindex = 1 527 523 bufsize = 8 524 528 525 ! 529 526 !-- All Child processes get the same number of arrays. … … 539 536 !-- First stride: compute size and set index 540 537 DO i = 1, children(childid)%inter_npes 541 542 538 ape => children(childid)%pes(i) 543 544 539 DO j = 1, ape%nr_arrays 545 546 540 ar => ape%array_list(j) 547 541 IF ( ar%nrdims == 2 ) THEN … … 553 547 ENDIF 554 548 ar%sendindex = myindex 549 555 550 ! 556 551 !-- Using intra communicator for MPU_Alltoall, the numbers of the child processes are after 557 552 !-- the parent ones. 558 559 553 myindex_s(j,i-1+children(childid)%model_npes) = myindex 560 554 … … 563 557 ar%sendsize = arlen 564 558 ENDDO 565 566 ENDDO 559 ENDDO 560 567 561 ! 568 562 !-- Using MPI_Alltoall to send indices from Parent to Child 569 563 !-- The data comming back from the child processes are ignored. 570 571 564 CALL MPI_ALLTOALL( myindex_s, lo_nr_arrays, MPI_INTEGER, myindex_r, lo_nr_arrays, MPI_INTEGER, & 572 565 children(childid)%intra_comm, ierr ) … … 579 572 CALL MPI_ALLTOALL( myindex_s, lo_nr_arrays, MPI_INTEGER, myindex_r, lo_nr_arrays, MPI_INTEGER, & 580 573 children(childid)%intra_comm, ierr ) 574 581 575 ! 582 576 !-- Create RMA (One Sided Communication) window for data buffer parent to child transfer. … … 592 586 CALL MPI_WIN_CREATE( base_array_pc, winsize, wp, MPI_INFO_NULL, children(childid)%intra_comm, & 593 587 children(childid)%win_parent_child, ierr ) 588 594 589 ! 595 590 !-- Open window to set data 596 591 CALL MPI_WIN_FENCE( 0, children(childid)%win_parent_child, ierr ) 592 597 593 ! 598 594 !-- Second stride: set buffer pointer 599 595 DO i = 1, children(childid)%inter_npes 600 601 596 ape => children(childid)%pes(i) 602 603 597 DO j = 1, ape%nr_arrays 604 605 598 ar => ape%array_list(j) 606 599 ar%sendbuf = C_LOC( base_array_pc(ar%sendindex) ) 607 608 600 IF ( ar%sendindex + ar%sendsize > bufsize ) THEN 609 601 WRITE( message_string, '(a,i4,4i7,1x,a)' ) 'parent buffer too small ',i , & … … 613 605 ENDDO 614 606 ENDDO 607 615 608 ! 616 609 !-- Child to parent direction 617 610 bufsize = 8 611 618 612 ! 619 613 !-- First stride: compute size and set index … … 643 637 644 638 CALL MPI_BARRIER( children(childid)%intra_comm, ierr ) 639 645 640 ! 646 641 !-- Second stride: set buffer pointer … … 659 654 ! Description: 660 655 ! ------------ 661 !662 656 !> Fill buffer in RMA window to enable the client to fetch the dat with MPI_Get 663 657 !--------------------------------------------------------------------------------------------------! 664 658 SUBROUTINE pmc_s_fillbuffer( childid, waittime, particle_transfer ) 665 666 IMPLICIT NONE667 659 668 660 INTEGER(iwp) :: ierr !< … … 687 679 REAL(wp) :: t2 !< 688 680 689 REAL(wp), INTENT(OUT), OPTIONAL :: waittime 681 REAL(wp), INTENT(OUT), OPTIONAL :: waittime !< 690 682 691 683 REAL(wp), POINTER, DIMENSION(:) :: buf !< … … 695 687 REAL(wp), POINTER, DIMENSION(:,:,:) :: data_3d !< 696 688 697 TYPE(pedef), POINTER :: ape !< 689 TYPE(pedef), POINTER :: ape !< 690 698 691 TYPE(arraydef), POINTER :: ar !< 699 692 … … 702 695 !-- without sychronization at this point and a barrier is not necessary. 703 696 !-- Please note that waittime has to be set in pmc_s_fillbuffer AND pmc_c_getbuffer. 704 IF ( PRESENT( waittime ) ) THEN697 IF ( PRESENT( waittime ) ) THEN 705 698 t1 = pmc_time() 706 699 CALL MPI_BARRIER( children(childid)%intra_comm, ierr ) … … 717 710 ar => ape%array_list(j) 718 711 myindex = 1 719 720 712 IF ( ar%dimkey == 2 .AND. .NOT.lo_ptrans ) THEN ! PALM 2D REAL*8 Array 721 722 713 buf_shape(1) = ape%nrele 723 714 CALL C_F_POINTER( ar%sendbuf, buf, buf_shape ) … … 727 718 myindex = myindex + 1 728 719 ENDDO 729 730 720 ELSEIF ( ar%dimkey == 3 .AND. .NOT.lo_ptrans ) THEN ! PALM 3D REAL*8 Array 731 732 721 buf_shape(1) = ape%nrele*ar%a_dim(4) 733 722 CALL C_F_POINTER( ar%sendbuf, buf, buf_shape ) … … 739 728 ENDDO 740 729 ELSEIF ( ar%dimkey == 22 .AND. lo_ptrans ) THEN ! 2D INTEGER*8 Array for particle Transfer 741 742 730 buf_shape(1) = ape%nrele 743 731 CALL C_F_POINTER( ar%sendbuf, ibuf, buf_shape ) … … 750 738 ENDDO 751 739 ENDDO 740 752 741 ! 753 742 !-- Buffer is filled … … 757 746 758 747 759 760 !--------------------------------------------------------------------------------------------------! 761 ! Description: 762 ! ------------ 763 ! 748 !--------------------------------------------------------------------------------------------------! 749 ! Description: 750 ! ------------ 764 751 !> Get client data from RMM window 765 752 !--------------------------------------------------------------------------------------------------! 766 753 SUBROUTINE pmc_s_getdata_from_buffer( childid, waittime , particle_transfer, child_process_nr ) 767 768 IMPLICIT NONE769 754 770 755 INTEGER(iwp) :: ierr !< … … 805 790 REAL(wp), POINTER, DIMENSION(:,:,:) :: data_3d !< 806 791 807 TYPE(pedef), POINTER :: ape !< 792 TYPE(pedef), POINTER :: ape !< 793 808 794 TYPE(arraydef), POINTER :: ar !< 809 795 … … 832 818 ENDIF 833 819 834 DO ip = ip_start, ip_end820 DO ip = ip_start, ip_end 835 821 ape => children(childid)%pes(ip) 836 822 DO j = 1, ape%nr_arrays … … 848 834 CYCLE ! Particle arrays are not transfered here 849 835 ENDIF 836 850 837 buf_shape(1) = nr 838 851 839 IF(lo_ptrans) THEN 852 840 CALL C_F_POINTER( ar%recvbuf, ibuf, buf_shape ) … … 874 862 CALL MPI_WIN_UNLOCK( target_pe, children(childid)%win_parent_child, ierr ) 875 863 ENDIF 864 876 865 myindex = 1 866 877 867 IF ( ar%dimkey == 2 .AND. .NOT. lo_ptrans ) THEN 878 879 868 CALL C_F_POINTER( ar%data, data_2d, ar%a_dim(1:2) ) 880 869 DO ij = 1, ape%nrele … … 882 871 myindex = myindex + 1 883 872 ENDDO 884 885 873 ELSE IF ( ar%dimkey == 3 .AND. .NOT. lo_ptrans ) THEN 886 887 874 CALL C_F_POINTER( ar%data, data_3d, ar%a_dim(1:3) ) 888 875 DO ij = 1, ape%nrele … … 891 878 myindex = myindex + ar%a_dim(4) 892 879 ENDDO 893 894 880 ELSE IF ( ar%dimkey == 22 .AND. lo_ptrans) THEN 895 896 881 CALL C_F_POINTER( ar%data, idata_2d, ar%a_dim(1:2) ) 897 882 DO ij = 1, ape%nrele … … 899 884 myindex = myindex + 1 900 885 ENDDO 901 902 886 ENDIF 903 887 ENDDO … … 910 894 ! Description: 911 895 ! ------------ 912 !913 896 !> broadcast name of transfer arrays from child thread 0 to parent threads 914 897 !--------------------------------------------------------------------------------------------------! … … 917 900 ! 918 901 !-- Get data array description and name from child 919 IMPLICIT NONE920 921 902 INTEGER(iwp), INTENT(IN) :: childid !< 922 903 923 904 TYPE(da_namedef) :: myname !< 905 924 906 925 907 DO … … 939 921 940 922 941 942 !--------------------------------------------------------------------------------------------------! 943 ! Description: 944 ! ------------ 945 ! 946 !> @Todo: Missing subroutine description. 923 !--------------------------------------------------------------------------------------------------! 924 ! Description: 925 ! ------------ 926 !> @todo: Missing subroutine description. 947 927 !--------------------------------------------------------------------------------------------------! 948 928 SUBROUTINE pmc_s_setarray( childid, nrdims, dims, array_adr, second_adr, dimkey ) … … 950 930 ! 951 931 !-- Set array for child inter process 0 952 IMPLICIT NONE953 954 932 INTEGER(iwp) :: i !< local counter 955 933 … … 965 943 TYPE(C_PTR), INTENT(IN), OPTIONAL :: second_adr !< 966 944 967 TYPE(pedef), POINTER :: ape !< 945 TYPE(pedef), POINTER :: ape !< 946 968 947 TYPE(arraydef), POINTER :: ar !< 969 948 … … 985 964 ar%po_data(2) = C_NULL_PTR 986 965 ENDIF 987 988 966 ENDDO 989 967 … … 991 969 992 970 993 994 !--------------------------------------------------------------------------------------------------! 995 ! Description: 996 ! ------------ 997 ! 998 !> @Todo: Missing subroutine description. 971 !--------------------------------------------------------------------------------------------------! 972 ! Description: 973 ! ------------ 974 !> @todo: Missing subroutine description. 999 975 !--------------------------------------------------------------------------------------------------! 1000 976 SUBROUTINE pmc_s_set_active_data_array( childid, iactive ) 1001 1002 IMPLICIT NONE1003 977 1004 978 INTEGER(iwp) :: ip !< … … 1008 982 INTEGER(iwp), INTENT(IN) :: iactive !< 1009 983 1010 TYPE(pedef), POINTER :: ape !< 984 TYPE(pedef), POINTER :: ape !< 985 1011 986 TYPE(arraydef), POINTER :: ar !< 1012 987 … … 1024 999 END SUBROUTINE pmc_s_set_active_data_array 1025 1000 1001 1002 !--------------------------------------------------------------------------------------------------! 1003 ! Description: 1004 ! ------------ 1005 !> @todo: Missing function description. 1006 !--------------------------------------------------------------------------------------------------! 1026 1007 INTEGER FUNCTION pmc_s_get_child_npes( child_id ) 1027 IMPLICIT NONE1028 1008 1029 1009 INTEGER(iwp),INTENT(IN) :: child_id !< … … 1032 1012 1033 1013 RETURN 1014 1034 1015 END FUNCTION pmc_s_get_child_npes 1035 1016 1036 1017 1037 1038 !--------------------------------------------------------------------------------------------------! 1039 ! Description: 1040 ! ------------ 1041 ! 1042 !> @Todo: Missing subroutine description. 1018 !--------------------------------------------------------------------------------------------------! 1019 ! Description: 1020 ! ------------ 1021 !> @todo: Missing subroutine description. 1043 1022 !--------------------------------------------------------------------------------------------------! 1044 1023 SUBROUTINE set_pe_index_list( mychild, index_list, nrp ) 1045 1046 IMPLICIT NONE1047 1024 1048 1025 INTEGER(iwp) :: i !< … … 1070 1047 TYPE(pedef), POINTER :: ape !< 1071 1048 1049 1072 1050 ! 1073 1051 !-- First, count entries for every remote child process … … 1076 1054 ape%nrele = 0 1077 1055 ENDDO 1056 1078 1057 ! 1079 1058 !-- Loop over number of coarse grid cells … … 1090 1069 1091 1070 remind = 0 1071 1092 1072 ! 1093 1073 !-- Second, create lists … … 1101 1081 ape%locind(ind)%j = index_list(2,j) 1102 1082 ENDDO 1083 1103 1084 ! 1104 1085 !-- Prepare number of elements for children processes 1105 1086 CALL pmc_alloc_mem( rldef, mychild%inter_npes * 2 ) 1087 1106 1088 ! 1107 1089 !-- Number of child processes * size of INTEGER (i just arbitrary INTEGER) … … 1109 1091 1110 1092 CALL MPI_WIN_CREATE( rldef, winsize, iwp, MPI_INFO_NULL, mychild%intra_comm, indwin, ierr ) 1093 1111 1094 ! 1112 1095 !-- Open window to set data … … 1115 1098 rldef(1) = 0 ! Index on remote process 0 1116 1099 rldef(2) = remind(1) ! Number of elements on remote process 0 1100 1117 1101 ! 1118 1102 !-- Reserve buffer for index array … … 1122 1106 rldef(i2+1) = remind(i) ! Number of elements on remote process 1123 1107 ENDDO 1108 1124 1109 ! 1125 1110 !-- Close window to allow child to access data 1126 1111 CALL MPI_WIN_FENCE( 0, indwin, ierr ) 1112 1127 1113 ! 1128 1114 !-- Child has retrieved data … … 1131 1117 i2 = 2 * mychild%inter_npes - 1 1132 1118 winsize = ( rldef(i2) + rldef(i2+1) ) * 2 1119 1133 1120 ! 1134 1121 !-- Make sure, MPI_ALLOC_MEM works … … 1140 1127 CALL MPI_WIN_CREATE( remindw, winsize * STORAGE_SIZE( i ) / 8, iwp, MPI_INFO_NULL, & 1141 1128 mychild%intra_comm, indwin2, ierr ) 1129 1142 1130 ! 1143 1131 !-- Open window to set data 1144 1132 CALL MPI_WIN_FENCE( 0, indwin2, ierr ) 1133 1145 1134 ! 1146 1135 !-- Create the 2D index list … … 1154 1143 rldef(i2) = rldef(i2)+2 1155 1144 ENDDO 1145 1156 1146 ! 1157 1147 !-- All data are set 1158 1148 CALL MPI_WIN_FENCE( 0, indwin2, ierr ) 1149 1159 1150 ! 1160 1151 !-- Don't know why, but this barrier is necessary before windows can be freed … … 1167 1158 ! 1168 1159 !-- TODO: check if the following idea needs to be done 1169 !-- S ollte funktionieren, Problem mitMPI implementation1160 !-- Should work, Problem with MPI implementation 1170 1161 !-- https://www.lrz.de/services/software/parallel/mpi/onesided 1171 1162 !-- CALL MPI_Free_mem (remindw, ierr) 1172 1163 1173 1164 END SUBROUTINE set_pe_index_list 1174 1175 1165 #endif 1166 1167 1176 1168 END MODULE pmc_parent
Note: See TracChangeset
for help on using the changeset viewer.