function [lon, lat, depth] = ts_meta ( ptrfile);
% TS_INTERP:  Interpolates a variable along time_vector from a pointer file.
%
% USAGE:  [lon, lat, depth] = ts_interp ( ptrfile, variable, time_vector );
%
% PARAMETERS:  
%   ptrfile:
%      pointer file of Netcdf files

if ( nargin ~= 1 )
    help ts_meta;
    return;
end

%
% Count the number of files beforehand
afid = fopen ( ptrfile, 'r' );
cdfname = fgetl ( afid );
fcount = 0;
while ( cdfname ~= -1 )
    fcount = fcount+1;
    cdfname = fgetl ( afid );
end




mexcdf ( 'setopts', 0 );

count = 0;

fseek ( afid, 0, 'bof' );
cdfname = fgetl ( afid );
while ( cdfname ~= -1 )

    %
    % open the file, make sure it has the variable in it
    [ncid, status] = mexcdf ( 'open', cdfname, 'nowrite' );
    if ( ncid == -1 )
        fprintf ( 2, 'Could not open %s.\n', cdfname );
        return;
    end

	count = count+1;
	
	%
	% OK, get the depth and variable
	[time, status] = mexcdf ( 'varget', ncid, 'time', [0], [-1] );
	if ( status == -1 )
	    fprintf ( 2, 'Could not retrieve time from %s.\n', cdfname );
	    return;
	end
	[time2, status] = mexcdf ( 'varget', ncid, 'time2', [0], [-1] );
	if ( status == -1 )
	    fprintf ( 2, 'Could not retrieve time2 from %s.\n', cdfname );
	    return;
	end

	time = time + time2/8.64e7;



	[lon(count), status] = mexcdf ( 'varget', ncid, 'lon', [0], [-1] );
	if ( status == -1 )
	    fprintf ( 2, 'Could not retrieve lon from %s.\n', variable, cdfname );
	    return;
	end

	[lat(count), status] = mexcdf ( 'varget', ncid, 'lat', [0], [-1] );
	if ( status == -1 )
	    fprintf ( 2, 'Could not retrieve lat from %s.\n', variable, cdfname );
	    return;
	end

	[depth(count), status] = mexcdf ( 'varget', ncid, 'depth', [0], [-1] );
	if ( status == -1 )
	    fprintf ( 2, 'Could not retrieve depth from %s.\n', variable, cdfname );
	    return;
	end




    mexcdf ( 'close', ncid );

    cdfname = fgetl ( afid );

end


lat = lat(:);
lon = lon(:);
depth = depth(:);




