prismdrv_def_mpi_comm.F90

Go to the documentation of this file.
00001 !------------------------------------------------------------------------
00002 ! Copyright 2006-2010, CERFACS, Toulouse, France.
00003 ! Copyright 2006-2010, NEC Europe Ltd., London, UK.
00004 ! All rights reserved. Use is subject to OASIS4 license terms.
00005 !-----------------------------------------------------------------------
00006 !BOP
00007 !
00008 ! !ROUTINE: PRISMDrv_Def_MPI_Comm
00009 !
00010 ! !INTERFACE
00011 subroutine prismdrv_def_mpi_comm (id_err)
00012 
00013 !
00014 ! !USES:
00015 !
00016   USE PRISMDrv, dummy_interface => PRISMDrv_Def_MPI_Comm
00017 !
00018   IMPLICIT NONE
00019 !
00020 ! !PARAMETERS:
00021 !
00022 
00023 !
00024 ! ! RETURN VALUE
00025 !
00026   INTEGER, INTENT (Out)               :: id_err
00027 
00028 ! !DESCRIPTION
00029 ! Subroutines "PRISMDrv_Def_mpi_comm" establishes basic communicators
00030 ! for code local and application-communication.
00031 !
00032 ! !REVISED HISTORY
00033 !   Date      Programmer   Description
00034 ! ----------  ----------   -----------
00035 ! 04/10/2002  R. Redler    Creation
00036 ! 25/11/2002  D. Declat    Merge with driver implementation
00037 ! EOP
00038 !----------------------------------------------------------------------
00039 ! $Id: prismdrv_def_mpi_comm.F90 2325 2010-04-21 15:00:07Z valcke $
00040 ! $Author: valcke $
00041 !----------------------------------------------------------------------
00042 !
00043 ! 0. Local declarations
00044 !
00045   CHARACTER(LEN=len_cvs_string), SAVE  :: mycvs = 
00046      '$Id: prismdrv_def_mpi_comm.F90 2325 2010-04-21 15:00:07Z valcke $'
00047 
00048   INTEGER                             :: index
00049   INTEGER                             :: key
00050   INTEGER                             :: color
00051   INTEGER                             :: comm
00052   
00053   INTEGER, PARAMETER :: nerrp = 1
00054   INTEGER            :: ierrp (nerrp)
00055 
00056 ! ---------------------------------------------------------------------
00057 !
00058 #ifdef VERBOSE
00059   PRINT *, '| | Enter PRISMDrv_Def_mpi_comm'
00060   call psmile_flushstd
00061 #endif
00062 ! a) Initialization
00063 ! -----------------
00064 
00065 ! b) Construct communicator for code local communication
00066 ! ------------------------------------------------------
00067 
00068   key   = 0
00069   color = 0
00070   
00071   CALL MPI_Comm_Split ( comm_drv_global, color, key, comm_drv_local, id_err )
00072 
00073   IF ( id_err /= MPI_SUCCESS ) THEN
00074       ierrp (1) = id_err
00075       id_err = PRISM_Error_MPI
00076       
00077       call psmile_error_common ( id_err, 'MPI_Comm_Split', &
00078          ierrp, 1, __FILE__, __LINE__ )
00079       RETURN
00080   ENDIF
00081 
00082 ! c)  Construct communicator for communication between coupler and application
00083 ! ----------------------------------------------------------------------------
00084 
00085   DO INDEX = 1, ig_nb_appl
00086 
00087 ! i.)  Set one color for each pair [application(index), coupler]
00088 
00089     key   = 0
00090     color = INDEX
00091 
00092 ! ii.) Generate a communicator for each pair
00093 
00094     CALL MPI_Comm_Split ( comm_drv_global, color, key, comm, id_err )
00095 
00096     IF ( id_err /= MPI_SUCCESS ) THEN
00097         ierrp (1) = id_err
00098         id_err = PRISM_Error_MPI
00099       
00100         call psmile_error_common ( id_err, 'MPI_Comm_Split', &
00101            ierrp, 1, __FILE__, __LINE__ )
00102         RETURN
00103     ENDIF
00104 
00105 ! iii.) Save the communicator for communication from application to coupler
00106 
00107     comm_coupling(index) = comm
00108 
00109     CALL MPI_Comm_Rank ( comm_coupling(index), driver_rank, id_err )
00110 
00111     IF ( id_err /= MPI_SUCCESS ) THEN
00112         ierrp (1) = id_err
00113         id_err = PRISM_Error_MPI
00114       
00115         call psmile_error_common ( id_err, 'MPI_Comm_Rank', &
00116            ierrp, 1, __FILE__, __LINE__ )
00117         RETURN
00118     ENDIF
00119 
00120   END DO
00121 
00122 
00123 ! d)  Construct a communicator comm_psmile containing all MPI processes
00124 !     which are connected to the PSMILe library
00125 ! ----------------------------------------------------------------------------
00126 
00127   key   = 0
00128   color = MPI_UNDEFINED
00129 
00130   CALL MPI_Comm_Split ( comm_drv_global, color, key,  &
00131      comm_psmile, id_err )
00132   
00133   IF ( id_err /= MPI_SUCCESS ) THEN
00134       ierrp (1) = id_err
00135       id_err = PRISM_Error_MPI
00136       
00137       call psmile_error_common ( id_err, 'MPI_Comm_Split', &
00138          ierrp, 1, __FILE__, __LINE__ )
00139       RETURN
00140   ENDIF
00141 !
00142 ! ---------------------------------------------------------------------
00143 !
00144 #ifdef VERBOSE
00145   PRINT *, '| | Quit PRISMDrv_Def_MPI_Comm'
00146   call psmile_flushstd
00147 #endif
00148 END SUBROUTINE PRISMDrv_Def_MPI_Comm
00149 
00150 

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1