-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsynthetic.f90
109 lines (100 loc) · 2.6 KB
/
synthetic.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
106
107
108
109
!Format transfer program
!transfer output of checkboard synthetic to input of checkboard inversion
!edited by sqdeng
program synthetic
implicit none
integer :: error,i
character(len=20) :: filedt,fileab
integer,external :: wc_l
integer :: ndt=0
integer,allocatable:: dtidone(:), dtidtwo(:)
character(len=7) :: dtsta
real :: dtimeone, dtimetwo
real :: dtweight
character :: dtpha
integer :: nabo=0
integer,allocatable :: absoid(:)
character(len=7) :: abosta
real :: abotime
real :: aboweight
character :: abopha
filedt='dt.syn'
fileab='absolute.syn'
ndt=wc_l(filedt)+5
nabo=wc_l(fileab)+5
write(*,*) ndt,nabo
allocate(dtidone(ndt))
allocate(dtidtwo(ndt))
allocate(absoid(nabo))
write(*,*) 'Transforming synthetic data starts... '
open(1,file='dt.syn',status='old')
open(2,file='syn.dt' )
i=1
do while(.true.)
read(1,*,iostat=error) dtidone(i), dtidtwo(i), dtsta, dtimeone, dtimetwo, dtweight, dtpha
if(error/=0) exit
if(i>1) then
if(dtidone(i) == dtidone(i-1) .and. dtidtwo(i) == dtidtwo(i-1)) then
write(2,1002) dtsta, dtimeone, dtimetwo, dtweight, dtpha
else
write(2,1001) "#",dtidone(i), dtidtwo(i)
write(2,1002) dtsta, dtimeone, dtimetwo, dtweight, dtpha
end if
else
write(2,1001) "#",dtidone(i), dtidtwo(i)
write(2,1002) dtsta, dtimeone, dtimetwo, dtweight, dtpha
end if
i=i+1
if(i>=ndt) then
write(*,*) "Please increse ndt parameter..."
stop
end if
end do
close(1)
close(2)
1001 format(a1,1x,i12,1x,i12)
1002 format(a7,1x,f10.4,1x,f10.4,1x,f6.3,1x,a1)
open(3,file='absolute.syn',status='old')
open(4,file='syn.absolute' )
i=1
do while(.true.)
read(3,*,iostat=error) absoid(i), abosta, abotime, aboweight, abopha
if(error/=0) exit
if(i>1) then
if(absoid(i) == absoid(i-1)) then
write(4,2002) abosta, abotime, aboweight, abopha
else
write(4,2001) "#",absoid(i)
write(4,2002) abosta, abotime, aboweight, abopha
end if
else
write(4,2001) "#",absoid(i)
write(4,2002) abosta, abotime, aboweight, abopha
end if
i=i+1
if(i>=nabo) then
write(*,*) "Please increse nabo parameter..."
stop
end if
end do
close(3)
close(4)
write(*,*) 'Transforming synthetic data succeeds... '
2001 format(a1,4x,i14)
2002 format(a7,3x,f8.2,3x,f8.2,3x,a1)
stop
end program
integer function wc_l(filein)
implicit none
integer :: error
character(len=20) filein,line
wc_l=0
open(10,file=trim(filein),status='old')
do while(.true.)
read(10,*,iostat=error) line
if(error/=0) exit
wc_l=wc_l+1
end do
close(10)
return
end