00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 subroutine psmile_def_mpi_compcomm ( ierror )
00012
00013
00014
00015 use PRISM_constants
00016 use PSMILe, dummy_interface => PSMILe_Def_MPI_CompComm
00017
00018 implicit none
00019
00020
00021
00022 Integer, Intent (Out) :: ierror
00023
00024
00025
00026
00027
00028
00029
00030 integer :: noRankset
00031 integer :: my_rank, my_size
00032 integer :: comp_rank, min_rank, max_rank, inc_rank
00033 integer :: color
00034 integer :: key
00035 integer :: i
00036 integer :: comp_index, n_comps
00037 integer :: rankset_index
00038
00039 Integer, parameter :: nerrp = 2
00040 Integer :: ierrp (nerrp)
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 Character(len=len_cvs_string), save :: mycvs =
00060 '$Id: psmile_def_mpi_compcomm.F90 2325 2010-04-21 15:00:07Z valcke $'
00061
00062
00063
00064 #ifdef VERBOSE
00065 print *, trim(ch_id), ': PSMILe_Def_MPI_CompComm: start'
00066
00067 call psmile_flushstd
00068 #endif /* VERBOSE */
00069
00070
00071
00072
00073
00074 call MPI_Comm_Rank ( Appl%comm, my_rank, ierror )
00075
00076 if ( ierror /= MPI_SUCCESS ) then
00077 ierrp (1) = ierror
00078 ierror = PRISM_Error_MPI
00079
00080 call psmile_error ( ierror, 'MPI_Comm_Rank', &
00081 ierrp, 1, __FILE__, __LINE__ )
00082 return
00083 endif
00084
00085 call MPI_Comm_Size ( Appl%comm, my_size, ierror )
00086
00087 if ( ierror /= MPI_SUCCESS ) then
00088 ierrp (1) = ierror
00089 ierror = PRISM_Error_MPI
00090
00091 call psmile_error ( ierror, 'MPI_Comm_Rank', &
00092 ierrp, 1, __FILE__, __LINE__ )
00093 return
00094 endif
00095
00096 comp_index = 1
00097
00098 do i = 2, Appl%sequence_number
00099 comp_index = comp_index + PRISM_noCompsPerAppl(i-1)
00100 enddo
00101
00102 rankset_index = 1
00103
00104 do i = 2, comp_index
00105 rankset_index = rankset_index + PRISM_compRankSets(i-1)
00106 enddo
00107
00108
00109
00110
00111
00112 n_comps = PRISM_noCompsPerAppl(Appl%sequence_number)
00113
00114 Comps(1:n_comps)%comm = MPI_COMM_NULL
00115 Comps(1:n_comps)%comm_user = MPI_COMM_NULL
00116
00117 do i = 1, n_comps
00118 key = 0
00119 ierror = 0
00120
00121
00122
00123
00124
00125
00126 do noRankset = rankset_index, rankset_index + PRISM_compRankSets(i) - 1
00127
00128 min_rank = PRISM_rankSets (noRankset,1)
00129 max_rank = PRISM_rankSets (noRankset,2)
00130 inc_rank = PRISM_rankSets (noRankset,3)
00131
00132 color = 0
00133
00134 do comp_rank = min_rank, max_rank, inc_rank
00135
00136 if ( comp_rank > my_size - 1 ) then
00137
00138 ierrp (1) = comp_rank
00139 ierrp (2) = my_size - 1
00140 ierror = PRISM_Error_Parameter
00141
00142 call psmile_error ( ierror, 'nbr_procs comming from SCC', &
00143 ierrp, 2, __FILE__, __LINE__ )
00144 return
00145
00146 endif
00147
00148 if ( comp_rank == my_rank ) color = 1
00149
00150 enddo
00151
00152 enddo
00153
00154 call MPI_Comm_Split ( Appl%comm, color, key, Comps(i)%comm, ierror )
00155
00156 if ( ierror /= MPI_SUCCESS ) then
00157 ierrp (1) = ierror
00158 ierror = PRISM_Error_MPI
00159
00160 call psmile_error ( ierror, 'MPI_Comm_Split', &
00161 ierrp, 1, __FILE__, __LINE__ )
00162 return
00163 endif
00164
00165 #ifdef PRISM_ASSERTION
00166 if ( Comps(i)%comm == MPI_COMM_NULL ) then
00167 call psmile_assert ( __FILE__, __LINE__, &
00168 'Null Communicator generated')
00169 endif
00170 #endif /* PRISM_ASSERTION */
00171
00172 call MPI_Comm_dup ( Comps(i)%comm, Comps(i)%comm_user, ierror )
00173
00174 if ( ierror /= MPI_SUCCESS ) then
00175 ierrp (1) = ierror
00176 ierror = PRISM_Error_MPI
00177
00178 call psmile_error ( ierror, 'MPI_Comm_dup', &
00179 ierrp, 1, __FILE__, __LINE__ )
00180 return
00181 endif
00182
00183 enddo
00184
00185 #ifdef VERBOSE
00186 print *, trim(ch_id), ': PSMILe_Def_MPI_CompComm: eof ierror =', ierror
00187
00188 call psmile_flushstd
00189 #endif /* VERBOSE */
00190
00191 end subroutine PSMILe_Def_MPI_CompComm