BINASC |
|
|
| Source: [Fortran90 (16Aug18)] [Python (9Dec24)] | 10JAN25 | |
The Fortran version relies on the input filename containing a string .bin or .asc to identify the type of input file, which is then switched to form the name of the output file.
The Python version is a bit more flexible, but also more fragile —
Fortran and Python don't play nicely when it comes to binary files.
Installing BINASC
Download the source code: [binasc.f90]
or [binasc.py]
For the Fortran version, compile with any generic Fortran compiler, eg
which will create the executable: binascgfortran binasc.f90 -o binasc
For example
(
Python: the code is a function which can be run interactively or incorporated into another code. Arguments are optional (see [code header] for details). Running interactively from within the Python environment (<CR> indicates pressing the Enter/Return key)binasc Input file:rad_01000.asc Output to file: rad_01000.bin STOP R-BINASC: Successful completion
In this case the Python code has verified that the input file (rad_01000.asc) is an ASCII file, so assumed that the conversion will be to a binary file. It has also detected the .asc string in the filename so sets a default output filename with this part switched to .bin (the reverse also applies had the input filename been rad_01000.bin).python3 >>>from binasc import binasc >>>binasc() Input file:rad_01000.asc Output file: (<CR>=rad_01000.bin):<CR> >>>exit()