psmile_locations_direct.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_Locations_direct
00008 !
00009 ! !INTERFACE:
00010 
00011       subroutine psmile_locations_direct (control, global, search, method_id, &
00012                                           dir_index, ierror)
00013 !
00014 ! !USES:
00015 !
00016       use PRISM_constants
00017 !
00018       use PSMILe, dummy_interface => PSMILe_Locations_direct
00019 
00020       implicit none
00021 !
00022 ! !INPUT PARAMETERS:
00023 
00024       Type (Enddef_search), Intent (InOut) :: search
00025 
00026 !     Info's on coordinates to be searched
00027 !
00028       Integer,              Intent (In)    :: control (2, ndim_3d, search%npart)
00029 
00030 !     Local Index range found
00031 !
00032       Integer,              Intent (In)    :: global (2, ndim_3d, search%npart)
00033 
00034 !     Global Index range found
00035 !
00036       Integer,              Intent (In)    :: method_id
00037 
00038 !     Method id of donor cells (on this process)
00039 
00040 ! !OUTPUT PARAMETERS:
00041 !
00042       Integer,              Intent (Out)   :: dir_index
00043 
00044 !     Send index if data has to be directly transferred to the
00045 !     destination process.
00046 !     PRISM_undefined, if no data has to be sent.
00047 !
00048       Integer,              Intent (Out)   :: ierror
00049 
00050 !     Returns the error code of PSMILe_Locations_direct;
00051 !             ierror = 0 : No error
00052 !             ierror > 0 : Severe error
00053 !
00054 ! !LOCAL PARAMETERS
00055 !
00056 ! val_direct  = Code for locations which should to be directly transferred
00057 !               to the destination process.
00058 !
00059       Integer, Parameter              :: val_direct  =  1
00060 !
00061       Integer, Parameter              :: send_direct_index  = 2
00062 !
00063 ! !LOCAL VARIABLES
00064 !
00065 !     ... Method pointer
00066 !
00067       Type (Method), Pointer          :: mp
00068        
00069 !
00070 !     ... for locations to be stored and transferred
00071 !
00072       Type(Send_information), Pointer :: send_info
00073 !
00074       Integer                         :: ndir, index
00075 !
00076 !     ... for partitions
00077 !
00078       Integer                         :: ipart, i0
00079 !
00080 !     ... for error handling
00081 !
00082       Integer, Parameter              :: nerrp = 2
00083       Integer                         :: ierrp (nerrp)
00084 !
00085 ! !DESCRIPTION:
00086 !
00087 ! Subroutine "PSMILe_Locations_direct" stores the data on locations
00088 ! to be sent and received (on target process) for grids of type
00089 ! "PRISM_Gridless". Grids of type "PRISM_Gridless" are transferring the
00090 ! data always directly between the MPI processes.
00091 !
00092 ! !REVISION HISTORY:
00093 !
00094 !   Date      Programmer   Description
00095 ! ----------  ----------   -----------
00096 ! 03.07.21    H. Ritzdorf  created
00097 !
00098 !EOP
00099 !----------------------------------------------------------------------
00100 !
00101 !  $Id: psmile_locations_direct.F90 2788 2010-11-30 14:34:07Z hanke $
00102 !  $Author: hanke $
00103 !
00104    Character(len=len_cvs_string), save :: mycvs = 
00105        '$Id: psmile_locations_direct.F90 2788 2010-11-30 14:34:07Z hanke $'
00106 !
00107 !----------------------------------------------------------------------
00108 !
00109 !  Initialization
00110 !
00111 #ifdef VERBOSE
00112       print 9990, trim(ch_id), method_id, search%msg_intersections%first_tgt_method_id, &
00113                                search%sender
00114 
00115       call psmile_flushstd
00116 #endif /* VERBOSE */
00117 !
00118       ierror = 0
00119 !
00120       dir_index = PRISM_undefined
00121       mp => Methods(method_id)
00122 !
00123 #ifdef PRISM_ASSERTION
00124       if ( mp%status == PSMILe_Status_free .or. &
00125            mp%status == PSMILe_Status_undefined ) then
00126          call psmile_assert (__FILE__, __LINE__, "Incorrect method")
00127       endif
00128 #endif
00129 #ifdef PRISM_ASSERTION_WRONG
00130          !
00131          ! This search%range contains local indices and is not
00132          ! what is contained in search%msg_intersections, from where
00133          ! psmile_search_donor_gridless extracts the data
00134          ! to fill in the inter(section) array.
00135          ! In contrast, the search%range is filled in
00136          ! psmile_recv_req_subgrid.
00137          !
00138          do ipart = 1, search%npart
00139          if (global (1,1,ipart) < search%range (1,1,ipart) .or. &
00140              global (2,1,ipart) > search%range (2,1,ipart) .or. &
00141              global (1,2,ipart) < search%range (1,2,ipart) .or. &
00142              global (2,2,ipart) > search%range (2,2,ipart) .or. &
00143              global (1,3,ipart) < search%range (1,3,ipart) .or. &
00144              global (2,3,ipart) > search%range (2,3,ipart) ) then
00145              print *, ' ipart ', ipart
00146              print *, ' globl ', global (:,:,ipart)
00147              print *, ' range ', search%range (:,:,ipart)
00148              print *, ' contl ', control (:,:,ipart)
00149              call psmile_assert (__FILE__, __LINE__, "control is out of range")
00150          endif
00151          end do ! ipart
00152 #endif
00153 !
00154       ndir = 0
00155          do ipart = 1, search%npart
00156          ndir = ndir +                                    &
00157                 (control(2,1,ipart)-control(1,1,ipart)+1) &
00158               * (control(2,2,ipart)-control(1,2,ipart)+1) &
00159               * (control(2,3,ipart)-control(1,3,ipart)+1)
00160          end do
00161 !
00162 !----------------------------------------------------------------------------
00163 !     Generate send areas for data exchange with application process
00164 !----------------------------------------------------------------------------
00165 !
00166       if (ndir > 0) then
00167 !
00168         call psmile_get_info_index (method_id, send_direct_index, index, ierror)
00169         if (ierror > 0) return
00170 !
00171         dir_index = index
00172         send_info => mp%send_infos_direct(index)
00173 !
00174         send_info%dest   = search%sender
00175         send_info%nvec   = 1
00176         send_info%nparts = 1
00177         send_info%nloc   = ndir ! total number of locations
00178 !
00179         send_info%nrecv    = 0
00180         send_info%num2recv = 0
00181 !
00182         send_info%remote_method_id = search%msg_intersections%first_tgt_method_id
00183 !
00184 !       ... generate send areas for direct data exchange
00185 !
00186         call psmile_locations_alloc (send_info, ierror)
00187         if (ierror > 0) return
00188 !
00189 !       Allocate dummy "srcloc" vector (for a single point) in order
00190 !       to avoid problems with some runtime systems/compilers
00191 !
00192         Allocate (send_info%srclocs(1,1)%vector(ndim_3d), &
00193                   STAT = ierror)
00194         if ( ierror > 0 ) then
00195             ierrp (1) = ierror
00196             ierrp (2) = ndim_3d
00197 
00198             ierror = PRISM_Error_Alloc
00199 
00200             call psmile_error ( ierror, 'send_info%srclocs(1,1)%vector', &
00201                                 ierrp, 2, __FILE__, __LINE__ )
00202             return
00203         endif
00204 !
00205 !       Store all "search%nparts" partitions as "search%nparts" areas
00206 !
00207         Allocate (send_info%srcars(1,1)%vector(2*ndim_3d*search%npart), &
00208                   send_info%dstars(2,ndim_3d,search%npart), &
00209                   STAT = ierror)
00210         if ( ierror > 0 ) then
00211             ierrp (1) = ierror
00212             ierrp (2) = 2*ndim_3d * search%npart
00213 
00214             ierror = PRISM_Error_Alloc
00215 
00216             call psmile_error ( ierror, 'send_info%srcars(1,1)%vector', &
00217                                 ierrp, 2, __FILE__, __LINE__ )
00218             return
00219         endif
00220 !
00221 !       ... Store data for sending process
00222 !
00223         send_info%nars(1, 1) = search%npart
00224 !
00225            do ipart = 1, search%npart
00226            i0 = (ipart-1)*2*ndim_3d
00227 !
00228            send_info%srcars(1,1)%vector(i0+1) = control (1, 1, ipart)
00229            send_info%srcars(1,1)%vector(i0+2) = control (2, 1, ipart)
00230            send_info%srcars(1,1)%vector(i0+3) = control (1, 2, ipart)
00231            send_info%srcars(1,1)%vector(i0+4) = control (2, 2, ipart)
00232            send_info%srcars(1,1)%vector(i0+5) = control (1, 3, ipart)
00233            send_info%srcars(1,1)%vector(i0+6) = control (2, 3, ipart)
00234 !
00235            end do ! ipart
00236 !
00237 !       ... Store areas in GLOBAL indices of destination process
00238 !           Note: Has to be transferred in local indices in target process.
00239 !
00240         send_info%dstars (:, :, :) = global (: , :, :)
00241 !
00242       endif
00243 !
00244 !===> All done
00245 !
00246 #ifdef VERBOSE
00247       print 9980, trim(ch_id), ierror, dir_index
00248 
00249       call psmile_flushstd
00250 #endif /* VERBOSE */
00251 !
00252 !  Formats:
00253 !
00254 
00255 #ifdef VERBOSE
00256 
00257 9990 format (1x, a, ': psmile_locations_direct: method_id', i3, &
00258                     ' to ', i3, '(', i2, ')')
00259 9980 format (1x, a, ': psmile_locations_direct: eof ierror =', i3, &
00260                     '; dir_index', i7)
00261 
00262 #endif /* VERBOSE */
00263 
00264       end subroutine PSMILe_Locations_direct

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1