Conversation
| "integer(kind=4) :: ii ! Still not good\n", | ||
| "```\n", | ||
| "\n", | ||
| "There is no guarantee that every compiler will use the same kind values for the same variable types.\n", |
There was a problem hiding this comment.
This is a bit overdramatic, kind=4 and kind=8 will be 32 and 64 bit respectively.
| "### newunit\n", | ||
| "\n", | ||
| "Whenever you interact with a file, you need a unit, an integer value that references a specific open file.\n", | ||
| "Some I/O streams, specifically Standard Input, Standard Output, and Standard Error have compiler dependent values for these units, which unfortunately are not standardised.\n", |
There was a problem hiding this comment.
Not sure why you're talking about stdout etc here, but they also have defined constants in iso_fortran_env
| "\n", | ||
| "```fortran\n", | ||
| "program write_stream\n", | ||
| " use iso_fortran_env, only: int16\n", |
There was a problem hiding this comment.
Probably better to use int32, int16 isn't commonly used
| "name": "stdout", | ||
| "output_type": "stream", | ||
| "text": [ | ||
| "00000000 01 00 02 00 03 00 04 00 05 00 06 00 07 00 08 00 |................|\r\n", |
There was a problem hiding this comment.
Might need to explain what we're looking at here, and why 1 is represented as 01 00
| "\n", | ||
| "For an overview of possible data types, see [here](https://docs.scipy.org/doc/numpy/reference/arrays.interface.html#python-side).\n", | ||
| "\n", | ||
| "The integer values are correctly read in, but of course the 'H' and 'e' get mashed into a single integer value of 25928, 'll' becomes 27759, and so forth.\n", |
There was a problem hiding this comment.
If I was unfamiliar with binary files I don't think this would be an 'of course' statement
| "\n", | ||
| "### Python read\n", | ||
| "\n", | ||
| "To read this data in Python, you need to know the data type of the header, almost always an unsigned int, and usually 4 bytes in length:" |
There was a problem hiding this comment.
Can be a 32 or 64 bit value, depending on compiler options. Also be careful about big vs little endian values. It may be useful to write a known header at the start of the file so this can be identified, but then if you're going that in depth you should be using netcdf
| "source": [ | ||
| "## Introduction\n", | ||
| "\n", | ||
| "Fortran is still the go-to language for number crunching." |
There was a problem hiding this comment.
This could perhaps be either expanded or removed entirely
| "```\n", | ||
| "\n", | ||
| "There is no guarantee that every compiler will use the same kind values for the same variable types.\n", | ||
| "If for some reason you can not use `iso_fortran_env`, use the `selected_int_kind` and `selected_real_kind` methods instead:\n", |
There was a problem hiding this comment.
You could explain what the selected_*_kind() intrinsics do
Add a notebook about Fortran Binary Files