47 real(kind=kind(1.0D0)),
dimension(:),
allocatable :: x
49 integer,
dimension(2) :: data
50 integer :: mpi_err,mdl_id,cpl_root,cpl_mpi_comm
51 integer,
dimension(MPI_STATUS_SIZE) :: mpi_status
58 call mpi_recv(
data,2,mpi_integer,cpl_root,mpi_any_tag,cpl_mpi_comm&
69 call mpi_send(x,n,mpi_double_precision,cpl_root&
70 &,1,cpl_mpi_comm,mpi_err)
71 call mpi_recv(x,n,mpi_double_precision,cpl_root&
72 &,mpi_any_tag,cpl_mpi_comm,mpi_status,mpi_err)
83 call mpi_send(x,n,mpi_double_precision,cpl_root&
84 &,1,cpl_mpi_comm,mpi_err)
85 call mpi_recv(x,n,mpi_double_precision,cpl_root&
86 &,mpi_any_tag,cpl_mpi_comm,mpi_status,mpi_err)
89 if(mpi_status(mpi_tag) .eq. 1)
then
91 elseif(mpi_status(mpi_tag) .eq. 2)
then
93 elseif(mpi_status(mpi_tag) .eq. 3)
then
96 print*,
'Linear model error: unknown MPI_TAG: ',mpi_status(mpi_tag)
108 call mpi_finalize(mpi_err)
114 integer,
intent(in) :: n
115 real(kind=kind(1.0D0)),
intent(in),
dimension (n) :: x
116 real(kind=kind(1.0D0)),
dimension(n) :: f
124 integer,
intent(out) :: mdl_id,cpl_root,cpl_mpi_comm
125 integer :: mdl_num_proc=1
126 integer :: mpi_err,world_size,world_id
127 integer :: cpl_colour
128 integer :: particle_id,nens, da, nda
129 integer :: mdl_mpi_comm,mdlcolour
130 integer :: tmp_mdls_comm,models_id,models_size
131 call mpi_init(mpi_err)
133 call mpi_comm_rank(mpi_comm_world,world_id,mpi_err)
134 call mpi_comm_size(mpi_comm_world,world_size,mpi_err)
135 call mpi_comm_split(mpi_comm_world,da,world_id,tmp_mdls_comm,mpi_err)
136 call mpi_comm_size(tmp_mdls_comm,models_size,mpi_err)
137 call mpi_comm_rank(tmp_mdls_comm,models_id, mpi_err)
138 mdlcolour = models_id/mdl_num_proc
139 call mpi_comm_split(tmp_mdls_comm,mdlcolour,models_id,mdl_mpi_comm,mpi_err)
140 call mpi_comm_rank(mdl_mpi_comm,mdl_id,mpi_err)
141 if(mdl_id .eq. 0)
then
144 cpl_colour = mpi_undefined
146 call mpi_comm_split(mpi_comm_world,cpl_colour,mdlcolour,cpl_mpi_comm,mpi_err)
147 if(mdl_id .eq. 0)
then
148 call mpi_comm_size(cpl_mpi_comm,nens,mpi_err)
149 call mpi_comm_rank(cpl_mpi_comm,particle_id,mpi_err)
150 nda = world_size-models_size;nens = nens - nda
151 cpl_root = ((nda*particle_id)/nens)+nens
152 if(nda ==0) cpl_root = particle_id
subroutine initialise_mpi(mdl_id, cpl_root, cpl_mpi_comm)
real(kind=kind(1.0d0)) function, dimension(n) f(n, x)
program linear
program to implement a simple linear model of no use to anyone but for testing and debugging purposes...