-
Notifications
You must be signed in to change notification settings - Fork 5
/
read_sm3d.f90
105 lines (73 loc) · 2.73 KB
/
read_sm3d.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
99
100
101
102
103
104
105
module sm3d
use precision, only: dp,si
use file_admin, only: logf
contains
subroutine read_sm3d_dp_file_routine(filename,data_array)
character(len=*),intent(in) :: filename
real(kind=dp),pointer,dimension(:,:,:),intent(inout) :: data_array
integer :: m1,m2,m3
integer,dimension(3) :: shape_of_data
shape_of_data=shape(data_array)
! Open sm3d data file
open(unit=20,file=filename,form="unformatted",status="old")
! Read in data
read(20) m1,m2,m3
if (m1 /= shape_of_data(1) .or. m2 /= shape_of_data(2) .or. &
m3 /= shape_of_data(3)) then
write(logf,*) "Warning: file ",filename," unusable."
write(logf,*) "since mesh found in file: ",m1,m2,m3
write(logf,*) "and ",shape_of_data(:)," needed."
else
read(20) data_array
endif
! close file
close(20)
end subroutine read_sm3d_dp_file_routine
subroutine read_sm3d_si_file_routine(filename,data_array)
character(len=*),intent(in) :: filename
real(kind=si),pointer,dimension(:,:,:),intent(inout) :: data_array
integer :: m1,m2,m3
integer,dimension(3) :: shape_of_data
shape_of_data=shape(data_array)
! Open sm3d data file
open(unit=20,file=filename,form="unformatted",status="old")
! Read in data
read(20) m1,m2,m3
if (m1 /= shape_of_data(1) .or. m2 /= shape_of_data(2) .or. &
m3 /= shape_of_data(3)) then
write(logf,*) "Warning: file ",filename," unusable."
write(logf,*) "since mesh found in file: ",m1,m2,m3
write(logf,*) "and ",shape_of_data(:)," needed."
else
read(20) data_array
endif
! close file
close(20)
end subroutine read_sm3d_si_file_routine
subroutine write_sm3d_dp_file_routine(filename,data_array)
character(len=*),intent(in) :: filename
real(kind=dp),pointer,dimension(:,:,:),intent(inout) :: data_array
integer,dimension(3) :: shape_of_data
shape_of_data=shape(data_array)
! Open sm3d data file
open(unit=20,file=filename,form="unformatted",status="unknown")
! Write header and data
write(20) shape_of_data(1:3)
write(20) data_array
! close file
close(20)
end subroutine write_sm3d_dp_file_routine
subroutine write_sm3d_si_file_routine(filename,data_array)
character(len=*),intent(in) :: filename
real(kind=si),pointer,dimension(:,:,:),intent(inout) :: data_array
integer,dimension(3) :: shape_of_data
shape_of_data=shape(data_array)
! Open sm3d data file
open(unit=20,file=filename,form="unformatted",status="unknown")
! Write header and data
write(20) shape_of_data(1:3)
write(20) data_array
! close file
close(20)
end subroutine write_sm3d_si_file_routine
end module sm3d