![]() |
Shamrock 2025.10.0
Astrophysical Code
|
Class for reading and writing Fortran-style binary files. More...
#include <shambase/include/shambase/fortran_io.hpp>
Public Types | |
| using | fort_real = f64 |
| Fortran real type. | |
| using | fort_int = int |
| Fortran int type. | |
Public Member Functions | |
| FortranIOFile (std::basic_stringstream< byte > &&data_in, u64 length) | |
| Construct a new FortranIOFile object. | |
| std::basic_stringstream< byte > & | get_internal_buf () |
| Get a reference to the internal buffer. | |
| template<class... Args> | |
| void | write (Args &...args) |
| Write a list of arguments to the internal buffer. | |
| template<class... Args> | |
| void | read (Args &...args) |
| Read a list of arguments from the internal buffer. | |
| void | read_fixed_string (std::string &s, u32 len) |
| Read a fixed-length string from the buffer. | |
| void | write_fixed_string (std::string &s, u32 len) |
| Write a fixed-length string to the buffer. | |
| void | read_string_array (std::vector< std::string > &svec, u32 strlen, u32 str_count) |
| Read a fixed-length string array from the buffer. | |
| void | write_string_array (std::vector< std::string > &svec, u32 strlen, u32 str_count) |
| Write a fixed-length string array to the buffer. | |
| template<class T > | |
| void | read_val_array (std::vector< T > &vec, u32 val_count) |
| Read an array of values from the buffer. | |
| template<class T > | |
| void | write_val_array (std::vector< T > &vec, u32 val_count) |
| Write an array of values to the buffer. | |
| bool | finished_read () |
| Check if the end of the file has been reached. | |
| void | write_to_file (std::string fname) |
| Write the Fortran formatted file to disk. | |
Class for reading and writing Fortran-style binary files.
Definition at line 36 of file fortran_io.hpp.
Fortran int type.
Definition at line 136 of file fortran_io.hpp.
Fortran real type.
Definition at line 133 of file fortran_io.hpp.
|
inlineexplicit |
Construct a new FortranIOFile object.
| [in] | data_in | The input buffer to be used for reading and writing |
| [in] | length | The length of the input buffer |
Definition at line 144 of file fortran_io.hpp.
|
inline |
Check if the end of the file has been reached.
This function returns true if the end of the file has been reached, i.e. if all the data in the file has been read.
Definition at line 369 of file fortran_io.hpp.
|
inline |
Get a reference to the internal buffer.
Definition at line 158 of file fortran_io.hpp.
Read a list of arguments from the internal buffer.
This function reads a list of arguments from the internal buffer using the Fortran-like serialization format. The arguments are serialized in the following way: first the size of all arguments in bytes, then the arguments, and finally again the size of all arguments in bytes.
| Args | the types of the arguments to be read |
| [out] | args | the arguments to be read |
Definition at line 195 of file fortran_io.hpp.
Here is the call graph for this function:Read a fixed-length string from the buffer.
This function reads a fixed-length string from the buffer using the Fortran-like serialization format. The string is serialized in the following way: first the size of the string in bytes, then the string itself, and finally again the size of the string in bytes.
| [out] | s | the string to be read |
| len | the length of the string to be read |
Definition at line 216 of file fortran_io.hpp.
Here is the call graph for this function:
|
inline |
Read a fixed-length string array from the buffer.
This function reads a fixed-length string array from the buffer using the Fortran-like serialization format. The array is serialized in the following way: first the size of the array in bytes, then the array itself, and finally again the size of the array in bytes.
| [out] | svec | the output array of strings |
| [in] | strlen | the length of each string in the array |
| [in] | str_count | the number of strings in the array |
Definition at line 255 of file fortran_io.hpp.
Here is the call graph for this function:
|
inline |
Read an array of values from the buffer.
This function reads an array of values of type T from the buffer using the Fortran-like serialization format. The array is serialized in the following way: first the size of the array in bytes, then the array itself, and finally again the size of the array in bytes.
| T | The type in use |
| [out] | vec | the output array |
| [in] | val_count | the number of values in the array |
Definition at line 312 of file fortran_io.hpp.
Here is the call graph for this function:Write a list of arguments to the internal buffer.
This function writes a list of arguments to the internal buffer using the Fortran-like serialization format. The arguments are serialized in the following way: first the size of all arguments in bytes, then the arguments, and finally again the size of all arguments in bytes. This format is used by the Fortran standard for I/O.
| Args | the types of the arguments to be written |
| [in] | args | the arguments to be written |
Definition at line 176 of file fortran_io.hpp.
Here is the call graph for this function:Write a fixed-length string to the buffer.
This function writes a fixed-length string to the buffer using the Fortran-like serialization format. The string is serialized in the following way: first the size of the string in bytes, then the string itself, and finally again the size of the string in bytes.
| [out] | s | the string to be written |
| [in] | len | the length of the string to be written |
Definition at line 237 of file fortran_io.hpp.
Here is the call graph for this function:
|
inline |
Write a fixed-length string array to the buffer.
This function writes a fixed-length string array to the buffer using the Fortran-like serialization format. The array is serialized in the following way: first the size of the array in bytes, then the array itself, and finally again the size of the array in bytes.
| [in] | svec | the array of strings to write |
| [in] | strlen | the length of each string in the array |
| [in] | str_count | the number of strings in the array |
Definition at line 285 of file fortran_io.hpp.
Here is the call graph for this function:
|
inline |
Write the Fortran formatted file to disk.
| fname | Filename to write to |
| runtime_error | if the file could not be opened for writing |
Definition at line 378 of file fortran_io.hpp.
Here is the call graph for this function:
|
inline |
Write an array of values to the buffer.
This function writes an array of values of type T to the buffer using the Fortran-like serialization format. The array is serialized in the following way: first the size of the array in bytes, then the array itself, and finally again the size of the array in bytes.
| vec | The input array to be written |
| val_count | The number of values in the array |
| std::invalid_argument | if val_count is larger than vec.size() |
Definition at line 346 of file fortran_io.hpp.
Here is the call graph for this function: