BINASC

Source: [Fortran90 (16Aug18)] [Python (9Dec24)]
10JAN25
Contents

Introduction

BINASC is a Fortran90/Python program to convert RFM output spectra from binary to ASCII (plain text) or vice/versa.

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

gfortran binasc.f90 -o binasc
which will create the executable: binasc

Running BINASC

Fortran: to run the program, type binasc and respond to the prompts.

For example (user input)

binasc Input file: rad_01000.asc Output to file: rad_01000.bin STOP R-BINASC: Successful completion
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)
python3 >>>from binasc import binasc >>>binasc() Input file: rad_01000.asc Output file: (<CR>=rad_01000.bin): <CR> >>>exit()
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).

Version History

09DEC24
Python version
16AUG18
Converted to Fortran90. Adpated for RFM v5 binary files.
04OCT00
Original Fortran77