Opened 6 years ago

Last modified 5 years ago

#5315 new defect

Compiler fails when model has a long fileNamePrefix

Reported by: dariomangoni@… Owned by: Lennart Ochel
Priority: normal Milestone: Future
Component: FMI Version: v1.14.0-dev-nightly
Keywords: fmu Cc:

Description

FMU export (with buildModelFMU) fails when model name is too long.
Error message is not informative at all.

I don't know exactly which is the maximum length.
The problem disappears when the modelname is shortened.

Here is the build output:

Error: Error writing to file AltairVehicleTesting_Vehicles_VehicleFullFialaTyreSplitDriveline.fmutmp/sources/AltairVehicleTesting_Vehicles_VehicleFullFialaTyreSplitDriveline_literals.h.
Error: Error writing to file AltairVehicleTesting_Vehicles_VehicleFullFialaTyreSplitDriveline.fmutmp/sources/AltairVehicleTesting_Vehicles_VehicleFullFialaTyreSplitDriveline_functions.h.
Error: Error writing to file AltairVehicleTesting_Vehicles_VehicleFullFialaTyreSplitDriveline.fmutmp/sources/AltairVehicleTesting_Vehicles_VehicleFullFialaTyreSplitDriveline_functions.c.
Error: Error writing to file AltairVehicleTesting_Vehicles_VehicleFullFialaTyreSplitDriveline.fmutmp/sources/AltairVehicleTesting_Vehicles_VehicleFullFialaTyreSplitDriveline_includes.h.
Error: Error writing to file AltairVehicleTesting_Vehicles_VehicleFullFialaTyreSplitDriveline.fmutmp/sources/AltairVehicleTesting_Vehicles_VehicleFullFialaTyreSplitDriveline_records.c.
Error: Error writing to file AltairVehicleTesting_Vehicles_VehicleFullFialaTyreSplitDriveline.fmutmp/sources/AltairVehicleTesting_Vehicles_VehicleFullFialaTyreSplitDriveline_model.h.
Error: Error writing to file AltairVehicleTesting_Vehicles_VehicleFullFialaTyreSplitDriveline.fmutmp/sources/AltairVehicleTesting_Vehicles_VehicleFullFialaTyreSplitDriveline_01exo.c.
Error: Template error: A template call failed (C:\OpenModelica\bin\omc.exe: [unknown function name]). One possible reason could be that a template imported function call failed (which should not happen for functions called from within template code; templates assert pure 'match'/non-failing semantics).

Change History (8)

comment:1 by dariomangoni@…, 6 years ago

Summary: Export FMU fails when model has a long nameExport FMU fails when model has a long fileNamePrefix

comment:2 by dariomangoni@…, 6 years ago

Summary: Export FMU fails when model has a long fileNamePrefixCompiler fails when model has a long fileNamePrefix

The problem affects not only FMUs export but also normal compilation

comment:3 by Adrian Pop, 6 years ago

This problem has no easy solution. Maybe we could support windows long paths in OMEdit and OMC but gcc doesn't like them so we could generate the files but not compile them.

I guess we could detect if the paths are too long and propose the user the solution to have a short name top level model that extends the long model path which should work fine.

comment:4 by Martin Sjölund, 6 years ago

Why propose to extend a long model when you could just use fileNamePrefix="M"? We could just check for long paths and shorten them automatically (if fileNamePrefix is unset).

But the maximum length of a path depends on the working directory path, right?

comment:5 by dariomangoni@…, 6 years ago

buildModel, as well as buildModelFMU, accepts both className and fileNamePrefix arguments.
Neither in className nor in fileNamePrefix you have to put the working directory path.
The className argument, in fact, requires your model name, that is longer the more your model is nested into parent classes.

So, @sjoelund.se, can you extend more on what you mean by

the maximum length of a path depends on the working directory path

I restate the problem: suppose you have loaded a library with LoadFile("myLibrary/package.mo")
and you want to run a model that is under myLibrary > myPackage1 > myModel1 > myModel2 > myModelN
then you have to call buildModel(myLibrary.myPackage1.myModel1.myModel2.myModelN)
thus incurring in the problem.

The problem here is with className not accepting long strings. You can handle the problem either:

  1. handling long className strings (without any shortening), without forcing the user to give a short version in fileNamePrefix;
  2. force the user to provide a short fileNamePrefix BUT in this case the compiler should through a meaningful output, because the error that is reported by the compiler does not give any hint on this!
  3. automatically provide a fileNamePrefix, that is taken from an automatic shortening of className argument

However, I'm not a big fan of 3: when the className becomes long not because it is nested, but just because you just have a crazy user that gives long class names, how can you cut the name?
E.g. iamacrazyuserandilovelongclassnames
how and where is best to cut this? :-)

If 1 is too difficult, I would definitely vote for 2!

comment:6 by Martin Sjölund, 6 years ago

For 3, you just use XXXXXX and let tmpnam or something generate a path. The main problem with that is that it's very bad for mos-scripts as the name might not be the expected one (that works on Linux).

comment:7 by dariomangoni@…, 6 years ago

Ok, calling everything 'path' is somehow confusing, but I got the point.

The idea of temporary names could work fine for everyday compilation in which OMEdit automatically takes care of the compilation and simulation without anyuser intervention.

However, I would not like to have an FMU whose name is completely random.
I would not like to link to asdqwleuhalsdjf.dll when my model is called myVeryNiceModelName

comment:8 by anonymous, 5 years ago

a workaround that worked for me was to 'extend' the model with the long name in a new model with a short name

Note: See TracTickets for help on using tickets.