prism_get_localcomm.F90

Go to the documentation of this file.
00001 !-----------------------------------------------------------------------
00002 ! Copyright 2006-2010, CERFACS, Toulouse, France.
00003 ! Copyright 2006-2010, SGI Germany, Munich, Germany.
00004 ! Copyright 2006-2010, NEC Europe Ltd., London, UK.
00005 ! All rights reserved. Use is subject to OASIS4 license terms.
00006 !-----------------------------------------------------------------------
00007 !BOP
00008 !
00009 ! !ROUTINE: PRISM_Get_localcomm
00010 !
00011 ! !INTERFACE:
00012 
00013       subroutine prism_get_localcomm ( comp_id, local_comm, ierror )
00014 !
00015 ! !USES:
00016 !
00017       use PRISM, dummy_interface => PRISM_Get_localcomm
00018       use PSMILe
00019 
00020       implicit none
00021 
00022 !
00023 ! !INPUT PARAMETERS:
00024 !
00025       integer, intent(In)                 :: comp_id
00026 !
00027 ! !OUTPUT PARAMETERS:
00028 !
00029       integer, intent(Out)                :: ierror, local_comm
00030 
00031 ! ---------------------------------------------------------------------
00032 
00033 ! !LOCAL VARIABLES
00034 
00035       integer, parameter                  :: nerrp = 2
00036       integer, dimension (nerrp)          :: ierrp (nerrp)
00037 !
00038 ! !DESCRIPTION:
00039 !
00040 !     Provide Communicator - for component or application local communication
00041 !     This routine needs to be called only by MPI parallel codes to retrieve
00042 !     a local communicator 'local_comm' for internal MPI communication.
00043 
00044 !     If 'comp_id' argument is the component Id returned by routine
00045 !     prism_init_comp, 'local_comm' is a communicator gathering all
00046 !     component processes which called prism_init_comp with the same
00047 !     'comp_name' argument.
00048 !
00049 !     If instead of comp_id a predefined named integer PRISM_appl_id
00050 !     is provided, the returned local_comm is a communicator gathering
00051 !     all processes of the application.
00052 !
00053 ! !REVISION HISTORY:
00054 !
00055 !   Date      Programmer    Description
00056 ! ----------  -----------   -----------
00057 ! 03.12.01    H. Ritzdorf   created
00058 !
00059 !EOP
00060 !----------------------------------------------------------------------
00061 !
00062 ! $Id: prism_get_localcomm.F90 2687 2010-10-28 15:15:52Z coquart $
00063 ! $Author: coquart $
00064 !
00065   Character(len=len_cvs_string), save :: mycvs = 
00066       '$Id: prism_get_localcomm.F90 2687 2010-10-28 15:15:52Z coquart $'
00067 !
00068 !----------------------------------------------------------------------
00069 
00070 #ifdef VERBOSE
00071       print *, trim(ch_id), ': prism_get_localcomm: start'
00072       print *, trim(ch_id), ': prism_get_localcomm: comp_id =', comp_id
00073       call psmile_flushstd
00074 #endif /* VERBOSE */
00075 
00076       if ( .not. PRISM_is_initialized ) then
00077 
00078          ierror = PRISM_Error_Initialized
00079          ierrp (1) = comp_id
00080 
00081          call psmile_error (ierror, 'PRISM_Get_MPI_Comm', &
00082                             ierrp, 1, __FILE__, __LINE__)
00083          return
00084       endif
00085 
00086       ierror = 0
00087 
00088       if (comp_id == PRISM_Appl_id) then
00089          local_comm = Appl%comm_user
00090       else
00091 !
00092 !  Control Component id
00093 !
00094          if (comp_id < 1 .or. &
00095              comp_id > Number_of_Comps_allocated) then
00096 
00097             ierrp (1) = comp_id
00098             ierrp (2) = Number_of_Comps_allocated
00099 
00100             ierror = PRISM_Error_Arg
00101 
00102             call psmile_error ( ierror, 'comp_id', &
00103                                 ierrp, 2, __FILE__, __LINE__ )
00104             return
00105          endif
00106 !
00107          if (Comps(comp_id)%status == PSMILe_status_free) then
00108 
00109             ierrp (1) = comp_id
00110 
00111             ierror = PRISM_Error_Arg
00112 
00113             call psmile_error ( PRISM_Error_Arg, 'comp_id (not active)', &
00114                                 ierrp, 1, __FILE__, __LINE__ )
00115             return
00116          endif
00117 !
00118          local_comm = Comps(comp_id)%comm_user
00119       endif
00120 
00121 #ifdef PRISM_ASSERTION
00122       if (  local_comm == MPI_Comm_NULL ) then
00123         call psmile_assert ( __FILE__, __LINE__, &
00124           'returned communicator should be not MPI_COMM_NULL')
00125       endif
00126 #endif
00127 
00128 #ifdef VERBOSE
00129       print *, trim(ch_id), ': prism_get_localcomm: eof ierror =', &
00130                ierror, '; local_comm =', local_comm
00131 
00132       call psmile_flushstd
00133 #endif /* VERBOSE */
00134 
00135       end subroutine prism_get_localcomm

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1