Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALSimulation 6.2.0.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
LALSimIMRDataUtilities.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024 Lorenzo Pompili, Michael Puerrer
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with with program; see the file COPYING. If not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301 USA
18 */
19
20/**
21 * \author Lorenzo Pompili, Michael Puerrer
22 *
23 * \file
24 *
25 * \brief Auxiliary functions related to HDF5 waveform data files.
26 */
27
28#include <string.h>
29
30#include <lal/XLALError.h>
31#include <lal/LALMalloc.h>
33
34#ifdef LAL_HDF5_ENABLED
35#include <lal/H5FileIO.h>
36
37
38int ROM_check_version_number(LALH5File *file, INT4 version_major_in, INT4 version_minor_in, INT4 version_micro_in) {
39 INT4 version_major;
40 INT4 version_minor;
41 INT4 version_micro;
42
43 LALH5Generic gfile = {.file = file};
44 XLALH5AttributeQueryScalarValue(&version_major, gfile, "version_major");
45 XLALH5AttributeQueryScalarValue(&version_minor, gfile, "version_minor");
46 XLALH5AttributeQueryScalarValue(&version_micro, gfile, "version_micro");
47
48 if ((version_major_in != version_major) || (version_minor_in != version_minor) || (version_micro_in != version_micro)) {
49 XLAL_ERROR(XLAL_EIO, "Expected ROM data version %d.%d.%d, but got version %d.%d.%d.",
50 version_major_in, version_minor_in, version_micro_in, version_major, version_minor, version_micro);
51 }
52 else {
53 XLALPrintInfo("Reading ROM data version %d.%d.%d.\n", version_major, version_minor, version_micro);
54 return XLAL_SUCCESS;
55 }
56}
57
58int ROM_check_canonical_file_basename(LALH5File *file, const char file_name[], const char attribute[]) {
59
60 LALH5Generic gfile = {.file = file};
61 int len = XLALH5AttributeQueryStringValue(NULL, 0, gfile, attribute) + 1;
62 char *canonical_file_basename = XLALMalloc(len);
63 XLALH5FileQueryStringAttributeValue(canonical_file_basename, len, file, attribute);
64
65 if (strcmp(canonical_file_basename, file_name) != 0) {
66 XLAL_ERROR(XLAL_EIO, "Expected CANONICAL_FILE_BASENAME %s, but got %s.",
67 file_name, canonical_file_basename);
68 }
69 else {
70 XLALPrintInfo("ROM canonical_file_basename %s\n", canonical_file_basename);
71 }
72 XLALFree(canonical_file_basename);
73 return XLAL_SUCCESS;
74}
75
76#endif /* LAL_HDF5_ENABLED */
struct tagLALH5File LALH5File
Auxiliary functions related to HDF5 waveform data files.
int XLALH5AttributeQueryStringValue(char UNUSED *value, size_t UNUSED size, const LALH5Generic UNUSED object, const char UNUSED *key)
int XLALH5AttributeQueryScalarValue(void UNUSED *value, const LALH5Generic UNUSED object, const char UNUSED *key)
int XLALH5FileQueryStringAttributeValue(char UNUSED *value, size_t UNUSED size, LALH5File UNUSED *file, const char UNUSED *key)
int32_t INT4
void * XLALMalloc(size_t n)
void XLALFree(void *p)
int int int XLALPrintInfo(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
#define XLAL_ERROR(...)
XLAL_SUCCESS
XLAL_EIO
const char * file_name
Definition: sgwb.c:110
LALH5File * file