OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
inipar.F
Go to the documentation of this file.
1Copyright> OpenRadioss
2Copyright> Copyright (C) 1986-2025 Altair Engineering Inc.
3Copyright>
4Copyright> This program is free software: you can redistribute it and/or modify
5Copyright> it under the terms of the GNU Affero General Public License as published by
6Copyright> the Free Software Foundation, either version 3 of the License, or
7Copyright> (at your option) any later version.
8Copyright>
9Copyright> This program is distributed in the hope that it will be useful,
10Copyright> but WITHOUT ANY WARRANTY; without even the implied warranty of
11Copyright> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12Copyright> GNU Affero General Public License for more details.
13Copyright>
14Copyright> You should have received a copy of the GNU Affero General Public License
15Copyright> along with this program. If not, see <https://www.gnu.org/licenses/>.
16Copyright>
17Copyright>
18Copyright> Commercial Alternative: Altair Radioss Software
19Copyright>
20Copyright> As an alternative to this open-source version, Altair also offers Altair Radioss
21Copyright> software under a commercial license. Contact Altair to discuss further if the
22Copyright> commercial version may interest you: https://www.altair.com/radioss/.
23#ifdef MPI
24!||====================================================================
25!|| inipar ../engine/source/mpi/init/inipar.F
26!||--- called by ------------------------------------------------------
27!|| radioss2 ../engine/source/engine/radioss2.F
28!||--- calls -----------------------------------------------------
29!|| arret ../engine/source/system/arret.F
30!|| omp_get_max_threads ../engine/source/engine/openmp_stub.F90
31!|| omp_set_num_threads ../engine/source/engine/openmp_stub.F90
32!||--- uses -----------------------------------------------------
33!|| coupling_adapter_mod ../engine/source/coupling/coupling_adapter.F90
34!|| spmd_comm_world_mod ../engine/source/mpi/spmd_comm_world.F90
35!||====================================================================
36 SUBROUTINE inipar(coupling,ITID,ICAS,NNODES,INPUT,GOT_INPUT,NBTASK)
37C-----------------------------------------------------------------
38 USE coupling_adapter_mod
39 USE spmd_comm_world_mod, ONLY : spmd_comm_world
40#include "implicit_f.inc"
41#include "comlock.inc"
42#include "r4r8_p.inc"
43C-----------------------------------------------------------------
44C M e s s a g e P a s s i n g
45C-----------------------------------------------
46#include "spmd.inc"
47C-----------------------------------------------
48C D u m m y A r g u m e n t s
49C-----------------------------------------------
50 INTEGER ITID(*),ICAS, NNODES,GOT_INPUT,NBTASK(*)
51 CHARACTER*100 INPUT
52 type(coupling_type), intent(inout) :: coupling
53C-----------------------------------------------
54C C o m m o n B l o c k s
55C-----------------------------------------------
56#include "com01_c.inc"
57#include "task_c.inc"
58#include "scr05_c.inc"
59#include "units_c.inc"
60#include "commandline.inc"
61 INTEGER KEY, IERR
62C-----------------------------------------------
63C L o c a l V a r i a b l e s
64C-----------------------------------------------
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
71 INTEGER HOST_NUMBER
72 INTEGER NSPMDx2
73 INTEGER :: COLOUR
74 INTEGER (kind=MPI_ADDRESS_KIND) :: COLOUR_ADDR
75 INTEGER :: VALID
76 CHARACTER FILNAM*100
77#if defined(_OPENMP)
78 INTEGER OMP_GET_MAX_THREADS
79#endif
80C--------------------------------------------------
81C CONVENTIONS:
82C ispmd 0...NSPMD-1
83C--------------------------------------------------
84 IF(icas==1) THEN
85 REAL = mpi_real
86 IF(ir4r8==2) real = mpi_double_precision
87C
88 key = 0
89 CALL mpi_initialized(key, ierr)
90 valid = 0
91 colour_addr = 0
92
93 CALL mpi_init(ierror)
94
95 CALL mpi_comm_get_attr(mpi_comm_world, mpi_appnum,
96 * colour_addr, valid, ierror)
97
98 IF (ierror == mpi_success) THEN
99 colour = int(colour_addr)
100 ELSE
101 colour = 0 ! Default color if attribute not found
102 ENDIF
103 call coupling_configure(coupling, trim(coupling%FILNAM))
104
105#ifndef WITH_CWIPI
106 CALL mpi_comm_split(mpi_comm_world,colour,key,
107 * spmd_comm_world,ierror)
108#else
109 spmd_comm_world = coupling_get_communicator(coupling%adapter_ptr)
110#endif
111 CALL mpi_comm_size(spmd_comm_world, nnodes, ierror)
112 CALL mpi_comm_rank(spmd_comm_world, myrank, ierror)
113C
114 DO jrank=1,nnodes
115 it_spmd(jrank) = jrank-1
116 END DO
117C
118 IF (myrank==0) THEN
119C I AM THE FIRST ONE
120 ispmd = 0
121C
122C Calcul du nombre de threads { Calculating the number of threads }
123C
124#if defined(_OPENMP)
125 str = ' '
126 CALL getenv('omp_num_threads',STR)
127 NTHREAD1=0
128C nthread1 : nombre de threads fixe par la variable environnememt
129C {nthread1: number of threads fixed by the environment variable }
130 READ(STR,'(i10)',ERR=999)NTHREAD1
131 GOTO 1000
132 999 CONTINUE
133 NTHREAD1 = -1
134 1000 CONTINUE
135 IF(NTHREAD1>0)THEN
136 NTHREAD=NTHREAD1
137 ELSE
138 NTHREAD=NTHREAD0 ! defaut run precedent
139 END IF
140 IF (GOT_NTH == 1) THEN
141.AND..OR..AND. IF (NTHREAD>1 (NTH/= NTHREAD (NTH==NTHREAD
142.AND..AND. + NTHREAD1>0NTHREAD0>1NTHREAD1/=NTHREAD0)))THEN
143 WRITE(IOUT,*)
144 + '** warning : -nthread option used, default setting ignored'
145 WRITE(IOUT,*)' '
146 END IF
147 NTHREAD = NTH
148 ELSE
149.AND..AND. IF(NTHREAD1>0NTHREAD0>1NTHREAD1/=NTHREAD0)THEN
150 WRITE(IOUT,*)
151 + '** warning : omp_num_threads set, default setting ignored'
152 WRITE(IOUT,*)' '
153 END IF
154 ENDIF
155 IF(NTHREAD<=0) NTHREAD=1
156 IF(NTHREAD>NTHMAX) NTHREAD=NTHMAX
157#elif 1
158 NTHREAD = 1
159#endif
160 ELSE
161 CALL MPI_BCAST(
162 1 NSPMD,1,MPI_INTEGER,IT_SPMD(1),SPMD_COMM_WORLD,
163 2 IERROR )
164C recuperation de NTHREAD depuis process 0 { recovery of NTHREAD from process 0 }
165 CALL MPI_BCAST(
166 1 NTHREAD,1,MPI_INTEGER,IT_SPMD(1),SPMD_COMM_WORLD,
167 2 IERROR )
168C
169 IF (GOT_INPUT == 0)THEN
170 CALL MPI_BCAST(INPUT,100,MPI_CHARACTER,IT_SPMD(1),
171 . SPMD_COMM_WORLD,IERROR)
172 ENDIF
173C
174 DO J=2,NSPMD
175 IF(MYRANK==IT_SPMD(J))THEN
176 ISPMD = J-1
177 END IF
178 END DO
179cccc
180C code special pour MIC
181#if defined(__MIC__)
182 STR = ' '
183 CALL GETENV('omp_num_threads',STR)
184 NTHREAD1=0
185C nthread1 : nombre de threads fixe par la variable environnement sur le MIC
186 READ(STR,'(i10)',ERR=1999)NTHREAD1
187 GOTO 2000
188 1999 CONTINUE
189 NTHREAD1 = -1
190 2000 CONTINUE
191.AND. IF(NTHREAD1>0 NTHREAD1 /= NTHREAD)THEN
192 NTHREAD=NTHREAD1
193 WRITE(ISTDO,'(a,i4,a,i4)')
194 . '** warning: reset omp_num_threads to:',
195 . NTHREAD,' for mpi process',ISPMD+1
196 ENDIF
197#endif
198C control of nthread per MPI process
199 CALL MPI_GATHER(NTHREAD,1,MPI_INTEGER,NBTASK,1,MPI_INTEGER,
200 . IT_SPMD(1),SPMD_COMM_WORLD,IERROR)
201
202 END IF
203 ELSE IF(ICAS==3) THEN
204 IF(ISPMD == 0) THEN
205C
206C test cooherence NSPMD et nombre de proccesses MPI demandes (-np)
207C { NSPMD coherence test and number of MPI processes requested (-np) }
208C
209 IF (NSPMD /= NNODES) THEN
210 WRITE(IOUT,*)
211 . 'the required number of mpi processes does not match mpirun'
212 WRITE(IOUT,*)
213 . 'please, run with the proper number of mpi processes'
214 WRITE(IOUT,*)
215 . 'required(number of .rst files) nspmd =',NSPMD
216 WRITE(IOUT,*)
217 . 'available(-np argument of mpirun) =',NNODES
218 WRITE(IOUT,*)' '
219 WRITE(ISTDO,*)
220 . 'the required number of mpi processes does not match mpirun'
221 WRITE(ISTDO,*)
222 . 'please, run with the proper number of mpi processes'
223 WRITE(ISTDO,*)' '
224 WRITE(IOUT,*)
225 . ' e r r o r t e r m i n a t i o n'
226 WRITE(ISTDO,*)
227 . ' e r r o r t e r m i n a t i o n'
228 WRITE(IOUT,*)
229 . ' total number of cycles :', NCYCLE
230 WRITE(ISTDO,*)
231 . ' total number of cycles :', NCYCLE
232 ICODE=2
233 CALL MPI_ABORT(SPMD_COMM_WORLD,ICODE,ierror)
234 CALL ARRET(7)
235 END IF
236 IF(NSPMD > 1) THEN
237C envoi NSPMD de process0 vers les autres processes
238C { sending NSPMD from process0 to other processes }
239 CALL MPI_BCAST(NSPMD,1,MPI_INTEGER,IT_SPMD(1),
240 . SPMD_COMM_WORLD,IERROR)
241C envoi de NTHREAD de process0 vers les autres processes
242C { sending NTHREAD from process0 to other processes }
243 CALL MPI_BCAST(NTHREAD,1,MPI_INTEGER,IT_SPMD(1),
244 . SPMD_COMM_WORLD,IERROR)
245C
246 IF (GOT_INPUT == 0)THEN
247 CALL MPI_BCAST(INPUT,100,MPI_CHARACTER,IT_SPMD(1),
248 . SPMD_COMM_WORLD,IERROR)
249 ENDIF
250
251C control of nthread per MPI process
252 CALL MPI_GATHER(NTHREAD,1,MPI_INTEGER,NBTASK,1,MPI_INTEGER,
253 . IT_SPMD(1),SPMD_COMM_WORLD,IERROR)
254 IF(ISPMD==0)THEN
255 NBTASK(NSPMD+1)=0
256 DO I=1,NSPMD
257 NBTASK(NSPMD+1)=NBTASK(NSPMD+1)+NBTASK(I)
258 END DO
259 END IF
260 ELSE
261 NBTASK(1)=NTHREAD
262 NBTASK(2)=NTHREAD
263 END IF
264C
265 END IF
266C------------------------------------------------------------
267C Starting from now, ALL TASK ARE EQUAL ===> SPMD program
268C------------------------------------------------------------
269C
270C Init OpenMP
271C
272#if defined(_OPENMP)
273 CALL OMP_SET_NUM_THREADS(NTHREAD)
274 DO I = 1, 2*INTSEG
275 CALL OMP_INIT_LOCK(LLOCK(1,I))
276 ENDDO
277#endif
278C
279C Init local SPMD numbering on a node (L_SPMD)
280C
281 allocate(hostname(nspmd))
282 CALL MPI_GET_PROCESSOR_NAME(HSTNAM,RLEN,IERROR)
283 CALL MPI_GATHER(
284 . HSTNAM,MPI_MAX_PROCESSOR_NAME,MPI_CHARACTER,
285 . HOSTNAME ,MPI_MAX_PROCESSOR_NAME,MPI_CHARACTER,
286 . IT_SPMD(1),SPMD_COMM_WORLD,IERROR)
287
288 allocate(perm(nspmd))
289 allocate(host_numbers(nspmd))
290 allocate(buffer(2*nspmd))
291 IF(ISPMD==0)THEN
292C permutations during sort are saved
293 DO I = 1,NSPMD
294 PERM(I) = I
295 END DO
296C tri bulle basic
297 DO I = 1, NSPMD-1
298 DO J = I, NSPMD
299 IF(HOSTNAME(I) > HOSTNAME(J))THEN
300 HOST = HOSTNAME(I)
301 HOSTNAME(I) = HOSTNAME(J)
302 PERM(I) = J
303 HOSTNAME(J) = HOST
304 PERM(J) = I
305 END IF
306 END DO
307 END DO
308 HOST = ' '
309 LOCAL=0
310 HOST_NUMBER = 0
311 DO I = 1, NSPMD
312 IF(HOST /= HOSTNAME(I))THEN
313 HOST = HOSTNAME(I)
314 LOCAL = 1
315 HOST_NUMBER = HOST_NUMBER + 1
316 ELSE
317 LOCAL = LOCAL + 1
318 ENDIF
319 L_SPMD(PERM(I))=LOCAL-1
320 HOST_NUMBERS(PERM(I))=HOST_NUMBER
321 ENDDO
322C preparing MPI buffer
323C Local rank in the node
324 BUFFER(1:NSPMD) = L_SPMD(1:NSPMD)
325C host numbers
326 BUFFER(NSPMD+1:2*NSPMD) = HOST_NUMBERS(1:NSPMD)
327 deallocate(perm)
328 ENDIF
329 NSPMDx2 = NSPMD*2
330 CALL MPI_BCAST(BUFFER,NSPMDx2,MPI_INTEGER,IT_SPMD(1),
331 . SPMD_COMM_WORLD,IERROR)
332
333 L_SPMD(1:NSPMD) = BUFFER(1:NSPMD)
334 HOST_NUMBERS(1:NSPMD) = BUFFER(NSPMD+1:2*NSPMD)
335
336 NSPMD_PER_NODE=0
337C Count the number of SPMD on the local host
338 DO I = 1,NSPMD
339 IF(HOST_NUMBERS(I) == HOST_NUMBERS(ISPMD+1)) THEN
340 NSPMD_PER_NODE = NSPMD_PER_NODE + 1
341 ENDIF
342 END DO
343
344 deallocate(hostname)
345 deallocate(host_numbers)
346 deallocate(buffer)
347
348 ELSE IF(ICAS==2) THEN
349C
350 CALL MPI_BARRIER(SPMD_COMM_WORLD,IERROR)
351C
352 CALL MPI_FINALIZE(IERROR)
353 ENDIF
354C
355 RETURN
356 END
357C MPI
358
359#elif 1
360C
361C routines simplifiees non mpi
362C
363!||====================================================================
364!|| inipar ../engine/source/mpi/init/inipar.F
365!||--- called by ------------------------------------------------------
366!|| radioss2 ../engine/source/engine/radioss2.F
367!||--- calls -----------------------------------------------------
368!|| arret ../engine/source/system/arret.F
369!|| omp_get_max_threads ../engine/source/engine/openmp_stub.F90
370!|| omp_set_num_threads ../engine/source/engine/openmp_stub.F90
371!||--- uses -----------------------------------------------------
372!|| coupling_adapter_mod ../engine/source/coupling/coupling_adapter.F90
373!|| spmd_comm_world_mod ../engine/source/mpi/spmd_comm_world.F90
374!||====================================================================
375 SUBROUTINE INIPAR(coupling, ITID,ICAS,NNODES,INPUT,GOT_INPUT,NBTASK)
376C-----------------------------------------------------------------
377 USE SPMD_COMM_WORLD_MOD, ONLY : SPMD_COMM_WORLD
378 USE COUPLING_ADAPTER_MOD
379#include "implicit_f.inc"
380#include "comlock.inc"
381#include "r4r8_p.inc"
382C-----------------------------------------------
383C D u m m y A r g u m e n t s
384C-----------------------------------------------
385 INTEGER ITID(*),ICAS, NNODES,GOT_INPUT,NBTASK(*)
386 CHARACTER*100 INPUT
387C-----------------------------------------------
388C C o m m o n B l o c k s
389C-----------------------------------------------
390#include "spmd.inc"
391#include "com01_c.inc"
392#include "task_c.inc"
393#include "scr05_c.inc"
394#include "units_c.inc"
395#include "commandline.inc"
396C-----------------------------------------------
397C L o c a l V a r i a b l e s
398C-----------------------------------------------
399 type(coupling_type), intent(inout) :: coupling
400 INTEGER ICODE, I, NTHREAD1
401#if defined(_OPENMP)
402 INTEGER OMP_GET_MAX_THREADS
403#endif
404 CHARACTER (LEN=255) :: STR
405C--------------------------------------------------
406C CONVENTIONS:
407C ispmd 0...NSPMD-1
408C--------------------------------------------------
409 IF(ICAS==1) THEN
410C
411 REAL = 4
412 IF(IR4R8==2) REAL = 8
413C
414 NNODES= 1
415 ISPMD = 0
416#if defined(_OPENMP)
417 STR = ' '
418 CALL GETENV('omp_num_threads',STR)
419 NTHREAD1=0
420C nthread1 : nombre de threads fixe par la variable environnememt
421 READ(STR,'(i10)',ERR=999)NTHREAD1
422 GOTO 1000
423 999 CONTINUE
424 NTHREAD1 = -1
425 1000 CONTINUE
426 IF(NTHREAD1>0)THEN
427 NTHREAD=NTHREAD1
428 ELSE
429 NTHREAD=NTHREAD0 ! defaut run precedent
430 END IF
431 IF (GOT_NTH == 1) THEN
432.AND..OR..AND. IF (NTHREAD>1 (NTH/= NTHREAD (NTH==NTHREAD
433.AND..AND. + NTHREAD1>0NTHREAD0>1NTHREAD1/=NTHREAD0)))THEN
434 WRITE(IOUT,*)
435 + '** warning : -nthread option used, default setting ignored'
436 WRITE(IOUT,*)' '
437 END IF
438 NTHREAD = NTH
439 ELSE
440.AND..AND. IF(NTHREAD1>0NTHREAD0>1NTHREAD1/=NTHREAD0)THEN
441 WRITE(IOUT,*)
442 + '** warning : omp_num_threads set, default setting ignored'
443 WRITE(IOUT,*)' '
444 END IF
445 ENDIF
446 IF(NTHREAD<=0) NTHREAD=1
447 IF(NTHREAD>NTHMAX) NTHREAD=NTHMAX
448C
449#elif 1
450 NTHREAD = 1
451#endif
452 ELSE IF(ICAS==3) THEN
453C
454 IF (NSPMD /= NNODES) THEN
455 WRITE(IOUT,*)
456 . 'non hybrid executable only supports one spmd domain'
457 WRITE(IOUT,*)
458 . 'please, run starter with -nspmd 1 or USE hmpp executable'
459 WRITE(IOUT,*)
460 . 'required (number of .rst files) nspmd =',NSPMD
461 WRITE(IOUT,*)
462 . 'available =',NNODES
463 WRITE(IOUT,*)' '
464 WRITE(ISTDO,*)
465 . 'non hybrid executable ONLY supports one spmd domain'
466 WRITE(ISTDO,*)
467 . 'please, run starter with -nspmd 1 or use hmpp executable'
468 WRITE(ISTDO,*)' '
469 WRITE(iout,*)
470 . ' E R R O R T E R M I N A T I O N'
471 WRITE(istdo,*)
472 . ' E R R O R T E R M I N A T I O N'
473 WRITE(iout,*)
474 . ' TOTAL NUMBER OF CYCLES :', ncycle
475 WRITE(istdo,*)
476 . ' TOTAL NUMBER OF CYCLES :', ncycle
477 icode=2
478 CALL arret(7)
479C
480 ENDIF
481 nbtask(1)=nthread
482 nbtask(2)=nthread
483#if defined(_OPENMP)
484 CALL omp_set_num_threads(nthread)
485 DO i = 1, 2*intseg
486 CALL omp_init_lock(llock(1,i))
487 ENDDO
488#endif
489 ELSE IF(icas==2) THEN
490#if defined(_OPENMP)
491#endif
492 ENDIF
493 RETURN
494 END
495
496#endif
end diagonal values have been computed in the(sparse) matrix id.SOL
subroutine inipar(coupling, itid, icas, nnodes, input, got_input, nbtask)
Definition inipar.F:376
subroutine mpi_comm_split(comm, color, key, comm2, ierr)
Definition mpi.f:272
subroutine mpi_comm_size(comm, size, ierr)
Definition mpi.f:263
subroutine mpi_init(ierr)
Definition mpi.f:342
subroutine mpi_comm_rank(comm, rank, ierr)
Definition mpi.f:254
subroutine mpi_initialized(flag, ierr)
Definition mpi.f:350
for(i8=*sizetab-1;i8 >=0;i8--)
subroutine arret(nn)
Definition arret.F:87
program starter
Definition starter.F:39