psmile_get_intersect.F90

Go to the documentation of this file.
00001 !-----------------------------------------------------------------------
00002 ! Copyright 2006-2010, NEC Europe Ltd., London, UK.
00003 ! All rights reserved. Use is subject to OASIS4 license terms.
00004 !-----------------------------------------------------------------------
00005 !BOP
00006 !
00007 ! !ROUTINE: PSMILe_Get_intersect
00008 !
00009 ! !INTERFACE:
00010 
00011       subroutine psmile_get_intersect (ninter, nmyint, nnull, &
00012                                        num_intersect_per_grid, &
00013                                        num_dummy_intersect_per_grid, &
00014                                        lastag, ierror)
00015 !
00016 ! !USES:
00017 !
00018       use PRISM_constants
00019       use PSMILe_common, only : PSMILe_nullify_Enddef_search, num_req_types
00020       use PSMILe, dummy_interface => PSMILe_get_intersect
00021       implicit none
00022 !
00023 ! !INPUT PARAMETERS:
00024 !
00025       Integer, Intent (In)            :: ninter
00026 
00027 !     Contains total number of intersections found for the
00028 !     actual process.
00029 
00030       Integer, Intent (In)            :: nmyint
00031 
00032 !     Contains total number of intersections found which are located
00033 !     also on the actual process.
00034 
00035       Integer, Intent (In)            :: nnull
00036 
00037 !     Contains total number of dummy (empty) intersections found
00038 !     which were sent to a destination process
00039 
00040       Integer, Intent (In)            :: num_intersect_per_grid(:), 
00041                                          num_dummy_intersect_per_grid(:)
00042 
00043       Integer, Intent (In)            :: lastag
00044 
00045 !     Message tag used by PSMILe_find_intersect
00046 !
00047 !
00048 ! !OUTPUT PARAMETERS:
00049 !
00050       Integer, Intent (Out)           :: ierror
00051 
00052 !     Returns the error code of PSMILe_get_intersect;
00053 !             ierror = 0 : No error
00054 !             ierror > 0 : Severe error
00055 !
00056 ! !DEFINED PARAMETERS:
00057 !
00058       Logical, Parameter           :: new_search = .true.
00059 !
00060 !  TOL must become input parameter
00061 !
00062       Double Precision, parameter  :: tol = 1d-6
00063 !
00064 ! !LOCAL VARIABLES
00065 !
00066 !  ... for intersections sent
00067 !
00068       Integer                      :: ipart
00069 !
00070 !  ... for grid data sent by a partner process
00071 !
00072       Integer                      :: i
00073       Type (Enddef_search)         :: search
00074       Logical                      :: new_intersection
00075 
00076 !
00077 !  ... for communication
00078 !
00079       Integer                      :: index
00080       Integer                      :: lstatus (MPI_STATUS_SIZE)
00081 #ifndef PRISM_with_MPI2
00082       Integer, Allocatable         :: statuses (:, :)
00083 #endif
00084 !
00085 !  ... for finalize messages of global search
00086 !
00087       Integer                      :: dest, icomp, n
00088 !
00089       Integer                      :: fin_extra (2)
00090       Integer, Allocatable         :: fin_requests (:)
00091 !
00092 !  ... for error parameters
00093 !
00094       Integer, Parameter           :: nerrp = 3
00095       Integer                      :: ierrp (nerrp)
00096 !
00097 ! !DESCRIPTION:
00098 !
00099 ! Subroutine "PSMILe_get_intersect" receives the messages sent from
00100 ! routine "PSMILe_find_intersect", performs the actions required from
00101 ! other processes and performs the search of donor cells.
00102 !
00103 ! Doxygen documentation (requires mscgen tool)
00104 !> \file psmile_get_intersect.F90
00105 !! The following is a general overview on the messages exchanged between source\n
00106 !! and target. This routine mainly handles the header messages while the real\n
00107 !! messages are being dealt with in psmile_enddef_action.\n
00108 !! \msc
00109 !!   width = "750";
00110 !!   # entities
00111 !!   Target,Source,"other Sources";
00112 !!   ||| ;
00113 !!   --- [label="psmile_find_intersect:"] ;
00114 !!   Target => Source [label = "intersection (lasttag(100) reqidx(2)"] ;
00115 !!   --- [label="psmile_get_intersect:"] ;
00116 !!   Source rbox Source [label="initialise recv of data\n(psmile_recv_req_subgrid)"] ;
00117 !!   Target <= Source [label="return previouse message as\nacknowledgment (regtag(101) reqidx(1))"] ;
00118 !!   ||| ;
00119 !!   Target => Source [label="send grid data (grdtag(102) reqidx(3))"] ;
00120 !!   Source rbox Source [label="match grids\n(psmile_search_donor_cells)"] ;
00121 !!   ||| ;
00122 !!   Target :: "other Sources" [label="in case of global search for conservative remapping"] ;
00123 !!   Target <= Source [label="header for cell search\n(loctag(110) reqidx(>=num_req_types))"] ;
00124 !!   ||| ;
00125 !!   Target <= Source [label="send information on target cells\nonly partially covered by local data\n(celltag(107) received by psmile_enddef_action_cell)"] ;
00126 !!   ||| ;
00127 !!   Target <= "other Sources" [label="header for cell search (loctag(110) reqidx(>=num_req_types))"] ;
00128 !!   Target <= "other Sources" [label="send information on target cells only partially covered by local data\n(celltag(107) received by psmile_enddef_action_cell)"] ;
00129 !!   ||| ;
00130 !!   Target rbox Target [label="collect all information\non partially covered cells"] ;
00131 !!   ||| ;
00132 !!   Target => Source [label="inform about other processes covering\nthe same cells (celltag+1(108)\nrecevied by psmile_global_search_cell)"] ;
00133 !!   ||| ;
00134 !!   Target => "other Sources" [label="inform about other processes covering the same cells\n(celltag+1(108) recevied by psmile_global_search_cell)"] ;
00135 !!   Target :: "other Sources" [label="end of global for converv. remap."] ;
00136 !!   Target :: "other Sources" [label="in case of global search for points"] ;
00137 !!   Source => "other Sources" [label="request for points not found in\nlocal data (exttag(104) reqidx(4))"] ;
00138 !!   ||| ;
00139 !!   Source <= "other Sources" [label="return results of local search\n(rexttag(105) received by psmile_global_search_*)"] ;
00140 !!   Target :: "other Sources" [label="end of global search for points"] ;
00141 !!   Target <= Source [label="inform about points/cells being\nprovided by directly or through coupler\n(loctag(110) reqidx(>=num_req_types))"] ;
00142 !!   ||| ;
00143 !!   Target <= "other Sources" [label="inform about points/cells being provided by directly or through coupler\n(loctag(110) reqidx(>=num_req_types))"] ;
00144 !!   ||| ;
00145 !!   Target rbox "other Sources" [label="exchange of finish messages (exttag(104) reqidx(4))"] ;
00146 !! \endmsc
00147 !<
00148 !
00149 ! !REVISION HISTORY:
00150 !
00151 !   Date      Programmer   Description
00152 ! ----------  ----------   -----------
00153 ! 03.07.06    H. Ritzdorf  created
00154 !
00155 !EOP
00156 !----------------------------------------------------------------------
00157 !
00158 ! $Id: psmile_get_intersect.F90 2804 2010-12-07 10:07:10Z hanke $
00159 ! $Author: hanke $
00160 !
00161    Character(len=len_cvs_string), save :: mycvs = 
00162        '$Id: psmile_get_intersect.F90 2804 2010-12-07 10:07:10Z hanke $'
00163 !
00164 !----------------------------------------------------------------------
00165 
00166 #ifdef VERBOSE
00167       print 9990, trim(ch_id), ninter, nmyint, nnull
00168 
00169       call psmile_flushstd
00170 #endif /* VERBOSE */
00171 !
00172 !  Initialization
00173 !
00174       ierror = 0
00175 !
00176       paction%n      = 0
00177       paction%ninter = ninter
00178       paction%lastag = lastag
00179 !     paction%nmyint = nmyint
00180       paction%nmyint = 0
00181 !
00182       paction%grid2receive = .false.
00183       allocate(paction%n_answer2recv_per_grid(Number_of_Grids_allocated))
00184       paction%n_answer2recv_per_grid(:) = num_intersect_per_grid(:) - num_dummy_intersect_per_grid(:)
00185       new_intersection = .true.
00186 !
00187 !  n_answer = Number of answers containing requests for grid data received.
00188 !             If no grid data was required, the receiving process doesn't
00189 !             send an answer. This are "nnull" messages.
00190 !
00191       paction%n_answer = 0
00192 !     paction%n_answer2recv = ninter - nmyint - nnull
00193       paction%n_answer2recv = ninter - nnull
00194 !
00195 !  nloc_recv = Number of processes which have sent the locations for
00196 !              all grid functions (fields)
00197 !
00198       paction%nloc_recv = 0
00199 !
00200 !===> Number of outstanding receives for nearest neighbour points
00201 !
00202       paction%n_selected = 0
00203 !
00204 !===> Get number of finalize messages for global search
00205 !     ??? Feststellen, ob global search specifiziert wurde ?
00206 !
00207       paction%n_fin = 0
00208       paction%n_fin2recv = 0
00209       do icomp = 1, n_act_comp
00210          paction%n_fin2recv = paction%n_fin2recv + comp_infos(icomp)%size
00211       end do
00212 !
00213 !  lrequest (1)            = reqtag : Request to send grid data
00214 !  lrequest (2)            = lastag : Receive data on grid intersection
00215 !  lrequest (3)            = grdtag : Receive grid data
00216 !  lrequest (4)            = exttag : Receive request for extra search
00217 !  lrequest (5)            = seltag : Request to receive info on seleted points
00218 !                                     of nearest neighbour search
00219 !
00220 !  lrequest (num_req_types:nreq) = loctag+: Receive data on locations found
00221 !
00222       paction%nreq = num_req_types - 1 + paction%n_answer2recv
00223 !
00224       Allocate (paction%lrequest(paction%nreq), stat = ierror)
00225       if ( ierror /= 0 ) then
00226          ierrp (1) = paction%nreq
00227          ierror = PRISM_Error_Alloc
00228          call psmile_error ( ierror, 'paction%lrequest', &
00229                              ierrp, 1, __FILE__, __LINE__ )
00230          return
00231       endif
00232 !
00233       if (paction%n_answer2recv > 0) then
00234          Allocate (paction%loc_messages(msgloc_size, paction%n_answer2recv), &
00235                    stat = ierror)
00236          if ( ierror /= 0 ) then
00237             ierrp (1) = msgloc_size * paction%n_answer2recv
00238             ierror = PRISM_Error_Alloc
00239             call psmile_error ( ierror, 'paction%loc_messages', &
00240                                 ierrp, 1, __FILE__, __LINE__ )
00241             return
00242          endif
00243       end if
00244 !
00245       paction%lrequest (:) = MPI_REQUEST_NULL
00246 !
00247 !===> Set up request for a grid transfer (answer to tag "lastag")
00248 !
00249 !     n_answer2recv - n_answer is the number of messages to be received
00250 !
00251       if (paction%n_answer < paction%n_answer2recv) then
00252          call MPI_Irecv (paction%msgreq, nd_msgint, MPI_INTEGER,      &
00253                          MPI_ANY_SOURCE, reqtag, comm_psmile, &
00254                          paction%lrequest(1), ierror)
00255          if ( ierror /= MPI_SUCCESS ) then
00256             ierrp (1) = ierror
00257             ierror = PRISM_Error_MPI
00258 
00259             call psmile_error ( ierror, 'MPI_Irecv', &
00260                                 ierrp, 1, __FILE__, __LINE__ )
00261             return
00262          endif
00263 #ifdef DEBUG
00264          print *, ' Posting Irecv request(1) ', paction%lrequest(1), 'with tag ', reqtag
00265 #endif /* DEBUG */
00266       endif
00267 !
00268 !===> ... Set up request for receive of an extra search request
00269 !
00270       if (paction%n_fin2recv > 0) then
00271          call MPI_Irecv (paction%msg_extra, nd_msgextra, MPI_INTEGER, &
00272                          MPI_ANY_SOURCE, exttag, comm_psmile,         &
00273                          paction%lrequest(4), ierror)
00274 
00275          if ( ierror /= MPI_SUCCESS ) then
00276             ierrp (1) = ierror
00277             ierror = PRISM_Error_MPI
00278 
00279             call psmile_error ( ierror, 'MPI_Irecv', &
00280                                 ierrp, 1, __FILE__, __LINE__ )
00281             return
00282          endif
00283 #ifdef DEBUG
00284          print *, ' Posting Irecv request(4) ', paction%lrequest(4), 'with tag ', exttag
00285 #endif /* DEBUG */
00286       endif
00287 
00288       call psmile_nullify_enddef_search(search)
00289 
00290 !
00291 !-----------------------------------------------------------------------
00292 !     Wait for an action to be performed
00293 !
00294 !     Note: Either
00295 !             lrequest (2)
00296 !             wait for an intersection
00297 !           or
00298 !             lrequest (3) corresponds to grid2receive
00299 !              wait for grid data to be sent for the intersection
00300 !
00301 !           is active
00302 !-----------------------------------------------------------------------
00303 !
00304       do while ( paction%n          < paction%ninter        .or. &
00305                  paction%n_answer   < paction%n_answer2recv .or. &
00306                  paction%nloc_recv  < paction%n_answer2recv .or. &
00307                  paction%n_selected > 0                     .or. &
00308                  paction%grid2receive )
00309 
00310 ! if psmile is ready to receive an intersection and if there still
00311 ! intersection messages left to be received
00312          if (paction%ninter > 0         .and. &
00313              paction%n < paction%ninter .and. &
00314              new_intersection) then
00315 !
00316 !===> ... Set up request for receive of an intersection
00317 !
00318 #ifdef PRISM_ASSERTION
00319             if (paction%lrequest(2) /= MPI_REQUEST_NULL) then
00320                call psmile_assert ( __FILE__, __LINE__, &
00321                                     'paction%lrequest(2) is not finished !')
00322             endif
00323 #endif
00324 #define CONS_REMAP_DEADLOCK_WORKAROUND
00325 #ifndef CONS_REMAP_DEADLOCK_WORKAROUND
00326             call MPI_Irecv (paction%msgint, nd_msgint, MPI_INTEGER,      &
00327                            MPI_ANY_SOURCE, paction%lastag, comm_psmile, &
00328                            paction%lrequest(2), ierror)
00329 #else
00330             call MPI_Irecv (paction%msgint, nd_msgint, MPI_INTEGER,      &
00331                            maxval(paction%intersect_ranks), paction%lastag, comm_psmile, &
00332                            paction%lrequest(2), ierror)
00333             paction%intersect_ranks(maxloc(paction%intersect_ranks)) = -1
00334 #endif
00335 
00336             if ( ierror /= MPI_SUCCESS ) then
00337                ierrp (1) = ierror
00338                ierror = PRISM_Error_MPI
00339 
00340                call psmile_error ( ierror, 'MPI_Irecv', &
00341                                  ierrp, 1, __FILE__, __LINE__ )
00342                return
00343             endif
00344 #ifdef DEBUG
00345          print *, ' Posting Irecv request(2) ', paction%lrequest(2), 'with tag ', paction%lastag
00346 #endif /* DEBUG */
00347          endif
00348 
00349 !
00350 !===> ... Wait for a request
00351 !
00352 #ifdef DEBUG
00353          print 9960, trim(ch_id), paction%n, paction%ninter,                  &
00354                                   paction%n_answer, paction%n_answer2recv,    &
00355                                   paction%grid2receive,                       &
00356                                   paction%nloc_recv, paction%n_answer2recv,   &
00357                                   paction%n_selected
00358 
00359          call psmile_flushstd
00360          do i = 1, paction%nreq
00361             print *, '    list of requests ', i, paction%lrequest(i)
00362          enddo
00363          call psmile_flushstd
00364 #endif /* DEBUG */
00365          call MPI_Waitany (paction%nreq, paction%lrequest, index, lstatus, ierror)
00366 
00367          if ( ierror /= MPI_SUCCESS ) then
00368             ierrp (1) = ierror
00369             ierrp (2) = lstatus (MPI_SOURCE)
00370             ierrp (3) = lstatus (MPI_TAG)
00371 
00372             ierror = PRISM_Error_MPI
00373 
00374             print *, 'lstatus', lstatus
00375             call psmile_error ( ierror, 'MPI_Waitany', &
00376                                 ierrp, 3, __FILE__, __LINE__ )
00377             return
00378          endif
00379 
00380 #ifdef DEBUG
00381          print *, trim(ch_id), ": n, ninter, sender, index", &
00382                   paction%n, paction%ninter, lstatus (MPI_SOURCE), index
00383          call psmile_flushstd
00384 #endif /* DEBUG */
00385 
00386          if (index == MPI_UNDEFINED) then
00387 #ifdef PRISM_ASSERTION
00388             call psmile_assert ( __FILE__, __LINE__, &
00389                                  'request list is empty')
00390 #endif /* PRISM_ASSERTION */
00391             exit
00392          endif
00393 !
00394 !===> ... A request was completed
00395 !
00396          if (index == 3) then
00397 !
00398 !-----------------------------------------------------------------------
00399 !        index = 3: Grid data was received (tag ``grdtag'')
00400 !                   Note: The first request of "recv_req" was already
00401 !                         fulfilled.
00402 !
00403 !  Fehlt hier nicht noch ein counter fuer das while
00404 !-----------------------------------------------------------------------
00405 !
00406 #ifdef PRISM_ASSERTION
00407             if (lstatus(MPI_TAG) /= grdtag) then
00408                call psmile_assert ( __FILE__, __LINE__, &
00409                                    'wrong message tag; must be grdtag')
00410             endif
00411 #endif
00412 
00413 #ifdef PRISM_with_MPI2
00414             call MPI_Waitall ((ndim_3d+2)*search%npart-1, paction%recv_req(2:), &
00415                               MPI_STATUSES_IGNORE, ierror)
00416 #else
00417             Allocate (statuses (MPI_STATUS_SIZE,search%npart*(ndim_3d+2)-1), &
00418                       stat = ierror)
00419             if ( ierror /= 0 ) then
00420                ierrp (1) = MPI_STATUS_SIZE * (search%npart*(ndim_3d+2)-1)
00421                ierror = PRISM_Error_Alloc
00422                call psmile_error ( ierror, 'statuses', &
00423                                    ierrp, 1, __FILE__, __LINE__ )
00424                return
00425             endif
00426 
00427             call MPI_Waitall ((ndim_3d+2)*search%npart-1, paction%recv_req(2:), &
00428                               statuses, ierror)
00429 #endif
00430             if ( ierror /= MPI_SUCCESS ) then
00431                ierrp (1) = ierror
00432 
00433                ierror = PRISM_Error_MPI
00434 
00435                call psmile_error ( ierror, 'MPI_Waitall', &
00436                                    ierrp, 1, __FILE__, __LINE__ )
00437                return
00438             endif
00439 !
00440 #ifndef PRISM_with_MPI2
00441             Deallocate (statuses)
00442 #endif
00443             Deallocate (paction%recv_req)
00444 
00445             paction%grid2receive = .false.
00446 !
00447 !           ... Search donor cells
00448 !
00449             call psmile_search_donor_cells (search, tol, ierror )
00450             if (ierror > 0) return
00451 !
00452 ! ... to do
00453 
00454 !
00455 !           ... Deallocate arrays allocated
00456 !               The arrays and vectors were allocated in
00457 !               PSMILe_Recv_req_subgrid and PSMILe_Recv_req_coords_????
00458 !
00459             if (search%datatype == MPI_REAL) then
00460                do ipart = 1, search%npart
00461                   do i = 1, ndim_3d
00462                      Deallocate (search%search_real(i, ipart)%vector)
00463                   end do
00464                end do
00465 !
00466                Deallocate (search%search_real)
00467 !
00468             else if (search%datatype == MPI_DOUBLE_PRECISION) then
00469                do ipart = 1, search%npart
00470                   do i = 1, ndim_3d
00471                      Deallocate (search%search_dble(i, ipart)%vector)
00472                   end do
00473                end do
00474 !
00475                Deallocate (search%search_dble)
00476 !
00477 #if defined ( PRISM_QUAD_TYPE )
00478             else if (search%datatype == MPI_REAL16) then
00479                do ipart = 1, search%npart
00480                   do i = 1, ndim_3d
00481                   Deallocate (search%search_quad(i, ipart)%vector)
00482                   end do
00483                end do
00484 !
00485                Deallocate (search%search_quad)
00486 #endif
00487             endif
00488 !
00489             if (Associated(search%search_mask)) then
00490                do ipart = 1, search%npart
00491                   Deallocate(search%search_mask(ipart)%vector)
00492                end do
00493 !
00494                Deallocate (search%search_mask)
00495             endif
00496 !
00497             if (Associated(search%global_index)) then
00498                do ipart = 1, search%npart
00499                   Deallocate(search%global_index(ipart)%vector)
00500                end do
00501                Deallocate (search%global_index)
00502             endif
00503 
00504             Deallocate (search%msgint)
00505             Deallocate (search%dims)
00506             Deallocate (search%shape)
00507             Deallocate (search%range)
00508 !
00509 !===> ... Set up request for receive of an intersection
00510 !
00511             new_intersection = .true.
00512 !
00513          else
00514 
00515             new_intersection = .false.
00516 !
00517 !===> ... Perform default action
00518 !
00519             call psmile_enddef_action (search, index, lstatus, ierror)
00520             if (ierror > 0) return
00521          endif
00522 !
00523       end do ! do while (paction%n < paction%ninter .and. ...)
00524 !
00525 !===> All requests except for global search are fulfilled.
00526 !     Send info to processes.
00527 !     TODO: Send message over a tree in order to decrease the
00528 !           number of sends.
00529 !
00530       if (paction%n_fin2recv > 0) then
00531 
00532          Allocate (fin_requests (paction%n_fin2recv), stat = ierror)
00533          if ( ierror /= 0 ) then
00534             ierrp (1) = paction%n_fin2recv
00535             ierror = PRISM_Error_Alloc
00536             call psmile_error ( ierror, 'fin_requests', &
00537                                 ierrp, 1, __FILE__, __LINE__ )
00538             return
00539          endif
00540 !
00541          fin_extra (1) = PSMILe_Finalize_extra_search
00542          fin_extra (2) = 1 ! Number of processes finalized
00543 !
00544          n = 0
00545          do icomp = 1, n_act_comp
00546             do i = 1, comp_infos(icomp)%size
00547                dest = comp_infos(icomp)%psmile_ranks(i)
00548 
00549                n = n + 1
00550 
00551                call MPI_Isend (fin_extra, 2, MPI_INTEGER, &
00552                                dest, exttag, comm_psmile, &
00553                                fin_requests(n), ierror)
00554 !
00555                if ( ierror /= MPI_SUCCESS ) then
00556                   ierrp (1) = ierror
00557                   ierrp (2) = dest
00558                   ierrp (3) = exttag
00559                   ierror = PRISM_Error_Send
00560 
00561                   call psmile_error ( ierror, 'MPI_Isend', &
00562                                  ierrp, 3, __FILE__, __LINE__ )
00563                   return
00564                endif
00565 #ifdef DEBUGX
00566                print *, ' Posting Isend request ', fin_requests(n), &
00567                         ' with tag ', exttag, ' to dest ', dest
00568                call psmile_flushstd
00569 #endif /* DEBUGX */
00570             end do ! i = 1, comp_infos(icomp)%size
00571          end do ! icomp
00572 !
00573 !===> Wait that all finish messages of global search has been
00574 !     received.
00575 !     index 4: Message of extra_search (inclusive finish messages
00576 !              with command "PSMILe_Finalize_extra_search")
00577 !     index 5: Receive info on seleted points of nearest neighbour search
00578 !
00579          do while (paction%n_fin < paction%n_fin2recv .or. &
00580                    paction%n_selected > 0)
00581 #ifdef DEBUGX
00582             print 9950, trim(ch_id), paction%n_fin, paction%n_fin2recv
00583             do i = 4, 5
00584                print *, '    list of request ', i, paction%lrequest(i)
00585             enddo
00586             call psmile_flushstd
00587 #endif /* DEBUGX */
00588             call MPI_Waitany (2, paction%lrequest(4:5), index, lstatus, ierror)
00589 
00590             if ( ierror /= MPI_SUCCESS ) then
00591                ierrp (1) = ierror
00592                ierrp (2) = lstatus (MPI_SOURCE)
00593                ierrp (3) = lstatus (MPI_TAG)
00594 
00595                ierror = PRISM_Error_MPI
00596 
00597                print *, 'lstatus', lstatus
00598                call psmile_error ( ierror, 'MPI_Waitany', &
00599                                    ierrp, 3, __FILE__, __LINE__ )
00600                return
00601             endif
00602 #ifdef DEBUGX
00603             print *, ' returned index ', index
00604 #endif /* DEBUGX */
00605             index = index + (4-1)
00606 !
00607             call psmile_enddef_action (search, index, lstatus, ierror)
00608             if (ierror > 0) return
00609 !
00610          enddo ! while (paction%n_fin < paction%n_fin2recv .or. paction%n_selected > 0)
00611 !
00612 !===> Wait that all finish messages have been sent
00613 !
00614 #ifdef PRISM_with_MPI2
00615          call MPI_Waitall (paction%n_fin2recv, fin_requests, &
00616                            MPI_STATUSES_IGNORE, ierror)
00617 #else
00618          Allocate (statuses(MPI_STATUS_SIZE, paction%n_fin2recv), &
00619                    stat = ierror)
00620          if (ierror > 0) then
00621             ierrp (1) = ierror
00622             ierrp (2) = paction%n_fin2recv * MPI_STATUS_SIZE
00623 
00624             ierror = PRISM_Error_Alloc
00625             call psmile_error ( ierror, 'statuses', &
00626                                 ierrp, 2, __FILE__, __LINE__ )
00627             return
00628          endif
00629 
00630          call MPI_Waitall (paction%n_fin2recv, fin_requests, statuses, ierror)
00631 !
00632          Deallocate (statuses)
00633 #endif
00634 !
00635          if ( ierror /= MPI_SUCCESS ) then
00636             ierrp (1) = ierror
00637 
00638             ierror = PRISM_Error_MPI
00639 
00640             call psmile_error ( ierror, 'MPI_Waitall', &
00641                                 ierrp, 1, __FILE__, __LINE__ )
00642             return
00643          endif
00644 
00645          Deallocate (fin_requests)
00646 !
00647       endif ! paction%n_fin2recv > 0
00648 !
00649 !=======================================================================
00650 !     Free
00651 !=======================================================================
00652 !
00653       if (paction%n_answer2recv > 0) then
00654          Deallocate (paction%loc_messages)
00655       endif
00656 !
00657       Deallocate (paction%lrequest)
00658       Deallocate (paction%n_answer2recv_per_grid)
00659 !
00660 !===> All done
00661 !
00662 #ifdef DEBUG
00663 !
00664 !  Print send infos
00665 !
00666       do i = 1, Number_of_Methods_allocated
00667          if (Methods(i)%status  == PSMILe_status_defined) then
00668             call psmile_print_send_info (i, 0, 'end of psmile_get_intersect')
00669          endif
00670       end do
00671 #endif /* DEBUG */
00672 
00673 #ifdef VERBOSE
00674       print 9980, trim(ch_id), ierror
00675       call psmile_flushstd
00676 #endif /* VERBOSE */
00677 
00678 !
00679 !  Formats:
00680 !
00681 
00682 #ifdef VERBOSE
00683 
00684 9990 format (1x, a, ': psmile_get_intersect: ninter', i4, &
00685                     ', nmyint', i4, ', nnull', i4)
00686 9980 format (1x, a, ': psmile_get_intersect: eof ierror =', i3)
00687 
00688 #endif /* VERBOSE */
00689 
00690 #ifdef DEBUG
00691 9960 format (1x, a, ': psmile_get_intersect: calling waitany: n, ninter', 2i4, ';',&
00692             /2x,    'n_answer, n_answer2recv', 2i4, &
00693                     '; grid2receive ', l1, &
00694                     '; nloc_recv, nreq-num_req_types+1', 2i4, &
00695                     '; n_selected', i4)
00696 9950 format (1x, a, ': psmile_get_intersect: calling wait: n_fin, n_fin2recv', 2i4)
00697 #endif /* DEBUG */
00698       end subroutine PSMILe_get_intersect

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1