psmile_send_req_mask.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_Send_req_mask
00008 !
00009 ! !INTERFACE:
00010 
00011       subroutine psmile_send_req_mask (msg_intersections, &
00012                                        dest, tag, ierror)
00013 !
00014 ! !USES:
00015 !
00016       use PRISM_constants
00017 !
00018       use PSMILe, dummy_interface => PSMILe_Send_req_mask
00019 
00020       Implicit none
00021 !
00022 ! !INPUT PARAMETERS:
00023 !
00024       Type (enddef_msg_intersections), Intent (In) :: msg_intersections
00025 
00026 !     Contains the request for a subgrid.
00027 
00028       Integer, Intent (In)                         :: dest
00029 
00030 !     Specifies the sender of the request and the destination
00031 !     of the subgrid to be sent.
00032 
00033       Integer, Intent (In)                         :: tag
00034 
00035 !     Specifies the message tag used
00036 !
00037 ! !OUTPUT PARAMETERS:
00038 !
00039       Integer, Intent (Out)                        :: ierror
00040 
00041 !     Returns the error code of PSMILe_Send_req_mask;
00042 !             ierror = 0 : No error
00043 !             ierror > 0 : Severe error
00044 !
00045 ! !LOCAL VARIABLES
00046 !
00047 !     ... for the grid information
00048 !
00049       Integer                      :: grid_id
00050       Integer                      :: mask_id
00051 !
00052 !     ... for datatypes
00053 !
00054       Integer                      :: subarray_type
00055       Integer                      :: sizes (ndim_3d)
00056       Integer                      :: subsizes (ndim_3d)
00057       Integer                      :: starts (ndim_3d)
00058 !
00059 !     ... for the intersection
00060 !
00061       Integer                      :: inter (2, ndim_3d)
00062 !
00063       Integer                      :: ipart, npart
00064 !
00065 !     ... for error parameters
00066 !
00067       Integer, parameter           :: nerrp = 3
00068       Integer                      :: ierrp (nerrp)
00069 !
00070 ! !DESCRIPTION:
00071 !
00072 ! Subroutine "PSMILe_Send_req_mask" sends the mask requested
00073 ! to the destination process. The subgrid is sent after the corresponding
00074 ! request was received by routine "PSMILe_Get_intersect".
00075 !
00076 ! !REVISION HISTORY:
00077 !
00078 !   Date      Programmer   Description
00079 ! ----------  ----------   -----------
00080 ! 03.07.10    H. Ritzdorf  created
00081 !
00082 !EOP
00083 !----------------------------------------------------------------------
00084 !
00085 ! $Id: psmile_send_req_mask.F90 2787 2010-11-29 16:51:32Z hanke $
00086 ! $Author: hanke $
00087 !
00088    Character(len=len_cvs_string), save :: mycvs = 
00089        '$Id: psmile_send_req_mask.F90 2787 2010-11-29 16:51:32Z hanke $'
00090 !
00091 !----------------------------------------------------------------------
00092 !
00093 !  Initialization
00094 !
00095       ierror = 0
00096 
00097       npart     = msg_intersections%num_parts
00098       grid_id   = msg_intersections%tgt_grid_id
00099 !     field_id  = msg_intersections%first_tgt_var_id
00100 !     mask_id = Fields(field_id)%mask_id 
00101       mask_id   = msg_intersections%tgt_mask_id
00102 !
00103 #ifdef VERBOSE
00104       print 9990, trim(ch_id), grid_id, dest
00105 
00106       call psmile_flushstd
00107 #endif /* VERBOSE */
00108 
00109 #ifdef PRISM_ASSERTION
00110 
00111 !    Internal control: Is the data really available
00112 
00113       if (mask_id /= PRISM_UNDEFINED .and.          &
00114           (mask_id > Number_of_Masks_allocated .or. &
00115            mask_id < 1)) then
00116 !
00117          print *, trim(ch_id), ' method id, field_id, mask_id', &
00118                   msg_intersections%first_tgt_method_id,        &
00119                   msg_intersections%first_tgt_var_id,           &
00120                   msg_intersections%tgt_mask_id
00121          print *, trim(ch_id), ' original mask id', &
00122                                Fields(msg_intersections%first_tgt_var_id)%mask_id
00123          call psmile_assert ( __FILE__, __LINE__, &
00124                 'Mask id is out of range')
00125       endif
00126 
00127 #endif /* PRISM_ASSERTION */
00128 !
00129       if (mask_id /= PRISM_UNDEFINED) then
00130 !
00131          do ipart = 1, npart
00132 !
00133             inter = msg_intersections%intersections(ipart)%intersection
00134 !
00135 !===> Send Mask values
00136 !
00137             sizes (:) = Masks(mask_id)%mask_shape(2,:) -   &
00138                         Masks(mask_id)%mask_shape(1,:) + 1
00139 
00140             subsizes (:) = inter(2,:) - inter (1,:) + 1
00141 
00142             starts (:) = inter (1,:) - Masks(mask_id)%mask_shape(1,:)
00143 
00144 #if defined ( PRISM_with_MPI1 )
00145             call psmile_type_create_subarray (ndim_3d, sizes, subsizes, starts, &
00146                                           MPI_LOGICAL, subarray_type, ierror)
00147             if (ierror /= MPI_SUCCESS) then
00148                ierrp (1) = ierror
00149                ierror = PRISM_Error_MPI
00150 
00151                call psmile_error (ierror, 'PSMILe_Type_create_subarry', &
00152                                  ierrp, 1, __FILE__, __LINE__ )
00153                return
00154             endif
00155 #else
00156             call MPI_Type_create_subarray (ndim_3d, sizes, subsizes, starts, &
00157                                           MPI_ORDER_FORTRAN, MPI_LOGICAL, &
00158                                           subarray_type, ierror)
00159             if (ierror /= MPI_SUCCESS) then
00160                ierrp (1) = ierror
00161                ierror = PRISM_Error_MPI
00162 
00163                call psmile_error (ierror, 'MPI_Type_create_subarry', &
00164                                  ierrp, 1, __FILE__, __LINE__ )
00165                return
00166             endif
00167 #endif
00168 !
00169             call MPI_Type_commit (subarray_type, ierror)
00170             if (ierror /= MPI_SUCCESS) then
00171                ierrp (1) = ierror
00172                ierror = PRISM_Error_MPI
00173 
00174                call psmile_error ( ierror, 'MPI_Type_commit', &
00175                                  ierrp, 1, __FILE__, __LINE__ )
00176                return
00177             endif
00178 !
00179             call MPI_Send (Masks(mask_id)%mask_array, 1, subarray_type, &
00180                            dest, tag, comm_psmile, ierror)
00181             if (ierror /= MPI_SUCCESS) then
00182                ierrp (1) = ierror
00183                ierrp (2) = dest
00184                ierrp (3) = tag
00185                ierror = PRISM_Error_Send
00186 
00187                call psmile_error (ierror, 'MPI_Send', &
00188                                  ierrp, 3, __FILE__, __LINE__ )
00189                return
00190             endif
00191 !
00192             call MPI_type_free (subarray_type, ierror)
00193             if (ierror /= MPI_SUCCESS) then
00194                ierrp (1) = ierror
00195                ierror = PRISM_Error_MPI
00196 
00197                call psmile_error (ierror, 'MPI_Type_free', &
00198                                  ierrp, 1, __FILE__, __LINE__ )
00199                return
00200             endif
00201 !
00202          end do ! ipart
00203 
00204       else
00205 !
00206 !===> ... Send dummy request in order to get progress in psmile_get_intersect
00207 !
00208          call MPI_Send (mask_id, 0, MPI_LOGICAL, &
00209                         dest, tag, comm_psmile, ierror)
00210          if (ierror /= MPI_SUCCESS) then
00211             ierrp (1) = ierror
00212             ierrp (2) = dest
00213             ierrp (3) = tag
00214             ierror = PRISM_Error_Send
00215 
00216             call psmile_error (ierror, 'MPI_Send', &
00217                                ierrp, 3, __FILE__, __LINE__ )
00218             return
00219          endif
00220       endif ! (mask_id /= PRISM_UNDEFINED)
00221 !
00222 !===> All done
00223 !
00224 #ifdef VERBOSE
00225       print 9980, trim(ch_id), grid_id, ierror
00226 
00227       call psmile_flushstd
00228 #endif /* VERBOSE */
00229 !
00230 !  Formats:
00231 !
00232 9990 format (1x, a, ': psmile_send_req_mask: grid_id =', i3, &
00233                     '; dest =', i4)
00234 9980 format (1x, a, ': psmile_send_req_mask: eof grid_id =', i3, &
00235                     '; ierror =', i4)
00236 
00237       end subroutine PSMILe_Send_req_mask

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1