/* Name- processAIRS02.c Language- C Type- MAIN Version- 1.0 Date- 1/30/2017 Programmer- Mike Pettey (IMSG) Function- This program extracts data from P72 EDR files in HDF5 format and writes the data to an EDGE orbital file. The selected data is defined in the run script. Also in the run script are the starting date (YYYYMMDD) and hour and the ending date and hour. */ #include #include #include #include #include #include #include "nprovs_to_netcdf.h" #define ERR(e) {printf("Error: %s, error num = %d\n", nc_strerror(e),e);} #define NDIMS 1 int defineVariable(int nc_group_id, char *var_name, nc_type var_type, int ndims, int *dimids, char *attr_string, char *attr); void writeVariableByte(int group_id, int var_id, size_t *index, size_t *num_vals, char value); void writeVariableFloat(int group_id, int var_id, size_t *index, size_t *num_vals, float value); void writeVariableShort(int group_id, int var_id, size_t *index, size_t *num_vals, short value); void writeVariableInteger(int group_id, int var_id, size_t *index, size_t *num_vals, long value); void writeArrayFloat(int group_id, int var_id, size_t *index, size_t *num_vals, float *value); void writeArrayByte(int group_id, int var_id, size_t *index, size_t *num_vals, char *value); float interpolateValue(float pressure, int num_values, float *before_pressures, float *before_data); void writeAttributeShort(int grp, char *attrVariable, short attrValue); void writeAttributeText(int grp, char *attrVariable, char *attrValue); void processAIRS02(int date_to_process, struct file_data *files, struct platform *platform_ptr, int num_collocations, int platform_index, int data_type, int nc_date_group) { int n, i, date_type, recnum, collocation_num, retval; int nc_group_id, collocation_group_id; size_t num_colls, index[1], num_vals[1], index_2D[2], num_vals_2D[2]; float missing_float, latitude, longitude, level_data[100], cloud_data[2]; char level_byte_data[100], cloud_byte_data[2]; int year, month, day, hour, minute, second; long offset, yyyymmdd, hhmmss; char col_dir_name[50]; char string6[7], string10[11]; char *string[1]; short *buffer; int col_scalar_dim; int scalar_dim, dim_levels, dim_clouds; int dimid_scalar[1], col_dimid_scalar[1]; int dimid_levels[2], dimid_clouds[2]; int col_vid_lat, col_vid_lon, col_vid_date, col_vid_time; int vid_lat, vid_lon, vid_date, vid_time; int vid_granule, vid_daynight, vid_node, vid_topo, vid_landfrac; int vid_terrain, vid_fg_surfpres, vid_fg_surfpres_qc; int vid_skintemp, vid_skintemp_err, vid_surftemp, vid_surftemp_err; int vid_tropo_press, vid_tropo_temp, vid_tpw, vid_tpw_err; int vid_ret1_surf_temp, vid_ret1_air_temp; int vid_max_press_0, vid_max_press_01, vid_high_index_0, vid_high_index_01; int vid_press, vid_temp, vid_temp_err, vid_wvmr, vid_wvmr_err; int vid_mw_temp, vid_mw_wvmr, vid_reg_temp, vid_reg_wvmr; int vid_numclouds, vid_ctp, vid_ctt, vid_ca; FILE *in; num_colls = (size_t)num_collocations; missing_float = -32768.0; // If this is the baseline platform, then create another subgroup // for the collocation information if (platform_index == 0) { sprintf(col_dir_name, "Collocation_Info"); if ((retval = nc_def_grp(nc_date_group, col_dir_name, &collocation_group_id))) { if (retval != -42) ERR(retval); } writeAttributeShort(collocation_group_id, "Baseline_Data_Type", platform_ptr->type); writeAttributeText(collocation_group_id, "Baseline_Platform", platform_ptr->description); writeAttributeShort(collocation_group_id, "Baseline_Platform_ID", platform_ptr->id); } // Create a subgroup for this system platform if ((retval = nc_def_grp(nc_date_group, platform_ptr->dir_name, &nc_group_id))) { //if (retval != -42) ERR(retval); } // Set the platform type attribute to the data group type writeAttributeText(nc_group_id, "Platform_Name", platform_ptr->description); // clean_description? writeAttributeShort(nc_group_id, "Platform_ID", platform_ptr->id); writeAttributeShort(nc_group_id, "Platform_Type", platform_ptr->type); writeAttributeText(nc_group_id, "Platform_Data_Source", "AIRS version 2"); //writeAttributeText(nc_group_id, "Platform_NPROVS_Source_Name", nprovs_name); writeAttributeText(nc_group_id, "Platform_NPROVS_Source_Name", platform_ptr->description); // clean_description? // Define the dimensions if ((retval = nc_def_dim(nc_group_id, "Num_Collocations", num_colls, &scalar_dim))) ERR(retval); dimid_scalar[0] = scalar_dim; if ((retval = nc_def_dim(nc_group_id, "Layers", 100, &dim_levels))) ERR(retval); dimid_levels[0] = scalar_dim; dimid_levels[1] = dim_levels; if ((retval = nc_def_dim(nc_group_id, "Cloud_Layers", 2, &dim_clouds))) ERR(retval); dimid_clouds[0] = scalar_dim; dimid_clouds[1] = dim_clouds; if (platform_index == 0) { if ((retval = nc_def_dim(collocation_group_id, "Num_Collocations", num_colls, &col_scalar_dim))) ERR(retval); col_dimid_scalar[0] = col_scalar_dim; } // Define the variables if (platform_index == 0) { col_vid_lat = defineVariable(collocation_group_id, "latitude", NC_FLOAT, 1, col_dimid_scalar, "units", "degrees_north"); col_vid_lon = defineVariable(collocation_group_id, "longitude", NC_FLOAT, 1, col_dimid_scalar, "units", "degrees_east"); col_vid_date = defineVariable(collocation_group_id, "date", NC_INT, 1, col_dimid_scalar, "format", "yyyymmdd"); col_vid_time = defineVariable(collocation_group_id, "time", NC_INT, 1, col_dimid_scalar, "format", "hhmmss"); } vid_lat = defineVariable(nc_group_id, "latitude", NC_FLOAT, 1, dimid_scalar, "units", "degrees_north"); vid_lon = defineVariable(nc_group_id, "longitude", NC_FLOAT, 1, dimid_scalar, "units", "degrees_east"); vid_date = defineVariable(nc_group_id, "date", NC_INT, 1, dimid_scalar, "format", "yyyymmdd"); vid_time = defineVariable(nc_group_id, "time", NC_INT, 1, dimid_scalar, "format", "hhmmss"); vid_granule = defineVariable(nc_group_id, "daily_granule_number", NC_SHORT, 1, dimid_scalar, NULL, NULL); vid_daynight = defineVariable(nc_group_id, "day_night_flag", NC_BYTE, 1, dimid_scalar, "values", "0=night, 1=day, 2=both, -1=unexpected value"); vid_node = defineVariable(nc_group_id, "orbital_node", NC_BYTE, 1, dimid_scalar, "values", "0=ascending, 1=descending, 2=north pole, 3=south pole, -1=unexpected value"); vid_topo = defineVariable(nc_group_id, "mean_topography", NC_FLOAT, 1, dimid_scalar, "units", "m"); vid_landfrac = defineVariable(nc_group_id, "land_fraction", NC_FLOAT, 1, dimid_scalar, "units", "percent"); vid_terrain = defineVariable(nc_group_id, "surface_type", NC_BYTE, 1, dimid_scalar, "values", "0=coast, 1=land, 2=sea, 3=sea ice (high mw emiss), 4= sea ice (low emiss), 5=snow (high freq mw scattering), 6=glacier snow, 7=snow (low freq mw scattering)"); vid_fg_surfpres = defineVariable(nc_group_id, "first_guess_surface_pressure", NC_FLOAT, 1, dimid_scalar, "units", "hPa"); vid_fg_surfpres_qc = defineVariable(nc_group_id, "first_guess_surface_pressure_qc", NC_BYTE, 1, dimid_scalar, NULL, NULL); vid_skintemp = defineVariable(nc_group_id, "surface_skin_temperature", NC_FLOAT, 1, dimid_scalar, "units", "K"); vid_skintemp_err = defineVariable(nc_group_id, "surface_skin_temperature_error", NC_FLOAT, 1, dimid_scalar, "units", "K"); vid_surftemp = defineVariable(nc_group_id, "surface_air_temperature", NC_FLOAT, 1, dimid_scalar, "units", "K"); vid_surftemp_err = defineVariable(nc_group_id, "surface_air_temperature_error", NC_FLOAT, 1, dimid_scalar, "units", "K"); vid_tropo_press = defineVariable(nc_group_id, "tropopause_pressure", NC_FLOAT, 1, dimid_scalar, "units", "hPa"); vid_tropo_temp = defineVariable(nc_group_id, "tropopause_temperature", NC_FLOAT, 1, dimid_scalar, "units", "K"); vid_tpw = defineVariable(nc_group_id, "total_precipitable_water", NC_FLOAT, 1, dimid_scalar, "units", "kg/m^2"); vid_tpw_err = defineVariable(nc_group_id, "total_precipitable_water_error", NC_FLOAT, 1, dimid_scalar, "units", "kg/m^2"); vid_ret1_surf_temp = defineVariable(nc_group_id, "surface_temperature_after_first_retrieval", NC_FLOAT, 1, dimid_scalar, "units", "K"); vid_ret1_air_temp = defineVariable(nc_group_id, "surface_air_temperature_after_first_retrieval", NC_FLOAT, 1, dimid_scalar, "units", "K"); vid_max_press_0 = defineVariable(nc_group_id, "max_pressure_temperature_qc=0", NC_FLOAT, 1, dimid_scalar, "units", "hPa"); vid_max_press_01 = defineVariable(nc_group_id, "max_pressure_temperature_qc=0_or_1", NC_FLOAT, 1, dimid_scalar, "units", "hPa"); vid_high_index_0 = defineVariable(nc_group_id, "high_pressure_index_qc=0", NC_SHORT, 1, dimid_scalar, NULL, NULL); vid_high_index_01 = defineVariable(nc_group_id, "high_pressure_index_qc=0_or_1", NC_SHORT, 1, dimid_scalar, NULL, NULL); vid_press = defineVariable(nc_group_id, "pressure", NC_FLOAT, 2, dimid_levels, "units", "hPa"); vid_temp = defineVariable(nc_group_id, "temperature", NC_FLOAT, 2, dimid_levels, "units", "K"); vid_temp_err = defineVariable(nc_group_id, "temperature_error", NC_FLOAT, 2, dimid_levels, "units", "K"); vid_wvmr = defineVariable(nc_group_id, "water_vapor_mixing_ratio", NC_FLOAT, 2, dimid_levels, "units", "g/kg"); vid_wvmr_err = defineVariable(nc_group_id, "water_vapor_mixing_ratio_error", NC_FLOAT, 2, dimid_levels, "units", "g/kg"); vid_mw_temp = defineVariable(nc_group_id, "mw_only_temperature", NC_FLOAT, 2, dimid_levels, "units", "K"); vid_mw_wvmr = defineVariable(nc_group_id, "mw_only_water_vapor_mixing_ratio", NC_FLOAT, 2, dimid_levels, "units", "g/kg"); vid_reg_temp = defineVariable(nc_group_id, "after_regression_temperature", NC_FLOAT, 2, dimid_levels, "units", "K"); vid_reg_wvmr = defineVariable(nc_group_id, "after_regression_water_vapor_mixing_ratio", NC_FLOAT, 2, dimid_levels, "units", "g/kg"); vid_numclouds = defineVariable(nc_group_id, "number_of_cloud_layers", NC_BYTE, 1, dimid_scalar, NULL, NULL); vid_ctp = defineVariable(nc_group_id, "cloud_top_pressure", NC_FLOAT, 2, dimid_clouds, "units", "hPa"); vid_ctt = defineVariable(nc_group_id, "cloud_top_temperature", NC_FLOAT, 2, dimid_clouds, "units", "K"); vid_ca = defineVariable(nc_group_id, "cloud_fraction", NC_FLOAT, 2, dimid_clouds, "units", "percent"); // Allocate the memory used by the data buffer buffer = (short *)malloc(platform_ptr->length); collocation_num = -1; // Loop through each record in all of the files and read the data for // this data group into the buffer for (date_type=0; date_type<3; date_type++) { if (date_type == 0) { if ((in=fopen("prev_day.file", "r")) == NULL) { printf("\n\nThe previous day file could not be opened for input.\n"); printf("It will be skipped.\n\n"); in = NULL; } } else if (date_type == 1) { if ((in=fopen("in.file", "r")) == NULL) { printf("\n\nThe input file could not be opened for input.\n"); printf("It will be skipped.\n\n"); in = NULL; } } else { if ((in=fopen("next_day.file", "r")) == NULL) { printf("\n\nThe next day file could not be opened for input.\n"); printf("It will be skipped.\n\n"); in = NULL; } } for (recnum=0; recnumoffset; fseek(in, offset, SEEK_SET); fread(buffer, platform_ptr->length, 1, in); // Process this record if it matches the date to process if (files[date_type].use_record[recnum] == TRUE) { collocation_num++; // Index and num_vals are used to save a single value within the // variable array index[0] = collocation_num; num_vals[0] = 1; // Latitude and longitude if (buffer[3] != -32768) latitude = buffer[3] / 128.0; else latitude = -32768.0; if (buffer[4] != -32768) longitude = buffer[4] / 128.0; else longitude = -32768.0; writeVariableFloat(nc_group_id, vid_lat, index, num_vals, latitude); writeVariableFloat(nc_group_id, vid_lon, index, num_vals, longitude); // Date and time if ((buffer[5] != -32768) && (buffer[6] != -32768) && (buffer[7] != -32768) && (buffer[8] != -32768)) { year = buffer[5]; month = buffer[6] / 100; day = buffer[6] % 100; hour = buffer[7]; minute = buffer[8] / 100; second = buffer[8] % 100; yyyymmdd = (year * 10000) + (month * 100) + day; hhmmss = (hour * 10000) + (minute * 100) + second; } else { yyyymmdd = -32768; hhmmss = -32768; } writeVariableInteger(nc_group_id, vid_date, index, num_vals, yyyymmdd); writeVariableInteger(nc_group_id, vid_time, index, num_vals, hhmmss); // If this is the baseline system, save the collocation information if (platform_index == 0) { writeVariableFloat(collocation_group_id, col_vid_lat, index, num_vals, latitude); writeVariableFloat(collocation_group_id, col_vid_lon, index, num_vals, longitude); writeVariableInteger(collocation_group_id, col_vid_date, index, num_vals, yyyymmdd); writeVariableInteger(collocation_group_id, col_vid_time, index, num_vals, hhmmss); } // Start saving the rest of the fata string with the granule, scan line and fov writeVariableShort(nc_group_id, vid_granule, index, num_vals, buffer[12]); // Day/Night flag if ((buffer[13] == -32768) || (buffer[14] == -32768) || (buffer[15] == -32768) || (buffer[16] == -32768) || (buffer[17] == -32768) || (buffer[18] == -32768)) { writeVariableByte(nc_group_id, vid_daynight, index, num_vals, (char)-128); } else { string6[0] = buffer[13]; string6[1] = buffer[14]; string6[2] = buffer[15]; string6[3] = buffer[16]; string6[4] = buffer[17]; string6[5] = buffer[18]; string6[6] = '\0'; if (strcmp(string6, "Night") == 0) writeVariableByte(nc_group_id, vid_daynight, index, num_vals, (char)0); else if (strcmp(string6, "Day") == 0) writeVariableByte(nc_group_id, vid_daynight, index, num_vals, (char)1); else if (strcmp(string6, "Both") == 0) writeVariableByte(nc_group_id, vid_daynight, index, num_vals, (char)2); else writeVariableByte(nc_group_id, vid_daynight, index, num_vals, (char)-1); } // Oribital node if ((buffer[19] == -32768) || (buffer[20] == -32768) || (buffer[21] == -32768) || (buffer[22] == -32768) || (buffer[23] == -32768) || (buffer[24] == -32768) || (buffer[25] == -32768) || (buffer[26] == -32768) || (buffer[27] == -32768) || (buffer[28] == -32768)) { writeVariableByte(nc_group_id, vid_node, index, num_vals, (char)-128); } else { string10[0] = buffer[19]; string10[1] = buffer[20]; string10[2] = buffer[21]; string10[3] = buffer[22]; string10[4] = buffer[23]; string10[5] = buffer[24]; string10[6] = buffer[25]; string10[7] = buffer[26]; string10[8] = buffer[27]; string10[9] = buffer[28]; string10[10] = '\0'; if (strcmp(string10, "Ascending") == 0) writeVariableByte(nc_group_id, vid_node, index, num_vals, (char)0); else if (strcmp(string10, "Descending") == 0) writeVariableByte(nc_group_id, vid_node, index, num_vals, (char)1); else if (strcmp(string10, "NorthPole") == 0) writeVariableByte(nc_group_id, vid_node, index, num_vals, (char)2); else if (strcmp(string10, "SouthPole") == 0) writeVariableByte(nc_group_id, vid_node, index, num_vals, (char)3); else writeVariableByte(nc_group_id, vid_node, index, num_vals, (char)-1); } // Topography and land fraction if (buffer[29] != -32768) writeVariableFloat(nc_group_id, vid_topo, index, num_vals, (buffer[29]/1.0)); else writeVariableFloat(nc_group_id, vid_topo, index, num_vals, -32768.0); if (buffer[31] != -32768) writeVariableFloat(nc_group_id, vid_landfrac, index, num_vals, (buffer[31]/1000.0)); else writeVariableFloat(nc_group_id, vid_landfrac, index, num_vals, -32768.0); // Surface type and zenith angle if (buffer[33] != -32768) writeVariableByte(nc_group_id, vid_terrain, index, num_vals, (char)buffer[33]); else writeVariableByte(nc_group_id, vid_terrain, index, num_vals, (char)-128); // Surface data if (buffer[136] != -32768) writeVariableFloat(nc_group_id, vid_fg_surfpres, index, num_vals, (buffer[136]/10.0)); else writeVariableFloat(nc_group_id, vid_fg_surfpres, index, num_vals, -32768.0); if (buffer[135] != -32768) writeVariableByte(nc_group_id, vid_fg_surfpres_qc, index, num_vals, (char)buffer[135]); else writeVariableByte(nc_group_id, vid_fg_surfpres_qc, index, num_vals, (char)-128); if (buffer[352] != -32768) writeVariableFloat(nc_group_id, vid_skintemp, index, num_vals, (buffer[352]/64.0)); else writeVariableFloat(nc_group_id, vid_skintemp, index, num_vals, -32768.0); if (buffer[353] != -32768) writeVariableFloat(nc_group_id, vid_skintemp_err, index, num_vals, (buffer[353]/64.0)); else writeVariableFloat(nc_group_id, vid_skintemp_err, index, num_vals, -32768.0); if (buffer[349] != -32768) writeVariableFloat(nc_group_id, vid_surftemp, index, num_vals, (buffer[349]/64.0)); else writeVariableFloat(nc_group_id, vid_surftemp, index, num_vals, -32768.0); if (buffer[350] != -32768) writeVariableFloat(nc_group_id, vid_surftemp_err, index, num_vals, (buffer[350]/64.0)); else writeVariableFloat(nc_group_id, vid_surftemp_err, index, num_vals, -32768.0); // Tropopause data if (buffer[557] != -32768) writeVariableFloat(nc_group_id, vid_tropo_press, index, num_vals, (buffer[557]/10.0)); else writeVariableFloat(nc_group_id, vid_tropo_press, index, num_vals, -32768.0); if (buffer[558] != -32768) writeVariableFloat(nc_group_id, vid_tropo_temp, index, num_vals, (buffer[558]/64.0)); else writeVariableFloat(nc_group_id, vid_tropo_temp, index, num_vals, -32768.0); // TPW if (buffer[555] != -32768) writeVariableFloat(nc_group_id, vid_tpw, index, num_vals, (float)(exp(buffer[555]/1024.0))); else writeVariableFloat(nc_group_id, vid_tpw, index, num_vals, -32768.0); if (buffer[556] != -32768) writeVariableFloat(nc_group_id, vid_tpw_err, index, num_vals, (float)(exp(buffer[556]/1024.0))); else writeVariableFloat(nc_group_id, vid_tpw_err, index, num_vals, -32768.0); // Surface temperatures if (buffer[965] != -32768) writeVariableFloat(nc_group_id, vid_ret1_surf_temp, index, num_vals, (buffer[965]/64.0)); else writeVariableFloat(nc_group_id, vid_ret1_surf_temp, index, num_vals, -32768.0); if (buffer[966] != -32768) writeVariableFloat(nc_group_id, vid_ret1_air_temp, index, num_vals, (buffer[966]/64.0)); else writeVariableFloat(nc_group_id, vid_ret1_air_temp, index, num_vals, -32768.0); // QC values if (buffer[140] != -32768) writeVariableFloat(nc_group_id, vid_max_press_0, index, num_vals, (buffer[140]/10.0)); else writeVariableFloat(nc_group_id, vid_max_press_0, index, num_vals, -32768.0); if (buffer[141] != -32768) writeVariableFloat(nc_group_id, vid_max_press_01, index, num_vals, (buffer[141]/10.0)); else writeVariableFloat(nc_group_id, vid_max_press_01, index, num_vals, -32768.0); writeVariableShort(nc_group_id, vid_high_index_0, index, num_vals, buffer[138]); writeVariableShort(nc_group_id, vid_high_index_01, index, num_vals, buffer[139]); // Pressures index_2D[0] = collocation_num; index_2D[1] = 0; num_vals_2D[0] = 1; num_vals_2D[1] = 100; for (n=0; n<100; n++) { if (buffer[35+n] == -32768) level_data[n] = -32768.0; else if (n < 20) level_data[n] = buffer[35+n] / 1000.0; else level_data[n] = buffer[35+n] / 10.0; } writeArrayFloat(nc_group_id, vid_press, index_2D, num_vals_2D, level_data); // Temperatures for (n=0; n<100; n++) { if (buffer[149+n] != -32768) level_data[n] = buffer[149+n] / 64.0; else level_data[n] = -32768.0; } writeArrayFloat(nc_group_id, vid_temp, index_2D, num_vals_2D, level_data); for (n=0; n<100; n++) { if (buffer[249+n] != -32768) level_data[n] = buffer[249+n] / 64.0; else level_data[n] = -32768.0; } writeArrayFloat(nc_group_id, vid_temp_err, index_2D, num_vals_2D, level_data); // Water vapor mixing ratios for (n=0; n<100; n++) { if (buffer[355+n] != -32768) level_data[n] = (float)(exp(buffer[355+n]/1024.0)); else level_data[n] = -32768.0; } writeArrayFloat(nc_group_id, vid_wvmr, index_2D, num_vals_2D, level_data); for (n=0; n<100; n++) { if (buffer[455+n] != -32768) level_data[n] = (float)(exp(buffer[455+n]/1024.0)); else level_data[n] = -32768.0; level_data[n] = -32768.0; } writeArrayFloat(nc_group_id, vid_wvmr_err, index_2D, num_vals_2D, level_data); // MW Temperatures for (n=0; n<100; n++) { if (buffer[563+n] != -32768) level_data[n] = buffer[563+n] / 64.0; else level_data[n] = -32768.0; } writeArrayFloat(nc_group_id, vid_mw_temp, index_2D, num_vals_2D, level_data); // MW Water vapor mixing ratios for (n=0; n<100; n++) { if (buffer[765+n] != -32768) level_data[n] = (float)(exp(buffer[765+n]/1024.0)); else level_data[n] = -32768.0; } writeArrayFloat(nc_group_id, vid_mw_wvmr, index_2D, num_vals_2D, level_data); // After regression temperatures and water vapors for (n=0; n<100; n++) { if (buffer[663+n] != -32768) level_data[n] = buffer[663+n] / 64.0; else level_data[n] = -32768.0; } writeArrayFloat(nc_group_id, vid_reg_temp, index_2D, num_vals_2D, level_data); for (n=0; n<100; n++) { if (buffer[865+n] != -32768) level_data[n] = (float)(exp(buffer[865+n]/1024.0)); else level_data[n] = -32768.0; } writeArrayFloat(nc_group_id, vid_reg_wvmr, index_2D, num_vals_2D, level_data); // Cloud data index_2D[0] = collocation_num; index_2D[1] = 0; num_vals_2D[0] = 1; num_vals_2D[1] = 2; if (buffer[1167] != -32768) writeVariableByte(nc_group_id, vid_numclouds, index, num_vals, (char)buffer[1167]); else writeVariableByte(nc_group_id, vid_numclouds, index, num_vals, (char)-128); // Cloud top pressure for (n=0; n<2; n++) { if (buffer[1170+n] != -32768) cloud_data[n] = buffer[1170+n] / 10.0; else cloud_data[n] = -32768.0; } writeArrayFloat(nc_group_id, vid_ctp, index_2D, num_vals_2D, cloud_data); // Cloud top temperature for (n=0; n<2; n++) { if (buffer[1168+n] != -32768) cloud_data[n] = buffer[1168+n] / 64.0; else cloud_data[n] = -32768.0; } writeArrayFloat(nc_group_id, vid_ctt, index_2D, num_vals_2D, cloud_data); // Cloud fraction for (n=0; n<2; n++) { if (buffer[1172+n] != -32768) cloud_data[n] = buffer[1172+n] / 1000.0; else cloud_data[n] = -32768.0; } writeArrayFloat(nc_group_id, vid_ca, index_2D, num_vals_2D, cloud_data); // Other variables, if we figure out what they are } // if (yyyymmdd == date_to_process... } // for (recnum=0... if (in != NULL) fclose(in); } // for (date_type=0... // Free the memory used by the buffer free(buffer); } // end of file