% mk_tow_list.m - list of sample tows (time and pos)

fid = fopen('sam_list_read.txt','w');
fprintf(fid,['     Tow  Start  End       Start  ' ...
	     '                      End\n']);
fprintf(fid,['      #   Time   Time      Lat      Lon' ...
	     '                   Lat         Lon\n']);


for ii = 1:11
  if ii < 5
    eval(['load SAM_00',int2str(ii),'_fl'])
    hh=floor((yearday-floor(yearday))*24);
    minit=round((yearday-floor(yearday)-hh/24)*24*60);
    latdeg=floor(lat);
    latmin=(lat-latdeg)*60;
    londeg=floor(lon);
    lonmin=(lon-londeg)*60;
    fprintf(fid,['      %d   %2d:%2d   %2d:%2d    %2d ', ...
		 '%6.4f   %3d %6.4f    %2d %6.4f  %3d %6.4f \n'], ...
	    ii,hh(1),minit(1),hh(end),minit(end), ...
	    latdeg(1),latmin(1),londeg(1),lonmin(1), ...
	    latdeg(end),latmin(end),londeg(end),lonmin(end));
  else
    if ii <= 9
      if ii+1 < 10
	eval(['load SAM_00',int2str(ii+1),'_fl'])
      else
	eval(['load SAM_0',int2str(ii+1),'_fl'])
      end
      hh=floor((yearday-floor(yearday))*24);
      minit=round((yearday-floor(yearday)-hh/24)*24*60);
      latdeg=floor(lat);
      latmin=(lat-latdeg)*60;
      londeg=floor(lon);
      lonmin=(lon-londeg)*60;
      fprintf(fid,['      %d   %2d:%2d   %2d:%2d    %2d ', ...
		   '%6.4f   %3d %6.4f    %2d %6.4f  %3d %6.4f \n'], ...
	      ii,hh(1),minit(1),hh(end),minit(end), ...
	      latdeg(1),latmin(1),londeg(1),lonmin(1), ...
	      latdeg(end),latmin(end),londeg(end),lonmin(end));
    elseif ii~=11
      eval(['load SAM_0',int2str(ii+1),'_fl'])
      hh=floor((yearday-floor(yearday))*24);
      minit=round((yearday-floor(yearday)-hh/24)*24*60);
      latdeg=floor(lat);
      latmin=(lat-latdeg)*60;
      londeg=floor(lon);
      lonmin=(lon-londeg)*60;
      fprintf(fid,['     %d   %2d:%2d   %2d:%2d    %2d ', ...
		   '%6.4f   %3d %6.4f    %2d %6.4f  %3d %6.4f \n'], ...
	      ii,hh(1),minit(1),hh(end),minit(end), ...
	      latdeg(1),latmin(1),londeg(1),lonmin(1), ...
	      latdeg(end),latmin(end),londeg(end),lonmin(end));
    elseif ii==11
      eval(['load SAM_0',int2str(ii+2),'_fl'])
      hh=floor((yearday-floor(yearday))*24);
      minit=round((yearday-floor(yearday)-hh/24)*24*60);
      latdeg=floor(lat);
      latmin=(lat-latdeg)*60;
      londeg=floor(lon);
      lonmin=(lon-londeg)*60;
      fprintf(fid,['     %d   %2d:%2d   %2d:%2d    %2d ', ...
		   '%6.4f   %3d %6.4f    %2d %6.4f  %3d %6.4f \n'], ...
	      ii,hh(1),minit(1),hh(end),minit(end), ...
	      latdeg(1),latmin(1),londeg(1),lonmin(1), ...
	      latdeg(end),latmin(end),londeg(end),lonmin(end));
    end
  end
  
  
end

fclose(fid);