function status = match_varname()

global input_cdf;
global output_cdf;
global epic_key_data;


%fprintf ( 2, 'match_varname:\n' );

if ( strcmp ( input_cdf.buoy_varname, 'a' ) )
    output_cdf.epic_code = 4070;

elseif ( strcmp ( input_cdf.buoy_varname, 'a_1' ) )
    output_cdf.epic_code = 4070;

elseif ( strcmp ( input_cdf.buoy_varname, 'a_2' ) )
    output_cdf.epic_code = 4070;

elseif ( strcmp ( input_cdf.buoy_varname, 'air_temp' ) )
    output_cdf.epic_code = 21;

elseif ( strcmp ( input_cdf.buoy_varname, 'abads' ) )
    output_cdf.epic_code = 4074;

elseif ( strcmp ( input_cdf.buoy_varname, 'abads_1' ) )
    output_cdf.epic_code = 4074;

elseif ( strcmp ( input_cdf.buoy_varname, 'abads_2' ) )
    output_cdf.epic_code = 4074;

elseif ( strcmp ( input_cdf.buoy_varname, 'atmos_press' ) )
    output_cdf.epic_code = 915;

elseif ( strcmp ( input_cdf.buoy_varname, 'att_1' ) )
    output_cdf.epic_code = 55;

elseif ( strcmp ( input_cdf.buoy_varname, 'b' ) )
    output_cdf.epic_code = 4071;

elseif ( strcmp ( input_cdf.buoy_varname, 'b_1' ) )
    output_cdf.epic_code = 4071;

elseif ( strcmp ( input_cdf.buoy_varname, 'b_2' ) )
    output_cdf.epic_code = 4071;

elseif ( strcmp ( input_cdf.buoy_varname, 'bearing' ) )
    output_cdf.epic_code = 1411;

elseif ( strcmp ( input_cdf.buoy_varname, 'bbads' ) )
    output_cdf.epic_code = 4075;

elseif ( strcmp ( input_cdf.buoy_varname, 'bbads_1' ) )
    output_cdf.epic_code = 4075;

elseif ( strcmp ( input_cdf.buoy_varname, 'bbads_2' ) )
    output_cdf.epic_code = 4075;

elseif ( strcmp ( input_cdf.buoy_varname, 'c' ) )
    output_cdf.epic_code = 4072;

elseif ( strcmp ( input_cdf.buoy_varname, 'c_1' ) )
    output_cdf.epic_code = 4072;

elseif ( strcmp ( input_cdf.buoy_varname, 'c_2' ) )
    output_cdf.epic_code = 4072;

elseif ( strcmp ( input_cdf.buoy_varname, 'cbads' ) )
    output_cdf.epic_code = 4076;

elseif ( strcmp ( input_cdf.buoy_varname, 'cbads_1' ) )
    output_cdf.epic_code = 4076;

elseif ( strcmp ( input_cdf.buoy_varname, 'cbads_2' ) )
    output_cdf.epic_code = 4076;

elseif ( strcmp ( input_cdf.buoy_varname, 'compass' ) )
    output_cdf.epic_code = 1404;

elseif ( strcmp ( input_cdf.buoy_varname, 'cond_1' ) )
    output_cdf.epic_code = 50;

elseif ( strcmp ( input_cdf.buoy_varname, 'conductivity' ) )
    output_cdf.epic_code = 50;

elseif ( strcmp ( input_cdf.buoy_varname, 'd' ) )
    output_cdf.epic_code = 4073;

elseif ( strcmp ( input_cdf.buoy_varname, 'd_1' ) )
    output_cdf.epic_code = 4073;

elseif ( strcmp ( input_cdf.buoy_varname, 'd_2' ) )
    output_cdf.epic_code = 4073;

elseif ( strcmp ( input_cdf.buoy_varname, 'dbads' ) )
    output_cdf.epic_code = 4077;

elseif ( strcmp ( input_cdf.buoy_varname, 'dbads_1' ) )
    output_cdf.epic_code = 4077;

elseif ( strcmp ( input_cdf.buoy_varname, 'dbads_2' ) )
    output_cdf.epic_code = 4077;

elseif ( strcmp(input_cdf.buoy_varname,'east') & output_cdf.wind_flag )
    output_cdf.epic_code = 422;

elseif ( strcmp(input_cdf.buoy_varname,'east') & output_cdf.water_flag )
    output_cdf.epic_code = 1205;

elseif ( strcmp(input_cdf.buoy_varname,'east_lp') & output_cdf.wind_flag )
    output_cdf.epic_code = 422;

elseif ( strcmp(input_cdf.buoy_varname,'east_lp') & output_cdf.water_flag )
    output_cdf.epic_code = 1205;

elseif ( strcmp ( input_cdf.buoy_varname, 'factor' ) )
    output_cdf.epic_code = 81;

elseif ( strcmp ( input_cdf.buoy_varname, 'int_rotor1' ) )
    output_cdf.epic_code = 4001;

elseif ( strcmp ( input_cdf.buoy_varname, 'int_rotor2' ) )
    output_cdf.epic_code = 4003;

elseif ( strcmp ( input_cdf.buoy_varname, 'lower' ) )
    output_cdf.epic_code = 1404;

elseif ( strcmp(input_cdf.buoy_varname,'north') & output_cdf.wind_flag )
    output_cdf.epic_code = 423;

elseif ( strcmp(input_cdf.buoy_varname,'north') & output_cdf.water_flag )
    output_cdf.epic_code = 1206;

elseif ( strcmp(input_cdf.buoy_varname,'north_lp') & output_cdf.wind_flag )
    output_cdf.epic_code = 423;

elseif ( strcmp(input_cdf.buoy_varname,'north_lp') & output_cdf.water_flag )
    output_cdf.epic_code = 1206;

elseif ( strcmp ( input_cdf.buoy_varname, 'percent_1' ) )
    output_cdf.epic_code = 4011;

elseif ( strcmp ( input_cdf.buoy_varname, 'press' ) )
    output_cdf.epic_code = 4023;

elseif ( strcmp ( input_cdf.buoy_varname, 'pressure' ) )
    output_cdf.epic_code = 4023;

elseif ( strcmp ( input_cdf.buoy_varname, 'psdev' ) )
    output_cdf.epic_code = 850;

elseif ( strcmp ( input_cdf.buoy_varname, 'r1_r2' ) )
    output_cdf.epic_code = 4004;

elseif ( strcmp ( input_cdf.buoy_varname, 'rotor' ) )
    output_cdf.epic_code = 4001;

elseif ( strcmp ( input_cdf.buoy_varname, 'salinity' ) )
    output_cdf.epic_code = 40;

elseif ( strcmp ( input_cdf.buoy_varname, 'sea_surf_tem' ) )
    output_cdf.epic_code = 25;

elseif ( strcmp ( input_cdf.buoy_varname, 'sigma_t' ) )
    output_cdf.epic_code = 70;

elseif ( strcmp ( input_cdf.buoy_varname, 'sigma_theta' ) )
    output_cdf.epic_code = 71;

elseif ( strcmp ( input_cdf.buoy_varname, 'sndspd' ) )
    output_cdf.epic_code = 80;

elseif ( strcmp ( input_cdf.buoy_varname, 'temp_lp' ) )
    output_cdf.epic_code = 20;

elseif ( strcmp ( input_cdf.buoy_varname, 'temp' ) )
    output_cdf.epic_code = 20;

elseif ( strcmp ( input_cdf.buoy_varname, 'temp_1' ) )
    output_cdf.epic_code = 20;

elseif ( strcmp ( input_cdf.buoy_varname, 'temperature' ) )
    output_cdf.epic_code = 20;

elseif ( strcmp ( input_cdf.buoy_varname, 'tiltx' ) )
    output_cdf.epic_code = 4017;

elseif ( strcmp ( input_cdf.buoy_varname, 'tilty' ) )
    output_cdf.epic_code = 4018;

elseif ( strcmp ( input_cdf.buoy_varname, 'trans_1' ) )
    output_cdf.epic_code = 4010;

elseif ( strcmp ( input_cdf.buoy_varname, 'uperiod' ) )
    output_cdf.epic_code = 4056;

elseif ( strcmp ( input_cdf.buoy_varname, 'uperiod_1' ) )
    output_cdf.epic_code = 4056;

elseif ( strcmp ( input_cdf.buoy_varname, 'uperiod_2' ) )
    output_cdf.epic_code = 4056;

elseif ( strcmp ( input_cdf.buoy_varname, 'upper' ) )
    output_cdf.epic_code = 4000;

elseif ( strcmp ( input_cdf.buoy_varname, 'uvariance' ) )
    output_cdf.epic_code = 4050;

elseif ( strcmp ( input_cdf.buoy_varname, 'uvariance_1' ) )
    output_cdf.epic_code = 4050;

elseif ( strcmp ( input_cdf.buoy_varname, 'uvariance_2' ) )
    output_cdf.epic_code = 4050;

elseif ( strcmp ( input_cdf.buoy_varname, 'uvcovar' ) )
    output_cdf.epic_code = 4051;

elseif ( strcmp ( input_cdf.buoy_varname, 'uvcovar_1' ) )
    output_cdf.epic_code = 4051;

elseif ( strcmp ( input_cdf.buoy_varname, 'uvcovar_2' ) )
    output_cdf.epic_code = 4051;

elseif ( strcmp ( input_cdf.buoy_varname, 'uwcovar' ) )
    output_cdf.epic_code = 4053;

elseif ( strcmp ( input_cdf.buoy_varname, 'uwcovar_1' ) )
    output_cdf.epic_code = 4053;

elseif ( strcmp ( input_cdf.buoy_varname, 'uwcovar_2' ) )
    output_cdf.epic_code = 4053;

elseif ( strcmp(input_cdf.buoy_varname,'u_1') & output_cdf.wind_flag )
    output_cdf.epic_code = 422;

elseif ( strcmp(input_cdf.buoy_varname,'u_1') & output_cdf.water_flag )
    output_cdf.epic_code = 1205;

elseif ( strcmp(input_cdf.buoy_varname,'u_1_lp') & output_cdf.wind_flag )
    output_cdf.epic_code = 422;

elseif ( strcmp(input_cdf.buoy_varname,'u_1_lp') & output_cdf.water_flag )
    output_cdf.epic_code = 1205;

elseif ( strcmp(input_cdf.buoy_varname,'u_2') & output_cdf.wind_flag )
    output_cdf.epic_code = 422;

elseif ( strcmp(input_cdf.buoy_varname,'u_2') & output_cdf.water_flag )
    output_cdf.epic_code = 1205;

elseif ( strcmp(input_cdf.buoy_varname,'u_2_lp') & output_cdf.wind_flag )
    output_cdf.epic_code = 422;

elseif ( strcmp(input_cdf.buoy_varname,'u_2_lp') & output_cdf.water_flag )
    output_cdf.epic_code = 1205;

elseif ( strcmp(input_cdf.buoy_varname,'v_1') & output_cdf.wind_flag )
    output_cdf.epic_code = 423;

elseif ( strcmp(input_cdf.buoy_varname,'v_1') & output_cdf.water_flag )
    output_cdf.epic_code = 1206;

elseif ( strcmp(input_cdf.buoy_varname,'v_1_lp') & output_cdf.wind_flag )
    output_cdf.epic_code = 423;

elseif ( strcmp(input_cdf.buoy_varname,'v_1_lp') & output_cdf.water_flag )
    output_cdf.epic_code = 1206;

elseif ( strcmp(input_cdf.buoy_varname,'v_2') & output_cdf.wind_flag )
    output_cdf.epic_code = 423;

elseif ( strcmp(input_cdf.buoy_varname,'v_2') & output_cdf.water_flag )
    output_cdf.epic_code = 1206;

elseif ( strcmp(input_cdf.buoy_varname,'v_2_lp') & output_cdf.wind_flag )
    output_cdf.epic_code = 423;

elseif ( strcmp(input_cdf.buoy_varname,'v_2_lp') & output_cdf.water_flag )
    output_cdf.epic_code = 1206;

elseif ( strcmp(input_cdf.buoy_varname,'vdir') & output_cdf.wind_flag )
    output_cdf.epic_code = 410;

elseif ( strcmp(input_cdf.buoy_varname,'vdir') & output_cdf.water_flag )
    output_cdf.epic_code = 310;

elseif ( strcmp(input_cdf.buoy_varname,'vdir_1') & output_cdf.wind_flag )
    output_cdf.epic_code = 410;

elseif ( strcmp(input_cdf.buoy_varname,'vdir_1') & output_cdf.water_flag )
    output_cdf.epic_code = 310;

elseif ( strcmp(input_cdf.buoy_varname,'vdir_2') & output_cdf.wind_flag )
    output_cdf.epic_code = 410;

elseif ( strcmp(input_cdf.buoy_varname,'vdir_2') & output_cdf.water_flag )
    output_cdf.epic_code = 310;

elseif ( strcmp ( input_cdf.buoy_varname, 'vane' ) )
    output_cdf.epic_code = 1403;

elseif ( strcmp ( input_cdf.buoy_varname, 'vperiod' ) )
    output_cdf.epic_code = 4057;

elseif ( strcmp ( input_cdf.buoy_varname, 'vperiod_1' ) )
    output_cdf.epic_code = 4057;

elseif ( strcmp ( input_cdf.buoy_varname, 'vperiod_2' ) )
    output_cdf.epic_code = 4057;

elseif ( strcmp(input_cdf.buoy_varname,'vspd') & output_cdf.wind_flag )
    output_cdf.epic_code = 401;

elseif ( strcmp(input_cdf.buoy_varname,'vspd') & output_cdf.water_flag )
    output_cdf.epic_code = 300;

elseif ( strcmp(input_cdf.buoy_varname,'vspd_1') & output_cdf.wind_flag )
    output_cdf.epic_code = 401;

elseif ( strcmp(input_cdf.buoy_varname,'vspd_1') & output_cdf.water_flag )
    output_cdf.epic_code = 300;

elseif ( strcmp(input_cdf.buoy_varname,'vspd_2') & output_cdf.wind_flag )
    output_cdf.epic_code = 401;

elseif ( strcmp(input_cdf.buoy_varname,'vspd_2') & output_cdf.water_flag )
    output_cdf.epic_code = 300;

elseif ( strcmp ( input_cdf.buoy_varname, 'vvariance' ) )
    output_cdf.epic_code = 4052;

elseif ( strcmp ( input_cdf.buoy_varname, 'vvariance_1' ) )
    output_cdf.epic_code = 4052;

elseif ( strcmp ( input_cdf.buoy_varname, 'vvariance_2' ) )
    output_cdf.epic_code = 4052;

elseif ( strcmp ( input_cdf.buoy_varname, 'vwcovar' ) )
    output_cdf.epic_code = 4054;

elseif ( strcmp ( input_cdf.buoy_varname, 'vwcovar_1' ) )
    output_cdf.epic_code = 4054;

elseif ( strcmp ( input_cdf.buoy_varname, 'vwcovar_2' ) )
    output_cdf.epic_code = 4054;

elseif ( strcmp ( input_cdf.buoy_varname, 'w_1' ) )
    output_cdf.epic_code = 1204;

elseif ( strcmp ( input_cdf.buoy_varname, 'w_1_lp' ) )
    output_cdf.epic_code = 1204;

elseif ( strcmp ( input_cdf.buoy_varname, 'w_2' ) )
    output_cdf.epic_code = 1204;

elseif ( strcmp ( input_cdf.buoy_varname, 'w_2_lp' ) )
    output_cdf.epic_code = 1204;

elseif ( strcmp ( input_cdf.buoy_varname, 'wave_direc' ) )
    output_cdf.epic_code = 4062;

elseif ( strcmp ( input_cdf.buoy_varname, 'wave_height' ) )
    output_cdf.epic_code = 4061;

elseif ( strcmp ( input_cdf.buoy_varname, 'wave_period' ) )
    output_cdf.epic_code = 4060;

elseif ( strcmp ( input_cdf.buoy_varname, 'wvariance' ) )
    output_cdf.epic_code = 4055;

elseif ( strcmp ( input_cdf.buoy_varname, 'wvariance_1' ) )
    output_cdf.epic_code = 4055;

elseif ( strcmp ( input_cdf.buoy_varname, 'wvariance_2' ) )
    output_cdf.epic_code = 4055;

else
    fprintf ( 2, '\tCould not find a match for %s!!\n', input_cdf.buoy_varname );
    fprintf ( 2, '\tCheck the ''match_varnames'' file and add code to handle this.\n' );
    status = -1;
    return;
end
    

%
% Now get the rest of the info.
ind = find ( epic_key_data.epic_code == output_cdf.epic_code );
output_cdf.comment = epic_key_data.comment{ind};
output_cdf.fortran_format = epic_key_data.fortran_format{ind};
output_cdf.units = epic_key_data.units{ind};
output_cdf.generic_name = epic_key_data.generic_name{ind};
output_cdf.short_name = epic_key_data.short_name{ind};
output_cdf.long_name = epic_key_data.long_name{ind};

output_cdf.short_name = deblank ( output_cdf.short_name );
output_cdf.epic_varname = sprintf ( '%s_%d', output_cdf.short_name, output_cdf.epic_code );

status = 1;
return;

