Coverage Report: WriteRay.f90

Generated from GCOV analysis of Fortran source code

39.4%
Lines Executed
33 total lines
58.7%
Branches Executed
46 total branches
100.0%
Calls Executed
11 total calls
0
-
Source:WriteRay.f90
0
-
Graph:WriteRay.gcno
0
-
Data:WriteRay.gcda
0
-
Runs:29
1
-
!! Ray data compression and output formatting
2
-
MODULE WriteRay
3
-
!! Ray data compression, formatting, and output to ray files with selective point retention
4
-
5
-
! Compress the ray data keeping every iSkip point, points near surface or bottom, and last point.
6
-
! Write to RAYFile.
7
-
8
-
! During an eigenray calculation, subsets of the full ray may be passed
9
-
! These have lengths Nsteps1 vs. Nsteps for the entire ray
10
-
11
-
USE BellhopMod
12
-
USE sspMod
13
-
14
-
IMPLICIT NONE
15
-
PUBLIC
16
-
17
-
INTEGER, PRIVATE :: MaxNRayPoints = 500000 ! this is the maximum length of the ray vector that is written out
18
-
INTEGER, PRIVATE :: is, N2, iSkip
19
-
20
-
CONTAINS
21
-
22
118
SUBROUTINE WriteRay2D( alpha0, Nsteps1 )
23
-
!! The 2D version is for ray traces in (r,z) coordinates
24
-
25
-
INTEGER, INTENT( IN ) :: Nsteps1
26
-
REAL (KIND=8), INTENT( IN ) :: alpha0 ! take-off angle of this ray
27
-
28
-
! compression
29
-
! LP: This is silly for two reasons:
30
-
! 1) MaxN (maximum number of steps for a ray) is 100000, but MaxNRayPoints
31
-
! is 500000. Therefore iSkip will always be 1, and the whole vector will
32
-
! always be written.
33
-
! 2) Even if these constants were changed, the formula for iSkip is not
34
-
! ideal: iSkip will only become 2 once the number of steps in the ray is
35
-
! more than 2x MaxNRayPoints. If it's less than this, it'll just be
36
-
! truncated, which is arguably worse than skipping every other step.
37
-
38
118
N2 = 1
39
118
iSkip = MAX( Nsteps1 / MaxNRayPoints, 1 )
40
-
41
40427*
Stepping: DO is = 2, Nsteps1
42
-
! ensure that we always write ray points near bdry reflections (works only for flat bdry)
43
80618*
IF ( MIN( Bdry%Bot%HS%Depth - ray2D( is )%x( 2 ), ray2D( is )%x( 2 ) - Bdry%Top%HS%Depth ) < 0.2 .OR. &
44
121045
MOD( is, iSkip ) == 0 .OR. is == Nsteps1 ) THEN
45
40309
N2 = N2 + 1
46
120927*
ray2D( N2 )%x = ray2D( is )%x
47
-
END IF
48
-
END DO Stepping
49
-
50
-
! write to ray file
51
-
52
118
WRITE( RAYFile, * ) alpha0
53
118*
WRITE( RAYFile, * ) N2, ray2D( Nsteps1 )%NumTopBnc, ray2D( Nsteps1 )%NumBotBnc
54
-
55
40545*
DO is = 1, N2
56
121399*
WRITE( RAYFile, * ) ray2D( is )%x
57
-
END DO
58
-
59
118
END SUBROUTINE WriteRay2D
60
-
61
-
! **********************************************************************!
62
-
63
#####
SUBROUTINE WriteRay3D( alpha0, beta0, Nsteps1 )
64
-
!! The 3D version is for ray traces in (x,y,z) coordinates
65
-
66
-
INTEGER, INTENT( IN ) :: Nsteps1
67
-
REAL (KIND=8), INTENT( IN ) :: alpha0, beta0 ! take-off angle of this ray
68
-
69
-
! if Nx2D run, copy r-z rays to x-y-z rays
70
-
71
#####
IF ( Beam%RunType( 6 : 6 ) == '2' ) THEN
72
#####
ray3D%x( 1 ) = xs_3D( 1 ) + ray2D%x( 1 ) * COS( beta0 )
73
#####
ray3D%x( 2 ) = xs_3D( 2 ) + ray2D%x( 1 ) * SIN( beta0 )
74
#####
ray3D%x( 3 ) = ray2D%x( 2 )
75
#####
ray3D%NumTopBnc = ray2D%NumTopBnc
76
#####
ray3D%NumBotBnc = ray2D%NumBotBnc
77
-
END IF
78
-
79
-
! compression
80
-
! LP: Besides the problems mentioned above in the 2D version, this also does
81
-
! nothing because iSkip is overridden to 1 below.
82
-
83
#####
N2 = 1
84
#####
iSkip = MAX( Nsteps1 / MaxNRayPoints, 1 )
85
#####
iSkip = 1
86
-
87
#####
Stepping: DO is = 2, Nsteps1
88
-
! ensure that we always write ray points near boundary reflections
89
#####
IF ( MIN( Bdry%Bot%HS%Depth - ray3D( is )%x( 3 ), ray3D( is )%x( 3 ) - Bdry%Top%HS%Depth ) < 0.2 .OR. &
90
#####
MOD( is, iSkip ) == 0 .OR. is == Nsteps1 ) THEN
91
#####
N2 = N2 + 1
92
#####
ray3D( N2 )%x = ray3D( is )%x
93
-
END IF
94
-
END DO Stepping
95
-
96
-
! write to ray file
97
-
98
#####
WRITE( RAYFile, * ) alpha0
99
#####
WRITE( RAYFile, * ) N2, ray3D( Nsteps1 )%NumTopBnc, ray3D( Nsteps1 )%NumBotBnc
100
-
101
#####
DO is = 1, N2
102
#####
WRITE( RAYFile, * ) ray3D( is )%x
103
-
END DO
104
-
105
#####
END SUBROUTINE WriteRay3D
106
-
107
-
END MODULE WriteRay