1
1
!-------------------------------------------------------------------------------
3
! This file is part of the Code_Saturne Kernel, element of the
4
! Code_Saturne CFD tool.
6
! Copyright (C) 1998-2009 EDF S.A., France
8
! contact: saturne-support@edf.fr
10
! The Code_Saturne Kernel is free software; you can redistribute it
11
! and/or modify it under the terms of the GNU General Public License
12
! as published by the Free Software Foundation; either version 2 of
13
! the License, or (at your option) any later version.
15
! The Code_Saturne Kernel is distributed in the hope that it will be
16
! useful, but WITHOUT ANY WARRANTY; without even the implied warranty
17
! of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
! GNU General Public License for more details.
20
! You should have received a copy of the GNU General Public License
21
! along with the Code_Saturne Kernel; if not, write to the
22
! Free Software Foundation, Inc.,
23
! 51 Franklin St, Fifth Floor,
24
! Boston, MA 02110-1301 USA
3
! This file is part of Code_Saturne, a general-purpose CFD tool.
5
! Copyright (C) 1998-2011 EDF S.A.
7
! This program is free software; you can redistribute it and/or modify it under
8
! the terms of the GNU General Public License as published by the Free Software
9
! Foundation; either version 2 of the License, or (at your option) any later
12
! This program is distributed in the hope that it will be useful, but WITHOUT
13
! ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14
! FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17
! You should have received a copy of the GNU General Public License along with
18
! this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
19
! Street, Fifth Floor, Boston, MA 02110-1301, USA.
26
21
!-------------------------------------------------------------------------------
28
23
subroutine ecrhis &
31
( idbia0 , idbra0 , ndim , ncelet , ncel , &
32
nideve , nrdeve , nituse , nrtuse , modhis , &
33
idevel , ituser , ia , &
34
xyzcen , rdevel , rtuser , ra )
26
( ndim , ncelet , ncel , modhis , xyzcen , ra )
36
28
!===============================================================================
40
! ROUTINE D'ECRITURE DES HISTORIQUES
42
34
!-------------------------------------------------------------------------------
44
36
!__________________.____._____.________________________________________________.
45
37
! name !type!mode ! role !
46
38
!__________________!____!_____!________________________________________________!
47
! idbia0 ! i ! <-- ! number of first free position in ia !
48
! idbra0 ! i ! <-- ! number of first free position in ra !
49
39
! ndim ! i ! <-- ! spatial dimension !
50
40
! ncelet ! i ! <-- ! number of extended (real + ghost) cells !
51
41
! ncel ! i ! <-- ! number of cells !
52
! nideve, nrdeve ! i ! <-- ! sizes of idevel and rdevel arrays !
53
! nituse, nrtuse ! i ! <-- ! sizes of ituser and rtuser arrays !
54
! modhis ! e ! <-- ! indicateur valant 0,1 ou 2 !
55
! ! ! ! 1,2 = ecriture intermediaire, finale !
56
! idevel(nideve) ! ia ! <-> ! integer work array for temporary development !
57
! ituser(nituse) ! ia ! <-> ! user-reserved integer work array !
58
! ia(*) ! ia ! --- ! main integer work array !
59
! xyzcen ! tr ! <-- ! point associes aux volumes de control !
60
! (ndim,ncelet) ! ! ! !
61
! rdevel(nrdeve) ! ra ! <-> ! real work array for temporary development !
62
! rtuser(nrtuse) ! ra ! <-> ! user-reserved real work array !
63
! ra ! tr ! -- ! tableau des reels !
42
! modhis ! i ! <-- ! 0 or 1: initialize/output; 2: finalize !
43
! xyzcen ! ra ! <-- ! cell centers !
44
! (ndim, ncelet) ! ! ! !
45
! ra(*) ! ra ! <-- ! main real work array !
64
46
!__________________!____!_____!________________________________________________!
66
! TYPE : E (ENTIER), R (REEL), A (ALPHANUMERIQUE), T (TABLEAU)
67
! L (LOGIQUE) .. ET TYPES COMPOSES (EX : TR TABLEAU REEL)
68
! MODE : <-- donnee, --> resultat, <-> Donnee modifiee
69
! --- tableau de travail
48
! Type: i (integer), r (real), s (string), a (array), l (logical),
49
! and composite types (ex: ra real array)
50
! mode: <-- input, --> output, <-> modifies data, --- work array
51
!===============================================================================
53
!===============================================================================
55
!===============================================================================
70
64
!===============================================================================
74
!===============================================================================
76
!===============================================================================
85
!===============================================================================
89
integer idbia0, idbra0
90
70
integer ndim, ncelet, ncel
91
integer nideve , nrdeve , nituse , nrtuse
93
integer idevel(nideve), ituser(nituse), ia(*)
94
double precision xyzcen(ndim,ncelet)
95
double precision rdevel(nrdeve), rtuser(nrtuse), ra(*)
72
double precision xyzcen(ndim, ncelet)
73
double precision, dimension(*), target :: ra
99
character nomfic*300, nenvar*300
100
integer ii, ii1, ii2, lpos, inam1, inam2, lng
101
integer icap,ncap,ipp,ira,ipp2,nbpdte, jtcabs
102
integer idivdt, ixmsdt, idebia, idebra, ifinra, iel
77
character nompre*300, nomhis*300
78
integer tplnum, ii, ii1, ii2, lpre, lnom, lng
79
integer icap, ncap, ipp, ira, ipp2, jtcabs
80
integer idivdt, ixmsdt, iel
103
81
integer nbcap(nvppmx)
104
double precision xtcabs,xyztmp(3)
82
double precision xtcabs
105
83
double precision varcap(ncaptm)
107
! NOMBRE DE PASSAGES DANS LA ROUTINE
85
integer, dimension(:), allocatable :: lsttmp
86
double precision, dimension(:), allocatable, target :: momtmp
87
double precision, dimension(:,:), allocatable :: xyztmp
89
double precision, dimension(:), pointer :: varptr => null()
91
! Time plot number shift (in case multiple routines define plots)
97
! Number of passes in this routine
113
103
!===============================================================================
114
! 0. INITIALISATIONS LOCALES
104
! 0. Local initializations
115
105
!===============================================================================
117
107
ipass = ipass + 1
109
!--> If no probe data has been output or there are no probes, return
110
if ((ipass.eq.1 .and. modhis.eq.2) .or. ncapt.eq.0) return
122
!--> Il n'y a pas eu d'historiques ou s'il n'y a pas de capteur
123
if((ipass.eq.1.and.modhis.eq.2) .or. ncapt.eq.0) return
125
117
!===============================================================================
126
! 1. RECHERCHE DES NOEUDS PROCHES -> NODCAP
118
! 1. Search for neighboring nodes -> nodcap
127
119
!===============================================================================
129
121
if (ipass.eq.1) then
134
( ncelet, ncel, xyzcen , &
135
xyzcap(1,ii), xyzcap(2,ii), xyzcap(3,ii), &
136
nodcap(ii), ndrcap(ii))
126
(ncelet, ncel, xyzcen, &
127
xyzcap(1,ii), xyzcap(2,ii), xyzcap(3,ii), nodcap(ii), ndrcap(ii))
141
132
!===============================================================================
142
! 2. OUVERTURE DU FICHIER DE STOCKAGE hist.tmp
133
! 2. Initialize output
143
134
!===============================================================================
145
if(ipass.eq.1 .and. irangp.le.0) then
148
call verlon (nomfic,ii1,ii2,lpos)
136
! Create directory if required
137
if (ipass.eq.1 .and. irangp.le.0) then
138
call csmkdr(emphis, len(emphis))
151
nomfic(ii2+1:ii2+8) = 'hist.tmp'
153
open (unit=imphis(1), file=nomfic(ii1:ii2), &
154
status='unknown', form='unformatted', &
158
!===============================================================================
159
! 3. ECRITURE DES RESULTATS dans le FICHIER DE STOCKAGE
160
!===============================================================================
162
if(modhis.eq.0.or.modhis.eq.1) then
165
if(ihisvr(ipp,1).ne.0) then
144
! Number of probes per variable
146
nbcap(ipp) = ihisvr(ipp,1)
147
if (nbcap(ipp).lt.0) nbcap(ipp) = ncapt
150
allocate(lsttmp(ncapt))
151
allocate(xyztmp(3, ncapt))
153
! Initialize one output per variable
157
if (ihisvr(ipp,1) .gt. 0) then
158
do ii=1, ihisvr(ipp,1)
159
lsttmp(ii) = ihisvr(ipp,ii+1)
160
if (irangp.lt.0 .or. irangp.eq.ndrcap(ihisvr(ipp, ii+1))) then
161
xyztmp(1, ii) = xyzcen(1, nodcap(ihisvr(ipp, ii+1)))
162
xyztmp(2, ii) = xyzcen(2, nodcap(ihisvr(ipp, ii+1)))
163
xyztmp(3, ii) = xyzcen(3, nodcap(ihisvr(ipp, ii+1)))
165
if (irangp.ge.0) then
167
call parbcr(ndrcap(ihisvr(ipp,ii+1)), lng , xyztmp(1, ii))
172
do ii = 1, nbcap(ipp)
174
if (irangp.lt.0 .or. irangp.eq.ndrcap(ii)) then
175
xyztmp(1, ii) = xyzcen(1, nodcap(ii))
176
xyztmp(2, ii) = xyzcen(2, nodcap(ii))
177
xyztmp(3, ii) = xyzcen(3, nodcap(ii))
179
if (irangp.ge.0) then
181
call parbcr(ndrcap(ii), lng , xyztmp(1, ii))
187
if (nbcap(ipp) .gt. 0) then
189
if (irangp.le.0) then
193
call verlon(emphis, ii1, ii2, lpre)
195
nompre(1:lpre) = emphis(ii1:ii2)
196
call verlon(prehis, ii1, ii2, lnom)
198
nompre(lpre+1:lpre+lnom) = prehis(ii1:ii2)
199
call verlon(nompre, ii1, ii2, lpre)
204
call verlon(nomvar(ipp), ii1, ii2, lnom)
206
nomhis(1:lnom) = nomvar(ipp)(ii1:ii2)
209
call tppini(tplnum, nomhis, nompre, tplfmt, idtvar, nthsav, tplflw, &
211
nbcap(ipp), lsttmp(1), xyzcap(1,1), lnom, lpre)
213
endif ! (irangp.le.0)
224
!===============================================================================
226
!===============================================================================
228
if (modhis.eq.0 .or. modhis.eq.1) then
231
if (ihisvr(ipp,1).ne.0) then
166
232
ira = abs(ipp2ra(ipp))
168
! Pour les moments, il faut eventuellement diviser par le temps cumule
234
! For moments, we must divide by the cumulative time
169
235
idivdt = ippmom(ipp)
236
if (idivdt.eq.0) then
237
varptr => ra(ira:ira+ncel)
174
ifinra = ixmsdt + ncel
175
call rasize ('ecrhis', ifinra)
180
ra(ixmsdt+iel-1) = ra(ira+iel-1)/ max(ra(idivdt+iel-1),epzero)
182
elseif(idivdt.lt.0) then
184
ra(ixmsdt+iel-1) = ra(ira+iel-1)/ max(dtcmom(-idivdt),epzero)
187
! ra(ixmsdt+iel-1) = ra(ira+iel-1)
188
! inutile car on a pose ixmsdt = ira
239
allocate(momtmp(ncel))
241
if (idivdt.gt.0) then
243
momtmp(iel) = ra(ira+iel-1)/max(ra(idivdt+iel-1),epzero)
245
elseif (idivdt.lt.0) then
247
momtmp(iel) = ra(ira+iel-1)/max(dtcmom(-idivdt),epzero)
191
if(ihisvr(ipp,1).lt.0) then
252
if (ihisvr(ipp,1).lt.0) then
192
253
do icap = 1, ncapt
193
254
if (irangp.lt.0) then
194
varcap(icap) = ra(ixmsdt+nodcap(icap)-1)
255
varcap(icap) = varptr(nodcap(icap))
196
call parhis(nodcap(icap), ndrcap(icap), ra(ixmsdt), varcap(icap))
257
call parhis(nodcap(icap), ndrcap(icap), varptr, varcap(icap))
202
263
do icap = 1, ihisvr(ipp,1)
203
264
if (irangp.lt.0) then
204
varcap(icap) = ra(ixmsdt+nodcap(ihisvr(ipp,icap+1))-1)
265
varcap(icap) = varptr(nodcap(ihisvr(ipp,icap+1)))
206
267
call parhis(nodcap(ihisvr(ipp,icap+1)), &
208
269
ndrcap(ihisvr(ipp,icap+1)), &
209
ra(ixmsdt), varcap(icap))
270
varptr, varcap(icap))
212
273
ncap = ihisvr(ipp,1)
214
if (irangp.le.0) then
215
write(imphis(1)) ntcabs, ttcabs, (varcap(icap), icap=1,ncap)
222
!===============================================================================
223
! 4. EN CAS DE SAUVEGARDE INTERMEDIAIRE OU FINALE,
224
! TRANSMISSION DES INFORMATIONS DANS LES DIFFERENTS FICHIERS
225
!===============================================================================
227
! On sauve aussi au premier passage pour permettre une
228
! verification des le debut du calcul
230
if(modhis.eq.1 .or. modhis.eq.2 .or. ipass.eq.1) then
232
! --> nombre de pas de temps enregistres
240
! --> nombre de capteur par variable
242
nbcap(ipp) = ihisvr(ipp,1)
243
if(nbcap(ipp).lt.0) nbcap(ipp) = ncapt
246
! --> ecriture un fichier par variable
249
if (ihisvr(ipp,1).ne.0) then
251
if (irangp.le.0) then
255
call verlon ( nomfic,ii1,ii2,lpos)
258
call verlon(nenvar,inam1,inam2,lpos)
260
call undscr(inam1,inam2,nenvar)
262
nomfic(ii2+1:ii2+lpos) = nenvar(inam1:inam2)
263
call verlon ( nomfic,ii1,ii2,lpos)
266
call verlon(nenvar,inam1,inam2,lpos)
268
call undscr(inam1,inam2,nenvar)
270
nomfic(ii2+1:ii2+lpos) = nenvar(inam1:inam2)
272
nomfic(ii2+1:ii2+1) = '.'
275
call verlon(nenvar,inam1,inam2,lpos)
277
call undscr(inam1,inam2,nenvar)
279
nomfic(ii2+1:ii2+lpos) = nenvar(inam1:inam2)
282
open (unit=imphis(2), file=nomfic (ii1:ii2), &
283
status='UNKNOWN', form='FORMATTED', &
288
write(imphis(2),102) nomvar(ipp)
295
if(ihisvr(ipp,1).gt.0) then
296
do ii=1,ihisvr(ipp,1)
297
if (irangp.lt.0 .or. irangp.eq.ndrcap(ihisvr(ipp,ii+1))) then
298
xyztmp(1) = xyzcen(1,nodcap(ihisvr(ipp,ii+1)))
299
xyztmp(2) = xyzcen(2,nodcap(ihisvr(ipp,ii+1)))
300
xyztmp(3) = xyzcen(3,nodcap(ihisvr(ipp,ii+1)))
302
if (irangp.ge.0) then
304
call parbcr(ndrcap(ihisvr(ipp,ii+1)), lng , xyztmp)
308
write(imphis(2),105) ihisvr(ipp,ii+1), &
309
xyztmp(1), xyztmp(2), xyztmp(3)
312
elseif(ihisvr(ipp,1).lt.0) then
314
if (irangp.lt.0 .or. irangp.eq.ndrcap(ii)) then
315
xyztmp(1) = xyzcen(1,nodcap(ii))
316
xyztmp(2) = xyzcen(2,nodcap(ii))
317
xyztmp(3) = xyzcen(3,nodcap(ii))
319
if (irangp.ge.0) then
321
call parbcr(ndrcap(ii), lng , xyztmp)
325
write(imphis(2),105) ii, xyztmp(1), xyztmp(2), xyztmp(3)
333
write(imphis(2),106) nbpdte
343
write(imphis(2),110) nomvar(ipp)
344
write(imphis(2),111) (icap, icap=1,nbcap(ipp))
345
write(imphis(2),112) ('-', icap=1,nbcap(ipp))
348
! --> boucle sur les differents enregistrements et les variables
352
if(ihisvr(ipp2,1).ne.0) then
354
jtcabs, xtcabs, (varcap(icap),icap=1,nbcap(ipp2))
356
write(imphis(2),1000) &
357
jtcabs, xtcabs, (varcap(icap),icap=1,nbcap(ipp))
362
! --> fermeture fichier
372
!===============================================================================
374
!===============================================================================
376
#if defined(_CS_LANG_FR)
378
100 format ('# ---------------------------------------------------')
379
101 format ('# Fichier historique en temps')
380
102 format ('# Variable ',A16)
382
104 format ('# Position des capteurs (colonne)')
383
105 format ('# ',I6,')',3(1X,E14.7))
384
106 format ('# Nombre d''enregistrements :',I7)
386
'# Colonne 1 : Numero du pas de temps ',/, &
387
'# 2 : Temps physique (ou No pas de temps*dtref ',/, &
388
'# en pas de temps non uniforme)',/, &
389
'# 3 a 100 : Valeur aux capteurs')
393
100 format ('# ---------------------------------------------------')
394
101 format ('# Time monitoring file')
395
102 format ('# Variable ',A16)
397
104 format ('# Monitoring point coordinates (column)')
398
105 format ('# ',I6,')',3(1X,E14.7))
399
106 format ('# Number of records:',I7)
401
'# Column 1 : Time step number ',/, &
402
'# 2 : Physical time (or Nb of time steps*dtref ',/, &
403
'# with non uniform time step)',/, &
404
'# 3 to 100 : Value at monitoring points')
408
110 format ('#TITLE: ', A16)
409
111 format ('#COLUMN_TITLES: nt | t ', 100(' | ',I3))
410
112 format ('#COLUMN_UNITS: iter s', 100(1x, A))
411
1000 format ( 1(1x,i7,1x),101(1x,e14.7))
276
if (idivdt.ne.0) then
280
if (irangp.le.0 .and. ncap.gt.0) then
282
call tplwri(tplnum, tplfmt, ncap, ntcabs, ttcabs, varcap)
290
!===============================================================================
292
!===============================================================================
294
if (modhis.eq.2) then
297
if (ihisvr(ipp,1).lt.0) then
302
if (irangp.le.0 .and. ncap.gt.0) then
304
call tplend(tplnum, tplfmt)
311
!===============================================================================
313
!===============================================================================