« lib/App/SeismicUnixGui/misc/name.pm
↑ Summary
lib/App/SeismicUnixGui/configs/big_streams/immodpg_config.pm »
| 1 | package App::SeismicUnixGui::misc::manage_files_by2; | ||
| 2 | |||
| 3 | =head1 DOCUMENTATION | ||
| 4 | |||
| 5 | =head2 SYNOPSIS | ||
| 6 | Contains methods/subroutines/functions to operate on directories | ||
| 7 | |||
| 8 | PROGRAM NAME: manage_files_by2 | ||
| 9 | AUTHOR: Juan Lorenzo | ||
| 10 | DATE: V 1. March 3 2008 | ||
| 11 | V 2 May 27 2014 | ||
| 12 | |||
| 13 | DESCRIPTION: | ||
| 14 | modified from | ||
| 15 | manage_files_by to stricts requirements using Moose | ||
| 16 | manage_files_by class | ||
| 17 | |||
| 18 | =head2 USE | ||
| 19 | |||
| 20 | =head3 NOTES | ||
| 21 | |||
| 22 | =head4 | ||
| 23 | Examples | ||
| 24 | |||
| 25 | =head3 NOTES | ||
| 26 | |||
| 27 | =head4 CHANGES and their DATES | ||
| 28 | |||
| 29 | =cut | ||
| 30 | |||
| 31 | use Moose; | ||
| 32 | our $VERSION = '0.0.1'; | ||
| 33 | |||
| 34 | use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants'; | ||
| 35 | use aliased 'App::SeismicUnixGui::sunix::shell::cat_su'; | ||
| 36 | use aliased 'App::SeismicUnixGui::sunix::shell::cat_txt'; | ||
| 37 | use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config'; | ||
| 38 | use aliased 'App::SeismicUnixGui::misc::control'; | ||
| 39 | use aliased 'App::SeismicUnixGui::misc::message'; | ||
| 40 | use aliased 'App::SeismicUnixGui::sunix::data::data_out'; | ||
| 41 | use aliased 'App::SeismicUnixGui::misc::flow'; | ||
| 42 | use aliased 'App::SeismicUnixGui::misc::readfiles'; | ||
| 43 | |||
| 44 | use Carp; | ||
| 45 | |||
| 46 | |||
| 47 | =head2 Instantiate | ||
| 48 | |||
| 49 | modules | ||
| 50 | |||
| 51 | =cut | ||
| 52 | my $control = control->new(); | ||
| 53 | my $readfiles = readfiles->new(); | ||
| 54 | |||
| 55 | =head2 clear memory | ||
| 56 | |||
| 57 | |||
| 58 | =cut | ||
| 59 | |||
| 60 | $control->clear(); | ||
| 61 | $readfiles->clear(); | ||
| 62 | |||
| 63 | =head2 define private hash | ||
| 64 | to share | ||
| 65 | |||
| 66 | =cut | ||
| 67 | |||
| 68 | my @array1; | ||
| 69 | my @array2; | ||
| 70 | |||
| 71 | my $manage_files_by2 = { | ||
| 72 | _all_lines_aref => '', | ||
| 73 | _appendix => '', | ||
| 74 | _cat_base_file_name_out => '', | ||
| 75 | _delete_base_file_name => '', | ||
| 76 | _directory => '', | ||
| 77 | _file_in => '', | ||
| 78 | _inbound_list => '', | ||
| 79 | _pathNfile => '', | ||
| 80 | _program_name => '', | ||
| 81 | _suffix_type => '', | ||
| 82 | }; | ||
| 83 | |||
| 84 | =head2 sub clear | ||
| 85 | |||
| 86 | Clear all memory | ||
| 87 | |||
| 88 | =cut | ||
| 89 | |||
| 90 | sub clear { | ||
| 91 | my $self = @_; | ||
| 92 | $manage_files_by2->{_all_lines_aref} = ''; | ||
| 93 | $manage_files_by2->{_appendix} = ''; | ||
| 94 | $manage_files_by2->{_cat_base_file_name_out} = ''; | ||
| 95 | $manage_files_by2->{_delete_base_file_name} = ''; | ||
| 96 | $manage_files_by2->{_inbound_list} = ''; | ||
| 97 | $manage_files_by2->{_directory} = ''; | ||
| 98 | $manage_files_by2->{_file_in} = ''; | ||
| 99 | $manage_files_by2->{_pathNfile} = ''; | ||
| 100 | $manage_files_by2->{_program_name} = ''; | ||
| 101 | $manage_files_by2->{_suffix_type} = ''; | ||
| 102 | |||
| 103 | } | ||
| 104 | |||
| 105 | =head2 sub _exists | ||
| 106 | |||
| 107 | Another (private) way to see if a file exists | ||
| 108 | input is a scalar | ||
| 109 | |||
| 110 | |||
| 111 | =cut | ||
| 112 | |||
| 113 | sub _exists { | ||
| 114 | |||
| 115 | my ($file) = @_; | ||
| 116 | |||
| 117 | if ($file) { | ||
| 118 | |||
| 119 | # default situation is to have a file non-existent | ||
| 120 | my $answer = 0; | ||
| 121 | |||
| 122 | # -e returns 1 or '' | ||
| 123 | # verified by JL | ||
| 124 | # print("existence test for $file\n\n"); | ||
| 125 | if ( -e $file ) { | ||
| 126 | |||
| 127 | # print("file existence verified; answer=$answer\n\n"); | ||
| 128 | $answer = 1; | ||
| 129 | } | ||
| 130 | |||
| 131 | # answer=1 if existent and =0 if non-existent | ||
| 132 | # print ("file non-existence verified; answer=$answer\n\n") ; | ||
| 133 | # verified by JL | ||
| 134 | return ($answer); | ||
| 135 | } | ||
| 136 | else { | ||
| 137 | print("\n"); | ||
| 138 | } | ||
| 139 | |||
| 140 | } | ||
| 141 | |||
| 142 | |||
| 143 | |||
| 144 | =head2 sub _read_2cols | ||
| 145 | |||
| 146 | read in a 2-columned file | ||
| 147 | reads cols 1 and 2 in a text file | ||
| 148 | |||
| 149 | |||
| 150 | =cut | ||
| 151 | |||
| 152 | sub _read_2cols { | ||
| 153 | |||
| 154 | my ($ref_origin) = @_; | ||
| 155 | |||
| 156 | if ( length $ref_origin ) { | ||
| 157 | |||
| 158 | # CASE 1 | ||
| 159 | # declare locally scoped variables | ||
| 160 | my ( $i, $line, $t, $x, $num_rows ); | ||
| 161 | my ( @TIME, @TIME_OUT, @OFFSET, @OFFSET_OUT ); | ||
| 162 | |||
| 163 | # print("manage_files_by2,_read_2_cols, $$ref_origin\n"); | ||
| 164 | |||
| 165 | # open the file of interest | ||
| 166 | open( FILE, $$ref_origin ) || print("Can't open $$ref_origin \n"); | ||
| 167 | |||
| 168 | #set the counter | ||
| 169 | $i = 1; | ||
| 170 | |||
| 171 | # read contents of shotpoint geometry file | ||
| 172 | while ( $line = <FILE> ) { | ||
| 173 | |||
| 174 | #print("\n$line"); | ||
| 175 | chomp($line); | ||
| 176 | ( $t, $x ) = split( " ", $line ); | ||
| 177 | $TIME[$i] = $t; | ||
| 178 | $OFFSET[$i] = $x; | ||
| 179 | |||
| 180 | #print("\n $TIME[$i] $OFFSET[$i]\n"); | ||
| 181 | $i = $i + 1; | ||
| 182 | |||
| 183 | } | ||
| 184 | |||
| 185 | close(FILE); | ||
| 186 | |||
| 187 | $num_rows = $i - 1; | ||
| 188 | |||
| 189 | # print out the number of lines of data for the user | ||
| 190 | #print ("\nThis file contains $num_rows row(s) of data\n"); | ||
| 191 | |||
| 192 | # to prevent contaminating outside variables | ||
| 193 | @TIME_OUT = @TIME; | ||
| 194 | @OFFSET_OUT = @OFFSET; | ||
| 195 | |||
| 196 | return ( \@TIME_OUT, \@OFFSET_OUT, $num_rows ); | ||
| 197 | } | ||
| 198 | elsif ( not length $ref_origin | ||
| 199 | and length $manage_files_by2->{_pathNfile} ) | ||
| 200 | { | ||
| 201 | |||
| 202 | # CASE 2 | ||
| 203 | # declare locally scoped variables | ||
| 204 | my ( $i, $line, $t, $x, $num_rows ); | ||
| 205 | my ( @TIME, @TIME_OUT, @OFFSET, @OFFSET_OUT ); | ||
| 206 | my $pathNfile = $manage_files_by2->{_pathNfile}; | ||
| 207 | |||
| 208 | # print("manage_files_by2,read_2cols,$pathNfile\n"); | ||
| 209 | |||
| 210 | # open the file of interest | ||
| 211 | open( FILE, $pathNfile ) | ||
| 212 | || print("Can't open $pathNfile \n"); | ||
| 213 | |||
| 214 | #set the counter | ||
| 215 | $i = 0; | ||
| 216 | |||
| 217 | # read contents of shotpoint geometry file | ||
| 218 | while ( $line = <FILE> ) { | ||
| 219 | |||
| 220 | # print("\n$line"); | ||
| 221 | chomp($line); | ||
| 222 | |||
| 223 | # split line on tab | ||
| 224 | ( $t, $x ) = split( /\t/, $line ); | ||
| 225 | $TIME[$i] = $t; | ||
| 226 | $OFFSET[$i] = $x; | ||
| 227 | |||
| 228 | $i = $i + 1; | ||
| 229 | |||
| 230 | } | ||
| 231 | |||
| 232 | # print("\n--$TIME[0]--$OFFSET[0]\n"); | ||
| 233 | # print("\n--$TIME[1]--$OFFSET[1]\n"); | ||
| 234 | close(FILE); | ||
| 235 | |||
| 236 | $num_rows = $i; | ||
| 237 | |||
| 238 | # print out the number of lines of data for the user | ||
| 239 | # print ("\nmanage_files_by2,read_2cols,num_rows=$num_rows\n"); | ||
| 240 | |||
| 241 | # to prevent contaminating outside variables | ||
| 242 | @TIME_OUT = @TIME; | ||
| 243 | @OFFSET_OUT = @OFFSET; | ||
| 244 | |||
| 245 | return ( \@TIME_OUT, \@OFFSET_OUT, $num_rows ); | ||
| 246 | |||
| 247 | } | ||
| 248 | else { | ||
| 249 | print("manage_files_by2,read_2cols, missing reference to pathNfile\n"); | ||
| 250 | } | ||
| 251 | |||
| 252 | return (); | ||
| 253 | } | ||
| 254 | |||
| 255 | =head2 sub _set_pathNfile | ||
| 256 | |||
| 257 | =cut | ||
| 258 | |||
| 259 | sub _set_pathNfile { | ||
| 260 | |||
| 261 | my ( $self,) = @_; | ||
| 262 | |||
| 263 | if ( length $manage_files_by2->{_file_in} | ||
| 264 | && length $manage_files_by2->{_directory}) { | ||
| 265 | |||
| 266 | $manage_files_by2->{_pathNfile} = $manage_files_by2->{_directory}.'/'.$manage_files_by2->{_file_in}; | ||
| 267 | # print("manage_files_by2, _set_pathNfile, pathNfile=$manage_files_by2->{_pathNfile} \n"); | ||
| 268 | return (); | ||
| 269 | } | ||
| 270 | else { | ||
| 271 | print("manage_files_by2, _set_pathNfile, missing parameters\n"); | ||
| 272 | } | ||
| 273 | return (); | ||
| 274 | } | ||
| 275 | |||
| 276 | =head2 sub clean | ||
| 277 | |||
| 278 | delete a pre-existing file | ||
| 279 | directory of a file | ||
| 280 | |||
| 281 | =cut | ||
| 282 | |||
| 283 | sub clean { | ||
| 284 | my ($self) = @_; | ||
| 285 | |||
| 286 | if ( length $manage_files_by2->{_delete_base_file_name} | ||
| 287 | and length $manage_files_by2->{_suffix_type} ) | ||
| 288 | { | ||
| 289 | |||
| 290 | use App::SeismicUnixGui::misc::SeismicUnix | ||
| 291 | qw($gx $in $out $on $go $to $txt | ||
| 292 | $suffix_ascii $off $offset $pick $profile | ||
| 293 | $su $suffix_profile $sx $suffix_su $suffix_target | ||
| 294 | $suffix_pick $suffix_target_tilde | ||
| 295 | $suffix_txt $target $target_tilde $tracl); | ||
| 296 | |||
| 297 | my $Project = Project_config->new(); | ||
| 298 | my $file = manage_files_by2->new(); | ||
| 299 | |||
| 300 | my $DATA_SEISMIC_BIN = $Project->DATA_SEISMIC_BIN; | ||
| 301 | my $DATA_SEISMIC_SEGY = $Project->DATA_SEISMIC_SEGY; | ||
| 302 | my $DATA_SEISMIC_SU = $Project->DATA_SEISMIC_SU; | ||
| 303 | my $DATA_SEISMIC_TXT = $Project->DATA_SEISMIC_TXT; | ||
| 304 | my $GEOPSY_PICKS = $Project->GEOPSY_PICKS; | ||
| 305 | my $GEOPSY_PROFILES = $Project->GEOPSY_PROFILES; | ||
| 306 | my $GEOPSY_TARGETS = $Project->GEOPSY_TARGETS; | ||
| 307 | my $file_name = $manage_files_by2->{_delete_base_file_name}; | ||
| 308 | my $suffix_type = $manage_files_by2->{_suffix_type}; | ||
| 309 | my $outbound; | ||
| 310 | |||
| 311 | if ( $suffix_type eq $txt ) { | ||
| 312 | |||
| 313 | $outbound = $DATA_SEISMIC_TXT . '/' . $file_name . $suffix_txt; | ||
| 314 | |||
| 315 | } | ||
| 316 | elsif ( $suffix_type eq $su ) { | ||
| 317 | |||
| 318 | $outbound = $DATA_SEISMIC_SU . '/' . $file_name . $suffix_su; | ||
| 319 | |||
| 320 | } | ||
| 321 | |||
| 322 | elsif ( $suffix_type eq $pick ) { | ||
| 323 | |||
| 324 | $outbound = $GEOPSY_PICKS . '/' . $file_name . $suffix_pick; | ||
| 325 | |||
| 326 | print("manage_files_by2, clean, outbound=$outbound\n"); | ||
| 327 | |||
| 328 | } | ||
| 329 | |||
| 330 | elsif ( $suffix_type eq $profile ) { | ||
| 331 | |||
| 332 | $outbound = $GEOPSY_PROFILES . '/' . $file_name . $suffix_profile; | ||
| 333 | |||
| 334 | print("manage_files_by2, clean, outbound=$outbound\n"); | ||
| 335 | |||
| 336 | } | ||
| 337 | |||
| 338 | elsif ( $suffix_type eq $target ) { | ||
| 339 | |||
| 340 | $outbound = $GEOPSY_TARGETS . '/' . $file_name . $suffix_target; | ||
| 341 | |||
| 342 | print("manage_files_by2, clean, outbound=$outbound\n"); | ||
| 343 | |||
| 344 | } | ||
| 345 | |||
| 346 | elsif ( $suffix_type eq $target_tilde ) { | ||
| 347 | |||
| 348 | $outbound = | ||
| 349 | $GEOPSY_TARGETS . '/' . $file_name . $suffix_target_tilde; | ||
| 350 | print("manage_files_by2, clean, outbound=$outbound\n"); | ||
| 351 | |||
| 352 | } | ||
| 353 | |||
| 354 | else { | ||
| 355 | print("manage_files_by2, clean, unexpected value\n"); | ||
| 356 | } | ||
| 357 | |||
| 358 | my $ans = _exists($outbound); | ||
| 359 | |||
| 360 | # print("manage_files_by2, clean, ans = $ans\n"); | ||
| 361 | |||
| 362 | if ($ans) { | ||
| 363 | |||
| 364 | _delete($outbound); | ||
| 365 | |||
| 366 | # print( | ||
| 367 | #"manage_files_by2, clean, Cleaning for pre-existing $outbound \n" | ||
| 368 | # ); | ||
| 369 | |||
| 370 | } | ||
| 371 | else { | ||
| 372 | # print("manage_files_by2, clean, file does not exist NADA\n"); | ||
| 373 | } | ||
| 374 | |||
| 375 | } | ||
| 376 | else { | ||
| 377 | print("manage_files_by2, set_geom4calc, missing values\n"); | ||
| 378 | print( | ||
| 379 | "manage_files_by2, clean, delete_base_file_name=$manage_files_by2->{_delete_base_file_name}\n" | ||
| 380 | ); | ||
| 381 | |||
| 382 | } | ||
| 383 | |||
| 384 | } | ||
| 385 | |||
| 386 | =head2 sub _delete | ||
| 387 | |||
| 388 | This (provate) function/method deletes files | ||
| 389 | |||
| 390 | =cut | ||
| 391 | |||
| 392 | sub _delete { | ||
| 393 | |||
| 394 | my ($outbound) = @_; | ||
| 395 | |||
| 396 | # get directory names | ||
| 397 | # print("\n manage_files_by2, delete, Deleting $outbound \n"); | ||
| 398 | |||
| 399 | system( | ||
| 400 | " \\ | ||
| 401 | rm $outbound \\ | ||
| 402 | " | ||
| 403 | ); | ||
| 404 | |||
| 405 | } | ||
| 406 | |||
| 407 | =head2 sub clear_empty_files | ||
| 408 | |||
| 409 | =cut | ||
| 410 | |||
| 411 | sub clear_empty_files { | ||
| 412 | |||
| 413 | my ($self) = @_; | ||
| 414 | |||
| 415 | if ( length( $manage_files_by2->{_directory} ) ) { | ||
| 416 | |||
| 417 | my $dir = $manage_files_by2->{_directory}; | ||
| 418 | |||
| 419 | my ( @size, @file_name, @inode ); | ||
| 420 | my ( $i, $junk, $cmd_file_name, $num_file_names ); | ||
| 421 | my ( $cmd_inode, $cmd_size, $index_node_number ); | ||
| 422 | |||
| 423 | # print("manage_files_by2, clear_empty_files, dir=$manage_files_by2->{_directory} \n"); | ||
| 424 | |||
| 425 | # print("\n manage_files_by2, clear_empty_files in dir=$dir\n"); | ||
| 426 | chomp $dir; | ||
| 427 | |||
| 428 | $cmd_file_name = "ls -1 $dir"; | ||
| 429 | $cmd_size = "ls -s1 $dir"; | ||
| 430 | $cmd_inode = "ls -i1 $dir"; | ||
| 431 | @file_name = `$cmd_file_name`; | ||
| 432 | @size = `$cmd_size`; | ||
| 433 | @inode = `$cmd_inode`; | ||
| 434 | $num_file_names = scalar @file_name; | ||
| 435 | |||
| 436 | for ( my $i = 0 ; $i < $num_file_names ; $i++ ) { | ||
| 437 | chomp $file_name[$i]; | ||
| 438 | chomp $inode[$i]; | ||
| 439 | |||
| 440 | $inode[$i] =~ s/^\s+//g; # trim spaces at start | ||
| 441 | ( $inode[$i], $junk ) = split( / /, $inode[$i] ); | ||
| 442 | |||
| 443 | $file_name[$i] =~ s/^\s+//g; # trim spaces at start | ||
| 444 | ( $file_name[$i], $junk ) = split( / /, $file_name[$i] ); | ||
| 445 | } | ||
| 446 | |||
| 447 | for ( my $i = 1 ; $i <= $num_file_names ; $i++ ) { | ||
| 448 | |||
| 449 | chomp $size[$i]; | ||
| 450 | $size[$i] =~ s/^\s+//g; # trim spaces at start | ||
| 451 | ( $size[$i], $junk ) = split( / /, $size[$i] ); | ||
| 452 | |||
| 453 | } | ||
| 454 | |||
| 455 | for ( my $i = 0, my $j = 1 ; $i < $num_file_names ; $i++, $j++ ) { | ||
| 456 | |||
| 457 | my $test = ( -d $dir . '/' . $file_name[$i] ); | ||
| 458 | if ( $size[$j] == 0 | ||
| 459 | && not($test) ) | ||
| 460 | { | ||
| 461 | my $ans = ($test); | ||
| 462 | |||
| 463 | # print("CASE of not a directory and file =0\n"); | ||
| 464 | # print("CASE name inode size = $file_name[$i] $inode[$i] $size[$j]\n"); | ||
| 465 | |||
| 466 | $index_node_number = $inode[$i]; | ||
| 467 | my $flow = ( | ||
| 468 | "cd $dir | ||
| 469 | find . -inum $index_node_number -exec rm {} \\;" | ||
| 470 | ); | ||
| 471 | |||
| 472 | # print $flow; | ||
| 473 | system $flow; | ||
| 474 | |||
| 475 | } | ||
| 476 | else { | ||
| 477 | |||
| 478 | # print("immodpg,clean_trash,size>0,line=$i, NADA\n"); | ||
| 479 | } | ||
| 480 | } | ||
| 481 | |||
| 482 | } | ||
| 483 | else { | ||
| 484 | |||
| 485 | } | ||
| 486 | |||
| 487 | return (); | ||
| 488 | } | ||
| 489 | |||
| 490 | =head2 sub count_lines | ||
| 491 | |||
| 492 | this function counts the numbers of lines in a text file | ||
| 493 | |||
| 494 | =cut | ||
| 495 | |||
| 496 | sub count_lines { | ||
| 497 | my ( $self, $ref_origin ) = @_; | ||
| 498 | |||
| 499 | # print ("\nmanage_files_by,count_lines The input file is called $$ref_origin\n"); | ||
| 500 | |||
| 501 | # open the file of interest | ||
| 502 | open( my $IN, '<', $$ref_origin ) or die "Can't open $$ref_origin, $!\n"; | ||
| 503 | my $cnt; | ||
| 504 | $cnt++ while <$IN>; | ||
| 505 | close($IN); | ||
| 506 | |||
| 507 | my $num_lines = $cnt; | ||
| 508 | |||
| 509 | # print ("line number = $num_lines\n"); | ||
| 510 | |||
| 511 | return ($num_lines); | ||
| 512 | } | ||
| 513 | |||
| 514 | =head2 sub delete | ||
| 515 | |||
| 516 | This function/method deletes files | ||
| 517 | |||
| 518 | =cut | ||
| 519 | |||
| 520 | sub delete { | ||
| 521 | |||
| 522 | my ( $self, $outbound ) = @_; | ||
| 523 | |||
| 524 | # get directory names | ||
| 525 | # print("\n manage_files_by2, delete, Deleting $outbound \n"); | ||
| 526 | |||
| 527 | system( | ||
| 528 | " \\ | ||
| 529 | rm $outbound \\ | ||
| 530 | " | ||
| 531 | ); | ||
| 532 | |||
| 533 | } | ||
| 534 | |||
| 535 | =head2 sub does_file_exist | ||
| 536 | |||
| 537 | =cut | ||
| 538 | |||
| 539 | sub does_file_exist { | ||
| 540 | |||
| 541 | my ( $does_file_exist, $ref_file ) = @_; | ||
| 542 | |||
| 543 | $does_file_exist->{ref_file} = $$ref_file if defined($ref_file); | ||
| 544 | |||
| 545 | # print("manage_files_by2,does_file_exist,file name is, $$ref_file\n"); | ||
| 546 | |||
| 547 | # default situation is to have a file non-existent | ||
| 548 | my $answer = 0; | ||
| 549 | |||
| 550 | # -e returns 1 or '' | ||
| 551 | # verified by JL | ||
| 552 | # print("plain file for test is $$ref_file\n\n"); | ||
| 553 | if ( -f $does_file_exist->{ref_file} ) { | ||
| 554 | |||
| 555 | # print ("manage_files_by2,does_file_exist,$$ref_file file exists\n\n") ; | ||
| 556 | $answer = 1; | ||
| 557 | } | ||
| 558 | else { | ||
| 559 | # print("manage_files_by2,does_file_exist,$$ref_file is missing\n\n") ; | ||
| 560 | } | ||
| 561 | |||
| 562 | # answer=1 if existent and =0 if non-existent | ||
| 563 | # verified by JL | ||
| 564 | return ($answer); | ||
| 565 | } | ||
| 566 | |||
| 567 | sub does_file_exist_sref { | ||
| 568 | |||
| 569 | my ( $self, $ref_file ) = @_; | ||
| 570 | |||
| 571 | if ($ref_file) { | ||
| 572 | |||
| 573 | my $file = $$ref_file; | ||
| 574 | |||
| 575 | # print("manage_files_by2,does_file_exist_sref,file name is, $$ref_file\n"); | ||
| 576 | |||
| 577 | # default situation is to have a file non-existent | ||
| 578 | my $answer = 0; | ||
| 579 | |||
| 580 | # -e returns 1 or '' | ||
| 581 | # verified by JL | ||
| 582 | # print("file for exist test is $$ref_file\n\n"); | ||
| 583 | # actually dies it exist and is it a plain file!! | ||
| 584 | if ( -f $file ) { | ||
| 585 | |||
| 586 | # print ("file existence verified\n\n") ; | ||
| 587 | $answer = 1; | ||
| 588 | } | ||
| 589 | |||
| 590 | # answer=1 if existent and =0 if non-existent | ||
| 591 | #verified by JL | ||
| 592 | return ($answer); | ||
| 593 | } | ||
| 594 | else { | ||
| 595 | print("does_file_exist_sref, ref_file is missing\n"); | ||
| 596 | } | ||
| 597 | |||
| 598 | } | ||
| 599 | |||
| 600 | =head2 sub exists | ||
| 601 | |||
| 602 | Another way to see if a file exists | ||
| 603 | input is a scalar | ||
| 604 | |||
| 605 | |||
| 606 | =cut | ||
| 607 | |||
| 608 | sub exists { | ||
| 609 | |||
| 610 | my ( $self, $file ) = @_; | ||
| 611 | |||
| 612 | if ($file) { | ||
| 613 | |||
| 614 | # default situation is to have a file non-existent | ||
| 615 | my $answer = 0; | ||
| 616 | |||
| 617 | # -e returns 1 or '' | ||
| 618 | # verified by JL | ||
| 619 | # print("existence test for $file\n\n"); | ||
| 620 | if ( -e $file ) { | ||
| 621 | |||
| 622 | # print("file existence verified; answer=$answer\n\n"); | ||
| 623 | $answer = 1; | ||
| 624 | } | ||
| 625 | |||
| 626 | # answer=1 if existent and =0 if non-existent | ||
| 627 | # print ("file non-existence verified; answer=$answer\n\n") ; | ||
| 628 | #verified by JL | ||
| 629 | return ($answer); | ||
| 630 | } | ||
| 631 | else { | ||
| 632 | print("\n"); | ||
| 633 | } | ||
| 634 | |||
| 635 | } | ||
| 636 | |||
| 637 | =head2 sub get_3cols_aref | ||
| 638 | |||
| 639 | This function reads 3 cols in a text file | ||
| 640 | |||
| 641 | =cut | ||
| 642 | |||
| 643 | sub get_3cols_aref { | ||
| 644 | |||
| 645 | my ( $reference, $file_name, $skip_lines ) = @_; | ||
| 646 | my ( @X, @Y, @Z ); | ||
| 647 | my $lines; | ||
| 648 | |||
| 649 | print("\nThe input file is called $file_name\n"); | ||
| 650 | |||
| 651 | # open the file of interest | ||
| 652 | open( FILE, "$file_name" ) || print("Can't open $file_name, $!\n"); | ||
| 653 | |||
| 654 | # skip lines | ||
| 655 | for ( my $i = 0 ; $i < $skip_lines ; $i++ ) { | ||
| 656 | $lines = <FILE>; | ||
| 657 | print("line $i = $lines\n"); | ||
| 658 | } | ||
| 659 | |||
| 660 | #set the counter | ||
| 661 | my $i = 0; | ||
| 662 | |||
| 663 | # read contents of file | ||
| 664 | while ( my $lines = <FILE> ) { | ||
| 665 | |||
| 666 | # print("$lines"); | ||
| 667 | chomp($lines); | ||
| 668 | my ( $x, $y, $z ) = split( " ", $lines ); | ||
| 669 | |||
| 670 | print("\n$x \n"); | ||
| 671 | $X[$i] = $x; | ||
| 672 | $Y[$i] = $y; | ||
| 673 | $Z[$i] = $z; | ||
| 674 | |||
| 675 | #print("\n @X[$i] @Y[$i] @Z[$i] \n"); | ||
| 676 | $i++; | ||
| 677 | } | ||
| 678 | |||
| 679 | # number of geophones stations in file | ||
| 680 | my $num_rows = $i - 1; | ||
| 681 | |||
| 682 | print ("This file contains $num_rows rows\n\n\n"); | ||
| 683 | # close the file of interest | ||
| 684 | close(FILE); | ||
| 685 | |||
| 686 | # make sure arrays do not contaminate outside | ||
| 687 | |||
| 688 | return ( \@X, \@Y, \@Z ); | ||
| 689 | |||
| 690 | } | ||
| 691 | |||
| 692 | =head2 sub get_5cols_aref | ||
| 693 | |||
| 694 | this function reads 5 cols in a text file | ||
| 695 | |||
| 696 | =cut | ||
| 697 | |||
| 698 | sub get_5cols_aref { | ||
| 699 | |||
| 700 | my ( $self, $file_name ) = @_; | ||
| 701 | |||
| 702 | if ( length $file_name ) { | ||
| 703 | |||
| 704 | my @ID; | ||
| 705 | my @X; | ||
| 706 | my @Y; | ||
| 707 | my @Z; | ||
| 708 | my @W; | ||
| 709 | my ($lines); | ||
| 710 | my $i = 0; | ||
| 711 | |||
| 712 | # print( | ||
| 713 | #"\n manage_files_by2, get_5cols_aref, The input file with 5 cols is called $file_name\n" | ||
| 714 | # ); | ||
| 715 | |||
| 716 | # open the file of interest | ||
| 717 | open( FILE, $file_name ) || print("Can't open $!\n"); | ||
| 718 | |||
| 719 | # read contents of file | ||
| 720 | while ( $lines = <FILE> ) { | ||
| 721 | |||
| 722 | #print("$lines"); | ||
| 723 | chomp($lines); | ||
| 724 | my ( $ident, $x, $y, $z, $w ) = split( " ", $lines ); | ||
| 725 | |||
| 726 | #print("\n $ident \n"); | ||
| 727 | $ID[$i] = $ident; | ||
| 728 | $X[$i] = $x; | ||
| 729 | $Y[$i] = $y; | ||
| 730 | $Z[$i] = $z; | ||
| 731 | $W[$i] = $w; | ||
| 732 | |||
| 733 | $i++; | ||
| 734 | |||
| 735 | } | ||
| 736 | $i = $i - 1; | ||
| 737 | |||
| 738 | # print ("This file contains number of indices: $i\n\n\n"); | ||
| 739 | # close the file of interest | ||
| 740 | close(FILE); | ||
| 741 | |||
| 742 | my @output_array = ( \@ID, \@X, \@Y, \@Z, \@W ); | ||
| 743 | return ( \@output_array ); | ||
| 744 | |||
| 745 | } | ||
| 746 | else { | ||
| 747 | print("\n, manage_files_by2, get_5cols_aref, missing a value\n"); | ||
| 748 | } | ||
| 749 | |||
| 750 | print("\nThe input file with 5 cols is called $file_name\n"); | ||
| 751 | |||
| 752 | } | ||
| 753 | |||
| 754 | =head2 sub get 1 column | ||
| 755 | |||
| 756 | =cut | ||
| 757 | |||
| 758 | sub get_1col { | ||
| 759 | |||
| 760 | # this function reads first col from a text file | ||
| 761 | my ($self) = @_; | ||
| 762 | |||
| 763 | if ( length $manage_files_by2->{_directory} | ||
| 764 | && length $manage_files_by2->{_file_in} ) | ||
| 765 | { | ||
| 766 | |||
| 767 | my @OFFSET; | ||
| 768 | _set_pathNfile(); | ||
| 769 | my $pathNfile = $manage_files_by2->{_pathNfile}; | ||
| 770 | # print( | ||
| 771 | # "\nmanage_files_by2, get_1col, The input is called $pathNfile\n"); | ||
| 772 | |||
| 773 | # open the file of interest | ||
| 774 | open( FILE, $pathNfile ) || print("Can't open $pathNfile, $!\n"); | ||
| 775 | |||
| 776 | #set the counter | ||
| 777 | my $i = 0; | ||
| 778 | |||
| 779 | # read contents of shotpoint geometry file | ||
| 780 | while ( my $line = <FILE> ) { | ||
| 781 | |||
| 782 | #print("\n$line"); | ||
| 783 | chomp($line); | ||
| 784 | my ($x) = $line; | ||
| 785 | $OFFSET[$i] = $x; | ||
| 786 | |||
| 787 | # print( | ||
| 788 | # "\n manage_files_by2, read_1col, Reading 1 col file:$OFFSET[$i]\n"); | ||
| 789 | $i = $i + 1; | ||
| 790 | } | ||
| 791 | |||
| 792 | close(FILE); | ||
| 793 | |||
| 794 | my $num_rows = scalar @OFFSET; | ||
| 795 | |||
| 796 | # print out the number of lines of data for the user | ||
| 797 | # print( | ||
| 798 | #"manage_files_by2, read_1col, This file contains $num_rows rows of data\n\n\n" | ||
| 799 | # ); | ||
| 800 | |||
| 801 | # make sure arrays do not contaminate outside | ||
| 802 | my $result = \@OFFSET; | ||
| 803 | |||
| 804 | return ( $result, $num_rows ); | ||
| 805 | } | ||
| 806 | |||
| 807 | } | ||
| 808 | |||
| 809 | |||
| 810 | =head2 sub get_base_file_names_aref | ||
| 811 | |||
| 812 | read a list of file names | ||
| 813 | remove the su suffix | ||
| 814 | return array reference of the | ||
| 815 | list of names without su suffixes | ||
| 816 | |||
| 817 | =cut | ||
| 818 | |||
| 819 | sub get_base_file_name_aref { | ||
| 820 | my ($self) = @_; | ||
| 821 | |||
| 822 | # simple check | ||
| 823 | if ( length $manage_files_by2->{_inbound_list} ) { | ||
| 824 | |||
| 825 | my $inbound_list = $manage_files_by2->{_inbound_list}; | ||
| 826 | |||
| 827 | my ( $file_names_aref, $num_files ) = $readfiles->cols_1p($inbound_list); | ||
| 828 | $control->set_aref($file_names_aref); | ||
| 829 | # TODO to general suffix | ||
| 830 | $control->remove_su_suffix4aref(); | ||
| 831 | my $base_file_name_aref = $control->get_base_file_name_aref(); | ||
| 832 | |||
| 833 | # print("manage_files_by2, get_base_file_names, values=@$base_file_name_aref\n"); | ||
| 834 | |||
| 835 | my $result_a = $base_file_name_aref; | ||
| 836 | my $result_b = $num_files; | ||
| 837 | return ( $result_a, $result_b); | ||
| 838 | |||
| 839 | } | ||
| 840 | else { | ||
| 841 | print("_get_base_file_name_aref, missing inbound lsit\n"); | ||
| 842 | return (); | ||
| 843 | } | ||
| 844 | } | ||
| 845 | |||
| 846 | =pod sub get_whole | ||
| 847 | |||
| 848 | open and read | ||
| 849 | the complete file | ||
| 850 | line by line | ||
| 851 | #print ("lines are @{$manage_files_by2->{_all_lines_aref}}\n"); | ||
| 852 | print ("We seem to have $manage_files_by2->{_num_lines} lines total\n"); | ||
| 853 | |||
| 854 | =cut | ||
| 855 | |||
| 856 | sub get_whole { | ||
| 857 | my ($self) = @_; | ||
| 858 | my @all_lines; | ||
| 859 | |||
| 860 | if ( | ||
| 861 | ( | ||
| 862 | length $manage_files_by2->{_directory} | ||
| 863 | && length $manage_files_by2->{_file_in} | ||
| 864 | ) | ||
| 865 | or length $manage_files_by2->{_pathNfile} | ||
| 866 | ) | ||
| 867 | { | ||
| 868 | my $inbound; | ||
| 869 | my $i = 0; | ||
| 870 | |||
| 871 | # full directory directory plus file name | ||
| 872 | if ( length $manage_files_by2->{_directory} | ||
| 873 | && length $manage_files_by2->{_file_in} ) | ||
| 874 | { | ||
| 875 | $inbound = | ||
| 876 | $manage_files_by2->{_directory} . '/' | ||
| 877 | . $manage_files_by2->{_file_in}; | ||
| 878 | |||
| 879 | # print("manage_files_by2, get_whole, $inbound\n"); | ||
| 880 | |||
| 881 | } | ||
| 882 | elsif ( length $manage_files_by2->{_pathNfile} ) { | ||
| 883 | |||
| 884 | $inbound = $manage_files_by2->{_pathNfile}; | ||
| 885 | |||
| 886 | # print("manage_files_by2, get_whole, $inbound\n"); | ||
| 887 | |||
| 888 | } | ||
| 889 | else { | ||
| 890 | print("manage_files_by2_get_whole, unexpected variable\n"); | ||
| 891 | } | ||
| 892 | |||
| 893 | open( my $fh, '<', $inbound ) | ||
| 894 | or die "Could not open file '$manage_files_by2->{_file_in}' $!"; | ||
| 895 | while ( my $row = <$fh> ) { | ||
| 896 | |||
| 897 | chomp $row; | ||
| 898 | $all_lines[$i] = $row; | ||
| 899 | |||
| 900 | # print "I read: " . $all_lines[$i] . " <--from the file, i=" . $i . "\n"; | ||
| 901 | $i++; | ||
| 902 | } | ||
| 903 | |||
| 904 | $manage_files_by2->{_all_lines_aref} = \@all_lines; | ||
| 905 | close($fh); | ||
| 906 | |||
| 907 | $manage_files_by2->{_num_lines} = | ||
| 908 | scalar @{ $manage_files_by2->{_all_lines_aref} }; | ||
| 909 | |||
| 910 | } | ||
| 911 | else { | ||
| 912 | print( | ||
| 913 | "manage_files_by2, get_whole, missing either directory or file name, or both \n" | ||
| 914 | ); | ||
| 915 | } | ||
| 916 | |||
| 917 | my $result_ref = \@all_lines; | ||
| 918 | return ($result_ref); | ||
| 919 | } | ||
| 920 | |||
| 921 | =head2 sub set_directory | ||
| 922 | |||
| 923 | =cut | ||
| 924 | |||
| 925 | sub set_directory { | ||
| 926 | |||
| 927 | my ( $self, $dir ) = @_; | ||
| 928 | |||
| 929 | if ( length($dir) ) { | ||
| 930 | |||
| 931 | $manage_files_by2->{_directory} = $dir; | ||
| 932 | |||
| 933 | # print("manage_files_by2, set_directory, dir=$manage_files_by2->{_directory} \n"); | ||
| 934 | |||
| 935 | } | ||
| 936 | else { | ||
| 937 | print("manage_files_by2, set_directory, missing value\n"); | ||
| 938 | } | ||
| 939 | |||
| 940 | return (); | ||
| 941 | } | ||
| 942 | |||
| 943 | =head2 sub set_file_in | ||
| 944 | |||
| 945 | =cut | ||
| 946 | |||
| 947 | sub set_file_in { | ||
| 948 | |||
| 949 | my ( $self, $file_in ) = @_; | ||
| 950 | |||
| 951 | if ( length($file_in) ) { | ||
| 952 | |||
| 953 | $manage_files_by2->{_file_in} = $file_in; | ||
| 954 | |||
| 955 | # print("manage_files_by2, set_file_in, file=$manage_files_by2->{_file_in} \n"); | ||
| 956 | |||
| 957 | } | ||
| 958 | else { | ||
| 959 | print("manage_files_by2, set_file_in, missing value\n"); | ||
| 960 | } | ||
| 961 | |||
| 962 | return (); | ||
| 963 | |||
| 964 | } | ||
| 965 | |||
| 966 | |||
| 967 | =head2 sub set_inbound_list | ||
| 968 | |||
| 969 | =cut | ||
| 970 | |||
| 971 | sub set_inbound_list { | ||
| 972 | my ($self,$inbound_list) = @_; | ||
| 973 | |||
| 974 | if ( length $inbound_list ) { | ||
| 975 | |||
| 976 | $control->set_back_slashBgone($inbound_list); | ||
| 977 | $inbound_list = $control->get_back_slashBgone(); | ||
| 978 | $manage_files_by2->{_inbound_list} = $inbound_list; | ||
| 979 | |||
| 980 | } | ||
| 981 | else { | ||
| 982 | print("manage_files_by2, set_inbound_list, missing list\n"); | ||
| 983 | return (); | ||
| 984 | } | ||
| 985 | |||
| 986 | } | ||
| 987 | |||
| 988 | |||
| 989 | =head2 | ||
| 990 | |||
| 991 | read a 1-column file | ||
| 992 | |||
| 993 | =cut | ||
| 994 | |||
| 995 | sub read_1col_aref { | ||
| 996 | |||
| 997 | # open and read and input file | ||
| 998 | my ( $caller, $ref_file_name ) = @_; | ||
| 999 | |||
| 1000 | #declare locally scoped variables | ||
| 1001 | my ( $j, $num_rows ); | ||
| 1002 | my ( $i, $x ); | ||
| 1003 | my @X; | ||
| 1004 | my $line; | ||
| 1005 | |||
| 1006 | # print( | ||
| 1007 | #"manage_files_by2,read_1col_aref,The output file name = $$ref_file_name\n" | ||
| 1008 | # ); | ||
| 1009 | |||
| 1010 | # set the counter | ||
| 1011 | |||
| 1012 | $i = 0; | ||
| 1013 | open( IN, "<$$ref_file_name" ) | ||
| 1014 | or die "Could not open file '$$ref_file_name'. $!"; | ||
| 1015 | |||
| 1016 | # read contents of file | ||
| 1017 | while ( $line = <IN> ) { | ||
| 1018 | |||
| 1019 | # print("\n$line"); | ||
| 1020 | chomp($line); | ||
| 1021 | ($x) = split( " ", $line ); | ||
| 1022 | $X[$i] = $x; | ||
| 1023 | |||
| 1024 | # print("\n $X[$i]\n"); | ||
| 1025 | $i++; | ||
| 1026 | |||
| 1027 | } | ||
| 1028 | |||
| 1029 | close(FILE); | ||
| 1030 | |||
| 1031 | $num_rows = $i; | ||
| 1032 | |||
| 1033 | # print ("\nThis file contains $num_rows row(s) of data\n"); | ||
| 1034 | |||
| 1035 | return ( \@X ); | ||
| 1036 | |||
| 1037 | } | ||
| 1038 | |||
| 1039 | =pod | ||
| 1040 | |||
| 1041 | read in a 2-columned file | ||
| 1042 | reads cols 1 and 2 in a text file | ||
| 1043 | |||
| 1044 | |||
| 1045 | =cut | ||
| 1046 | |||
| 1047 | sub read_2cols_aref { | ||
| 1048 | |||
| 1049 | my ( $variable, $inbound, $spacer ) = @_; | ||
| 1050 | |||
| 1051 | if ( length $inbound | ||
| 1052 | and $spacer ) | ||
| 1053 | { | ||
| 1054 | |||
| 1055 | # print("manage_files_by2, read_2cols_ref, inbound=$inbound\n"); | ||
| 1056 | |||
| 1057 | # declare locally scoped variables | ||
| 1058 | my ( $i, $line, $t, $x, $num_rows ); | ||
| 1059 | my ( @TIME, @OFFSET ); | ||
| 1060 | |||
| 1061 | # open the file of interest | ||
| 1062 | open( FILE, $inbound ) || print("Can't open $inbound \n"); | ||
| 1063 | |||
| 1064 | #set the counter | ||
| 1065 | $i = 0; | ||
| 1066 | |||
| 1067 | # read contents of shotpoint geometry file | ||
| 1068 | while ( $line = <FILE> ) { | ||
| 1069 | |||
| 1070 | # print("\n$line"); | ||
| 1071 | chomp($line); | ||
| 1072 | ( $t, $x ) = split( $spacer, $line ); | ||
| 1073 | $TIME[$i] = $t; | ||
| 1074 | $OFFSET[$i] = $x; | ||
| 1075 | |||
| 1076 | # print("\n $TIME[$i] $OFFSET[$i]\n"); | ||
| 1077 | $i = $i + 1; | ||
| 1078 | |||
| 1079 | } | ||
| 1080 | |||
| 1081 | close(FILE); | ||
| 1082 | |||
| 1083 | $num_rows = $i - 1; | ||
| 1084 | |||
| 1085 | # print out the number of lines of data for the user | ||
| 1086 | #print ("\nThis file contains $num_rows row(s) of data\n"); | ||
| 1087 | |||
| 1088 | my @array_out = ( \@TIME, \@OFFSET ); | ||
| 1089 | my $result = \@array_out; | ||
| 1090 | |||
| 1091 | return ($result); | ||
| 1092 | |||
| 1093 | } | ||
| 1094 | else { | ||
| 1095 | print("manage_files_by2, read_2cols_ref, missing variables\n"); | ||
| 1096 | return (); | ||
| 1097 | } | ||
| 1098 | |||
| 1099 | } | ||
| 1100 | |||
| 1101 | =pod | ||
| 1102 | |||
| 1103 | read in a 2-columned file | ||
| 1104 | reads cols 1 and 2 in a text file | ||
| 1105 | |||
| 1106 | |||
| 1107 | =cut | ||
| 1108 | |||
| 1109 | sub read_2cols { | ||
| 1110 | |||
| 1111 | my ( $variable, $ref_origin ) = @_; | ||
| 1112 | |||
| 1113 | if ( length $ref_origin ) { | ||
| 1114 | |||
| 1115 | # CASE 1 | ||
| 1116 | # declare locally scoped variables | ||
| 1117 | my ( $i, $line, $t, $x, $num_rows ); | ||
| 1118 | my ( @TIME, @TIME_OUT, @OFFSET, @OFFSET_OUT ); | ||
| 1119 | |||
| 1120 | # print("manage_files_by2,read_2cols $$ref_origin\n"); | ||
| 1121 | |||
| 1122 | # open the file of interest | ||
| 1123 | open( FILE, $$ref_origin ) || print("Can't open $$ref_origin \n"); | ||
| 1124 | |||
| 1125 | #set the counter | ||
| 1126 | $i = 1; | ||
| 1127 | |||
| 1128 | # read contents of shotpoint geometry file | ||
| 1129 | while ( $line = <FILE> ) { | ||
| 1130 | |||
| 1131 | #print("\n$line"); | ||
| 1132 | chomp($line); | ||
| 1133 | ( $t, $x ) = split( " ", $line ); | ||
| 1134 | $TIME[$i] = $t; | ||
| 1135 | $OFFSET[$i] = $x; | ||
| 1136 | |||
| 1137 | #print("\n $TIME[$i] $OFFSET[$i]\n"); | ||
| 1138 | $i = $i + 1; | ||
| 1139 | |||
| 1140 | } | ||
| 1141 | |||
| 1142 | close(FILE); | ||
| 1143 | |||
| 1144 | $num_rows = $i - 1; | ||
| 1145 | |||
| 1146 | # print out the number of lines of data for the user | ||
| 1147 | #print ("\nThis file contains $num_rows row(s) of data\n"); | ||
| 1148 | |||
| 1149 | # to prevent contaminating outside variables | ||
| 1150 | @TIME_OUT = @TIME; | ||
| 1151 | @OFFSET_OUT = @OFFSET; | ||
| 1152 | |||
| 1153 | return ( \@TIME_OUT, \@OFFSET_OUT, $num_rows ); | ||
| 1154 | } | ||
| 1155 | elsif ( not length $ref_origin | ||
| 1156 | and length $manage_files_by2->{_pathNfile} ) | ||
| 1157 | { | ||
| 1158 | |||
| 1159 | # CASE 2 | ||
| 1160 | # declare locally scoped variables | ||
| 1161 | my ( $i, $line, $t, $x, $num_rows ); | ||
| 1162 | my ( @TIME, @TIME_OUT, @OFFSET, @OFFSET_OUT ); | ||
| 1163 | my $pathNfile = $manage_files_by2->{_pathNfile}; | ||
| 1164 | |||
| 1165 | # print("manage_files_by2,read_2cols,$pathNfile\n"); | ||
| 1166 | |||
| 1167 | # open the file of interest | ||
| 1168 | open( FILE, $pathNfile ) | ||
| 1169 | || print("Can't open $pathNfile \n"); | ||
| 1170 | |||
| 1171 | #set the counter | ||
| 1172 | $i = 0; | ||
| 1173 | |||
| 1174 | # read contents of shotpoint geometry file | ||
| 1175 | while ( $line = <FILE> ) { | ||
| 1176 | |||
| 1177 | # print("\n$line"); | ||
| 1178 | chomp($line); | ||
| 1179 | |||
| 1180 | # split line on tab | ||
| 1181 | ( $t, $x ) = split( /\t/, $line ); | ||
| 1182 | $TIME[$i] = $t; | ||
| 1183 | $OFFSET[$i] = $x; | ||
| 1184 | |||
| 1185 | $i = $i + 1; | ||
| 1186 | |||
| 1187 | } | ||
| 1188 | |||
| 1189 | # print("\n--$TIME[0]--$OFFSET[0]\n"); | ||
| 1190 | # print("\n--$TIME[1]--$OFFSET[1]\n"); | ||
| 1191 | close(FILE); | ||
| 1192 | |||
| 1193 | $num_rows = $i; | ||
| 1194 | |||
| 1195 | # print out the number of lines of data for the user | ||
| 1196 | # print ("\nmanage_files_by2,read_2cols,num_rows=$num_rows\n"); | ||
| 1197 | |||
| 1198 | # to prevent contaminating outside variables | ||
| 1199 | @TIME_OUT = @TIME; | ||
| 1200 | @OFFSET_OUT = @OFFSET; | ||
| 1201 | |||
| 1202 | return ( \@TIME_OUT, \@OFFSET_OUT, $num_rows ); | ||
| 1203 | |||
| 1204 | } | ||
| 1205 | else { | ||
| 1206 | print( | ||
| 1207 | "manage_files_by2,read_2cols, missing reference to pathNfile\n"); | ||
| 1208 | } | ||
| 1209 | |||
| 1210 | return (); | ||
| 1211 | } | ||
| 1212 | |||
| 1213 | sub read_1col { | ||
| 1214 | |||
| 1215 | # this function reads 1 col from a text file | ||
| 1216 | |||
| 1217 | my ( $self, $file_name ) = @_; | ||
| 1218 | my @OFFSET; | ||
| 1219 | |||
| 1220 | # print( | ||
| 1221 | # "\nmanage_files_by2, read_1col, The input file is called $file_name\n" | ||
| 1222 | # ); | ||
| 1223 | |||
| 1224 | # open the file of interest | ||
| 1225 | open( FILE, $file_name ) || print("Can't open $file_name, $!\n"); | ||
| 1226 | |||
| 1227 | #set the counter | ||
| 1228 | my $i = 0; | ||
| 1229 | |||
| 1230 | # read contents of shotpoint geometry file | ||
| 1231 | while ( my $line = <FILE> ) { | ||
| 1232 | |||
| 1233 | #print("\n$line"); | ||
| 1234 | chomp($line); | ||
| 1235 | my ($x) = $line; | ||
| 1236 | $OFFSET[$i] = $x; | ||
| 1237 | |||
| 1238 | # print( | ||
| 1239 | # "\n manage_files_by2, read_1col, Reading 1 col file:$OFFSET[$i]\n" | ||
| 1240 | # ); | ||
| 1241 | $i = $i + 1; | ||
| 1242 | |||
| 1243 | } | ||
| 1244 | |||
| 1245 | close(FILE); | ||
| 1246 | |||
| 1247 | my $num_rows = scalar @OFFSET; | ||
| 1248 | |||
| 1249 | # print out the number of lines of data for the user | ||
| 1250 | # print( | ||
| 1251 | #"manage_files_by2, read_1col, This file contains $num_rows rows of data\n\n\n" | ||
| 1252 | # ); | ||
| 1253 | |||
| 1254 | # make sure arrays do not contaminate outside | ||
| 1255 | my $result = \@OFFSET; | ||
| 1256 | |||
| 1257 | return ( $result, $num_rows ); | ||
| 1258 | |||
| 1259 | } | ||
| 1260 | |||
| 1261 | =pod | ||
| 1262 | |||
| 1263 | read in a 2-columned file | ||
| 1264 | reads cols 1 and 2 in a text file | ||
| 1265 | |||
| 1266 | |||
| 1267 | =cut | ||
| 1268 | |||
| 1269 | sub get_10cols_aref { | ||
| 1270 | |||
| 1271 | my ( $self, $inbound, $skip ) = @_; | ||
| 1272 | |||
| 1273 | # print("$inbound--\n"); | ||
| 1274 | |||
| 1275 | if ( length $inbound | ||
| 1276 | and $skip ) | ||
| 1277 | { | ||
| 1278 | |||
| 1279 | # declare locally scoped variables | ||
| 1280 | my ( $i, $j, $k, $line, $num_rows ); | ||
| 1281 | my ( @a, @b, @c, @d, @e, @f, @g, @h, @i, @j ); | ||
| 1282 | my @value; | ||
| 1283 | my (@row_aref); | ||
| 1284 | |||
| 1285 | # match one or more spaces from start of line | ||
| 1286 | # before the first number | ||
| 1287 | my $spacer = '^\s+'; | ||
| 1288 | |||
| 1289 | # open the file of interest | ||
| 1290 | open( FILE, $inbound ) || print("Can't open $inbound \n"); | ||
| 1291 | |||
| 1292 | # set the counter | ||
| 1293 | $i = 0; | ||
| 1294 | $j = 0; | ||
| 1295 | |||
| 1296 | # read contents of shotpoint geometry file | ||
| 1297 | while ( $line = <FILE> ) { | ||
| 1298 | |||
| 1299 | if ( $i >= $skip ) { | ||
| 1300 | chomp($line); | ||
| 1301 | my @stuff = split( $spacer, $line ); | ||
| 1302 | my $last_idx = $#stuff; | ||
| 1303 | my @value = @stuff[ 1 .. $last_idx ]; | ||
| 1304 | $row_aref[$j] = \@value; | ||
| 1305 | $j = $j + 1; | ||
| 1306 | |||
| 1307 | # print ("value_0=$value[0]---\n"); | ||
| 1308 | } | ||
| 1309 | $i = $i + 1; | ||
| 1310 | } | ||
| 1311 | |||
| 1312 | $num_rows = $i - 1; | ||
| 1313 | close(FILE); | ||
| 1314 | |||
| 1315 | # print out the number of lines of data for the user | ||
| 1316 | # print("\nThis file contains $num_rows row(s) of data\n"); | ||
| 1317 | my $result = \@row_aref; | ||
| 1318 | return ($result); | ||
| 1319 | |||
| 1320 | } | ||
| 1321 | else { | ||
| 1322 | print("manage_files_by2, get_10cols_ref, missing variables\n"); | ||
| 1323 | return (); | ||
| 1324 | |||
| 1325 | } | ||
| 1326 | } | ||
| 1327 | |||
| 1328 | =head2 sub read_tx_curves2plot | ||
| 1329 | |||
| 1330 | |||
| 1331 | =cut | ||
| 1332 | |||
| 1333 | sub read_tx_curves2plot { | ||
| 1334 | |||
| 1335 | my ( $self, $curve_aref ) = @_; | ||
| 1336 | |||
| 1337 | if ( length $curve_aref ) { | ||
| 1338 | |||
| 1339 | my @curve = @$curve_aref; | ||
| 1340 | my $num_files = scalar @curve; | ||
| 1341 | my $first = 0; | ||
| 1342 | my $last = $num_files - 1; | ||
| 1343 | my @color; | ||
| 1344 | my ( $ref_T, $ref_X ); | ||
| 1345 | my @num_tx_pairs; | ||
| 1346 | |||
| 1347 | =head2 Define | ||
| 1348 | |||
| 1349 | private hash | ||
| 1350 | |||
| 1351 | =cut | ||
| 1352 | |||
| 1353 | my $read_tx_curves2plot = { | ||
| 1354 | _curves => '', | ||
| 1355 | _curve_color => '', | ||
| 1356 | _num_tx_pairs => '', | ||
| 1357 | }; | ||
| 1358 | |||
| 1359 | =head2 Define | ||
| 1360 | |||
| 1361 | curve color | ||
| 1362 | |||
| 1363 | =cut | ||
| 1364 | |||
| 1365 | $color[0] = 'red'; | ||
| 1366 | $color[1] = 'blue'; | ||
| 1367 | $color[2] = 'green'; | ||
| 1368 | $color[3] = 'yellow'; | ||
| 1369 | $color[4] = 'white'; | ||
| 1370 | $color[5] = 'black'; | ||
| 1371 | $color[6] = 'purple'; | ||
| 1372 | $color[7] = 'orange'; | ||
| 1373 | $color[8] = 'magenta'; | ||
| 1374 | $color[9] = 'brown'; | ||
| 1375 | |||
| 1376 | =head2 Collect | ||
| 1377 | |||
| 1378 | curve data | ||
| 1379 | |||
| 1380 | =cut | ||
| 1381 | |||
| 1382 | if ( $num_files == 1 ) { | ||
| 1383 | |||
| 1384 | # first case = 0 | ||
| 1385 | $read_tx_curves2plot->{_curves} = | ||
| 1386 | $read_tx_curves2plot->{_curves} . $curve[$first]; | ||
| 1387 | |||
| 1388 | ( $ref_T, $ref_X, $num_tx_pairs[$first] ) = | ||
| 1389 | _read_2cols( \$curve[$first] ); | ||
| 1390 | |||
| 1391 | $read_tx_curves2plot->{_num_tx_pairs} = | ||
| 1392 | $read_tx_curves2plot->{_num_tx_pairs} . $num_tx_pairs[$first]; | ||
| 1393 | $read_tx_curves2plot->{_curve_color} = | ||
| 1394 | $read_tx_curves2plot->{_curve_color} . $color[$first]; | ||
| 1395 | } | ||
| 1396 | else { | ||
| 1397 | # print(" # files ==1 2\n"); | ||
| 1398 | } | ||
| 1399 | |||
| 1400 | if ( $num_files > 1 ) { | ||
| 1401 | |||
| 1402 | # first case = 0 | ||
| 1403 | $read_tx_curves2plot->{_curves} = | ||
| 1404 | $read_tx_curves2plot->{_curves} . $curve[$first] . ','; | ||
| 1405 | |||
| 1406 | ( $ref_T, $ref_X, $num_tx_pairs[$first] ) = | ||
| 1407 | _read_2cols( \$curve[$first] ); | ||
| 1408 | |||
| 1409 | $read_tx_curves2plot->{_num_tx_pairs} = | ||
| 1410 | $read_tx_curves2plot->{_num_tx_pairs} | ||
| 1411 | . $num_tx_pairs[$first] . ','; | ||
| 1412 | $read_tx_curves2plot->{_curve_color} = | ||
| 1413 | $read_tx_curves2plot->{_curve_color} . $color[$first] . ','; | ||
| 1414 | |||
| 1415 | if ( $num_files >= 2 ) { | ||
| 1416 | |||
| 1417 | for ( my $i = 1 ; $i < ($last) ; $i++ ) { | ||
| 1418 | |||
| 1419 | # middle cases | ||
| 1420 | ( $ref_T, $ref_X, $num_tx_pairs[$i] ) = | ||
| 1421 | _read_2cols( \$curve[$i] ); | ||
| 1422 | |||
| 1423 | $read_tx_curves2plot->{_curves} = | ||
| 1424 | $read_tx_curves2plot->{_curves} . $curve[$i] . ','; | ||
| 1425 | $read_tx_curves2plot->{_num_tx_pairs} = | ||
| 1426 | $read_tx_curves2plot->{_num_tx_pairs} | ||
| 1427 | . $num_tx_pairs[$i] . ','; | ||
| 1428 | $read_tx_curves2plot->{_curve_color} = | ||
| 1429 | $read_tx_curves2plot->{_curve_color} . $color[$i] . ','; | ||
| 1430 | } | ||
| 1431 | |||
| 1432 | # last case | ||
| 1433 | $read_tx_curves2plot->{_curves} = | ||
| 1434 | $read_tx_curves2plot->{_curves} . $curve[$last]; | ||
| 1435 | |||
| 1436 | ( $ref_T, $ref_X, $num_tx_pairs[ ( $num_files - 1 ) ] ) = | ||
| 1437 | _read_2cols( \$curve[$last] ); | ||
| 1438 | |||
| 1439 | $read_tx_curves2plot->{_num_tx_pairs} = | ||
| 1440 | $read_tx_curves2plot->{_num_tx_pairs} | ||
| 1441 | . $num_tx_pairs[$last]; | ||
| 1442 | $read_tx_curves2plot->{_curve_color} = | ||
| 1443 | $read_tx_curves2plot->{_curve_color} . $color[$last]; | ||
| 1444 | |||
| 1445 | #print("\tcurve colors=$read_tx_curves2plot->{_curve_color}\n"); | ||
| 1446 | #print("\tnum_tx_pairs = $read_tx_curves2plot->{_num_tx_pairs}\n"); | ||
| 1447 | } | ||
| 1448 | else { | ||
| 1449 | # print(" # files > 2\n"); | ||
| 1450 | } | ||
| 1451 | } | ||
| 1452 | else { | ||
| 1453 | # print(" # files > 0 \n"); | ||
| 1454 | } | ||
| 1455 | |||
| 1456 | my $result = $read_tx_curves2plot; | ||
| 1457 | |||
| 1458 | return ($result); | ||
| 1459 | } | ||
| 1460 | else { | ||
| 1461 | print( | ||
| 1462 | "manage_files_by2, read_tx_curves2plot, missing curve aref=@{$curve_aref}\n" | ||
| 1463 | ); | ||
| 1464 | return (); | ||
| 1465 | } | ||
| 1466 | } | ||
| 1467 | |||
| 1468 | =head2 sub read_par | ||
| 1469 | |||
| 1470 | read parameter file | ||
| 1471 | file name is a scalar reference (to | ||
| 1472 | scalar file name) | ||
| 1473 | o/p includes array of array references | ||
| 1474 | |||
| 1475 | =cut | ||
| 1476 | |||
| 1477 | sub read_par { | ||
| 1478 | |||
| 1479 | my ( $self, $ref_file_name ) = @_; | ||
| 1480 | |||
| 1481 | # print("\nmanage_files_by2,read_par, The input file is called $$ref_file_name\n"); | ||
| 1482 | |||
| 1483 | =pod Steps | ||
| 1484 | |||
| 1485 | 1. open file | ||
| 1486 | |||
| 1487 | 2. set the counter | ||
| 1488 | |||
| 1489 | 3. read contents of parameter file | ||
| 1490 | |||
| 1491 | 4. odd-numbered lines contain tnmo and even contain vnmo | ||
| 1492 | |||
| 1493 | |||
| 1494 | =cut | ||
| 1495 | |||
| 1496 | open( FILE, $$ref_file_name ) | ||
| 1497 | || print("Can't open $$ref_file_name, $!\n"); | ||
| 1498 | |||
| 1499 | my $row = -1; | ||
| 1500 | my (@Items); | ||
| 1501 | my ( $i, $line ); | ||
| 1502 | my ( @row, @ValuesPerRow ); | ||
| 1503 | |||
| 1504 | while ( $line = <FILE> ) { | ||
| 1505 | $row++; | ||
| 1506 | my @things; | ||
| 1507 | |||
| 1508 | # print("manage_files_by2,read_par, $line"); | ||
| 1509 | |||
| 1510 | =pod | ||
| 1511 | |||
| 1512 | 1. remove end of line | ||
| 1513 | 2. calculate number of useful elements | ||
| 1514 | 2. only leave the numbers with commas in between: | ||
| 1515 | e.g. things=tnmo 0.0567282,0.271768 | ||
| 1516 | N.B. these are only 2 things and not 3 things | ||
| 1517 | |||
| 1518 | =cut | ||
| 1519 | |||
| 1520 | chomp($line); | ||
| 1521 | @things = split /[=,]/, $line; | ||
| 1522 | |||
| 1523 | # print("manage_files_by2,read_par, things=@things, row= $row\n"); | ||
| 1524 | $Items[$row] = \@things; | ||
| 1525 | $ValuesPerRow[$row] = scalar(@things); | ||
| 1526 | |||
| 1527 | # print("manage_files_by2,read_par, ValuesPerRow=$ValuesPerRow[$row], row=$row\n"); | ||
| 1528 | |||
| 1529 | } | ||
| 1530 | close(FILE); | ||
| 1531 | |||
| 1532 | # print("manage_files_by2,read_par, ROW 0 @{$Items[0]} \n"); | ||
| 1533 | # print("manage_files_by2,read_par, ROW 1 @{$Items[1]} \n"); | ||
| 1534 | # print("manage_files_by2,read_par, ROW 0,1 Values per rows: @ValuesPerRow\n"); | ||
| 1535 | return ( \@Items, \@ValuesPerRow ); | ||
| 1536 | } | ||
| 1537 | |||
| 1538 | =head2 sub set_appendix | ||
| 1539 | |||
| 1540 | set file for catting | ||
| 1541 | |||
| 1542 | =cut | ||
| 1543 | |||
| 1544 | sub set_appendix { | ||
| 1545 | my ( $self, $appendix ) = @_; | ||
| 1546 | |||
| 1547 | if ( length $appendix ) { | ||
| 1548 | |||
| 1549 | $manage_files_by2->{_appendix} = $appendix; | ||
| 1550 | |||
| 1551 | # print("manage_files_by2, set_appendix, base_file_name_out = $appendix\n"); | ||
| 1552 | } | ||
| 1553 | else { | ||
| 1554 | print("manage_files_by2, set_appendix, missing variable\n"); | ||
| 1555 | } | ||
| 1556 | |||
| 1557 | my $result; | ||
| 1558 | |||
| 1559 | return ($result); | ||
| 1560 | |||
| 1561 | } | ||
| 1562 | |||
| 1563 | =head2 sub set_pathNfile | ||
| 1564 | |||
| 1565 | =cut | ||
| 1566 | |||
| 1567 | sub set_pathNfile { | ||
| 1568 | |||
| 1569 | my ( $self, $pathNfile ) = @_; | ||
| 1570 | |||
| 1571 | if ( length($pathNfile) ) { | ||
| 1572 | |||
| 1573 | $manage_files_by2->{_pathNfile} = $pathNfile; | ||
| 1574 | |||
| 1575 | # print("manage_files_by2, set_pathNfile, pathNfile=$manage_files_by2->{_pathNfile} \n"); | ||
| 1576 | |||
| 1577 | } | ||
| 1578 | else { | ||
| 1579 | print("manage_files_by2, set_pathNfile, missing value\n"); | ||
| 1580 | } | ||
| 1581 | |||
| 1582 | return (); | ||
| 1583 | } | ||
| 1584 | |||
| 1585 | =head2 sub set_cat_base_file_name_out | ||
| 1586 | |||
| 1587 | =cut | ||
| 1588 | |||
| 1589 | sub set_cat_base_file_name_out { | ||
| 1590 | my ( $self, $base_file_name_out ) = @_; | ||
| 1591 | |||
| 1592 | if ( length $base_file_name_out ) { | ||
| 1593 | |||
| 1594 | # print( | ||
| 1595 | #"manage_files_by2, set_cat_base_file_name_out, base_file_name_out = $base_file_name_out\n" | ||
| 1596 | # ); | ||
| 1597 | |||
| 1598 | $manage_files_by2->{_cat_base_file_name_out} = $base_file_name_out; | ||
| 1599 | } | ||
| 1600 | else { | ||
| 1601 | print( | ||
| 1602 | "manage_files_by2, set_cat_base_file_name_out, missing variable\n" | ||
| 1603 | ); | ||
| 1604 | } | ||
| 1605 | |||
| 1606 | my $result; | ||
| 1607 | |||
| 1608 | return ($result); | ||
| 1609 | |||
| 1610 | } | ||
| 1611 | |||
| 1612 | =head2 sub set_cat_su | ||
| 1613 | |||
| 1614 | append individual output files to | ||
| 1615 | a major product file | ||
| 1616 | |||
| 1617 | =cut | ||
| 1618 | |||
| 1619 | sub set_cat_su { | ||
| 1620 | |||
| 1621 | my ($self) = @_; | ||
| 1622 | |||
| 1623 | if ( length $manage_files_by2->{_cat_base_file_name_out} | ||
| 1624 | and length $manage_files_by2->{_appendix} ) | ||
| 1625 | { | ||
| 1626 | |||
| 1627 | =head2 SYNOPSIS | ||
| 1628 | |||
| 1629 | PERL PROGRAM NAME: | ||
| 1630 | |||
| 1631 | AUTHOR: | ||
| 1632 | |||
| 1633 | DATE: | ||
| 1634 | |||
| 1635 | DESCRIPTION: | ||
| 1636 | |||
| 1637 | Version: | ||
| 1638 | |||
| 1639 | =head2 USE | ||
| 1640 | |||
| 1641 | =head3 NOTES | ||
| 1642 | |||
| 1643 | =head4 Examples | ||
| 1644 | |||
| 1645 | =head2 SYNOPSIS | ||
| 1646 | |||
| 1647 | =head3 SEISMIC UNIX NOTES | ||
| 1648 | |||
| 1649 | =head2 CHANGES and their DATES | ||
| 1650 | |||
| 1651 | =cut | ||
| 1652 | |||
| 1653 | use Moose; | ||
| 1654 | use App::SeismicUnixGui::misc::SeismicUnix | ||
| 1655 | qw($append $in $out $on $go $to $suffix_ascii $off | ||
| 1656 | $suffix_segd $su $suffix_segy $suffix_sgy $suffix_su | ||
| 1657 | $suffix_segd $suffix_txt $suffix_bin); | ||
| 1658 | |||
| 1659 | my $Project = Project_config->new(); | ||
| 1660 | my $DATA_SEISMIC_BIN = $Project->DATA_SEISMIC_BIN; | ||
| 1661 | my $DATA_SEISMIC_SEGY = $Project->DATA_SEISMIC_SEGY; | ||
| 1662 | my $DATA_SEISMIC_SU = $Project->DATA_SEISMIC_SU; | ||
| 1663 | my $DATA_SEISMIC_TXT = $Project->DATA_SEISMIC_TXT; | ||
| 1664 | |||
| 1665 | my $log = message->new(); | ||
| 1666 | my $run = flow->new(); | ||
| 1667 | my $cat_su = cat_su->new(); | ||
| 1668 | my $data_out = data_out->new(); | ||
| 1669 | |||
| 1670 | =head2 Declare | ||
| 1671 | |||
| 1672 | local variables | ||
| 1673 | |||
| 1674 | =cut | ||
| 1675 | |||
| 1676 | my (@flow); | ||
| 1677 | my (@items); | ||
| 1678 | my (@cat_su); | ||
| 1679 | my (@data_out); | ||
| 1680 | |||
| 1681 | =head2 Set up | ||
| 1682 | |||
| 1683 | cat_su parameter values | ||
| 1684 | |||
| 1685 | =cut | ||
| 1686 | |||
| 1687 | $cat_su->clear(); | ||
| 1688 | $cat_su->base_file_name1( | ||
| 1689 | quotemeta( | ||
| 1690 | $DATA_SEISMIC_SU . '/' . $manage_files_by2->{_appendix} | ||
| 1691 | ) | ||
| 1692 | . $suffix_su | ||
| 1693 | ); | ||
| 1694 | |||
| 1695 | # $cat_su->base_file_name2( | ||
| 1696 | # quotemeta( $DATA_SEISMIC_SU . '/' . '00000004' ) . $suffix_su ); | ||
| 1697 | $cat_su[1] = $cat_su->Step(); | ||
| 1698 | |||
| 1699 | =head2 Set up | ||
| 1700 | |||
| 1701 | data_out parameter values | ||
| 1702 | |||
| 1703 | =cut | ||
| 1704 | |||
| 1705 | $data_out->clear(); | ||
| 1706 | $data_out->base_file_name( | ||
| 1707 | quotemeta( $manage_files_by2->{_cat_base_file_name_out} ) ); | ||
| 1708 | $data_out->suffix_type($su); | ||
| 1709 | $data_out[1] = $data_out->Step(); | ||
| 1710 | |||
| 1711 | =head2 DEFINE FLOW(s) | ||
| 1712 | |||
| 1713 | |||
| 1714 | =cut | ||
| 1715 | |||
| 1716 | @items = ( $cat_su[1], $append, $data_out[1], $go ); | ||
| 1717 | $flow[1] = $run->modules( \@items ); | ||
| 1718 | |||
| 1719 | =head2 RUN FLOW(s) | ||
| 1720 | |||
| 1721 | |||
| 1722 | =cut | ||
| 1723 | |||
| 1724 | $run->flow( \$flow[1] ); | ||
| 1725 | |||
| 1726 | =head2 LOG FLOW(s) | ||
| 1727 | |||
| 1728 | to screen and FILE | ||
| 1729 | |||
| 1730 | =cut | ||
| 1731 | |||
| 1732 | $log->screen( $flow[1] ); | ||
| 1733 | |||
| 1734 | $log->file(localtime); | ||
| 1735 | $log->file( $flow[1] ); | ||
| 1736 | |||
| 1737 | } | ||
| 1738 | else { | ||
| 1739 | print(",manage_files_by2, cat_su, missing variables \n"); | ||
| 1740 | print( | ||
| 1741 | ",manage_files_by2, cat_su, manage_files_by2->{_cat_base_file_name_out}=$manage_files_by2->{_cat_base_file_name_out} \n" | ||
| 1742 | ); | ||
| 1743 | print( | ||
| 1744 | ",manage_files_by2, cat_su, manage_files_by2->{_appendix}=$manage_files_by2->{_appendix} \n" | ||
| 1745 | ); | ||
| 1746 | } | ||
| 1747 | |||
| 1748 | } # end set_cat_su | ||
| 1749 | |||
| 1750 | =head2 sub set_cat_txt | ||
| 1751 | |||
| 1752 | append individual output files to | ||
| 1753 | a major product file | ||
| 1754 | |||
| 1755 | =cut | ||
| 1756 | |||
| 1757 | sub set_cat_txt { | ||
| 1758 | |||
| 1759 | my ($self) = @_; | ||
| 1760 | |||
| 1761 | if ( length $manage_files_by2->{_cat_base_file_name_out} | ||
| 1762 | and length $manage_files_by2->{_appendix} ) | ||
| 1763 | { | ||
| 1764 | |||
| 1765 | =head2 SYNOPSIS | ||
| 1766 | |||
| 1767 | PERL PROGRAM NAME: | ||
| 1768 | |||
| 1769 | AUTHOR: | ||
| 1770 | |||
| 1771 | DATE: | ||
| 1772 | |||
| 1773 | DESCRIPTION: | ||
| 1774 | |||
| 1775 | Version: | ||
| 1776 | |||
| 1777 | =head2 USE | ||
| 1778 | |||
| 1779 | =head3 NOTES | ||
| 1780 | |||
| 1781 | =head4 Examples | ||
| 1782 | |||
| 1783 | =head2 SYNOPSIS | ||
| 1784 | |||
| 1785 | =head3 SEISMIC UNIX NOTES | ||
| 1786 | |||
| 1787 | =head2 CHANGES and their DATES | ||
| 1788 | |||
| 1789 | =cut | ||
| 1790 | |||
| 1791 | use Moose; | ||
| 1792 | use App::SeismicUnixGui::misc::SeismicUnix | ||
| 1793 | qw($append $in $out $on $go $to $suffix_ascii $off $suffix_segd $suffix_segy $suffix_sgy $suffix_su $suffix_segd $suffix_txt $suffix_bin); | ||
| 1794 | |||
| 1795 | my $Project = Project_config->new(); | ||
| 1796 | my $DATA_SEISMIC_BIN = $Project->DATA_SEISMIC_BIN; | ||
| 1797 | my $DATA_SEISMIC_SEGY = $Project->DATA_SEISMIC_SEGY; | ||
| 1798 | my $DATA_SEISMIC_SU = $Project->DATA_SEISMIC_SU; | ||
| 1799 | my $DATA_SEISMIC_TXT = $Project->DATA_SEISMIC_TXT; | ||
| 1800 | |||
| 1801 | my $log = message->new(); | ||
| 1802 | my $run = flow->new(); | ||
| 1803 | my $cat_txt = cat_txt->new(); | ||
| 1804 | my $data_out = data_out->new(); | ||
| 1805 | |||
| 1806 | =head2 Declare | ||
| 1807 | |||
| 1808 | local variables | ||
| 1809 | |||
| 1810 | =cut | ||
| 1811 | |||
| 1812 | my (@flow); | ||
| 1813 | my (@items); | ||
| 1814 | my (@cat_txt); | ||
| 1815 | my (@data_out); | ||
| 1816 | |||
| 1817 | =head2 Set up | ||
| 1818 | |||
| 1819 | cat_txt parameter values | ||
| 1820 | |||
| 1821 | =cut | ||
| 1822 | |||
| 1823 | $cat_txt->clear(); | ||
| 1824 | $cat_txt->base_file_name1( | ||
| 1825 | quotemeta( | ||
| 1826 | $DATA_SEISMIC_TXT . '/' . $manage_files_by2->{_appendix} | ||
| 1827 | ) | ||
| 1828 | . $suffix_txt | ||
| 1829 | ); | ||
| 1830 | |||
| 1831 | $cat_txt[1] = $cat_txt->Step(); | ||
| 1832 | |||
| 1833 | =head2 Set up | ||
| 1834 | |||
| 1835 | data_out parameter values | ||
| 1836 | |||
| 1837 | =cut | ||
| 1838 | |||
| 1839 | $data_out->clear(); | ||
| 1840 | $data_out->base_file_name( | ||
| 1841 | quotemeta( $manage_files_by2->{_cat_base_file_name_out} ) ); | ||
| 1842 | $data_out->suffix_type( quotemeta('txt') ); | ||
| 1843 | $data_out[1] = $data_out->Step(); | ||
| 1844 | |||
| 1845 | =head2 DEFINE FLOW(s) | ||
| 1846 | |||
| 1847 | |||
| 1848 | =cut | ||
| 1849 | |||
| 1850 | @items = ( $cat_txt[1], $append, $data_out[1], $go ); | ||
| 1851 | $flow[1] = $run->modules( \@items ); | ||
| 1852 | |||
| 1853 | =head2 RUN FLOW(s) | ||
| 1854 | |||
| 1855 | |||
| 1856 | =cut | ||
| 1857 | |||
| 1858 | $run->flow( \$flow[1] ); | ||
| 1859 | |||
| 1860 | =head2 LOG FLOW(s) | ||
| 1861 | |||
| 1862 | to screen and FILE | ||
| 1863 | |||
| 1864 | =cut | ||
| 1865 | |||
| 1866 | $log->screen( $flow[1] ); | ||
| 1867 | |||
| 1868 | $log->file(localtime); | ||
| 1869 | $log->file( $flow[1] ); | ||
| 1870 | |||
| 1871 | } | ||
| 1872 | else { | ||
| 1873 | print(",manage_files_by2, cat_txt, missing variables \n"); | ||
| 1874 | print( | ||
| 1875 | ",manage_files_by2, cat_txt, manage_files_by2->{_cat_base_file_name_out}=$manage_files_by2->{_cat_base_file_name_out} \n" | ||
| 1876 | ); | ||
| 1877 | print( | ||
| 1878 | ",manage_files_by2, cat_txt, manage_files_by2->{_appendix}=$manage_files_by2->{_appendix} \n" | ||
| 1879 | ); | ||
| 1880 | } | ||
| 1881 | |||
| 1882 | } # end set_cat_txt | ||
| 1883 | |||
| 1884 | =head2 sub set_delete_base_file_name | ||
| 1885 | |||
| 1886 | =cut | ||
| 1887 | |||
| 1888 | sub set_delete_base_file_name { | ||
| 1889 | my ( $self, $base_file_name ) = @_; | ||
| 1890 | |||
| 1891 | if ( length $base_file_name ) { | ||
| 1892 | |||
| 1893 | # print( | ||
| 1894 | # "manage_files_by2, set_delete_base_file_name, base_file_name = $base_file_name\n" | ||
| 1895 | # ); | ||
| 1896 | |||
| 1897 | $manage_files_by2->{_delete_base_file_name} = $base_file_name; | ||
| 1898 | |||
| 1899 | } | ||
| 1900 | else { | ||
| 1901 | print( | ||
| 1902 | "manage_files_by2, set_delete_base_file_name, missing variable\n" | ||
| 1903 | ); | ||
| 1904 | } | ||
| 1905 | |||
| 1906 | my $result; | ||
| 1907 | return ($result); | ||
| 1908 | |||
| 1909 | } | ||
| 1910 | |||
| 1911 | #=head2 sub set_porgram_name | ||
| 1912 | # | ||
| 1913 | #=cut | ||
| 1914 | # | ||
| 1915 | #sub set_program_name { | ||
| 1916 | # | ||
| 1917 | # my ( $self, $program_name ) = @_; | ||
| 1918 | # | ||
| 1919 | # if ( length $program_name ) { | ||
| 1920 | # | ||
| 1921 | # $manage_files_by2->{_program_name} = $program_name; | ||
| 1922 | # | ||
| 1923 | # } | ||
| 1924 | # else { | ||
| 1925 | # carp "missing program_name"; | ||
| 1926 | # print("manage_files_by2,set_program_name,missing program_name\n"); | ||
| 1927 | # } | ||
| 1928 | # | ||
| 1929 | #} | ||
| 1930 | |||
| 1931 | =head2 sub suffix_type | ||
| 1932 | |||
| 1933 | geometry values | ||
| 1934 | |||
| 1935 | =cut | ||
| 1936 | |||
| 1937 | sub set_suffix_type { | ||
| 1938 | my ( $self, $suffix_type ) = @_; | ||
| 1939 | |||
| 1940 | my $result; | ||
| 1941 | |||
| 1942 | if ( length $suffix_type ) { | ||
| 1943 | |||
| 1944 | $manage_files_by2->{_suffix_type} = $suffix_type; | ||
| 1945 | |||
| 1946 | } | ||
| 1947 | else { | ||
| 1948 | print("manage_files_by2, missing suffix_type=$suffix_type\n"); | ||
| 1949 | } | ||
| 1950 | |||
| 1951 | return ($result); | ||
| 1952 | } | ||
| 1953 | |||
| 1954 | =pod sub unique_elements | ||
| 1955 | |||
| 1956 | filter out only unique elements from an array | ||
| 1957 | |||
| 1958 | =cut | ||
| 1959 | |||
| 1960 | sub unique_elements { | ||
| 1961 | my ( $self, $array_ref ) = @_; | ||
| 1962 | |||
| 1963 | my $results_ref; | ||
| 1964 | |||
| 1965 | if ($array_ref) { | ||
| 1966 | |||
| 1967 | my @unique_progs; | ||
| 1968 | my $total_num_progs4flow = scalar @{$array_ref}; | ||
| 1969 | my $false = 0; | ||
| 1970 | my $true = 1; | ||
| 1971 | my $num_unique_progs = 1; | ||
| 1972 | |||
| 1973 | my $repeated = $false; | ||
| 1974 | |||
| 1975 | # the first program is always unique | ||
| 1976 | $unique_progs[0] = @{$array_ref}[0]; | ||
| 1977 | |||
| 1978 | # print("1. manage_files_by2, first program in flow: @{$array_ref}[0]\n"); | ||
| 1979 | # print("2. manage_files_by2, num_unique_progs=$num_unique_progs\n\n"); | ||
| 1980 | |||
| 1981 | for ( my $i = 1 ; $i < $total_num_progs4flow ; $i++ ) { | ||
| 1982 | |||
| 1983 | for ( my $j = 0 ; $j < $num_unique_progs ; $j++ ) { | ||
| 1984 | |||
| 1985 | if ( $unique_progs[$j] eq @{$array_ref}[$i] ) { | ||
| 1986 | |||
| 1987 | # print("3. manage_files_by2, program index #$i in flow: @{$array_ref}[$i]\n"); | ||
| 1988 | # print("4. manage_files_by2, repeated program detected \n"); | ||
| 1989 | # print("5. manage_files_by2, prog repeated: @{$array_ref}[$i]\n\n"); | ||
| 1990 | $repeated = $true; | ||
| 1991 | |||
| 1992 | # exit if-loop and increment $j | ||
| 1993 | } | ||
| 1994 | else { | ||
| 1995 | # print("6. manage_files_by2, program index #$i in flow: @{$array_ref}[$i]\n"); | ||
| 1996 | # print("7. manage_files_by2, prog @{array_ref}[$i] is unique\n\n"); | ||
| 1997 | # print("8. manage_files_by2,unique_prog detected=@{$array_ref}[$i] \n"); | ||
| 1998 | } | ||
| 1999 | |||
| 2000 | } | ||
| 2001 | |||
| 2002 | if ($repeated) { | ||
| 2003 | |||
| 2004 | $repeated = $false; #reset for next check | ||
| 2005 | |||
| 2006 | } | ||
| 2007 | else { | ||
| 2008 | push @unique_progs, @{$array_ref}[$i]; | ||
| 2009 | |||
| 2010 | # print("9. manage_files_by2,unique new program found for output \n"); | ||
| 2011 | $num_unique_progs++; | ||
| 2012 | |||
| 2013 | # print("10. manage_files_by2, num_unique_progs=$num_unique_progs\n\n"); | ||
| 2014 | } | ||
| 2015 | |||
| 2016 | } # end all programs | ||
| 2017 | |||
| 2018 | # print("3. manage_files_by2, unique_progs are: @unique_progs\n"); | ||
| 2019 | # print ("3. manage_files_by2, num_unique_progs=$num_unique_progs\n\n"); | ||
| 2020 | |||
| 2021 | $results_ref = \@unique_progs; | ||
| 2022 | return ($results_ref); | ||
| 2023 | |||
| 2024 | } | ||
| 2025 | else { | ||
| 2026 | print("manage_files_by2,unique_elements, missing array\n"); | ||
| 2027 | return (); | ||
| 2028 | |||
| 2029 | } # end if | ||
| 2030 | } | ||
| 2031 | |||
| 2032 | =pod | ||
| 2033 | |||
| 2034 | write out a 1-column file | ||
| 2035 | |||
| 2036 | =cut | ||
| 2037 | |||
| 2038 | sub write_1col_aref { | ||
| 2039 | |||
| 2040 | # open and write to output file | ||
| 2041 | my ( $variable, $ref_X, $ref_file_name, $ref_fmt ) = @_; | ||
| 2042 | |||
| 2043 | # print("\n manage_files_by2,write_1col_aref,The output file name = $$ref_file_name\n"); | ||
| 2044 | # print("\n manage_files_by2,write_1col_aref,VALUE: @$ref_X\n"); | ||
| 2045 | # print("\n manage_files_by2,write_1col_aref,The output file uses the following format: $$ref_fmt\n"); | ||
| 2046 | my $num_rows = scalar @$ref_X; | ||
| 2047 | |||
| 2048 | # $variable is an unused hash | ||
| 2049 | |||
| 2050 | # print("\n manage_files_by2,write_1col_aref,The output file contains $num_rows rows\n"); | ||
| 2051 | |||
| 2052 | open( OUT, ">$$ref_file_name" ); | ||
| 2053 | |||
| 2054 | for ( my $j = 0 ; $j < $num_rows ; $j++ ) { | ||
| 2055 | |||
| 2056 | printf OUT "$$ref_fmt\n", @$ref_X[$j]; | ||
| 2057 | |||
| 2058 | # print @$ref_X[$j]."\n"; | ||
| 2059 | |||
| 2060 | } | ||
| 2061 | |||
| 2062 | close(OUT); | ||
| 2063 | return (); | ||
| 2064 | |||
| 2065 | } | ||
| 2066 | |||
| 2067 | =pod | ||
| 2068 | |||
| 2069 | write out a 1-columned file | ||
| 2070 | |||
| 2071 | =cut | ||
| 2072 | |||
| 2073 | sub write_1col1 { | ||
| 2074 | |||
| 2075 | # open and write to output file | ||
| 2076 | my ( $variable, $ref_X, $ref_file_name, $ref_fmt ) = @_; | ||
| 2077 | |||
| 2078 | #declare locally scoped variables | ||
| 2079 | my $j; | ||
| 2080 | |||
| 2081 | my $num_rows = scalar $$ref_X; | ||
| 2082 | |||
| 2083 | # $variable is an unused hash | ||
| 2084 | |||
| 2085 | #print("\nThe subroutine has is called $variable\n"); | ||
| 2086 | #print("\nThe output file contains $num_rows rows\n"); | ||
| 2087 | #print("\nThe output file uses the following format: $$ref_fmt\n"); | ||
| 2088 | open( OUT, ">$$ref_file_name" ); | ||
| 2089 | |||
| 2090 | for ( $j = 1 ; $j <= $num_rows ; $j++ ) { | ||
| 2091 | |||
| 2092 | #print OUT ("$$ref_X[$j] $$ref_Y[$j]\n"); | ||
| 2093 | printf OUT "$$ref_fmt\n", $$ref_X[$j]; | ||
| 2094 | |||
| 2095 | #print("$$ref_X[$j] $$ref_Y[$j]\n"); | ||
| 2096 | } | ||
| 2097 | |||
| 2098 | close(OUT); | ||
| 2099 | return (); | ||
| 2100 | |||
| 2101 | } | ||
| 2102 | |||
| 2103 | =pod | ||
| 2104 | |||
| 2105 | write out a 2-columned file | ||
| 2106 | with formatting | ||
| 2107 | |||
| 2108 | print("\nThe subroutine has is called %$self\n"); | ||
| 2109 | print("\nThe output file contains $num_rows rows\n"); | ||
| 2110 | print("\nThe output file uses the following format:--$$ref_fmt--\n"); | ||
| 2111 | print("\nThe output file name is $$ref_file_name\n"); | ||
| 2112 | |||
| 2113 | =cut | ||
| 2114 | |||
| 2115 | sub write_2cols { | ||
| 2116 | my ( $self, $ref_X, $ref_Y, $num_rows, $ref_file_name, $ref_fmt ) = @_; | ||
| 2117 | |||
| 2118 | # print("format=$$ref_fmt\n"); | ||
| 2119 | |||
| 2120 | # Open output file for writing (overwrite if it exists) | ||
| 2121 | open( OUT, ">$$ref_file_name" ) | ||
| 2122 | or die "Cannot open file $$ref_file_name for writing: $!"; | ||
| 2123 | |||
| 2124 | for ( my $j = 0 ; $j < $num_rows ; $j++ ) { | ||
| 2125 | |||
| 2126 | # Write formatted X and Y values to file | ||
| 2127 | # $$ref_fmt might be something like "%10.4f %10.4f" | ||
| 2128 | printf OUT "$$ref_fmt\n", $$ref_X[$j], $$ref_Y[$j]; | ||
| 2129 | |||
| 2130 | # print("index=$j;$$ref_X[$j] $$ref_Y[$j]\n"); | ||
| 2131 | } | ||
| 2132 | |||
| 2133 | close(OUT); | ||
| 2134 | return (); | ||
| 2135 | |||
| 2136 | } | ||
| 2137 | |||
| 2138 | =head2 sub write_5cols | ||
| 2139 | |||
| 2140 | WRITE OUT FILE | ||
| 2141 | open and write to output file | ||
| 2142 | |||
| 2143 | =cut | ||
| 2144 | |||
| 2145 | sub write_5cols { | ||
| 2146 | |||
| 2147 | my ( $self, $ref_X, $ref_Y, $ref_Z, $ref_A, $ref_B, $file_name, $fmt ) = | ||
| 2148 | @_; | ||
| 2149 | |||
| 2150 | if (length $ref_X && | ||
| 2151 | length $ref_Y && | ||
| 2152 | length $ref_A && | ||
| 2153 | length $ref_B && | ||
| 2154 | length $file_name && | ||
| 2155 | length $fmt ) { | ||
| 2156 | |||
| 2157 | my $num_rows = scalar @$ref_X; | ||
| 2158 | # $num_rows=5; | ||
| 2159 | print ("manage_files_by2,write_5cols,num_rows, $num_rows\n"); | ||
| 2160 | |||
| 2161 | # open( OUT, ">$file_name" ); | ||
| 2162 | |||
| 2163 | for ( my $j = 0 ; $j < $num_rows ; $j++ ) { | ||
| 2164 | |||
| 2165 | # printf OUT "$fmt", @$ref_X[$j], @$ref_Y[$j], @$ref_Z[$j], | ||
| 2166 | # @$ref_A[$j], @$ref_B[$j]; | ||
| 2167 | print ("$fmt @$ref_X[$j], @$ref_Y[$j], @$ref_Z[$j],@$ref_A[$j], @$ref_B[$j]\n"); | ||
| 2168 | } | ||
| 2169 | |||
| 2170 | close(OUT); | ||
| 2171 | } else{ | ||
| 2172 | print("manage_files_by2,write_5cols, incompelte values\n"); | ||
| 2173 | } | ||
| 2174 | |||
| 2175 | |||
| 2176 | # print( | ||
| 2177 | # "\nmanage_files_by2,write_5cols,The output file is called $file_name\n" | ||
| 2178 | # ); | ||
| 2179 | |||
| 2180 | } | ||
| 2181 | |||
| 2182 | =head2 sub write_par | ||
| 2183 | |||
| 2184 | write parameter file | ||
| 2185 | file name is a scalar reference to | ||
| 2186 | scalar file name | ||
| 2187 | |||
| 2188 | =cut | ||
| 2189 | |||
| 2190 | sub write_par { | ||
| 2191 | |||
| 2192 | my ( $self, $ref_outbound, $ref_array_tnmo_row, $ref_array_vnmo_row, | ||
| 2193 | $first_name, $second_name ) | ||
| 2194 | = @_; | ||
| 2195 | |||
| 2196 | # print("\nmanage_files_by2,write_par,The input file is called $$ref_outbound\n"); | ||
| 2197 | |||
| 2198 | =head2 local definitions | ||
| 2199 | |||
| 2200 | =cut | ||
| 2201 | |||
| 2202 | my $values_per_row; | ||
| 2203 | my @tnmo_array = @$ref_array_tnmo_row; | ||
| 2204 | my @vnmo_array = @$ref_array_vnmo_row; | ||
| 2205 | my $number_of_values_per_row = scalar @tnmo_array; | ||
| 2206 | |||
| 2207 | =pod Steps | ||
| 2208 | |||
| 2209 | odd-numbered lines contain tnmo and even contain vnmo | ||
| 2210 | e.g., tnmo=1,2,3 | ||
| 2211 | vnm==4,5,6 | ||
| 2212 | |||
| 2213 | =cut | ||
| 2214 | |||
| 2215 | =head2 open and write values | ||
| 2216 | |||
| 2217 | =cut | ||
| 2218 | |||
| 2219 | open( my $fh, '>', $$ref_outbound ); | ||
| 2220 | |||
| 2221 | print $fh ("$first_name=$tnmo_array[1]"); | ||
| 2222 | |||
| 2223 | for ( my $i = 2 ; $i < $number_of_values_per_row ; $i++ ) { | ||
| 2224 | |||
| 2225 | print $fh (",$tnmo_array[$i]"); | ||
| 2226 | |||
| 2227 | } | ||
| 2228 | |||
| 2229 | print $fh ("\n"); | ||
| 2230 | |||
| 2231 | print $fh ("$second_name=$vnmo_array[1]"); | ||
| 2232 | |||
| 2233 | for ( my $i = 2 ; $i < $number_of_values_per_row ; $i++ ) { | ||
| 2234 | |||
| 2235 | print $fh (",$vnmo_array[$i]"); | ||
| 2236 | |||
| 2237 | } | ||
| 2238 | |||
| 2239 | close($fh); | ||
| 2240 | return (); | ||
| 2241 | } | ||
| 2242 | |||
| 2243 | =head2 sub write_multipar | ||
| 2244 | |||
| 2245 | write parameter file | ||
| 2246 | file name is a scalar reference to | ||
| 2247 | scalar file name | ||
| 2248 | |||
| 2249 | =cut | ||
| 2250 | |||
| 2251 | sub write_multipar { | ||
| 2252 | |||
| 2253 | my ( $self, $ref_outbound, $ref_array_cdp_row, | ||
| 2254 | $ref_array_tnmo_row, $ref_array_vnmo_row, $first_name, $second_name ) | ||
| 2255 | = @_; | ||
| 2256 | |||
| 2257 | # print( | ||
| 2258 | # "\nmanage_files_by2,write_par,The input file is called $$ref_outbound\n" | ||
| 2259 | # ); | ||
| 2260 | |||
| 2261 | =head2 local definitions | ||
| 2262 | |||
| 2263 | =cut | ||
| 2264 | |||
| 2265 | my $values_per_row; | ||
| 2266 | my @cdp_array = $ref_array_cdp_row; | ||
| 2267 | my @tnmo_array = @$ref_array_tnmo_row; | ||
| 2268 | my @vnmo_array = @$ref_array_vnmo_row; | ||
| 2269 | my $number_of_values_per_row = scalar @tnmo_array; | ||
| 2270 | my $number_of_cdp_per_row = scalar @cdp_array; | ||
| 2271 | |||
| 2272 | # print("@$ref_array_cdp_row \n"); | ||
| 2273 | # print("$number_of_values_per_row \n"); | ||
| 2274 | |||
| 2275 | =pod Steps | ||
| 2276 | |||
| 2277 | odd-numbered lines contain tnmo and even contain vnmo | ||
| 2278 | e.g., tnmo=1,2,3 | ||
| 2279 | vnm==4,5,6 | ||
| 2280 | |||
| 2281 | =cut | ||
| 2282 | |||
| 2283 | =head2 open and write values | ||
| 2284 | |||
| 2285 | =cut | ||
| 2286 | |||
| 2287 | #print("manage_files_by2,par, tnmo_row @tnmo_array\n"); | ||
| 2288 | #print("manage_files_by2,par, vnmo_row @vnmo_array\n"); | ||
| 2289 | #print("manage_files_by2,par, tnmo_row $tnmo_array[1] \n"); | ||
| 2290 | #print("manage_files_by2,par, ref_outbound $$ref_outbound \n"); | ||
| 2291 | |||
| 2292 | open( my $fh, '>', $$ref_outbound ); | ||
| 2293 | |||
| 2294 | print $fh ("$first_name=$tnmo_array[1]"); | ||
| 2295 | |||
| 2296 | for ( my $i = 2 ; $i < $number_of_values_per_row ; $i++ ) { | ||
| 2297 | |||
| 2298 | print $fh (",$tnmo_array[$i]"); | ||
| 2299 | |||
| 2300 | } | ||
| 2301 | |||
| 2302 | print $fh ("\n"); | ||
| 2303 | |||
| 2304 | print $fh ("second_name=$vnmo_array[1]"); | ||
| 2305 | |||
| 2306 | for ( my $i = 2 ; $i < $number_of_values_per_row ; $i++ ) { | ||
| 2307 | |||
| 2308 | print $fh (",$vnmo_array[$i]"); | ||
| 2309 | |||
| 2310 | } | ||
| 2311 | |||
| 2312 | print $fh ("\n"); | ||
| 2313 | |||
| 2314 | close($fh); | ||
| 2315 | return (); | ||
| 2316 | } | ||
| 2317 | |||
| 2318 | 1; |