OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
spmd_wiout.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/.
23C
24!||====================================================================
25!|| spmd_wiout ../engine/source/mpi/generic/spmd_wiout.F
26!||--- called by ------------------------------------------------------
27!|| fvstats ../engine/source/airbag/fvstats.F
28!|| fxbypid ../engine/source/constraints/fxbody/fxbypid.F
29!|| lectur ../engine/source/input/lectur.F
30!|| rbypid ../engine/source/constraints/general/rbody/rbypid.F
31!|| resol ../engine/source/engine/resol.F
32!|| sz_print ../engine/source/output/restart/arralloc.F
33!||--- calls -----------------------------------------------------
34!||--- uses -----------------------------------------------------
35!|| io_mod ../engine/share/modules/io_mod.F
36!|| message_mod ../engine/share/message_module/message_mod.F
37!|| spmd_comm_world_mod ../engine/source/mpi/spmd_comm_world.F90
38!||====================================================================
39 SUBROUTINE spmd_wiout(IOUT,IWIOUT)
40C ecrit le buffer L01 sur p0
41 USE message_mod
42 USE io_mod
43C-----------------------------------------------
44C I m p l i c i t T y p e s
45C-----------------------------------------------
46 USE spmd_comm_world_mod, ONLY : spmd_comm_world
47#include "implicit_f.inc"
48C-----------------------------------------------------------------
49C M e s s a g e P a s s i n g
50C-----------------------------------------------
51#include "spmd.inc"
52C-----------------------------------------------
53C C o m m o n B l o c k s
54C-----------------------------------------------
55#include "com01_c.inc"
56#include "task_c.inc"
57C-----------------------------------------------
58C D u m m y A r g u m e n t s
59C-----------------------------------------------
60 INTEGER IOUT, IWIOUT
61C-----------------------------------------------
62C L o c a l V a r i a b l e s
63C-----------------------------------------------
64#ifdef MPI
65 INTEGER MSGTYP,INFO,LOC_PROC,
66 . BUFSIZ,MSGOFF,SIZ,I,P,LEN,N,II,
67 . IOS,STATUS(MPI_STATUS_SIZE),IERROR,IBLANC,LNEW
68 INTEGER, DIMENSION(:),ALLOCATABLE :: IWA
69
70
71 INTEGER :: NINDX_PROC,SIZE_MESSAGE
72 INTEGER, DIMENSION(NSPMD) :: IWIOUT_SPMD
73 INTEGER, DIMENSION(NSPMD) :: PROC_RCV,DISPLACEMENT
74 INTEGER :: INDX,REQ_S
75 INTEGER, DIMENSION(NSPMD) :: REQ_R
76
77 DATA msgoff/105/
78 CHARACTER(LEN=NCHAROUT) :: LINE
79C-----------------------------------------------
80C S o u r c e L i n e s
81C-----------------------------------------------
82C IWIOUT est utilise pour connaitre le nb max de characteres a echanger
83 ! MPI comm : every proc sends its IWIOUT_SAVE to the main proc
84 iwiout_spmd(1:nspmd) = 0
85 CALL mpi_gather( iwiout_save,1,mpi_integer,
86 . iwiout_spmd,1,mpi_integer,
87 . 0,spmd_comm_world,ierror)
88
89
90 loc_proc = ispmd + 1
91 len = ncharout
92 IF(ispmd/=0) ALLOCATE(iwa(iwiout+1))
93! ---------------------------------
94! Main proc : receives the message from other proc and writes the message in the *.out file
95 IF(ispmd==0) THEN
96 nindx_proc = 0
97 size_message = 0
98 ! ------------------
99 displacement(1:nspmd) = 0
100 DO p = 2, nspmd
101 IF(iwiout_spmd(p)/=0) THEN
102 nindx_proc = nindx_proc + 1
103 proc_rcv(nindx_proc) = p
104 displacement(nindx_proc) = size_message
105 size_message = size_message + iwiout_spmd(p) + 1
106 ENDIF
107 ENDDO
108 ALLOCATE(iwa(size_message))
109 ! ------------------
110 DO i=1,nindx_proc
111 p = proc_rcv(i)
112 msgtyp = msgoff
113 CALL mpi_irecv(iwa(1+displacement(i)),iwiout_spmd(p)+1,mpi_integer,it_spmd(p),
114 . msgtyp,spmd_comm_world,req_r(i),ierror)
115
116
117 ENDDO
118 ! ------------------
119 DO ii=1,nindx_proc
120 CALL mpi_waitany(nindx_proc,req_r,indx,status,ierror)
121 p = proc_rcv(indx)
122 siz = iwiout_spmd(p)
123 DO n = 1, siz, len
124C traitement special pour eliminer les blancs de fin de chaine
125 i = len
126 iblanc = ichar(' ')
127 DO WHILE (iwa(displacement(indx)+n+i)==iblanc.AND.i>1)
128 i = i-1
129 ENDDO
130 lnew = i
131C
132 DO i = 1, lnew
133 line(i:i) = char(iwa(displacement(indx)+n+i))
134 ENDDO
135 WRITE(iout,fmt='(A)')line(1:lnew)
136 ENDDO
137 ENDDO
138 ! ------------------
139! ---------------------------------
140 ELSE
141! Secondary proc : sends the message to the main proc
142C rewind fait ds check REWIND(UNIT=IOUT)
143 IF(iwiout_save>0) THEN
144 ios = 0
145 siz = 1
146 ! ------------------
147 DO WHILE(ios==0)
148 READ(unit=iout,iostat=ios,fmt='(A)') line
149 IF(ios==0) THEN
150 DO i = 1, len
151 iwa(siz+i) = ichar(line(i:i))
152 ENDDO
153 siz = siz + len
154 ENDIF
155 ENDDO
156 ! ------------------
157 iwa(1) = siz-1
158 rewind(unit=iout)
159 WRITE(unit=iout,iostat=ios,fmt='(A)')
160 msgtyp = msgoff
161 CALL mpi_isend(iwa ,siz ,mpi_integer,it_spmd(1),
162 . msgtyp,spmd_comm_world,req_s,ierror )
163
164 CALL mpi_wait(req_s,status,ierror)
165 ! ------------------
166 ENDIF
167 ENDIF
168! ---------------------------------
169 DEALLOCATE(iwa)
170C
171
172#endif
173 RETURN
174 END SUBROUTINE spmd_wiout
subroutine mpi_isend(buf, cnt, datatype, dest, tag, comm, ireq, ierr)
Definition mpi.f:382
subroutine mpi_wait(ireq, status, ierr)
Definition mpi.f:525
subroutine mpi_waitany(cnt, array_of_requests, index, status, ierr)
Definition mpi.f:549
subroutine mpi_gather(sendbuf, cnt, datatype, recvbuf, reccnt, rectype, root, comm, ierr)
Definition mpi.f:56
subroutine mpi_irecv(buf, cnt, datatype, source, tag, comm, ireq, ierr)
Definition mpi.f:372
integer iwiout_save
Definition io_mod.F:30
subroutine spmd_wiout(iout, iwiout)
Definition spmd_wiout.F:40