1 | include(dom.inc)
2 | ! ===============================================================
3 | ! Copyright (c) CERFACS (all rights reserved)
4 | ! ===============================================================
5 |
6 | ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7 | ! module: ensight_write.f
8 | !
9 | ! author: Andre Kaufmann, 14/16.08.2000
10 | ! author: Charles Martin, 11.09.2004
11 | ! last change: J. Amaya, O. Cabrit, A. Roux - 11/2006
12 | ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
13 | module ensightgold_write
14 | use ensight_variables
15 | implicit none
16 |
17 | ! format identifier : 1 binary
18 | ! 2 ascii without line numbers
19 | ! 3 ascii with line numbers
20 |
21 | DOM_INT :: ensight_write_format = 1
22 |
23 | ! debug information
24 | logical :: ensight_write_debug = .false.
25 |
26 | contains
27 | ! ================================================================
28 | ! ================================================================
29 | ! write real scalar fields to ascii file
30 | ! ================================================================
31 | subroutine write_real_scalar_ascii(n,startn,nbrscalar, &
32 | & field,identifier, &
33 | & filename)
34 | implicit none
35 | DOM_INT i,n,startn,nbrscalar
36 | DOM_INT m,nbrloop,nbrmod
37 | character*80 identifier
38 | character*240 filename
39 | real*4,dimension(:,:)::field
40 |
41 | if(ensight_write_debug) then
42 | write(*,*) 'writing scalar field with identifier ', &
43 | & identifier
44 | write(*,*) 'to the ascii file ',filename
45 | endif
46 |
47 | if(ensight_write_debug) then
48 | write(*,*) ' identifier ',identifier
49 | write(*,*) ' nbrscalar ',nbrscalar
50 | write(*,*) ' startn,n ',startn,n
51 | endif
52 |
53 |
54 | open(2,file=filename,form='formatted')
55 | write(2,'(A)') identifier
56 | write(2,'(A)') 'part'
57 | write(2,'(i10)') 1
58 | write(2,'(A)') 'coordinates'
59 |
60 | do m=1,n
61 | write(2,'(e12.5)') field(nbrscalar,startn+m-1)
62 | enddo
63 |
64 | close(2)
65 |
66 | end subroutine write_real_scalar_ascii
67 | ! ================================================================
68 | ! write real vector fields
69 | ! ================================================================
70 |
71 | ! ================================================================
72 | ! write real vector fields to ascii
73 | ! ================================================================
74 | subroutine write_real_vector_ascii(n,ndim,startn,nbrvector, &
75 | & field,identifier,filename)
76 | implicit none
77 | DOM_INT i,k,n,ndim,startn,nbrvector
78 | DOM_INT m,nbrloop,nbrmod
79 | character*80 identifier
80 | character*240 filename
81 | real*4,dimension(:,:)::field
82 | real*4,allocatable,dimension(:)::dummyfield
83 | !
84 | ! debug info
85 | !
86 | if(ensight_write_debug) then
87 | write(*,*) 'writing vector field with identifier ', &
88 | & identifier
89 | write(*,*) 'to the ascii file ',filename
90 | endif
91 |
92 | open(2,file=filename,form='formatted')
93 |
94 | if(ensight_write_debug) then
95 | write(*,*) ' identifier ',identifier
96 | write(*,*) ' ndim ',ndim
97 | write(*,*) ' startn,n ',startn,n
98 | endif
99 |
100 | if(allocated(dummyfield)) deallocate(dummyfield)
101 | !
102 | ! write identifier
103 | !
104 | write(2,'(A)') identifier
105 | write(2,'(A)') 'part'
106 | write(2,'(i10)') 1
107 | write(2,'(A)') 'coordinates'
108 | !
109 | ! 2d
110 | !
111 | if(ndim.eq.2) then
112 | allocate(dummyfield(1:3*n))
113 | do k=1,2
114 | do i=startn,startn+n-1
115 | dummyfield((k-1)*n+i)=field(nbrvector,(k-1)*n+i)
116 | enddo
117 | enddo
118 | k =3
119 | do i=startn,startn+n-1
120 | dummyfield((k-1)*n+i)=0.0d0
121 | enddo
122 |
123 | do m=1,3*n
124 | write(2,'(e12.5)') dummyfield(m)
125 | enddo
126 |
127 | if(allocated(dummyfield)) deallocate(dummyfield)
128 | !
129 | ! 3d
130 | !
131 | else if(ndim.eq.3) then
132 |
133 | do k=1,3
134 | do m=1,n
135 | write(2,'(e12.5)') field(nbrvector,(k-1)*n+m-1+startn)
136 | enddo
137 | enddo
138 |
139 | !
140 | ! wrong dimension
141 | !
142 | else
143 | write(*,*) 'wrong vector dimension (ndim=',ndim,')'
144 | endif
145 | close(2)
146 |
147 | end subroutine write_real_vector_ascii
148 | ! ================================================================
149 | !
150 | ! write the solution files
151 | !
152 | ! ================================================================
153 | subroutine ensight_write_sol(path,recid)
154 | implicit none
155 | character*80 path
156 | character*240 fname,filename
157 | character*8 recid8,recid
158 | character*7 recid7
159 | DOM_INT i,j,k,pl,fnl,rl,n,nn
160 | logical itexists
161 | real*4, dimension(:), allocatable :: scalar1
162 | real*4, dimension(:), allocatable :: scalar2
163 | real*4, dimension(:), allocatable :: scalar3
164 |
165 | recid8 = recid
166 |
167 |
168 | !
169 | ! write scalar fields
170 | !
171 | do i=1,ensight_nscalars
172 | !
173 | ! create composite filename
174 | !
175 | pl = len_trim(path)
176 | fname = ensight_scal_fn(i)
177 | fnl = len_trim(fname)
178 | rl = len_trim(recid)
179 |
180 | if (ensight_nrec.gt.1) then
181 | filename = path(1:pl)//'/'//fname(1:fnl)//'.ensight' &
182 | & //recid(1:rl)
183 | else
184 | filename = path(1:pl)//'/'//fname(1:fnl)//'.ensight'
185 | endif
186 |
187 | ! if(pl.ge.1) then
188 | ! filename = path(1:pl)//fname(1:fnl)//'.ensight'//recid(1:rl)
189 | ! else
190 | ! filename = './'//fname(1:fnl)//'.ensight'//recid(1:rl)
191 | ! endif
192 |
193 | ! write(*,*) ' pl,fnl :',pl,fnl
194 | ! write(*,*) ' sname :',ensight_scal_fn(i)
195 | ! write(*,*) ' filename :',filename
196 | !
197 | ! check for existance
198 | !
199 | n = len_trim(filename)
200 | inquire(file=filename,exist=itexists)
201 |
202 | !
203 | ! and write it to the specified filename
204 | !
205 |
206 | if(itexists.AND.(.NOT.ensight_overwrite)) then
207 | write(*,*) ' WARNING: file exists: ',filename(1:n)
208 | write(*,*) ' The old file will be kept.'
209 | else if(ensight_write_format.eq.1) then
210 | !
211 | ! write binary field
212 | !
213 | if (itexists) then
214 | write(*,*) ' WARNING: file exists: ',filename(1:n)
215 | write(*,*) ' The old file will be erased'
216 | endif
217 |
218 | if(allocated(scalar1)) deallocate(scalar1)
219 | allocate(scalar1(1:ensight_nnode))
220 | scalar1(:)=ensight_scalars(i,:)
221 | if(ensight_write_debug) print*, 'writing scalar#',i
222 | nn=len_trim(ensight_scal_name(i))
223 | call write_real_scalar_bin(filename,n, &
224 | & ensight_scal_name(i),nn,scalar1,ensight_nnode)
225 | deallocate(scalar1)
226 | !
227 | ! write ascii field
228 | !
229 | else if(ensight_write_format.ge.2) then
230 | if (itexists) then
231 | write(*,*) ' WARNING: file exists: ',filename(1:n)
232 | write(*,*) ' The old file will be erased'
233 | endif
234 | call write_real_scalar_ascii(ensight_nnode,1,i, &
235 | & ensight_scalars, &
236 | & ensight_scal_name(i), &
237 | & filename)
238 | else
239 | write(*,*) "wrong ensight write frmt", &
240 | & ensight_write_format
241 | endif
242 |
243 | enddo
244 | !
245 | ! write vector fields
246 | !
247 | do i=1,ensight_nvectors
248 | !
249 | ! create composite filename
250 | !
251 | pl = len_trim(path)
252 | fname = "/"//ensight_vec_fn(i)
253 | fnl = len_trim(fname)
254 | rl = len_trim(recid)
255 |
256 | if (ensight_nrec.gt.1) then
257 | filename = path(1:pl)//fname(1:fnl)//'.ensight'//recid(1:rl)
258 | else
259 | filename = path(1:pl)//fname(1:fnl)//'.ensight'
260 | endif
261 |
262 |
263 | ! if(pl.ge.1) then
264 | ! filename = path(1:pl)//fname(1:fnl)//'.ensight'//recid(1:rl)
265 | ! else
266 | ! filename = './'//fname(1:fnl)//'.ensight'//recid(1:rl)
267 | ! endif
268 |
269 | ! write(*,*) ' pl,fnl :',pl,fnl
270 | ! write(*,*) ' sname :',ensight_vec_fn(i)
271 | ! write(*,*) ' filename :',filename
272 | !
273 | ! check for existance
274 | !
275 | inquire(file=filename,exist=itexists)
276 | n = len_trim(filename)
277 |
278 | !
279 | ! and write it to the specified filename
280 | !
281 |
282 | if(itexists.AND.(.NOT.ensight_overwrite)) then
283 | write(*,*) ' WARNING: file exists: ',filename(1:n)
284 | else
285 | !
286 | ! write binary field
287 | !
288 | if(ensight_write_format.eq.1) then
289 |
290 | nn=len_trim(ensight_vec_name(i))
291 | if(allocated(scalar1)) deallocate(scalar1)
292 | if(allocated(scalar2)) deallocate(scalar2)
293 | if(allocated(scalar3)) deallocate(scalar3)
294 | allocate(scalar1(1:ensight_nnode))
295 | allocate(scalar2(1:ensight_nnode))
296 | allocate(scalar3(1:ensight_nnode))
297 |
298 | scalar1(:)=ensight_vectors(i,1:ensight_nnode)
299 | scalar2(:)= &
300 | & ensight_vectors(i,ensight_nnode+1:2*ensight_nnode)
301 | if(ensight_vectordims.eq.3) then
302 | scalar3(:)= &
303 | & ensight_vectors(i,2*ensight_nnode+1:3*ensight_nnode)
304 | else
305 | scalar3(:)=0.0
306 | endif
307 |
308 | nn=len_trim(ensight_vec_name(i))
309 | call write_real_vector_bin(filename,n, &
310 | & ensight_vec_name(i),nn,scalar1,scalar2,scalar3, &
311 | & ensight_nnode)
312 | deallocate(scalar1)
313 | deallocate(scalar2)
314 | deallocate(scalar3)
315 |
316 | else if(ensight_write_format.ge.2) then
317 |
318 | call write_real_vector_ascii(ensight_nnode, &
319 | & ensight_vectordims,1,i, &
320 | & ensight_vectors, &
321 | & ensight_vec_name(i), &
322 | & filename)
323 | else
324 | write(*,*) "wrong ensight write frmt ", &
325 | & ensight_write_format
326 | endif
327 | endif
328 |
329 | enddo
330 |
331 |
332 | end subroutine ensight_write_sol
333 | ! ================================================================
334 | !
335 | ! write the res info file
336 | !
337 | ! ================================================================
338 | subroutine ensight_write_case(path,prefix, &
339 | & iensight, &
340 | & istart,istep,nloop,multi)
341 | implicit none
342 | character*240 resname,sfname,vfname,filename
343 | character*80 path,prefix,sname,vname,buffer
344 | character*7 wildcard,wildcard7,recid7
345 | character*8 wildcard8,recid8,recid
346 | DOM_INT iensight,nloop,k,n
347 | real*4 time
348 | DOM_INT pl,prl,sl,wl,sfl,vl,vfl,fnl,iunsteady,irec
349 | DOM_INT istart,istep
350 | logical itexists
351 | logical multi, choices_needsolution
352 | character*13 fmt3int
353 | character*9 fmt2int
354 | character*5 fmt1int
355 |
356 | DATA fmt3int /'(i8,i8,i8)'/
357 | DATA fmt2int /'(i8,i8)'/
358 | DATA fmt1int /'(i8)'/
359 |
360 | pl = len_trim(path)
361 | prl= len_trim(prefix)
362 |
363 | ! For multiple solution cases set this to TRUE !
364 | choices_needsolution = .FALSE.
365 |
366 | if( prefix.ne.'none') then
367 | resname = path(1:pl)//'/'//prefix(1:prl)//'ensight.case'
368 | else
369 | resname = path(1:pl)//'/'//'ensight.case'
370 | endif
371 |
372 | !
373 | ! check for existance
374 | !
375 | inquire(file=resname,exist=itexists)
376 |
377 | !
378 | ! and write it to the specified filename
379 | !
380 | if(itexists.AND.(.NOT.ensight_overwrite)) then
381 | n = len_trim(resname)
382 | write(*,*) ' File exists !',resname(1:n)
383 | else
384 |
385 | open(unit=2,file=resname,form='formatted')
386 |
387 | if((iensight.eq.1).OR.(iensight.eq.-1).OR.(iensight.eq.0)) then
388 | wildcard7 = ' '
389 | wildcard8 = ' '
390 | else
391 | if(nloop.eq.1) then
392 | wildcard7 = '_******'
393 | wildcard8 = '_*******'
394 | else
395 | wildcard7 = '_*** '
396 | wildcard8 = '_*** '
397 | endif
398 | endif
399 | !
400 | ! Case file header:
401 | !
402 | write(2,'(A)') '# Ensight Gold case file generated by a2gold'
403 | write(2,'(A)') 'FORMAT'
404 | write(2,'(A)') ''
405 | write(2,'(A)') 'type: ensight gold'
406 | write(2,'(A)') ''
407 | write(2,'(A)') 'GEOMETRY'
408 | IF (multi) THEN
409 | write(2,'(A)') 'model: ensight.geo_*******'
410 | ELSE
411 | write(2,'(A)') 'model: ensight.geo'
412 | ENDIF
413 | write(2,'(A)') ''
414 | write(2,'(A)') 'VARIABLE'
415 | write(2,'(A)') ''
416 |
417 | !
418 | ! output time for unsteady, iteration for steady calculation
419 | !
420 | write(*,*)
421 | write(*,*)
422 |
423 |
424 | iunsteady = 0
425 | do irec=1,ensight_nrec
426 | if(ensight_time(irec).ne.0.0d0) then
427 | iunsteady = 1
428 | endif
429 | enddo
430 |
431 |
432 | !
433 | ! Scalar filenames and names of scalar fields
434 | !
435 | do k=1,ensight_nscalars
436 | sname = ensight_scal_name(k)
437 | sfname = ensight_scal_fn(k)
438 |
439 | sl = len_trim(sname)
440 | sfl = len_trim(sfname)
441 |
442 | wildcard = wildcard8
443 |
444 | ! filename = sfname(1:sfl)//wildcard
445 | if ((ensight_nrec.gt.1).and.choices_needsolution) then
446 | filename = sname(1:sl)//'.ensight_*******'
447 | else
448 | filename = sname(1:sl)//'.ensight'
449 | endif
450 |
451 | fnl = len_trim(filename)
452 | if (choices_needsolution) then
453 | if(prefix.ne.'none') then
454 | write(2,'(A,1X,A,1X,A)') 'scalar per node: 1 ', &
455 | & sname(1:sl),prefix(1:prl)//filename(1:fnl)
456 | else
457 | write(2,'(A,1X,A,1X,A)') 'scalar per node: 1 ', &
458 | & sname(1:sl),filename(1:fnl)
459 | endif
460 | else
461 | if(prefix.ne.'none') then
462 | write(2,'(A,1X,A,1X,A)') 'scalar per node: ', &
463 | & sname(1:sl),prefix(1:prl)//filename(1:fnl)
464 | else
465 | write(2,'(A,1X,A,1X,A)') 'scalar per node: ', &
466 | & sname(1:sl),filename(1:fnl)
467 | endif
468 | endif
469 | enddo
470 | !
471 | ! Vector filenames and names of vector fields
472 | !
473 | do k=1,ensight_nvectors
474 | vname = ensight_vec_name(k)
475 | vfname = ensight_vec_fn(k)
476 | vl = len_trim(vname)
477 | vfl = len_trim(vfname)
478 |
479 | wildcard = wildcard8
480 |
481 | ! filename = vfname(1:vfl)//wildcard
482 | if (ensight_nrec.gt.1) then
483 | filename = vfname(1:vfl)//'.ensight_*******'
484 | else
485 | filename = vfname(1:vfl)//'.ensight'
486 | endif
487 |
488 | fnl = len_trim(filename)
489 | if (choices_needsolution) then
490 | if(prefix.ne.'none') then
491 | write(2,'(A,1X,A,1X,A)') 'vector per node: 1 ', &
492 | & vname(1:vl),prefix(1:prl)//filename(1:fnl)
493 | else
494 | write(2,'(A,1X,A,1X,A)') 'vector per node: 1 ', &
495 | & vname(1:vl),filename(1:fnl)
496 | endif
497 | else
498 | if(prefix.ne.'none') then
499 | write(2,'(A,1X,A,1X,A)') 'vector per node: ', &
500 | & vname(1:vl),prefix(1:prl)//filename(1:fnl)
501 | else
502 | write(2,'(A,1X,A,1X,A)') 'vector per node: ', &
503 | & vname(1:vl),filename(1:fnl)
504 | endif
505 | endif
506 | enddo
507 | ! write time
508 | ! iunsteady = 0
509 | ! do irec=1,ensight_nrec
510 | ! if(ensight_time(irec).ne.0.0d0) then
511 | ! iunsteady = 1
512 | ! endif
513 | ! enddo
514 |
515 | if(choices_needsolution) then
516 | write(2,'(A)') 'TIME'
517 | write(2,'(A)') ''
518 | write(2,'(A)') 'time set: 1'
519 | write(2,'(A,1X,I10)') 'number of steps: ',ensight_nrec
520 | write(2,'(A,1X,I10)') 'filename start number:',istart
521 | write(2,'(A,1X,I10)') 'filename increment:',istep
522 | write(2,'(A)') 'time values:'
523 | do irec=1,ensight_nrec
524 | write(*,*) irec,'time =',ensight_time(irec), &
525 | & 'iteration =',ensight_iter(irec)
526 | write(2,'(e12.5)') ensight_time(irec)
527 | enddo
528 |
529 | endif
530 |
531 | close(2)
532 |
533 | ! -----------------------------------------------------
534 | ! Write index of last file read and target path
535 | ! for ensight files for 'ens' command file
536 | ! -----------------------------------------------------
537 | pl = len_trim(path)
538 | prl= len_trim(prefix)
539 |
540 | if( prefix.ne.'none') then
541 | sname = path(1:pl)//'/'//prefix(1:prl)//'ens_startup_time'
542 | else
543 | sname = path(1:pl)//'/ens_startup_time'
544 | endif
545 |
546 | ! open( 2,file=sname,form='formatted')
547 | ! write(2,'(A,1X,I2)') 'data: start_time',ensight_nrec-1
548 | ! close(2)
549 |
550 | ! sname='ens_targetpath'
551 | ! open( 2,file=sname,form='formatted')
552 | ! write(2,*) path(1:pl)
553 | ! write(2,*) prefix(1:prl)
554 | ! close(2)
555 |
556 |
557 | if( prefix.ne.'none') then
558 | sname = path(1:pl)//'/'//prefix(1:prl)//'ensight_startup.cmd'
559 | else
560 | sname = path(1:pl)//'/ensight_startup.cmd'
561 | endif
562 |
563 | open( 2,file=sname,form='formatted')
564 | write(2,'(A,1X)') 'VERSION 7.62'
565 | write(2,'(A,1X)') 'data: binary_files_are big_endian'
566 | write(2,'(A,1X)') 'data: format case'
567 | write(2,'(A,1X)') 'data: path .'
568 | write(2,'(A,1X)') 'data: geometry ensight.case'
569 | write(2,'(A,1X)') 'data: start_time 1'
570 | write(2,'(A,1X)') 'data: read'
571 | write(2,'(A,1X)') 'data_partbuild: begin'
572 | write(2,'(A,1X)') 'data_partbuild: data_type unstructured'
573 | write(2,'(A,1X)') 'data_partbuild: description'
574 | write(2,'(A,1X)') 'data_partbuild: select_begin'
575 | write(2,'(A,1X)') ' 1 '
576 | write(2,'(A,1X)') 'data_partbuild: select_end'
577 | write(2,'(A,1X)') 'data_partbuild: create'
578 | write(2,'(A,1X)') 'data_partbuild: end'
579 |
580 | close(2)
581 |
582 | endif
583 |
584 | end subroutine ensight_write_case
585 |
586 | ! ================================================================
587 | !
588 | ! write the multiple geometry res info file
589 | !
590 | ! ================================================================
591 | subroutine ensight_write_multiple_case(path,prefix, &
592 | & iensight, &
593 | & istart,istep,nloop)
594 | implicit none
595 | character*240 resname,sfname,vfname,filename
596 | character*80 path,prefix,sname,vname,geomname,buffer
597 | character*7 recid
598 | character*7 wildcard7,recid7
599 | character*8 wildcard8,recid8,wildcard
600 | DOM_INT iensight,nloop,k,n
601 | real*4 time
602 | DOM_INT pl,prl,sl,sfl,vl,vfl,fnl,iunsteady,irec
603 | DOM_INT istart,istep
604 | logical itexists
605 | character*13 fmt3int
606 | character*9 fmt2int
607 | character*5 fmt1int
608 |
609 | DATA fmt3int /'(i8,i8,i8)'/
610 | DATA fmt2int /'(i8,i8)'/
611 | DATA fmt1int /'(i8)'/
612 |
613 | pl = len_trim(path)
614 | prl= len_trim(prefix)
615 |
616 | if( prefix.ne.'none') then
617 | resname = path(1:pl)//'/'//prefix(1:prl)//'ensight.res'
618 | else
619 | resname = path(1:pl)//'ensight.res'
620 | endif
621 |
622 | !
623 | ! check for existance
624 | !
625 | inquire(file=resname,exist=itexists)
626 |
627 | !
628 | ! and write it to the specified filename
629 | !
630 | if(itexists.AND.(.NOT.ensight_overwrite)) then
631 | n = len_trim(resname)
632 | write(*,*) ' WARNING: file exists: ',resname(1:n)
633 | else
634 |
635 | open(unit=2,file=resname,form='formatted')
636 |
637 | if((iensight.eq.1).OR.(iensight.eq.-1)) then
638 | wildcard7 = ' '
639 | wildcard8 = ' '
640 | else
641 | if(nloop.eq.1) then
642 | wildcard7 = '_******'
643 | wildcard8 = '_*******'
644 | else
645 | wildcard7 = '_*** '
646 | wildcard8 = '_*** '
647 | endif
648 | endif
649 | !
650 | ! as resultfile format requires, store number of scalars,
651 | ! number of vectors and the geometry change flag are in the
652 | ! first line and the number of following fields in the
653 | ! following line
654 | !
655 | write(2,fmt3int) ensight_nscalars,ensight_nvectors,1
656 | write(2,fmt1int) ensight_nrec
657 | !
658 | ! output time for unsteady, iteration for steady calculation
659 | !
660 | write(*,*)
661 | write(*,*)
662 | ! write(*,*) ' nrec= ',ensight_nrec
663 |
664 | iunsteady = 0
665 | do irec=1,ensight_nrec
666 | if(ensight_time(irec).ne.0.0d0) then
667 | iunsteady = 1
668 | endif
669 | enddo
670 |
671 | if(iunsteady.eq.1) then
672 | ! write(*,*) ' unsteady calculation :',ensight_nrec
673 | do irec=1,ensight_nrec
674 | write(*,*) irec,'time = ',ensight_time(irec), &
675 | & ' iteration = ',ensight_iter(irec)
676 | write(2,'(e12.5)') ensight_time(irec)
677 | enddo
678 | else
679 | write(*,*) ' steady calculation :',ensight_nrec
680 | do irec=1,ensight_nrec
681 | write(*,*) irec,' iteration =',ensight_iter(irec)
682 | time = ensight_iter(irec)
683 | write(2,'(e12.5)') time
684 | enddo
685 | endif
686 | !
687 | ! start index and step for multiple solution files
688 | !
689 | if(ensight_nrec.ne.1) then
690 | if(nloop.eq.1) then
691 | write(2,fmt2int) istart,istep
692 | else
693 | write(2,fmt2int) 1,1
694 | endif
695 | endif
696 | !
697 | ! geometry file name
698 | !
699 |
700 | if(ensight_write_debug) write(*,*) '->8'
701 | wildcard = wildcard8
702 |
703 | geomname = 'ensight.geo_*******'
704 | fnl = len_trim(geomname)
705 | write(2,'(1X,A,1X,A)') geomname(1:fnl)
706 |
707 | if( ensight_write_debug ) then
708 | write(*,*) ' 1. compose geometry name : '
709 | write(*,*) ' wildcard7 = ',wildcard7
710 | write(*,*) ' wildcard8 = ',wildcard8
711 | write(*,*) ' geomname = ',geomname
712 | endif
713 |
714 | !
715 | ! Scalar filenames and names of scalar fields
716 | !
717 | do k=1,ensight_nscalars
718 | sname = ensight_scal_name(k)
719 | sfname = ensight_scal_fn(k)
720 |
721 | sl = len_trim(sname)
722 | sfl = len_trim(sfname)
723 |
724 | wildcard = wildcard8
725 |
726 | ! filename = sfname(1:sfl)//wildcard
727 | filename = sname(1:sl)//'.ensight_*******'
728 |
729 | fnl = len_trim(filename)
730 | if(prefix.ne.'none') then
731 | write(2,'(1X,A,1X,A)') prefix(1:prl)// &
732 | & filename(1:fnl),sname(1:sl)
733 | else
734 | write(2,'(1X,A,1X,A)') filename(1:fnl),sname(1:sl)
735 | endif
736 | enddo
737 | !
738 | ! Vector filenames and names of vector fields
739 | !
740 | do k=1,ensight_nvectors
741 | vname = ensight_vec_name(k)
742 | vfname = ensight_vec_fn(k)
743 | vl = len_trim(vname)
744 | vfl = len_trim(vfname)
745 |
746 | wildcard = wildcard8
747 |
748 | ! filename = vfname(1:vfl)//wildcard
749 | filename = vfname(1:vfl)//'.ensight_*******'
750 |
751 | fnl = len_trim(filename)
752 | if(prefix.ne.'none') then
753 | write(2,'(1X,A,1X,A)') prefix(1:prl)// &
754 | & filename(1:fnl),vname(1:vl)
755 | else
756 | write(2,'(1X,A,1X,A)') filename(1:fnl),vname(1:vl)
757 | endif
758 | enddo
759 |
760 | close(2)
761 |
762 | ! -----------------------------------------------------
763 | ! Write index of last file read and target path
764 | ! for ensight files for 'ens' command file
765 | ! -----------------------------------------------------
766 | pl = len_trim(path)
767 | prl= len_trim(prefix)
768 |
769 | if( prefix.ne.'none') then
770 | sname = path(1:pl)//'/'//prefix(1:prl)//'ens_startup_time'
771 | else
772 | sname = path(1:pl)//'/ens_startup_time'
773 | endif
774 |
775 | ! open( 2,file=sname,form='formatted')
776 | ! write(2,'(A,1X,I2)') 'data: start_time',ensight_nrec-1
777 | ! close(2)
778 |
779 | ! sname='ens_targetpath'
780 | ! open( 2,file=sname,form='formatted')
781 | ! write(2,*) path(1:pl)
782 | ! write(2,*) prefix(1:prl)
783 | ! close(2)
784 |
785 |
786 | if( prefix.ne.'none') then
787 | sname = path(1:pl)//'/'//prefix(1:prl)//'ensight_startup.cmd'
788 | else
789 | sname = path(1:pl)//'/ensight_startup.cmd'
790 | endif
791 |
792 |
793 | if(ensight_nrec.eq.1) then
794 |
795 | write ( recid7, '(a1,i6.6)' ) '_',ensight_nrec
796 | write ( recid8, '(a1,i7.7)' ) '_',ensight_nrec
797 |
798 |
799 | if( ensight_write_debug ) then
800 | write(*,*) ' 2. compose geometry name : '
801 | write(*,*) ' wildcard7 = ',wildcard7
802 | write(*,*) ' wildcard8 = ',wildcard8
803 | write(*,*) ' geomname = ',geomname
804 | endif
805 |
806 |
807 |
808 | n = len_trim(geomname)
809 | if(n.gt.8) then
810 | n = n-8
811 | endif
812 | geomname = geomname(1:n)//recid8
813 |
814 | if( ensight_write_debug ) then
815 | write(*,*) ' 3. compose geometry name : '
816 | write(*,*) ' wildcard7 = ',wildcard7
817 | write(*,*) ' wildcard8 = ',wildcard8
818 | write(*,*) ' geomname = ',geomname
819 | endif
820 |
821 | open( 2,file=sname,form='formatted')
822 | write(2,'(A,1X)') 'VERSION 8.07'
823 | write(2,'(A,1X)') 'view: hidden_surface ON'
824 | write(2,'(A,1X)') 'data: binary_files_are big_endian'
825 | write(2,'(A,1X)') 'data: format case'
826 | write(2,'(A,1X)') 'data: path .'
827 | write(2,'(A,1X)') 'data: geometry ', geomname
828 | write(2,'(A,1X,I2)') 'data: start_time',ensight_nrec-1
829 | write(2,'(A,1X)') 'data: read'
830 | write(2,'(A,1X)') 'data_partbuild: begin'
831 | write(2,'(A,1X)') 'data_partbuild: data_type unstructured'
832 | write(2,'(A,1X)') 'data_partbuild: select_begin'
833 | write(2,'(A,1X)') ' 1 '
834 | write(2,'(A,1X)') 'data_partbuild: select_end'
835 | write(2,'(A,1X)') 'data_partbuild: description'
836 | write(2,'(A,1X)') 'data_partbuild: create'
837 | write(2,'(A,1X)') 'data_partbuild: end'
838 |
839 | close(2)
840 | else
841 |
842 | k = 1
843 |
844 | open( 2,file=sname,form='formatted')
845 | write(2,'(A,1X)') 'VERSION 7.11'
846 | write(2,'(A,1X)') 'data: binary_files_are big_endian'
847 | write(2,'(A,1X)') 'data: format ensight'
848 |
849 | ! Uncomment and setup choices variable for multiple solutions !
850 | ! irec= (k-1)*choices_step_multiple +
851 | ! & choices_start_multiple
852 | irec= 1
853 |
854 | write ( recid7, '(a1,i6.6)' ) '_',irec
855 | write ( recid8, '(a1,i7.7)' ) '_',irec
856 |
857 |
858 | if( ensight_write_debug ) then
859 | write(*,*) ' (a) geomname = ',geomname
860 | endif
861 |
862 |
863 | n = len_trim(geomname)
864 | if(n.gt.8) then
865 | n = n-8
866 | endif
867 | geomname = geomname(1:n)//recid8
868 |
869 | if( ensight_write_debug ) then
870 | write(*,*) ' geomname = ',geomname
871 | endif
872 |
873 | n = len_trim(geomname)
874 | buffer = 'data: geometry '//geomname(1:n)
875 | n = len_trim(buffer)
876 | write(2,'(A,1X)') buffer(1:n)
877 |
878 | write(2,'(A,1X)') 'data: result ensight.res'
879 | write(2,'(A,1X,I2)') 'data: start_time',ensight_nrec-1
880 | write(2,'(A,1X)') 'data: read'
881 | write(2,'(A,1X)') 'data_partbuild: begin'
882 | write(2,'(A,1X)') 'data_partbuild: data_type unstructured'
883 | write(2,'(A,1X)') 'data_partbuild: select_begin'
884 | write(2,'(A,1X)') ' 1 '
885 | write(2,'(A,1X)') 'data_partbuild: select_end'
886 | write(2,'(A,1X)') 'data_partbuild: description'
887 | write(2,'(A,1X)') 'data_partbuild: create'
888 | write(2,'(A,1X)') 'data_partbuild: end'
889 |
890 | do k=2,ensight_nrec
891 |
892 | ! Uncomment and setup choices variable for multiple solutions !
893 | ! irec= (k-1)*choices_step_multiple +
894 | ! & choices_start_multiple
895 | irec= 1
896 |
897 | write ( recid7, '(a1,i6.6)' ) '_',irec
898 | write ( recid8, '(a1,i7.7)' ) '_',irec
899 |
900 | if( ensight_write_debug ) then
901 | write(*,*) ' (b) geomname = ',geomname
902 | endif
903 |
904 |
905 | n = len_trim(geomname)
906 | if(n.gt.8) then
907 | n = n-8
908 | endif
909 | geomname = geomname(1:n)//recid8
910 |
911 |
912 | if( ensight_write_debug ) then
913 | write(*,*) ' geomname = ',geomname
914 | endif
915 |
916 | ! write(*,*) ' geomname = ',geomname
917 |
918 | write(2,'(A,1X,I2)') 'case: add Case ',k
919 | write(2,'(A,1X,I2)') 'case: select Case ',k
920 | write(2,'(A,1X)') 'data: native_binary ON'
921 | write(2,'(A,1X)') 'data: format ensight'
922 |
923 | n = len_trim(geomname)
924 | buffer = 'data: geometry '//geomname(1:n)
925 | n = len_trim(buffer)
926 | write(2,'(A,1X)') buffer(1:n)
927 | write(2,'(A,1X)') 'data: result ensight.res'
928 | ! write(2,'(A,1X,I2)') 'data: start_time',0
929 | write(2,'(A,1X)') 'data: read'
930 | write(2,'(A,1X)') 'data_partbuild: begin'
931 | ! write(2,'(A,1X)') 'data_partbuild: data_type unstructured'
932 | ! write(2,'(A,1X)') 'data_partbuild: description'
933 | ! write(2,'(A,1X)') 'data_partbuild: select_begin'
934 | ! write(2,'(A,1X)') ' 1 '
935 | ! write(2,'(A,1X)') 'data_partbuild: select_end'
936 | ! write(2,'(A,1X)') 'data_partbuild: create'
937 | write(2,'(A,1X)') 'data_partbuild: end'
938 | enddo
939 |
940 | close(2)
941 |
942 |
943 | endif
944 |
945 |
946 | endif
947 |
948 | end subroutine ensight_write_multiple_case
949 |
950 | ! ================================================================
951 | !
952 | ! write the multiple geometry case files V8.07
953 | ! Authors : J. Amaya, O. Cabrit, A. Roux - 11/2006
954 | !
955 | ! ================================================================
956 | subroutine ens_write_multicase_V8_07(path,prefix, &
957 | & iensight, &
958 | & istart,istep,nloop)
959 |
960 | implicit none
961 |
962 | character*80 path,prefix
963 | DOM_INT istart,istep,iensight,nloop
964 | character*240 stupfile,casefile,sfname,vfname,geomfile,filename
965 | character*80 sname,vname
966 | real*4 time
967 | DOM_INT pl,prl,irec,irecord,n,k,sl,wl,sfl,vl,vfl,fnl,j
968 | logical itexists
969 | character*8 recid, recordid
970 |
971 | ! ---------------------------------------
972 | ! | Check if there is already a .cmd file |
973 | ! ---------------------------------------
974 |
975 | pl = len_trim(path)
976 | prl = len_trim(prefix)
977 |
978 | if ( prefix.ne.'none') then
979 | stupfile = path(1:pl)//'/'//prefix(1:prl) &
980 | & //'ensight_startup.cmd'
981 | else
982 | stupfile = path(1:pl)//'ensight_startup.cmd'
983 | endif
984 |
985 | inquire(file=stupfile,exist=itexists)
986 |
987 | if(itexists) then
988 | n = len_trim(stupfile)
989 | if (.NOT.ensight_overwrite) then
990 | write(*,*) ' ERROR: File already exists: ',stupfile(1:n)
991 | write(*,*) ' check your visu.choices file for'
992 | write(*,*) ' file overwriting.'
993 | stop
994 | else
995 | write(*,*) ' WARNING: File already exists: ',stupfile(1:n)
996 | write(*,*) ' overwriting the old visual files'
997 | endif
998 | endif
999 |
1000 | open(3,file=stupfile,form='formatted')
1001 | write(3,'(A,1X)') 'VERSION 8.07'
1002 | write(3,'(A,1X)') 'view: hidden_surface ON'
1003 |
1004 | ! -----------------------------------------------------------
1005 | ! | Setup an ensight case and command lines for each solution |
1006 | ! -----------------------------------------------------------
1007 |
1008 | do j=1, ensight_nrec
1009 | irecord = (j-1)*istep+istart
1010 | write(recordid,'(a1,i7.7)') '_',irecord
1011 | if ( prefix.ne.'none') then
1012 | casefile = path(1:pl)//'/'//prefix(1:prl)// &
1013 | & 'ensight.case'//recordid
1014 | else
1015 | casefile = path(1:pl)//'ensight.case'//recordid
1016 | endif
1017 |
1018 | ! -----------------------------------------------------
1019 | ! | Inquire for the existance of .case file and open it |
1020 | ! -----------------------------------------------------
1021 |
1022 | inquire(file=casefile,exist=itexists)
1023 | if(itexists) then
1024 | n = len_trim(casefile)
1025 | if (.NOT.ensight_overwrite) then
1026 | write(*,*) ' ERROR: File already exists: ',casefile(1:n)
1027 | write(*,*) ' check your visu.choices file for'
1028 | write(*,*) ' file overwriting.'
1029 | else
1030 | write(*,*) ' WARNING: File already exists: ',casefile(1:n)
1031 | write(*,*) ' overwriting the old visual files'
1032 | endif
1033 | endif
1034 |
1035 | open(unit=2,file=casefile,form='formatted')
1036 |
1037 | ! -------------------------
1038 | ! | Write .case file header |
1039 | ! -------------------------
1040 |
1041 | write(2,'(A)') '# Ensight Gold case file'
1042 | write(2,'(A)') 'FORMAT'
1043 | write(2,'(A)') ''
1044 | write(2,'(A)') 'type: ensight gold'
1045 | write(2,'(A)') ''
1046 | write(2,'(A)') 'GEOMETRY'
1047 | write(2,'(A,A)') 'model: ensight.geo',recordid
1048 | write(2,'(A)') ''
1049 | write(2,'(A)') 'VARIABLE'
1050 | write(2,'(A)') ''
1051 |
1052 | ! ------------------------------------------
1053 | ! | Write scalars information into case file |
1054 | ! ------------------------------------------
1055 |
1056 | do k=1,ensight_nscalars
1057 | sname = ensight_scal_name(k)
1058 | sfname = ensight_scal_fn(k)
1059 |
1060 | sl = len_trim(sname)
1061 | sfl = len_trim(sfname)
1062 |
1063 | filename = sname(1:sl)//'.ensight_*******'
1064 | fnl = len_trim(filename)
1065 |
1066 | if(prefix.ne.'none') then
1067 | write(2,'(A,1X,A,1X,A)') 'scalar per node: 1 ', &
1068 | & sname(1:sl),prefix(1:prl)//filename(1:fnl)
1069 | else
1070 | write(2,'(A,1X,A,1X,A)') 'scalar per node: 1 ', &
1071 | & sname(1:sl),filename(1:fnl)
1072 | endif
1073 | enddo
1074 |
1075 | ! ------------------------------------------
1076 | ! | Write vectors information into case file |
1077 | ! ------------------------------------------
1078 |
1079 | do k=1,ensight_nvectors
1080 | vname = ensight_vec_name(k)
1081 | vfname = ensight_vec_fn(k)
1082 | vl = len_trim(vname)
1083 | vfl = len_trim(vfname)
1084 |
1085 | filename = vfname(1:vfl)//'.ensight_*******'
1086 | fnl = len_trim(filename)
1087 |
1088 | if(prefix.ne.'none') then
1089 | write(2,'(A,1X,A,1X,A)') 'vector per node: 1 ', &
1090 | & vname(1:vl),prefix(1:prl)//filename(1:fnl)
1091 | else
1092 | write(2,'(A,1X,A,1X,A)') 'vector per node: 1 ', &
1093 | & vname(1:vl),filename(1:fnl)
1094 | endif
1095 | enddo
1096 |
1097 | ! ----------------------------------------------------
1098 | ! | Write time into case file and close the .case file |
1099 | ! ----------------------------------------------------
1100 |
1101 | write(2,'(A)') 'TIME'
1102 | write(2,'(A)') ''
1103 | write(2,'(A)') 'time set: 1'
1104 | write(2,'(A,1X,I10)') 'number of steps: ',ensight_nrec
1105 | write(2,'(A,1X,I10)') 'filename start number:',istart
1106 | write(2,'(A,1X,I10)') 'filename increment:',istep
1107 | write(2,'(A)') 'time values:'
1108 | do irec=1,ensight_nrec
1109 | write(2,'(e12.5)') ensight_time(irec)
1110 | enddo
1111 |
1112 | close(2)
1113 |
1114 | ! -------------------------------------------------------
1115 | ! | Write the ensight startup command lines for this case |
1116 | ! -------------------------------------------------------
1117 |
1118 | if (j.gt.1) then
1119 | write(3,'(A,1X,I2)') 'case: add Case', j
1120 | write(3,'(A,1X,I2)') 'case: select Case', j
1121 | endif
1122 | write(3,'(A,1X)') 'data: binary_files_are big_endian'
1123 | write(3,'(A,1X)') 'data: format case'
1124 | write(3,'(A,1X)') 'data: path .'
1125 | fnl = len_trim(casefile)
1126 | write(3,'(A,A,1X)') 'data: geometry ensight.case',recordid
1127 | write(3,'(A,1X,I2)') 'data: start_time', irecord
1128 | write(3,'(A,1X)') 'data: read'
1129 | write(3,'(A,1X)') 'data_partbuild: begin'
1130 | write(3,'(A,1X)') 'data_partbuild: data_type unstructured'
1131 | write(3,'(A,1X)') 'data_partbuild: select_all'
1132 | write(3,'(A,1X)') 'data_partbuild: description'
1133 | write(3,'(A,1X)') 'data_partbuild: create'
1134 | write(3,'(A,1X)') 'data_partbuild: end'
1135 | if (j.gt.1) then
1136 | write(3,'(A,1X)') 'part: select_begin'
1137 | write(3,'(I2)') j
1138 | write(3,'(A,1X)') 'part: select_end'
1139 | write(3,'(A,1X)') 'part: modify_begin'
1140 | write(3,'(A,1X)') 'part: visible OFF'
1141 | write(3,'(A,1X)') 'part: modify_end'
1142 | endif
1143 |
1144 | enddo
1145 |
1146 | ! --------------------------------
1147 | ! | Close the ensight command file |
1148 | ! --------------------------------
1149 |
1150 | close(3)
1151 |
1152 | end subroutine ens_write_multicase_V8_07
1153 |
1154 |
1155 | end module ensightgold_write
1156 |
ensightgold_write.F could be called by: