Problem reading binary output file

Dear all,

After running a simulation with OpenFAST, I tried to read the binary output file I had requested. To do that, I used the function readFASTbinary provided in the Matlab toolbox. However, I got an error. To check if it was the file I had obtained, I checked the function with one of the .outb files provided: ‘5MW_Land_BD_DLL_WTurb.outb’. The problem appeared again: “Could not read entire 5MW_Land_BD_DLL_WTurb.outb file: read 0 of 1260063 values”.

I checked the code on the function line by line and at first it appeared to run correctly, since I obtained the FIleID, number of channels and of time steps, and the first time and time increment. However, after getting the channel slopes and offsets, I couldn’t get the description, units nor names of the channels. I checked with Python and noticed that ‘LenDesc’ should be read right after ‘TimeIncr’ since the description starts a few positions after. I tried on Matlab skipping ‘ColScl’ and ‘ColOff’ and I managed to get the description, units and channel names. The rest of the function didn’t work.

In summary, with this code the function didn’t work:

[code]
FileID = fread( fid, 1, ‘int16’,machinefmt); % FAST output file format, INT(2)

NumOutChans  = fread( fid, 1, 'int32',machinefmt);             % The number of output channels, INT(4)
NT           = fread( fid, 1, 'int32',machinefmt);             % The number of time steps, INT(4)

if FileID == FileFmtID.WithTime
    TimeScl  = fread( fid, 1, 'float64',machinefmt);           % The time slopes for scaling, REAL(8)
    TimeOff  = fread( fid, 1, 'float64',machinefmt);           % The time offsets for scaling, REAL(8)
else
    TimeOut1 = fread( fid, 1, 'float64',machinefmt);           % The first time in the time series, REAL(8)
    TimeIncr = fread( fid, 1, 'float64',machinefmt);           % The time increment, REAL(8)
end

ColScl       = fread( fid, NumOutChans, 'float32',machinefmt); % The channel slopes for scaling, REAL(4)
ColOff       = fread( fid, NumOutChans, 'float32',machinefmt); % The channel offsets for scaling, REAL(4)

LenDesc      = fread( fid, 1,           'int32',machinefmt );  % The number of characters in the description string, INT(4)
DescStrASCII = fread( fid, LenDesc,     'uint8',machinefmt );  % DescStr converted to ASCII
DescStr      = char( DescStrASCII' );                     

if FileID == FileFmtID.ChanLen
    LenName = 15;
    LenUnit = LenName;
end

ChanName = cell(NumOutChans+1,1);                   % initialize the ChanName cell array
for iChan = 1:NumOutChans+1 
    ChanNameASCII = fread( fid, LenName, 'uint8',machinefmt ); % ChanName converted to numeric ASCII
    ChanName{iChan}= strtrim( char(ChanNameASCII') );
end

ChanUnit = cell(NumOutChans+1,1);                   % initialize the ChanUnit cell array
for iChan = 1:NumOutChans+1
    ChanUnitASCII = fread( fid, LenUnit, 'uint8',machinefmt ); % ChanUnit converted to numeric ASCII
    ChanUnit{iChan}= strtrim( char(ChanUnitASCII') );
end
[/code]

I couldn’t even get the description of the file. Just by skipping reading ‘ColScl’ and ‘ColOff’, I got the description, units and channels.

Has something changed in the structure of the binary output files? Is the function wrong? Or am I doing something wrong?

Thank you,

Rubén González

Dear Ruben,

Are you outputting the binary file with OutFileFmt=2? The readFASTbinary script provided in the MATLAB Toolbox should be able to read this file type without problem.

In OpenFAST, a different binary file type is available by specifying OutFileFmt=0. This is really an undocumented feature for use in the regression tests (r-tests). I can see the readFASTbinary script having trouble reading this type of binary output file.

Best regards,

Dear Jason,

That was exactly the problem, I didn’t check properly the ‘.fst’ file. It works completely fine now. I will be much cautious the next time.

Thank you very much for your attention and the prompt answer.

Best regards,

Rubén González

Dear Rubén,

I’m glad that solved the problem. I’ve now raised this issue on OpenFAST: github.com/OpenFAST/openfast/issues/331.

Best regards,

Dear all,

I’m having some problems trying to run MLife with .outb files. Let me share with you the debugging process I have been following.

I’m doing big sets of simulations, so I’m using the binary output format to save space. These files are created in batch mode with the OutFileFmt=2. To check the results, I’m using the readFASTbinary.m function from the Matlab toolbox. I have checked many .outb files, and everything is working fine.

I’m using MLife with an exact input file that worked well with ASCII output files. I am changing the FileFormat to 2 (FAST binary), but I get this error:

Error using fread
Invalid size.

Error in ReadFASTbinary (line 42)
    DescStrASCII = fread( fid, LenDesc,     'uint8' );  % DescStr converted to ASCII
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in load_file_header (line 36)
      [~, cellNames, cellUnits, ~] = ReadFASTbinary(fileName);
                                     ^^^^^^^^^^^^^^^^^^^^^^^^
Error in process_mlife_inputs (line 169)
      [names, units] = load_file_header(FileInfo.FileName{1}, FileInfo.FileFormat, FileInfo.NamesLine, FileInfo.UnitsLine, ...
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in mlife (line 275)
   [FileInfo, Statistics, Fatigue] = process_mlife_inputs(FileInfo, Statistics, Fatigue, dataDirectory);
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in MLife_template (line 9)
[Fatigue, Statistics] = mlife(settingsFile, dataDirectory, outputDirectory);
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

As it calls the error on the readFASTbinary file of the MLife directory, I tried to change it to the one that comes in the Matlab toolbox. It resulted in MLife going a “step forward” but still having an error.


Error using process_mlife_inputs (line 190)
  For fatigue channel #1, the channel number must be between 1 and 4 (inclusive).

Error in mlife (line 275)
   [FileInfo, Statistics, Fatigue] = process_mlife_inputs(FileInfo, Statistics, Fatigue, dataDirectory);
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in MLife_template (line 9)
[Fatigue, Statistics] = mlife(settingsFile, dataDirectory, outputDirectory);
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

To solve this error, I changed the numbers of my channels (81 and 82, to calculate tower base moments) to 3 and 4. With this change I could make MLife finish processing my .outb file. To be sure it wasn’t a problem from my .outb files. I repeated this process with different files, always getting the same result.

At this point I was starting to think that there was something wrong with the readFASTBinary from MLife. To be sure of this, I created a copy of the Matlab toolbox only changing this file (swapping the runFASTbinary of the matlab toolbox with the readFASTbinary from the MLife directory). I ran the same .outb files with this new toolbox, and an error happened.


Error using fread
Invalid size.

Error in ReadFASTbinary (line 42)
    DescStrASCII = fread( fid, LenDesc,     'uint8' );  % DescStr converted to ASCII
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in mark1 (line 8)
[Channels, ChannelNames, ChannelUnits] = ReadFASTbinary(FileName);
                                         ^^^^^^^^^^^^^^^^^^^^^^^^

With this I finished my debugging process.
What is your opinion, could there be a problem with the readFASTbinary function from MLife?
Could anyone try to replicate this with an .outb file?

Best regards,