Esempio n. 1
0
int harp_export_netcdf(const char *filename, const harp_product *product)
{
    netcdf_dimensions dimensions;
    int result;
    int ncid;

    if (filename == NULL)
    {
        harp_set_error(HARP_ERROR_INVALID_ARGUMENT, "filename is NULL");
        return -1;
    }

    if (product == NULL)
    {
        harp_set_error(HARP_ERROR_INVALID_ARGUMENT, "product is NULL");
        return -1;
    }

    result = nc_create(filename, 0, &ncid);
    if (result != NC_NOERR)
    {
        harp_set_error(HARP_ERROR_NETCDF, "%s", nc_strerror(result));
        harp_add_error_message(" (%s)", filename);
        return -1;
    }

    dimensions_init(&dimensions);

    if (write_product(ncid, product, &dimensions) != 0)
    {
        harp_add_error_message(" (%s)", filename);
        nc_close(ncid);
        dimensions_done(&dimensions);
        return -1;
    }

    dimensions_done(&dimensions);

    result = nc_close(ncid);
    if (result != NC_NOERR)
    {
        harp_set_error(HARP_ERROR_NETCDF, "%s", nc_strerror(result));
        harp_add_error_message(" (%s)", filename);
        return -1;
    }

    return 0;
}
Esempio n. 2
0
int main()  // THIS IS BASICALLY ADMIN MENU ONLY IT CURRENTLY DOES TWO JOBS 1. CALL WRITE_PRODUCT 2.CALL READALL_PRODUCT
{
	char ans, ch;
	printf("\n------------------------------------------");
	printf("\n\t*Welcome To NesNas Supermarket*\t |\n");
	printf("------------------------------------------");
	printf("\n ADMIN MENU\t\t\t\t |\n");
	do
	{
	printf("------------------------------------------");
    printf("\n 1 For Accept \t\t\t\t |");
    printf("\n 2 For Display \t\t\t\t |");
	printf("\n 3 For Displaying Particular Record\t | ");
	printf("\n 4 For Modificaton \t\t\t |");
	printf("\n 5 For Deletion \t\t\t |");
    printf("\n 6 EXIT.\t\t\t\t |");
	printf("\n------------------------------------------");
        printf("\n\n Select -> ");
        scanf("%c",&ch);

        switch(ch)
            {
                case '1': write_product();
			break;

                case '2': readall_product();
			break;

		case '3':part_prod();
			break;

		case '4':mod_rec();
			break;

		case '5':del_rec();
			break;

		default: printf("\n INVALID OPERATION \n");
            }	// END OF SWITCH

    }while( ch != '6' );

}
Esempio n. 3
0
void server_product(int sockfd)

{

  char error_text[TDATA_TEXT_LEN];
  
  int forever = TRUE;
  int storm_locked, track_locked;

  si32 dtime;
  
  tdata_request_t request;
  static storm_file_handle_t s_handle;
  static track_file_handle_t t_handle;
  
  /*
   * initialize the file indices
   */
  
  RfInitStormFileHandle(&s_handle, Glob->prog_name);

  RfInitTrackFileHandle(&t_handle, Glob->prog_name);

  /*
   * set up the request
   */

  memset ((void *) &request,
	  (int) 0,
	  (size_t) sizeof(tdata_request_t));

  request.request = TDATA_REQUEST_DATA;
  request.mode = TDATA_PRODUCT;
  request.source = TDATA_REALTIME;
  request.track_set = TDATA_ALL_AT_TIME;
  request.target_entries = TDATA_CURRENT_ENTRIES_ONLY;

  /*
   * loop waiting for new data
   */
  
  while (forever) {

    /*
     * check for new data if applicable
     */
    
    if (new_data()) {
      
      if (Glob->params.debug >= DEBUG_NORM)
	fprintf(stderr, "New data available\n");
      
      /*
       * initialize file locking flags - the files get locked in
       * get_realtime_info()
       */
      
      storm_locked = FALSE;
      track_locked = FALSE;
    
      if (get_realtime_info (&request, &s_handle, &t_handle,
			     &dtime, error_text,
			     &storm_locked, &track_locked)) {

	fprintf(stderr, "%s:server_product\n", Glob->prog_name);
	fprintf(stderr, "%s\n", error_text);

      } else {
	
	if (write_product(sockfd,
			  &s_handle,
			  &t_handle,
			  dtime)) {

	  fprintf(stderr, "%s:server_product\n", Glob->prog_name);
	  fprintf(stderr, "Error writing product\n");

	} /* if (write_product(... */

      } /* if (get_realtime_info (... */

      /*
       * unlock files
       */
      
      if (storm_locked && (s_handle.header_file != NULL)) {
	if (ta_unlock_file(s_handle.header_file_path,
			   s_handle.header_file)) {
	  fprintf(stderr, "WARNING - %s:server_product\n", Glob->prog_name);
	}
      }
      
      if (track_locked && (t_handle.header_file != NULL)) {
	if (ta_unlock_file(t_handle.header_file_path,
			   t_handle.header_file)) {
	  fprintf(stderr, "WARNING - %s:server_product\n", Glob->prog_name);
	}
      }
      
    } /* if (new_data()) */

    sleep (1);

    if (connection_down(sockfd)) {
      fprintf(stderr, "track server exiting - broken connection\n");
      return;
    }
    
  } /* while (forever) */

}