output_options.h 2.85 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*******************************************************************************
 * This file is part of SWIFT.
 * Copyright (c) 2020 Josh Borrow (josh.borrow@durham.ac.uk)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 ******************************************************************************/
#ifndef SWIFT_OUTPUT_OPTIONS_H
#define SWIFT_OUTPUT_OPTIONS_H

22
/* Local headers. */
Matthieu Schaller's avatar
Matthieu Schaller committed
23
#include "io_compression.h"
24
#include "output_list.h"
25
#include "part_type.h"
26
#include "restart.h"
27

28
/*! Default value for SelectOutput */
29 30
#define compression_level_default compression_write_lossless

31
/*! Default name for the SelectOutput header */
32 33
#define select_output_header_default_name "Default"

34 35 36 37 38 39 40 41
/**
 * @brief Output selection properties, including the parsed files.
 **/
struct output_options {

  /*! Select output file, parsed */
  struct swift_params* select_output;

42 43 44 45 46
  /* Number of fields to write for each output selection and ptype.
   * We need one more than max num of output styles, in case the Default
   * output style is used but not specified. */
  int num_fields_to_write[OUTPUT_LIST_MAX_NUM_OF_SELECT_OUTPUT_STYLES + 1]
                         [swift_type_count];
47 48 49 50 51
};

/* Create and destroy */
void output_options_init(struct swift_params* parameter_file, int mpi_rank,
                         struct output_options* output_options);
52
void output_options_clean(struct output_options* output_options);
53 54 55 56 57 58 59

/* Restart files */
void output_options_struct_dump(struct output_options* output_options,
                                FILE* stream);
void output_options_struct_restore(struct output_options* output_options,
                                   FILE* stream);

60
/* Logic functions */
Matthieu Schaller's avatar
Matthieu Schaller committed
61
enum lossy_compression_schemes output_options_get_field_compression(
62 63
    const struct output_options* output_options, const char* snapshot_type,
    const char* field_name, const enum part_type part_type,
Matthieu Schaller's avatar
Matthieu Schaller committed
64
    const enum lossy_compression_schemes comp_level_current_default);
65

Matthieu Schaller's avatar
Matthieu Schaller committed
66
enum lossy_compression_schemes output_options_get_ptype_default_compression(
67 68 69 70 71 72
    struct swift_params* output_params, const char* snapshot_type,
    const enum part_type part_type);

int output_options_get_num_fields_to_write(
    const struct output_options* output_options, const char* selection_name,
    const int ptype);
73

74
#endif