Simulink wont run 2nd time round

Hi

I have recently upgraded from a windows XP (32bit) to windows 7 (64bit) machine (and 32bit matlab to 64 bit matlab, Version 8.0 (R2012b)).

I have managed to port my old simulink control program across, but it wasn’t happy. After a little rummaging around, I downloaded FAST_SFunc.mexw64, FAST_v7.02.00d-bjj from the link in a post from Bonnie, but I cannot find it anymore.

My simulation now runs happily for the first time that it is loaded, but if I try to run it after it is allowed to complete, or I choose to stop it, I receive this message in simulink:

Output returned by S-function ‘FAST_SFunc’ in ‘VSPR/FAST Nonlinear Wind Turbine/S-Function’ during flag=3 call must be a real vector of length 82.

I have 82 outputs. I have tried a clc, clear all in the matlab command window. If I close matlab and simulink and reopen them, it works again, but only once before the above error.

The Matlab command window looks the same for both happy and crashing runs:

   -------------------------------------------------
   Enter the name of the FAST input file to read    
   -------------------------------------------------

input_fast =

C:\WTG_Sim\LRProjects\SampleController\Trunk\src\FASTInterface\Upwind5MW.fst


  Running NWTC Subroutine Library (v1.07.02a-mlb, 21-May-2013).

  Running FAST (v7.02.00d-bjj, 20-Feb-2013)-Compiled as S-Function for Simulink.

  Heading of the FAST input file: NREL 5.0 MW Baseline Wind Turbine for Use in Offshore Analysis.

  Running NWTC Subroutine Library (v1.07.02a-mlb, 21-May-2013).

  Running AeroDyn (v13.00.02a-bjj, 20-Feb-2013).
  Heading of the AeroDyn input file: NREL 5.0 MW offshore baseline aerodynamic input properties;
  Compatible with AeroDyn v12.58.

  Running NWTC Subroutine Library (v1.07.02a-mlb, 21-May-2013).

  Using InflowWind (v1.02.00c-bjj, 23-Apr-2013)

  Assuming C:\WTG_Sim\LRProjects\SampleController\Trunk\src\FASTInterface\test_9ms.bts is a binary
  FF wind file.

  Running NWTC Subroutine Library (v1.07.02a-mlb, 21-May-2013).

  Reading a 13x13 grid (130 m wide, 25.221 m to 155.22 m above ground) with a characterstic wind
  speed of 9 m/s. This full-field file was generated by TurbSim (v1.50, 25-Sep-2009) on
  24-Apr-2013 at 14:34:59.
  Processed 12489 time steps of 20-Hz full-field data (624.4 seconds).

  FAST_SFunc initialized with 55 inputs and 82 outputs.
  FAST_SFunc completed.


  Total Real Time:       1.7819 minutes
  Total CPU Time:        1.7384 minutes
  Simulated Time:        10 minutes
  Time Ratio (Sim/CPU):  5.7525

If I figure it out, I’ll post the fix. If other people are finding the same thing or have any ideas, I’d appreciate them.

Thanks

Alec

Hi, Alec.

I think I’ve encountered that Simulink error before, but I can’t recall what it ended up being. Here are some things to check:

[]Does Simulink_CertTest.m (in the FAST/CertTest folder) run?[/]
[]Are you using the correct Read_FAST_Input.m file? If you’ve got an input file for FAST v7.02.x, you’ll need a different version of Read_FAST_Input.m than for FAST v7.01.x. (The first few unlucky people who downloaded FAST v7.02.x may have the wrong version of this file.)[/]

Theoretically, Simulink should call FAST_SFunc with flag=0 for initialization (when it writes “FAST_SFunc initialized…”), then call it with flag=3 for each step of the simulation, then call it with flag=9 for termination (when it writes “FAST_SFunc completed”). The error message makes me wonder if the initialization isn’t getting done the second time… or if somehow the output vector from the Fortran code is a different size than the vector of outputs from the Matlab side… but it’s hard to tell.

Thanks Bonnie

I’ve tried a few things.

I did upgrade to 7.02 and hadn’t added OutFileFmt to the ReadFastInput. I fixed that and it didn’t make any difference. I found a few other bugs, which also didn’t make any difference.

I have found that pressing the Step Forward button for the first few simulation iterations and then pressing the Run button allows the simulation to run, whereas just pressing the Run button results in the same warning:

Sigh. :unamused: