-
Notifications
You must be signed in to change notification settings - Fork 6
/
post.f90
executable file
·52 lines (40 loc) · 1.22 KB
/
post.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
module post
implicit none
type scalar_field
real, dimension(3) :: coord
real :: value
end type
type vector_field
real, dimension(3) :: coord
real, dimension(3) :: value
end type
character(len=20), parameter :: POS_HEADER = 'View "field" {'
character(len=2), parameter :: POS_FOOTER = '};'
contains
subroutine save_scalar_field(filename, field)
character(len=*), intent(in) :: filename
type(scalar_field), dimension(:), intent(in) :: field
integer :: i
open(unit=10, file=filename)
write (10, '(A)'), POS_HEADER
do i = 1, size(field)
write (10, 100), field(i) % coord, field(i) % value
end do
write (10, '(A)'), POS_FOOTER
close(10)
100 format ('SP(', F, ',', F, ',', F, '){', E, '};')
end subroutine
subroutine save_vector_field(filename, field)
character(len=*), intent(in) :: filename
type(vector_field), dimension(:), intent(in) :: field
integer :: i
open(unit=10, file=filename)
write (10, '(A)'), POS_HEADER
do i = 1, size(field)
write (10, 100), field(i) % coord, field(i) % value
end do
write (10, '(A)'), POS_FOOTER
close(10)
100 format ('VP(', F, ',', F, ',', F, '){', E, ',', E, ',', E'};')
end subroutine
end module