psmile_search_donor_extra.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_Search_
00008 !
00009 ! !INTERFACE:
00010 
00011       subroutine psmile_search_donor_extra (search, tol, ierror)
00012 !
00013 ! !USES:
00014 !
00015       use PRISM
00016 !
00017       use PSMILe, dummy_interface => PSMILe_Search_donor_extra
00018 
00019       implicit none
00020 !
00021 ! !INPUT PARAMETERS:
00022 !
00023 !     Integer, Intent (In)                :: tag
00024 !
00025 !     Specifies the message tag used
00026 
00027       Double Precision, Intent (In)       :: tol
00028 
00029 !     Absolute tolerance for search of "identical" points
00030 !     TOL >= 0.0
00031 
00032 !
00033 ! !INPUT/OUTPUT PARAMETERS:
00034 !
00035       Type (Enddef_global_search), Intent (InOut) :: search
00036 
00037 !     Data on the points to be searched
00038 !
00039 ! !OUTPUT PARAMETERS:
00040 !
00041       Integer,              Intent (Out)   :: ierror
00042 
00043 !     Returns the error code of PSMILe_Search_donor_extra;
00044 !             ierror = 0 : No error
00045 !             ierror > 0 : Severe error
00046 !
00047 ! !LOCAL VARIABLES
00048 !
00049       Real                         :: rtol
00050 #if defined ( PRISM_QUAD_TYPE )
00051       Real (kind=PRISM_QUAD_TYPE)  :: qtol
00052 #endif
00053 !
00054 !     ... for grids and components
00055 !
00056 ! comp_id = Component Id of the component in which the donor cells
00057 !           should be searched.
00058 !
00059       Integer                      :: comp_id, grid_id
00060       Integer                      :: icomp
00061 !
00062 !     ... for fields
00063 !
00064       Integer                      :: j
00065       Integer                      :: var_id
00066       Integer                      :: transi_id
00067       Type (Taskout_type), Pointer :: Taskout(:)
00068 !
00069 !     ... methods searched
00070 !
00071       Integer                      :: method_id
00072 !
00073 !     ... for error parameters
00074 !
00075       Integer, parameter           :: nerrp = 3
00076       Integer                      :: ierrp (nerrp)
00077 !
00078 ! !DESCRIPTION:
00079 !
00080 ! Subroutine "PSMILe_Search_donor_extra" perfoms the additional (global)
00081 ! search for coordinates sent by the requesting process.
00082 !
00083 !
00084 ! !REVISION HISTORY:
00085 !
00086 !   Date      Programmer   Description
00087 ! ----------  ----------   -----------
00088 ! 2003-07-21  H. Ritzdorf  created
00089 ! 2011-02-25  M. Hanke     cleanup of code that was
00090 !                          supposed to be used in the future
00091 !
00092 !EOP
00093 !----------------------------------------------------------------------
00094 !
00095 ! $Id: psmile_search_donor_extra.F90 3112 2011-04-07 15:03:18Z hanke $
00096 ! $Author: hanke $
00097 !
00098    Character(len=len_cvs_string), save :: mycvs = 
00099        '$Id: psmile_search_donor_extra.F90 3112 2011-04-07 15:03:18Z hanke $'
00100 !
00101 !----------------------------------------------------------------------
00102 !
00103 !  Initialization
00104 !
00105 #ifdef VERBOSE
00106       print 9990, trim(ch_id), search%msg_extra%global_comp_id, search%sender
00107 
00108       call psmile_flushstd
00109 #endif /* VERBOSE */
00110 
00111       rtol = tol
00112 
00113 #if defined ( PRISM_QUAD_TYPE )
00114       qtol = tol
00115 #endif
00116 
00117 !     Search global comp_id in comp_infos
00118 
00119       do icomp = 1, n_act_comp
00120          if (comp_infos(icomp)%global_comp_id == search%msg_extra%global_comp_id) exit
00121       enddo
00122 
00123       if (icomp > n_act_comp) then
00124          ierror = PRISM_Error_internal
00125          ierrp (1) = search%msg_extra%global_comp_id
00126          ierrp (2) = n_act_comp
00127 
00128          call psmile_error ( ierror, &
00129                             'Cannot found global comp_id in active components', &
00130                              ierrp, 2, __FILE__, __LINE__ )
00131          return
00132       endif
00133 
00134       comp_id = comp_infos(icomp)%comp_id
00135 
00136 #ifdef PRISM_ASSERTION
00137 !
00138 !===> Internal control
00139 !
00140       if (comp_id < 1 .or. &
00141           comp_id > Number_of_Comps_allocated .or. &
00142           Comps(comp_id)%status /= PSMILe_status_defined) then
00143 
00144           print *, trim(ch_id), ": comp id =",         &
00145                    comp_id, Number_of_Comps_allocated, &
00146                    Comps(comp_id)%status
00147           call psmile_assert ( __FILE__, __LINE__, &
00148                               'invalid comp id')
00149       endif
00150 #endif
00151 !
00152 !===> Search Field with the global var Id
00153 !
00154 !rr
00155 !rr         do var_id = 1, Number_of_Fields_allocated
00156 !rr         if (Fields(var_id)%global_var_id == global_var_id) exit
00157 !rr         end do
00158 !rr
00159       transi_id = search%msg_extra%transi_out_id
00160       grid_id   = search%msg_extra%local_grid_id
00161 
00162 getv: do var_id = 1, Number_of_Fields_allocated
00163          if (Associated (Fields(var_id)%Taskout)) then
00164 
00165             if ( Methods(Fields(var_id)%method_id)%grid_id /= grid_id ) cycle
00166             Taskout => Fields(var_id)%Taskout
00167 
00168 #ifdef DEBUGX
00169             do j = 1, size (Taskout)
00170                print 9960, j, &
00171                        Taskout(j)%origin_type, &
00172                        Taskout(j)%remote_transi_id, &
00173                        Taskout(j)%global_transi_id, &
00174                        Taskout(j)%remote_comp_id
00175             enddo
00176 #endif
00177 
00178             do j = 1, size (Taskout)
00179                if ( Taskout(j)%global_transi_id == transi_id ) exit getv
00180             enddo
00181          endif
00182       enddo getv
00183 !
00184       if (var_id > Number_of_Fields_allocated) then
00185 ! user Fehler ? var_id nicht definiert ?
00186 ! ist immer trans_id == global_var_id ?
00187          print *, 'comp_id, global var_id OUT', comp_id, transi_id
00188 !
00189 #ifdef DEBUG
00190          do var_id = 1, Number_of_Fields_allocated
00191             if (Associated (Fields(var_id)%Taskout)) then
00192                Taskout => Fields(var_id)%Taskout
00193 
00194                do j = 1, size (Taskout)
00195                   print 9960, j, &
00196                        Taskout(j)%origin_type, &
00197                        Taskout(j)%remote_transi_id, &
00198                        Taskout(j)%global_transi_id, &
00199                        Taskout(j)%remote_comp_id
00200                end do
00201             endif
00202          enddo
00203 #endif
00204          ierror = PRISM_Error_Internal
00205          ierrp (1) = comp_id
00206          ierrp (2) = transi_id
00207 !
00208          call psmile_error ( ierror, "Cannot find field on this process", &
00209                              ierrp, 2, __FILE__, __LINE__ )
00210          return
00211          
00212       endif
00213 !
00214       if (Fields(var_id)%comp_id /= comp_id) then
00215          print *, 'comp_id, var_id', &
00216             comp_id, var_id, transi_id, Fields(var_id)%comp_id
00217          ierror = PRISM_Error_Internal
00218          ierrp (1) = comp_id
00219          ierrp (2) = transi_id
00220          ierrp (3) = Fields(var_id)%comp_id
00221          call psmile_error ( ierror, "Inconsitent components for field", &
00222                              ierrp, 2, __FILE__, __LINE__ )
00223          return
00224       endif
00225 !
00226       method_id = Fields(var_id)%method_id
00227 
00228 #ifdef PRISM_ASSERTION
00229 !
00230 !===> Speziell case: Gridless grid
00231 !
00232       if (Grids(grid_id)%grid_type == PRISM_Gridless) then
00233          print *, trim(ch_id), ": comp id, grid_id",  &
00234                   comp_id, grid_id
00235          call psmile_assert ( __FILE__, __LINE__, &
00236                               'Extra search not for Gridless Grids')
00237       endif
00238 #endif
00239 !
00240 ! =======================================================================
00241 !     Are global indices available on both parts
00242 ! =======================================================================
00243 !
00244       if (search%msg_extra%partition_avail .and. &
00245           Associated (Grids(grid_id)%partition)) then
00246 
00247          call psmile_search_donor_extra_off (comp_infos(icomp), &
00248                      search, var_id, tol, ierror)
00249 #ifdef VERBOSE
00250          print 9980, trim(ch_id), grid_id, search%sender, ierror
00251          call psmile_flushstd
00252 #endif /* VERBOSE */
00253          return
00254       endif
00255 !
00256 ! =======================================================================
00257 !     Is this a nearest neighbour search
00258 ! =======================================================================
00259 !
00260       if (search%msg_extra%reqest_type == PSMILe_nnghbr3D) then
00261 
00262          call psmile_search_donor_extra_nn (comp_infos(icomp), &
00263                      search, var_id, tol, ierror)
00264 #ifdef VERBOSE
00265          print 9980, trim(ch_id), grid_id, search%sender, ierror
00266          call psmile_flushstd
00267 #endif /* VERBOSE */
00268          return
00269       endif
00270 
00271 !
00272 ! here was a big chunk of code for a local search. I removed it, because it was not used (see r2993)
00273 !
00274 
00275       ierror = PRISM_Error_Internal
00276       call psmile_error ( ierror, 'Global search currently support only if partition info is available', &
00277                         ierrp, 0, __FILE__, __LINE__ )
00278 !
00279 !===> All done
00280 !
00281 #ifdef VERBOSE
00282       print 9980, trim(ch_id), grid_id, search%sender, ierror
00283       call psmile_flushstd
00284 #endif /* VERBOSE */
00285 !
00286 !  Formats:
00287 !
00288 9990 format (1x, a, ': psmile_search_donor_extra: global comp_id =', i3, &
00289                     '; sender =', i4)
00290 9980 format (1x, a, ': psmile_search_donor_extra: eof grid id =', i3, &
00291                     '; sender =', i3, ', ierror =', i4)
00292 
00293 #ifdef DEBUG
00294 9960 format (1x, 'Taskout%In_channel(', i3, '): origin_type', i5, &
00295                  ', remote_transi_id', i4, &
00296                  ', global_transi_id', i4, ', remote_comp_id', i4)
00297 #endif
00298 
00299       end subroutine PSMILe_Search_donor_extra

Generated on 1 Dec 2011 for Oasis4 by  doxygen 1.6.1