lib/App/SeismicUnixGui/sunix/par/a2b.pm untested

filter: Statementstmt 0.0% 0 / 39 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 64 CC 6 SCAR 21.7
CC
6
Cov
0%
outpar
20.0
floats_per_line
6.0
n1
6.0
CRAP 8.8
1 package App::SeismicUnixGui::sunix::par::a2b;
2  
3 =head1 DOCUMENTATION
4  
5 =head2 SYNOPSIS
6  
7 PERL PROGRAM NAME: A2B - convert ascii floats to binary
8 AUTHOR: Juan Lorenzo (Perl module only)
9
10 DESCRIPTION:
11 Version: 0.0.4
12 Package used for interactive velocity analysis
13
14 DATE: Nov 1 2012,
15 sept. 13 2013
16 oct. 21 2013
17 July 15 2015
18  
19 =head2 USE
20  
21 =head3 NOTES
22  
23 =head4 Examples
24  
25 =head3 SEISMIC UNIX NOTES
26  
27 A2B - convert ascii floats to binary
28  
29 a2b <stdin >stdout outpar=/dev/null
30  
31 Required parameters:
32 none
33  
34 Optional parameters:
35 n1=2 floats per line in input file
36  
37 outpar=/dev/null output parameter file, contains the
38 number of lines (n=)
39 other choices for outpar are: /dev/tty,
40 /dev/stderr, or a name of a disk file
41  
42 Credits:
43 CWP: Jack K. Cohen, Dave Hale
44 Hans Ecke 2002: Replaced line-wise file reading via gets() with
45 float-wise reading via fscanf(). This makes it
46 much more robust: it does not impose a specific
47 structure on the input file.
48  
49  
50 =head2 CHANGES and their DATES
51  
52 =cut
53  
54 use Moose;
55 our $VERSION = '0.0.4';
56  
57 my $a2b = {
58 _floats_per_line => '',
59 _n1 => '',
60 _outpar => '',
61 _Step => '',
62 _note => '',
63 };
64  
65 =head2 sub Step
66  
67 collects switches and assembles bash instructions
68 by adding the program name
69  
70 =cut
71  
72 sub Step {
73  
74 $a2b->{_Step} = 'a2b' . $a2b->{_Step};
75 return ( $a2b->{_Step} );
76  
77 }
78  
79 =head2 sub note
80  
81 collects switches and assembles bash instructions
82 by adding the program name
83  
84 =cut
85  
86 sub note {
87  
88 $a2b->{_note} = 'a2b' . $a2b->{_note};
89 return ( $a2b->{_note} );
90  
91 }
92  
93 =head2 sub clear
94  
95 =cut
96  
97 sub clear {
98  
99 $a2b->{_floats_per_line} = '';
100 $a2b->{_n1} = '';
101 $a2b->{_outpar} = '';
102 $a2b->{_Step} = '';
103 $a2b->{_note} = '';
104 }
105  
106 =head2 subroutine floats_per_line
107  
108 you need to know how many numbers per line
109 will be in the output file
110  
111 =cut
112  
113 sub floats_per_line {
114  
115 my ( $self, $n1 ) = @_;
116 if ($n1) {
117  
118 $a2b->{_n1} = $n1;
119 $a2b->{_note} = $a2b->{_note} . ' n1=' . $a2b->{_n1};
120 $a2b->{_Step} = $a2b->{_Step} . ' n1=' . $a2b->{_n1};
121  
122 }
123 else {
124 print("a2b, floats_per_line, missing floats_per_line,\n");
125 }
126 }
127  
128 =head2 sub n1
129  
130 you need to know how many numbers per line
131 will be in the output file
132  
133 =cut
134  
135 sub n1 {
136  
137 my ( $self, $n1 ) = @_;
138 if ($n1) {
139  
140 $a2b->{_n1} = $n1;
141 $a2b->{_note} = $a2b->{_note} . ' n1=' . $a2b->{_n1};
142 $a2b->{_Step} = $a2b->{_Step} . ' n1=' . $a2b->{_n1};
143  
144 }
145 else {
146 print("a2b, n1, missing n1,\n");
147 }
148 }
149  
150 =head2 sub outpar
151  
152 sets how to redirect metadata
153 to either screen, a file, stderr, or
154 to be lost.
155
156 Internally, determine whether we have a string or a reference to an array
157  
158 =cut
159  
160 sub outpar {
161  
162 my ( $self, $outpar ) = @_;
163 if ($outpar) {
164  
165 if ( ref($outpar) eq "SCALAR" ) {
166  
167 # print("success\n\n") ;
168 $a2b->{_outpar} = $$outpar;
169 $a2b->{_note} = $a2b->{_note} . ' outpar =' . $a2b->{_outpar};
170 $a2b->{_Step} = $a2b->{_Step} . ' outpar=' . $a2b->{_outpar};
171 }
172 elsif ( ref($outpar) ne "SCALAR" ) {
173  
174 # not a scalar reference to an array
175 $a2b->{_outpar} = $outpar;
176 $a2b->{_note} = $a2b->{_note} . ' outpar =' . $a2b->{_outpar};
177 $a2b->{_Step} = $a2b->{_Step} . ' outpar=' . $a2b->{_outpar};
178  
179 }
180 else {
181 print("a2b, outpar, missing outpar,\n");
182 }
183 }
184 }
185  
186 =head2 sub get_max_index
187
188 max index = number of input variables -1
189
190 =cut
191  
192 sub get_max_index {
193 my ($self) = @_;
194  
195 # index=1
196 my $max_index = 1;
197  
198 return ($max_index);
199 }
200  
201 1;