include/ert/ecl/fortio.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2011 Equinor ASA, Norway.
3
4 The file 'fortio.h' is part of ERT - Ensemble based Reservoir Tool.
5
6 ERT is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 ERT is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.
14
15 See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
16 for more details.
17*/
18
19#ifndef ERT_FORTIO_H
20#define ERT_FORTIO_H
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25#include <stdlib.h>
26#include <stdio.h>
27#include <stdbool.h>
28
29#include <ert/util/util.h>
31
32typedef enum {
33 FORTIO_NOENTRY = 0, /* File does not exists at all - application error. */
34 FORTIO_EOF = 1, /* The file / record is empty */
35 FORTIO_OK = 2, /* The file / record is OK with: [32 bit header | data | 32 bit footer] */
40
41
42typedef struct fortio_struct fortio_type;
43
44 fortio_status_type fortio_check_buffer( FILE * stream , bool endian_flip , size_t buffer_size );
45 fortio_status_type fortio_check_file( const char * filename , bool endian_flip);
46 bool fortio_looks_like_fortran_file(const char * , bool );
47 void fortio_copy_record(fortio_type * , fortio_type * , int , void * , bool *);
48 fortio_type * fortio_open_reader(const char *, bool fmt_file , bool endian_flip_header);
49 fortio_type * fortio_open_writer(const char *, bool fmt_file , bool endian_flip_header);
50 fortio_type * fortio_open_readwrite(const char *, bool fmt_file , bool endian_flip_header);
51 fortio_type * fortio_open_append(const char *filename , bool fmt_file , bool endian_flip_header);
52 fortio_type * fortio_alloc_FILE_wrapper(const char * , bool , bool , bool , FILE * );
56 bool fortio_complete_read(fortio_type *, int record_size);
58 void fortio_complete_write(fortio_type * , int record_size);
61 bool fortio_fread_buffer(fortio_type * , char * buffer, int buffer_size);
62 void fortio_fwrite_record(fortio_type * , const char * buffer, int buffer_size);
67 void fortio_rewind(const fortio_type *fortio);
68 const char * fortio_filename_ref(const fortio_type * );
71 bool fortio_fseek( fortio_type * fortio , offset_type offset , int whence);
72 bool fortio_data_fskip(fortio_type* fortio, const int element_size, const int element_count, const int block_count);
73 void fortio_data_fseek(fortio_type* fortio, offset_type data_offset, size_t data_element, const int element_size, const int element_count, const int block_size);
74 int fortio_fileno( fortio_type * fortio );
77
80 bool fortio_stream_is_open( const fortio_type * fortio );
84
87
88#ifdef __cplusplus
89}
90#endif
91#endif
char * buffer
Definition: cJSON.h:161
bool fortio_fseek(fortio_type *fortio, offset_type offset, int whence)
bool fortio_fmt_file(const fortio_type *)
fortio_status_type fortio_check_buffer(FILE *stream, bool endian_flip, size_t buffer_size)
void fortio_init_write(fortio_type *, int)
void fortio_fwrite_record(fortio_type *, const char *buffer, int buffer_size)
bool fortio_data_fskip(fortio_type *fortio, const int element_size, const int element_count, const int block_count)
void fortio_fskip_buffer(fortio_type *, int)
bool fortio_is_fortio_file(fortio_type *)
fortio_type * fortio_open_append(const char *filename, bool fmt_file, bool endian_flip_header)
int fortio_fclean(fortio_type *fortio)
void fortio_free_FILE_wrapper(fortio_type *)
bool fortio_ftruncate(fortio_type *fortio, offset_type size)
void fortio_fwrite_error(fortio_type *fortio)
void fortio_fflush(fortio_type *)
bool fortio_fread_buffer(fortio_type *, char *buffer, int buffer_size)
FILE * fortio_get_FILE(const fortio_type *)
int fortio_init_read(fortio_type *)
int fortio_fileno(fortio_type *fortio)
fortio_type * fortio_alloc_FILE_wrapper(const char *, bool, bool, bool, FILE *)
UTIL_IS_INSTANCE_HEADER(fortio)
void fortio_fclose(fortio_type *)
offset_type fortio_ftell(const fortio_type *fortio)
bool fortio_assert_stream_open(fortio_type *fortio)
bool fortio_fopen_stream(fortio_type *fortio)
bool fortio_complete_read(fortio_type *, int record_size)
UTIL_SAFE_CAST_HEADER(fortio)
fortio_type * fortio_open_writer(const char *, bool fmt_file, bool endian_flip_header)
bool fortio_read_at_eof(fortio_type *fortio)
struct fortio_struct fortio_type
Definition: include/ert/ecl/fortio.h:42
int fortio_fskip_record(fortio_type *)
fortio_status_type fortio_check_file(const char *filename, bool endian_flip)
bool fortio_looks_like_fortran_file(const char *, bool)
void fortio_copy_record(fortio_type *, fortio_type *, int, void *, bool *)
bool fortio_fclose_stream(fortio_type *fortio)
bool fortio_stream_is_open(const fortio_type *fortio)
fortio_type * fortio_open_reader(const char *, bool fmt_file, bool endian_flip_header)
const char * fortio_filename_ref(const fortio_type *)
bool fortio_ftruncate_current(fortio_type *fortio)
void fortio_data_fseek(fortio_type *fortio, offset_type data_offset, size_t data_element, const int element_size, const int element_count, const int block_size)
fortio_type * fortio_open_readwrite(const char *, bool fmt_file, bool endian_flip_header)
fortio_status_type
Definition: include/ert/ecl/fortio.h:32
@ FORTIO_OK
Definition: include/ert/ecl/fortio.h:35
@ FORTIO_HEADER_MISMATCH
Definition: include/ert/ecl/fortio.h:38
@ FORTIO_EOF
Definition: include/ert/ecl/fortio.h:34
@ FORTIO_NOENTRY
Definition: include/ert/ecl/fortio.h:33
@ FORTIO_MISSING_TAIL
Definition: include/ert/ecl/fortio.h:37
@ FORTIO_MISSING_DATA
Definition: include/ert/ecl/fortio.h:36
void fortio_rewind(const fortio_type *fortio)
void fortio_complete_write(fortio_type *, int record_size)
long offset_type
Definition: util.h:76