36 SUBROUTINE inipar(coupling,ITID,ICAS,NNODES,INPUT,GOT_INPUT,NBTASK)
38 USE coupling_adapter_mod
39 USE spmd_comm_world_mod,
ONLY : spmd_comm_world
40#include "implicit_f.inc"
50 INTEGER ITID(*),ICAS, NNODES,GOT_INPUT,NBTASK(*)
52 type(coupling_type),
intent(inout) :: coupling
60#include
"commandline.inc"
65 INTEGER STATUS(MPI_STATUS_SIZE),IERROR,ICODE
66 INTEGER MYRANK, JRANK, I, J, NTHREAD1, LOCAL, RLEN
67 CHARACTER (LEN=255) :: STR
68 CHARACTER (LEN=MPI_MAX_PROCESSOR_NAME) :: HSTNAM,HOST
69 character(len=MPI_MAX_PROCESSOR_NAME),
dimension(:),
allocatable :: hostname
70 integer,
dimension(:),
allocatable :: perm,host_numbers,buffer
74 INTEGER (kind=MPI_ADDRESS_KIND) :: COLOUR_ADDR
78 INTEGER OMP_GET_MAX_THREADS
86 IF(ir4r8==2) real = mpi_double_precision
95 CALL mpi_comm_get_attr(mpi_comm_world, mpi_appnum,
96 * colour_addr, valid, ierror)
98 IF (ierror == mpi_success)
THEN
99 colour = int(colour_addr)
103 call coupling_configure(coupling, trim(coupling%FILNAM))
107 * spmd_comm_world,ierror)
109 spmd_comm_world = coupling_get_communicator(coupling%adapter_ptr)
115 it_spmd(jrank) = jrank-1
126 CALL getenv(
'OMP_NUM_THREADS',str)
129 READ(str,
'(I10)',err=999)nthread1
139 IF (got_nth == 1)
THEN
140 IF (nthread>1 .AND. (nth/= nthread .OR. (nth==nthread .AND.
141 + nthread1>0.AND.nthread0>1.AND.nthread1/=nthread0)))
THEN
143 +
'** WARNING : -nthread OPTION USED, DEFAULT SETTING IGNORED'
148 IF(nthread1>0.AND.nthread0>1.AND.nthread1/=nthread0)
THEN
150 +
'** WARNING : OMP_NUM_THREADS SET, DEFAULT SETTING IGNORED'
154 IF(nthread<=0) nthread=1
155 IF(nthread>nthmax) nthread=nthmax
161 1 nspmd,1,mpi_integer,it_spmd(1),spmd_comm_world,
165 1 nthread,1,mpi_integer,it_spmd(1),spmd_comm_world,
168 IF (got_input == 0)
THEN
169 CALL mpi_bcast(input,100,mpi_character,it_spmd(1),
170 . spmd_comm_world,ierror)
174 IF(myrank==it_spmd(j))
THEN
182 CALL getenv(
'OMP_NUM_THREADS',str)
185 READ(str,
'(I10)',err=1999)nthread1
190 IF(nthread1>0 .AND. nthread1 /= nthread)
THEN
192 WRITE(istdo,
'(A,I4,A,I4)')
193 .
'** WARNING: RESET OMP_NUM_THREADS TO:',
194 . nthread,
' FOR MPI PROCESS',ispmd+1
198 CALL mpi_gather(nthread,1,mpi_integer,nbtask,1,mpi_integer,
199 . it_spmd(1),spmd_comm_world,ierror)
202 ELSE IF(icas==3)
THEN
207 IF (nspmd /= nnodes)
THEN
209 .
'THE REQUIRED NUMBER OF MPI PROCESSES DOES NOT MATCH MPIRUN'
211 .
'PLEASE, RUN WITH THE PROPER NUMBER OF MPI PROCESSES'
213 .
'REQUIRED (number of .rst files) NSPMD =',nspmd
215 .
'AVAILABLE (-np argument of mpirun) =',nnodes
218 .
'THE REQUIRED NUMBER OF MPI PROCESSES DOES NOT MATCH MPIRUN'
220 .
'PLEASE, RUN WITH THE PROPER NUMBER OF MPI PROCESSES'
223 .
' E R R O R T E R M I N A T I O N'
225 .
' E R R O R T E R M I N A T I O N'
227 .
' TOTAL NUMBER OF CYCLES :', ncycle
229 .
' TOTAL NUMBER OF CYCLES :', ncycle
231 CALL mpi_abort(spmd_comm_world,icode,ierror)
236 CALL mpi_bcast(nspmd,1,mpi_integer,it_spmd(1),
237 . spmd_comm_world,ierror)
240 . spmd_comm_world,ierror)
242 IF (got_input == 0)
THEN
243 CALL mpi_bcast(input,100,mpi_character,it_spmd(1),
244 . spmd_comm_world,ierror)
248 CALL mpi_gather(nthread,1,mpi_integer,nbtask,1,mpi_integer,
249 . it_spmd(1),spmd_comm_world,ierror)
253 nbtask(nspmd+1)=nbtask(nspmd+1)+nbtask(i)
269 CALL omp_set_num_threads(nthread)
271 CALL omp_init_lock(llock(1,i))
277 allocate(hostname(nspmd))
280 . hstnam,mpi_max_processor_name,mpi_character,
281 . hostname ,mpi_max_processor_name,mpi_character,
282 . it_spmd(1),spmd_comm_world,ierror)
284 allocate(perm(nspmd))
285 allocate(host_numbers(nspmd))
286 allocate(buffer(2*nspmd))
295 IF(hostname(i) > hostname(j))
THEN
297 hostname(i) = hostname(j)
308 IF(host /= hostname(i))
THEN
311 host_number = host_number + 1
315 l_spmd(perm(i))=local-1
316 host_numbers(perm(i))=host_number
320 buffer(1:nspmd) = l_spmd(1:nspmd)
322 buffer(nspmd+1:2*nspmd) = host_numbers(1:nspmd)
326 CALL mpi_bcast(buffer,nspmdx2,mpi_integer,it_spmd(1),
327 . spmd_comm_world,ierror)
329 l_spmd(1:nspmd) = buffer(1:nspmd)
330 host_numbers(1:nspmd) = buffer(nspmd+1:2*nspmd)
335 IF(host_numbers(i) == host_numbers(ispmd+1))
THEN
336 nspmd_per_node = nspmd_per_node + 1
341 deallocate(host_numbers)
344 ELSE IF(icas==2)
THEN
367!||--- uses -----------------------------------------------------
368!|| coupling_adapter_mod ../engine/source/coupling/coupling_adapter.f90
370!||====================================================================
371 SUBROUTINE inipar(coupling, ITID,ICAS,NNODES,INPUT,GOT_INPUT,NBTASK)
373 USE spmd_comm_world_mod,
ONLY : spmd_comm_world
374 USE coupling_adapter_mod
375#include "implicit_f.inc"
376#include "comlock.inc"
381 INTEGER (*),ICAS, NNODES,GOT_INPUT,NBTASK(*)
387#include
"com01_c.inc"
389#include
"scr05_c.inc"
390#include
"units_c.inc"
391#include
"commandline.inc"
395 type(coupling_type),
intent(inout) :: coupling
396 INTEGER , I, NTHREAD1
398 INTEGER OMP_GET_MAX_THREADS
400 CHARACTER (LEN=255) :: STR
408 IF(ir4r8==2) real = 8
414 CALL getenv(
'OMP_NUM_THREADS',str)
417 READ(str,
'(I10)',err=999)nthread1
427 IF (got_nth == 1)
THEN
428 IF (nthread>1 .AND. (nth/= nthread .OR. (nth==nthread .AND.
429 + nthread1>0.AND.nthread0>1.AND.nthread1/=nthread0)))
THEN
431 +
'** WARNING : -nthread OPTION USED, DEFAULT SETTING IGNORED'
436 IF(nthread1>0.AND.nthread0>1.AND.nthread1/=nthread0)
THEN
438 +
'** WARNING : OMP_NUM_THREADS SET, DEFAULT SETTING IGNORED'
442 IF(nthread<=0) nthread=1
443 IF(nthread>nthmax) nthread=nthmax
448 ELSE IF(icas==3)
THEN
450 IF (nspmd /= nnodes)
THEN
452 .
'NON HYBRID EXECUTABLE ONLY SUPPORTS ONE SPMD DOMAIN'
454 .
'PLEASE, RUN STARTER WITH -nspmd 1 OR USE HMPP EXECUTABLE'
456 .
'REQUIRED (number of .rst files) NSPMD =',nspmd
458 .
'AVAILABLE =',nnodes
461 .
'NON HYBRID EXECUTABLE ONLY SUPPORTS ONE SPMD DOMAIN'
463 .
'PLEASE, RUN STARTER WITH -nspmd 1 OR USE HMPP EXECUTABLE'
466 .
' E R R O R T E R M I N A T I O N'
468 .
' E R R O R T E R M I N A T I O N'
470 .
' TOTAL NUMBER OF CYCLES :', ncycle
472 .
' TOTAL NUMBER OF CYCLES :', ncycle
480 CALL omp_set_num_threads(nthread)
482 CALL omp_init_lock(llock(1,i
485 ELSE IF(icas==2)
THEN
subroutine inipar(coupling, itid, icas, nnodes, input, got_input, nbtask)
subroutine mpi_finalize(ierr)
subroutine mpi_comm_split(comm, color, key, comm2, ierr)
subroutine mpi_get_processor_name(name, resultlen, ierror)
subroutine mpi_barrier(comm, ierr)
subroutine mpi_comm_size(comm, size, ierr)
subroutine mpi_bcast(buffer, cnt, datatype, root, comm, ierr)
subroutine mpi_init(ierr)
subroutine mpi_gather(sendbuf, cnt, datatype, recvbuf, reccnt, rectype, root, comm, ierr)
subroutine mpi_comm_rank(comm, rank, ierr)
subroutine mpi_initialized(flag, ierr)
subroutine mpi_abort(comm, ierrcode, ierr)