forked from reedmaxwell/EcoSLIM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtk_write.f90
98 lines (88 loc) · 2.81 KB
/
vtk_write.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
! Copyright 2010 Reed M. Maxwell
!
! This file is part of EcoSLIM; Originally in SLIM-Fast.
!
! SLIM-Fast is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License.
!
! SLIM-Fast is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with SLIM-Fast in /src/gpl.txt. If not, see <http://www.gnu.org/licenses/>.
SUBROUTINE vtk_write(time,x,conc_header,ixlim,iylim,izlim,icycle,n_constituents,Pnts,vtk_file)
real*8 :: time
REAL*8 :: x(:,:,:,:)
CHARACTER (LEN=20) :: conc_header(:)
INTEGER*4 :: ixlim
INTEGER*4 :: iylim
INTEGER*4 :: izlim
REAL*8 :: dx
REAL*8 :: dy
REAL*8 :: dz(izlim)
REAL*8 :: Pnts(:,:)
INTEGER :: icycle
INTEGER :: n_constituents
CHARACTER (LEN=200) :: vtk_file
INTEGER*4 i,j,k, ijk, debug,l, nxyz,nxyzp1
CHARACTER*1 lf
CHARACTER*12 num1, num2, num3
CHARACTER*8 ctime
real*8 number
debug = 0
!
! Open File
!
Write(ctime,'(i8.8)') icycle
OPEN(15,FILE=trim(vtk_file)//'.'//ctime//'.vtk',FORM='unformatted', &
access='stream',convert='BIG_ENDIAN')
!
! Write header info
!
lf = char(10) ! line feed character
Write(15) "# vtk DataFile Version 3.0"//lf
Write(15) "EcoSLIM Output"//lf
Write(15) "BINARY"//lf
Write(15) "DATASET STRUCTURED_GRID"//lf
!Write(15) "FIELD FieldData 1"//lf
!write(15) "TIME 1 1 double"//lf
!write(ctime, '(f8.3)') time
!write(15) ctime
!write(15) time
!write(15) lf
!Write(15) "CYCLE 1 1 int"//lf
!Write(num1,'(i12)') icycle
!Write(15) num1
!write(15) icycle
!Write(15) lf
Write(num1,'(i12)') ixlim+1
Write(num2,'(i12)') iylim+1
Write(num3,'(i12)') izlim+1
write(15) "DIMENSIONS "//num1//" "//num2//" "//num3//lf
nxyzp1 = (ixlim+1)*(iylim+1)*(izlim+1)
write(num1, '(i12)') nxyzp1
Write(15) "POINTS "//num1//" float"//lf
write(15) ((real(Pnts(i,j),kind=4), j=1,3), i=1,nxyzp1) ! This forces the expected write order
!write(15) lf
nxyz = (ixlim)*(iylim)*(izlim)
write(num1, '(i12)') nxyz
Write(15) "CELL_DATA "//num1//lf
do l = 1, n_constituents
write(15) "SCALARS "//trim(conc_header(l))//" float"//lf
Write(15) "LOOKUP_TABLE default"//lf
write(15) (((real(X(l,i,j,k),kind=4), i=1,ixlim), j=1,iylim), k=1,izlim)
!DO k=1,izlim
! DO j=1,iylim
! DO i=1,ixlim
! WRITE(15) x(l,i,j,k)
! END DO
! END DO
!END DO
!write(15) lf
end do ! l, n_constits
CLOSE(15)
RETURN
END SUBROUTINE vtk_write