version

version

Information

This information is part of the Modelica Standard Library maintained by the Modelica Association.

Define version information of package

Examples

package Modelica
  annotation(version="2.1",
             conversion(noneFromVersion="2.1 Beta 1",
                        from(version="1.5",
                             script="convertFromModelica1_5.mos")));
  ...
end Modelica;

model A
  annotation(version="1.0",
     uses(Modelica(version="1.5")));
  ...
end A;

model B
  annotation(uses(Modelica(version="2.1 Beta 1")));
  ...
end B;

In this example the model A uses an older version of the Modelica library and can be upgraded using the given script, and model B uses an older version of the Modelica library but no changes are required when upgrading.

Description

Version numbers are of the forms:

  • Main release versions:
    """ UNSIGNED_INTEGER { "." UNSIGNED_INTEGER } """
    Example: "2.1"
     
  • Pre-release versions:
    """ UNSIGNED_INTEGER { "." UNSIGNED_INTEGER } " " {S-CHAR} """
    Example: "2.1 Beta 1"
     
  • Un-ordered versions:
     """ NON-DIGIT {S-CHAR} """ 
    Example: "Test 1"

The main release versions are ordered using the hierarchical numerical names, and follow the corresponding pre-release versions. The pre-release versions of the same main release version are internally ordered alphabetically.

In a top-level class, the version number and the dependency to earlier versions of this class are defined using one or more of the following annotations:

  • version = CURRENT-VERSION-NUMBER
    Defines the version number of the model or package. All classes within this top-level class have this version number.
     
  • conversion ( noneFromVersion = VERSION-NUMBER)
    Defines that user models using the VERSION-NUMBER can be upgraded to the CURRENT-VERSION-NUMBER of the current class without any changes.
     
  • conversion ( from (version = VERSION-NUMBER, script = "?") )
    Defines that user models using the VERSION-NUMBER can be upgraded to the CURRENT-VERSION-NUMBER of the current class by applying the given script. The semantics of the conversion script is not defined.
     
  • uses(IDENT (version = VERSION-NUMBER) )
    Defines that classes within this top-level class uses version VERSION-NUMBER of classes within the top-level class IDENT. The annotations uses and conversion may contain several different sub-entries.

A top-level class, IDENT, with version VERSION-NUMBER can be stored in one of the following ways in a directory given in the MODELICAPATH:

  • The file IDENT ".mo"
    Example: Modelica.mo
  • The file IDENT " " VERSION-NUMBER ".mo"
    Example: Modelica 2.1.mo
  • The directory IDENT
    Example: Modelica
  • The directory IDENT " " VERSION-NUMBER
    Example: Modelica 2.1

This allows a tool to access multiple versions of the same package.

Related annotations: