#include #include /* #include */ #include #include main() { /* Reads data from the Scope2.new file. Converts to MKS units */ int day, line_num, oph, test, tilt, dayo, opho, testo, tilto; float day_decimal, day_decimal_alt, delta_q, delta_temp, freq_ave, freq_max, freq_min, hour, hrms_ave, hrms_min, hrms_max, hsig, inv_ht, lhf_ave, lhf_bulk, lhf_cov, lhf_iner, minutes, neg_z_over_L, phase_spd, qa, qs, shf_ave, shf_bulk, shf_cov, shf_iner, ta, tau_ave, tau_bulk, tau_cov, tau_iner, tw, u, ustar_cf, wave_age_ustar, wave_age_u, wind_dir, wstar, day_decimalo, day_decimal_alto, delta_qo, delta_tempo, freq_aveo, freq_maxo, freq_mino, houro, hrms_aveo, hrms_mino, hrms_maxo, hsigo, inv_hto, lhf_aveo, lhf_bulko, lhf_covo, lhf_inero, minuteso, neg_z_over_Lo, phase_spdo, qao, qso, shf_aveo, shf_bulko, shf_covo, shf_inero, tao, tau_aveo, tau_bulko, tau_covo, tau_inero, two, uo, ustar_cfo, wave_age_ustaro, wave_age_uo, wind_diro, wstaro; char month[4]; FILE *fp_data_old, *fp_data_new, *fp_out; /* open data file */ if( ( fp_data_new = fopen( "Scope2.new", "r" ) ) == NULL ) { printf( "Can not open the file Scope2.new\n" ); exit( 1 ); } if( ( fp_data_old = fopen( "Scope2.new.old", "r" ) ) == NULL ) { printf( "Can not open the file Scope2.new.old\n" ); exit( 1 ); } if( ( fp_out = fopen( "Scope_test_out.dat", "w" ) ) == NULL ) { printf( "Can not open the file Scope_test_out.dat\n" ); exit( 1 ); } /* skip first line */ fscanf(fp_data_new, "%*[^\n]\n" ); fscanf(fp_data_old, "%*[^\n]\n" ); line_num = 2; /* read in data */ while ( ( test = fscanf( fp_data_old, "%i %s %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %i %i %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f\n", &dayo, month, &houro, &uo, &two, &tao, &delta_tempo, &day_decimalo, &qso, &qao, &delta_qo, &shf_covo, &shf_inero, &shf_bulko, &shf_aveo, &lhf_covo, &lhf_inero, &lhf_bulko, &lhf_aveo, &tau_covo, &tau_inero, &tau_bulko, &tau_aveo, &ustar_cfo, &opho, &tilto, &inv_hto, &neg_z_over_Lo, &wstaro, &day_decimal_alto, &hrms_mino, &hrms_maxo, &freq_mino, &freq_maxo, &hrms_aveo, &freq_aveo, &phase_spdo, &wave_age_ustaro, &wave_age_uo, &hsigo, &wind_diro ) ) == 41 ) { fscanf( fp_data_new, "%i %s %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %i %i %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f\n", &day, month, &hour, &u, &tw, &ta, &delta_temp, &day_decimal, &qs, &qa, &delta_q, &shf_cov, &shf_iner, &shf_bulk, &shf_ave, &lhf_cov, &lhf_iner, &lhf_bulk, &lhf_ave, &tau_cov, &tau_iner, &tau_bulk, &tau_ave, &ustar_cf, &oph, &tilt, &inv_ht, &neg_z_over_L, &wstar, &day_decimal_alt, &hrms_min, &hrms_max, &freq_min, &freq_max, &hrms_ave, &freq_ave, &phase_spd, &wave_age_ustar, &wave_age_u, &hsig, &wind_dir ); day = day - dayo; hour = hour - houro; u = u - uo; tw = tw - two; ta = ta - tao; delta_temp = delta_temp - delta_tempo; day_decimal = day_decimal - day_decimalo; qs = qs - qso; qa = qa - qao; delta_q= delta_q - delta_qo; shf_cov = shf_cov - shf_covo; shf_iner = shf_iner - shf_inero; shf_bulk = shf_bulk - shf_bulko; shf_ave = shf_ave - shf_aveo; lhf_cov = lhf_cov - lhf_covo; lhf_iner = lhf_iner - lhf_inero; lhf_bulk = lhf_bulk - lhf_bulko; lhf_ave = lhf_ave - lhf_aveo; tau_cov = tau_cov - tau_covo; tau_iner= tau_iner - tau_inero; tau_bulk = tau_bulk - tau_bulko; tau_ave = tau_ave - tau_aveo; ustar_cf= ustar_cf - ustar_cfo; oph = oph - opho; tilt = tilt - tilto; inv_ht = inv_ht - inv_hto; neg_z_over_L = neg_z_over_L - neg_z_over_Lo; wstar = wstar - wstaro; day_decimal_alt = day_decimal_alt - day_decimal_alto; hrms_min = hrms_min - hrms_mino; hrms_max = hrms_max - hrms_maxo; freq_min = freq_min - freq_mino; freq_max = freq_max - freq_maxo; hrms_ave= hrms_ave - hrms_aveo; freq_ave = freq_ave - freq_aveo; phase_spd = phase_spd - phase_spdo; wave_age_ustar = wave_age_ustar - wave_age_ustaro; wave_age_u = wave_age_u - wave_age_uo; hsig = hsig - hsigo; wind_dir= wind_dir - wind_diro; line_num++; /* tke differences */ fprintf( fp_out, "%i %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %i %i %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f\n", day, hour, u, tw, ta, delta_temp, day_decimal, qs, qa, delta_q, shf_cov, shf_iner, shf_bulk, shf_ave, lhf_cov, lhf_iner, lhf_bulk, lhf_ave, tau_cov, tau_iner, tau_bulk, &tau_ave, ustar_cf, oph, tilt, inv_ht, neg_z_over_L, wstar, day_decimal_alt, hrms_min, hrms_max, freq_min, freq_max, hrms_ave, freq_ave, phase_spd, wave_age_ustar, wave_age_u, hsig, wind_dir ); } if ( test != -1 ) printf( "Read error on line %i of Scope2.new.old; test = %i\n", line_num, test ); printf( "%i lines of data\n", line_num ); }