#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ # # Process CTD file # # Match the time stamp from the Ctd file to the closest # time from the Atlas file, then put these variables at that time # #////////////////////////////////////////////////////////////////////////////// sub processCtd { $ncOffset = 0; @start = $ncOffset; NetCDF::varget1($ncID, $varID{"oasisTime"}, \@start, $ncTime); #----------------------------------------------------------------------- # process all records in Ctd file #----------------------------------------------------------------------- open( CTD, $ctdFile ) || die; while( ) { #-------------------------------------------------------------------- # Skip comment lines #-------------------------------------------------------------------- next if/^\#/; #-------------------------------------------------------------------- # Extract fields from file input #-------------------------------------------------------------------- s/^\s+//; @field = split('\s+',$_); for( $i=0; $i <= $#field; $i++ ) { if( $field[$i] =~ /\D\./ ) { $field[$i] = "-99.99"; } } $ctdTime = $field[0]; $ctd_sst = $field[3]; $salt = $field[5]; $transmiss = $field[6]; $fluor = $field[7]; $year = $field[8]; #-------------------------------------------------------------------- # convert ctd time to Epoch Secs # column 01 is YDAY, column 25 is YEAR. Both are needed for EPOCH SECS #-------------------------------------------------------------------- $epochSecs = timegm(0,0,0,1,0,substr($year,2,2)) + int(($ctdTime-1) * $secsPerDay); #-------------------------------------------------------------------- # set offset into nc file for this IO #-------------------------------------------------------------------- setNcOffset(); #-------------------------------------------------------------------- # write ctd values at ncOffset #-------------------------------------------------------------------- ctdIO( $ncOffset ); #-------------------------------------------------------------------- # grab next sequential ncTime (hopefully the next required) #-------------------------------------------------------------------- $ncOffset++; if( $ncOffset < $ncNumRecs ) { @ndx = $ncOffset; NetCDF::varget1($ncID, $varID{"oasisTime"}, \@ndx, $ncTime); } } close( CTD ); } #---processCtd---# #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ # # #////////////////////////////////////////////////////////////////////////////// sub ctdIO { @start = ($_[0]); NetCDF::varput1( $ncID, $varID{"ctd_sst"}, \@start, $ctd_sst ); NetCDF::varput1( $ncID, $varID{"salt"}, \@start, $salt ); NetCDF::varput1( $ncID, $varID{"transmiss"}, \@start, $transmiss ); NetCDF::varput1( $ncID, $varID{"fluor"}, \@start, $fluor ); } #---ctdIO---# #------------------------------------------------------------------------------ # require needs to evaluate a final TRUE statement #------------------------------------------------------------------------------ 1;