Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Revision history [back]

Problem with compiling FMU using BuildingsLibrary ReaderTMY3 in JModelica

I'm trying to compile and simulate a Modelica model that I've tested in Dymola using JModelica. The model uses the ReaderTMY3 component from the Modelica Buildings Library to read in weather data. The model simulates as expected in Dymola, but when I try to compile to an FMU in JModelica, I get the warning or error message below regarding the ReaderTMY3 finding an empty string for the latitude and time zone.

The latitude and time zone are present in the header of the .mos weather file, in the expected positions. Here is the relevant line of the .mos weather file (#LOCATION,Denver Centennial Golden Nr,CO,USA,TMY3,724666,39.74,-105.18,-7.0,1829.0). (I also tried omitting the spaces in the location name, and got the same messages.)

Does anyone have advice on how to resolve this? Thanks very much.

function Buildings.BoundaryConditions.WeatherData.BaseClasses.getLatitudeTMY3 input String filNam; output Real lat; Integer nexInd; String element; algorithm element := Buildings.BoundaryConditions.WeatherData.BaseClasses.getHeaderElementTMY3(filNam, "#LOCATION", "longitude", 7); (nexInd, lat) := Modelica.Utilities.Strings.Advanced.scanReal(element, 1, false); assert(nexInd > 1, "Error when converting the latitude '" + element + "' from a String to a Real."); lat := lat * 3.141592653589793 / 180; assert(abs(lat) <= 3.141592653589793 + 1.0E-15, "Wrong value for latitude. Received lat = " + String(lat) + " (= " + String(lat * 180 / 3.141592653589793) + " degrees)."); return; end Buildings.BoundaryConditions.WeatherData.BaseClasses.getLatitudeTMY3;

function Buildings.BoundaryConditions.WeatherData.BaseClasses.getTimeZoneTMY3 input String filNam; output Real timZon; Integer nexInd; String element; algorithm element := Buildings.BoundaryConditions.WeatherData.BaseClasses.getHeaderElementTMY3(filNam, "#LOCATION", "longitude", 9); (nexInd, timZon) := Modelica.Utilities.Strings.Advanced.scanReal(element, 1, false); assert(nexInd > 1, "Error when converting the time zone '" + element + "' from a String to a Real."); timZon := timZon * 3600; assert(abs(timZon) < 24 * 3600, "Wrong value for time zone. Received timZon = " + String(timZon) + " (= " + String(timZon / 3600) + " hours)."); return; end Buildings.BoundaryConditions.WeatherData.BaseClasses.getTimeZoneTMY3;