Bladed Knowledge Base

Converting ASCII outputs to binary
Category: Automation

Problem

It is tricky to understand the format and sequencing of Bladed binary output files. A simple worked example may help. (Also there are some cases where Bladed's built-in "Copy Results" converter does not work).

Solution

This example is a 2-D mooring table; other Bladed outputs are analogous.

Here's the entire contents of the header file, which is the .%01 file and is always an ASCII file, not binary.

FILE    Original_mooring.$01
ACCESS    D
FORM    F
RECL    8
FORMAT    R*8
CONTENT    'MooringStiffness'
CONFIG    ''
NDIMENS    3
DIMENS    7    3    3
GENLAB    'MooringStiffness'
VARIAB    'Force in X direction' 'Force in Z direction' 'Joint_0_angle' 'Joint_1_angle' 'Joint_2_angle' 'Joint_3_angle' 'Joint_4_angle'
VARUNIT    F F A A A A A
AXISLAB    'X displ'
AXIUNIT    L
AXIMETH    3
AXIVAL    -2.0000000 0.0000000 2.0000000
AXISLAB    'Z displ'
AXIUNIT    L
AXIMETH    3
AXIVAL    -3.0000000 -1.0000000 1.0000000
NVARS    0

So here you have 7 dependent variables (listed in VARIAB), and 2 independent variables: 'X displ' and 'Z displ'. "DIMENS   7    3    3" means 7 dependent variables, plus 3 different values of X displacement, and also 3 different values of Z displacement. 

The major index (i.e. the variable that changes "most slowly"), is the point ('Z displ'), followed by the first independent variable ('X displ'), and then the dependent variable. Dependent variables are referred to below as "series" (s0, s1, s2, s3, s4, s5, s6.)

E.g. with DIMENS 2 3 4 we would have 2 series instead of 7, for simplicity, and the entire .$01 file would consist of 2x3x4 = 24 entries, as follows:

z0_x0_s0             z0_x0_s1             z0_x1_s0             z0_x1_s1             z0_x2_s0             z0_x2_s1

z1_x0_s0             z1_x0_s1             z1_x1_s0             z1_x1_s1             z1_x2_s0             z1_x2_s1

z2_x0_s0             z2_x0_s1             z2_x1_s0             z2_x1_s1             z2_x2_s0             z2_x2_s1

z3_x0_s0             z3_x0_s1             z3_x1_s0             z3_x1_s1             z3_x2_s0             z3_x2_s1

The sequence of variables is in normal reading order, i.e. one line at a time, reading left to right. Tabs and line breaks added for illustration. So in reality the binary file would not have any of this "punctuation", it would just be "z0x0s0z0x0s1z0x1s0...." and so on.

The solution is very basic with some hard-coded dimensions, it's meant as only a starting point - the main thing it does is illustrate the correct ordering of output values in binary files. Here is the temporary download package  containing

- A C++ Visual Studio solution that reads in the example ASCII $01 test file and writes out a binary equivalent

- The executable (in debug version) which can be run directly to test the function.

- The test file itself (test1_ASCII.$01) - expected to be in C:\Temp.

- The header file (test1_binary.%01) which is human-readable and defines the format.





Keywords Outputs; output files; binary; ASCII; format; convert; conversion