00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 subroutine psmile_def_mpi_comm (ierror)
00012
00013
00014
00015 use PRISM_constants
00016 use PSMILe, dummy_interface => PSMILe_Def_MPI_Comm
00017
00018 implicit none
00019
00020
00021
00022 integer, Intent (Out) :: ierror
00023
00024
00025
00026
00027
00028
00029
00030 integer :: index
00031 integer :: key
00032 integer :: color
00033 integer :: comm
00034
00035 integer, parameter :: nerrp = 1
00036 integer :: ierrp (nerrp)
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 Character(len=len_cvs_string), save :: mycvs =
00064 '$Id: psmile_def_mpi_comm.F90 2325 2010-04-21 15:00:07Z valcke $'
00065
00066
00067
00068 #ifdef VERBOSE
00069 print *, trim(ch_id), ': PSMILe_Def_MPI_Comm: start'
00070
00071 call psmile_flushstd
00072 #endif /* VERBOSE */
00073
00074
00075
00076 if ( Appl%stand_alone ) then
00077
00078 comm_coupler = MPI_COMM_NULL
00079
00080 call MPI_Comm_dup ( comm_global, Appl%comm, ierror )
00081
00082 if ( ierror /= MPI_SUCCESS ) then
00083 ierrp (1) = ierror
00084 ierror = PRISM_Error_MPI
00085
00086 call psmile_error ( ierror, 'MPI_Comm_dup', &
00087 ierrp, 1, __FILE__, __LINE__ )
00088 return
00089 endif
00090
00091 else
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 print *, trim(ch_id), ': Colored application with ', &
00103 Appl%sequence_number
00104
00105 key = 0
00106 color = Appl%sequence_number
00107
00108 call MPI_Comm_Split ( comm_global, color, key, &
00109 Appl%comm, ierror )
00110
00111 if ( ierror /= MPI_SUCCESS ) then
00112 ierrp (1) = ierror
00113 ierror = PRISM_Error_MPI
00114
00115 call psmile_error ( ierror, 'MPI_Comm_Split', &
00116 ierrp, 1, __FILE__, __LINE__ )
00117 return
00118 endif
00119
00120
00121
00122
00123 do index = 1, noApplication
00124
00125
00126
00127 if ( index == Appl%sequence_number ) then
00128 color = index
00129 else
00130 color = MPI_UNDEFINED
00131 end if
00132
00133 if ( Appl%sequence_number == 0 ) color = index
00134
00135
00136
00137 call MPI_Comm_Split ( comm_global, color, key, &
00138 comm, ierror )
00139
00140 if ( ierror /= MPI_SUCCESS ) then
00141 ierrp (1) = ierror
00142 ierror = PRISM_Error_MPI
00143
00144 call psmile_error ( ierror, 'MPI_Comm_Split', &
00145 ierrp, 1, __FILE__, __LINE__ )
00146 return
00147 endif
00148
00149
00150
00151 if ( index == Appl%sequence_number ) then
00152
00153 comm_coupler = comm
00154
00155 call MPI_Comm_Rank ( comm_coupler, coupler_rank, ierror )
00156
00157 if ( ierror /= MPI_SUCCESS ) then
00158 ierrp (1) = ierror
00159 ierror = PRISM_Error_MPI
00160 call psmile_error ( ierror, 'MPI_Comm_Rank', &
00161 ierrp, 1, __FILE__, __LINE__ )
00162 return
00163 endif
00164
00165 endif
00166
00167 end do
00168
00169 endif
00170
00171
00172
00173
00174
00175 key = 0
00176 color = 1
00177
00178 call MPI_Comm_Split ( comm_global, color, key, &
00179 comm_psmile, ierror )
00180
00181 if ( ierror /= MPI_SUCCESS ) then
00182 ierrp (1) = ierror
00183 ierror = PRISM_Error_MPI
00184 call psmile_error ( ierror, 'MPI_Comm_Split', &
00185 ierrp, 1, __FILE__, __LINE__ )
00186 return
00187 endif
00188
00189
00190
00191
00192
00193 call MPI_Comm_dup ( Appl%comm, Appl%comm_user, ierror )
00194
00195 if ( ierror /= MPI_SUCCESS ) then
00196 ierrp (1) = ierror
00197 ierror = PRISM_Error_MPI
00198
00199 call psmile_error ( ierror, 'MPI_Comm_dup', &
00200 ierrp, 1, __FILE__, __LINE__ )
00201 return
00202 endif
00203
00204 call MPI_Comm_rank ( Appl%comm, Appl%rank, ierror )
00205
00206 if ( ierror /= MPI_SUCCESS ) then
00207 ierrp (1) = ierror
00208 ierror = PRISM_Error_MPI
00209
00210 call psmile_error ( ierror, 'MPI_Comm_rank', &
00211 ierrp, 1, __FILE__, __LINE__ )
00212 return
00213 endif
00214
00215 call MPI_Comm_size ( Appl%comm, Appl%size, ierror )
00216
00217 if ( ierror /= MPI_SUCCESS ) then
00218 ierrp (1) = ierror
00219 ierror = PRISM_Error_MPI
00220
00221 call psmile_error ( ierror, 'MPI_Comm_rank', &
00222 ierrp, 1, __FILE__, __LINE__ )
00223 return
00224 endif
00225
00226 #ifdef VERBOSE
00227 print *, trim(ch_id), ': PSMILe_Def_MPI_Comm: eof ierror =', ierror
00228
00229 call psmile_flushstd
00230 #endif /* VERBOSE */
00231
00232 end subroutine PSMILe_Def_MPI_Comm