33 integer :: mpi_err,mdl_id,cpl_root,cpl_mpi_comm
35 call mpi_finalize(mpi_err)
40 integer,
intent(out) :: mdl_id,cpl_root,cpl_mpi_comm
41 integer :: mdl_num_proc=1
42 integer :: mpi_err,world_size,world_id
44 integer :: particle_id,nens, da, nda
45 integer :: mdl_mpi_comm,mdlcolour
46 integer :: tmp_mdls_comm,models_id,models_size
47 call mpi_init(mpi_err)
48 if(mpi_err .eq. 0)
then
49 print*,
'mpi_init successful'
51 print*,
'mpi_init unsuccessful'
55 call mpi_comm_rank(mpi_comm_world,world_id,mpi_err)
56 if(mpi_err .eq. 0)
then
57 print*,
'mpi_comm_rank successful'
58 print*,
'world_id = ',world_id
60 print*,
'mpi_comm_rank unsuccessful'
64 call mpi_comm_size(mpi_comm_world,world_size,mpi_err)
65 if(mpi_err .eq. 0)
then
66 print*,
'mpi_comm_size successful'
67 print*,
'world_size = ',world_size
69 print*,
'mpi_comm_size unsuccessful'
73 call mpi_comm_split(mpi_comm_world,da,world_id,tmp_mdls_comm,mpi_err)
74 if(mpi_err .eq. 0)
then
75 print*,
'mpi_comm_split successful'
77 print*,
'mpi_comm_split unsuccessful'
81 call mpi_comm_size(tmp_mdls_comm,models_size,mpi_err)
82 if(mpi_err .eq. 0)
then
83 print*,
'mpi_comm_size successful'
84 print*,
'models_size = ',models_size
86 print*,
'mpi_comm_size unsuccessful'
90 call mpi_comm_rank(tmp_mdls_comm,models_id, mpi_err)
91 if(mpi_err .eq. 0)
then
92 print*,
'mpi_comm_rank successful'
93 print*,
'models_id = ',models_id
95 print*,
'mpi_comm_rank unsuccessful'
98 mdlcolour = models_id/mdl_num_proc
99 call mpi_comm_split(tmp_mdls_comm,mdlcolour,models_id,mdl_mpi_comm,mpi_err)
100 if(mpi_err .eq. 0)
then
101 print*,
'mpi_comm_split successful'
103 print*,
'mpi_comm_split unsuccessful'
107 call mpi_comm_rank(mdl_mpi_comm,mdl_id,mpi_err)
108 if(mpi_err .eq. 0)
then
109 print*,
'mpi_comm_rank successful'
110 print*,
'mdl_id = ',mdl_id
112 print*,
'mpi_comm_rank unsuccessful'
115 if(mdl_id .eq. 0)
then
118 cpl_colour = mpi_undefined
120 call mpi_comm_split(mpi_comm_world,cpl_colour,mdlcolour,cpl_mpi_comm,mpi_err)
121 if(mpi_err .eq. 0)
then
122 print*,
'mpi_comm_split successful'
124 print*,
'mpi_comm_split unsuccessful'
127 if(mdl_id .eq. 0)
then
128 call mpi_comm_size(cpl_mpi_comm,nens,mpi_err)
129 if(mpi_err .eq. 0)
then
130 print*,
'mpi_comm_size successful'
131 print*,
'nens = ',nens
133 print*,
'mpi_comm_size unsuccessful'
136 call mpi_comm_rank(cpl_mpi_comm,particle_id,mpi_err)
137 if(mpi_err .eq. 0)
then
138 print*,
'mpi_comm_rank successful'
139 print*,
'particle_id = ',particle_id
141 print*,
'mpi_comm_rank unsuccessful'
144 nda = world_size-models_size;nens = nens - nda
145 cpl_root = ((nda*particle_id)/nens)+nens
149 print*,
'cpl_root = ',cpl_root
program minimal_model_comms
subroutine initialise_mpi(mdl_id, cpl_root, cpl_mpi_comm)