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 2993 2011-02-25 10:34:50Z hanke $
00096 ! $Author: hanke $
00097 !
00098    Character(len=len_cvs_string), save :: mycvs = 
00099        '$Id: psmile_search_donor_extra.F90 2993 2011-02-25 10:34:50Z hanke $'
00100 !
00101 !----------------------------------------------------------------------
00102 !
00103 !  Initialization
00104 !
00105 #ifdef VERBOSE
00106       print 9990, trim(ch_id), search%msg_extra(5), 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(5)) exit
00121       enddo
00122 
00123       if (icomp > n_act_comp) then
00124          ierror = PRISM_Error_internal
00125          ierrp (1) = search%msg_extra(5)
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      global_var_id = search%msg_extra (6)
00155 !rr
00156 !rr         do var_id = 1, Number_of_Fields_allocated
00157 !rr         if (Fields(var_id)%global_var_id == global_var_id) exit
00158 !rr         end do
00159 !rr
00160       transi_id = search%msg_extra (6)
00161       grid_id = search%msg_extra (17)
00162 
00163 getv: do var_id = 1, Number_of_Fields_allocated
00164          if (Associated (Fields(var_id)%Taskout)) then
00165 
00166             if ( Methods(Fields(var_id)%method_id)%grid_id /= grid_id ) cycle
00167             Taskout => Fields(var_id)%Taskout
00168 
00169 #ifdef DEBUGX
00170             do j = 1, size (Taskout)
00171                print 9960, j, &
00172                        Taskout(j)%origin_type, &
00173                        Taskout(j)%remote_transi_id, &
00174                        Taskout(j)%global_transi_id, &
00175                        Taskout(j)%remote_comp_id
00176             enddo
00177 #endif
00178 
00179             do j = 1, size (Taskout)
00180                if ( Taskout(j)%global_transi_id == transi_id ) exit getv
00181             enddo
00182          endif
00183       enddo getv
00184 !
00185       if (var_id > Number_of_Fields_allocated) then
00186 ! user Fehler ? var_id nicht definiert ?
00187 ! ist immer trans_id == global_var_id ?
00188          print *, 'comp_id, global var_id OUT', comp_id, transi_id
00189 !
00190 #ifdef DEBUG
00191          do var_id = 1, Number_of_Fields_allocated
00192             if (Associated (Fields(var_id)%Taskout)) then
00193                Taskout => Fields(var_id)%Taskout
00194 
00195                do j = 1, size (Taskout)
00196                   print 9960, j, &
00197                        Taskout(j)%origin_type, &
00198                        Taskout(j)%remote_transi_id, &
00199                        Taskout(j)%global_transi_id, &
00200                        Taskout(j)%remote_comp_id
00201                end do
00202             endif
00203          enddo
00204 #endif
00205          ierror = PRISM_Error_Internal
00206          ierrp (1) = comp_id
00207          ierrp (2) = transi_id
00208 !
00209          call psmile_error ( ierror, "Cannot find field on this process", &
00210                              ierrp, 2, __FILE__, __LINE__ )
00211          return
00212          
00213       endif
00214 !
00215       if (Fields(var_id)%comp_id /= comp_id) then
00216          print *, 'comp_id, var_id', &
00217             comp_id, var_id, transi_id, Fields(var_id)%comp_id
00218          ierror = PRISM_Error_Internal
00219          ierrp (1) = comp_id
00220          ierrp (2) = transi_id
00221          ierrp (3) = Fields(var_id)%comp_id
00222          call psmile_error ( ierror, "Inconsitent components for field", &
00223                              ierrp, 2, __FILE__, __LINE__ )
00224          return
00225       endif
00226 !
00227       method_id = Fields(var_id)%method_id
00228 
00229 #ifdef PRISM_ASSERTION
00230 !
00231 !===> Speziell case: Gridless grid
00232 !
00233       if (Grids(grid_id)%grid_type == PRISM_Gridless) then
00234          print *, trim(ch_id), ": comp id, grid_id",  &
00235                   comp_id, grid_id
00236          call psmile_assert ( __FILE__, __LINE__, &
00237                               'Extra search not for Gridless Grids')
00238       endif
00239 #endif
00240 !
00241 ! =======================================================================
00242 !     Are global indices available on both parts
00243 ! =======================================================================
00244 !
00245       if (search%msg_extra (11) == 1 .and. &
00246           Associated (Grids(grid_id)%partition)) then
00247 
00248          call psmile_search_donor_extra_off (comp_infos(icomp), &
00249                      search, var_id, tol, ierror)
00250 #ifdef VERBOSE
00251          print 9980, trim(ch_id), grid_id, search%sender, ierror
00252          call psmile_flushstd
00253 #endif /* VERBOSE */
00254          return
00255       endif
00256 !
00257 ! =======================================================================
00258 !     Is this a nearest neighbour search
00259 ! =======================================================================
00260 !
00261       if (search%msg_extra(1) == PSMILe_nnghbr3D) then
00262 
00263          call psmile_search_donor_extra_nn (comp_infos(icomp), &
00264                      search, var_id, tol, ierror)
00265 #ifdef VERBOSE
00266          print 9980, trim(ch_id), grid_id, search%sender, ierror
00267          call psmile_flushstd
00268 #endif /* VERBOSE */
00269          return
00270       endif
00271 
00272 !
00273 ! here was a big chunk of code for a local search. I removed it, because it was not used (see r2993)
00274 !
00275 
00276       ierror = PRISM_Error_Internal
00277       call psmile_error ( ierror, 'Global search currently support only if partition info is available', &
00278                         ierrp, 0, __FILE__, __LINE__ )
00279 !
00280 !===> All done
00281 !
00282 #ifdef VERBOSE
00283       print 9980, trim(ch_id), grid_id, search%sender, ierror
00284       call psmile_flushstd
00285 #endif /* VERBOSE */
00286 !
00287 !  Formats:
00288 !
00289 9990 format (1x, a, ': psmile_search_donor_extra: global comp_id =', i3, &
00290                     '; sender =', i4)
00291 9980 format (1x, a, ': psmile_search_donor_extra: eof grid id =', i3, &
00292                     '; sender =', i3, ', ierror =', i4)
00293 
00294 #ifdef DEBUG
00295 9960 format (1x, 'Taskout%In_channel(', i3, '): origin_type', i5, &
00296                  ', remote_transi_id', i4, &
00297                  ', global_transi_id', i4, ', remote_comp_id', i4)
00298 #endif
00299 
00300       end subroutine PSMILe_Search_donor_extra

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1