Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 9656261

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Implement ModelicaIO_readMatrixSizes.
- Add ModelicaIO_readMatrixSizes as a known external function in EvalFunction. Belonging to [master]: - #2973
1 parent fe78a6d commit 9656261

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

Compiler/NFFrontEnd/NFEvalFunction.mo

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,7 @@ function isKnownLibraryExp
881881
algorithm
882882
isKnown := match exp
883883
case Absyn.STRING("ModelicaExternalC") then true;
884+
case Absyn.STRING("ModelicaIO") then true;
884885
case Absyn.ARRAY() then List.exist(exp.arrayExp, isKnownLibraryExp);
885886
else false;
886887
end match;
@@ -920,6 +921,7 @@ algorithm
920921
Integer i, i2;
921922
Boolean b;
922923
Real r;
924+
Integer dims[2];
923925

924926
case ("ModelicaInternal_countLines", {Expression.STRING(s1)})
925927
then Expression.INTEGER(ModelicaExternalC.Streams_countLines(s1));
@@ -976,6 +978,12 @@ algorithm
976978

977979
case ("OpenModelica_regex", _) then evaluateOpenModelicaRegex(args);
978980

981+
case ("ModelicaIO_readMatrixSizes", {Expression.STRING(s1), Expression.STRING(s2)})
982+
algorithm
983+
dims := ModelicaExternalC.Streams_readMatrixSize(s1, s2);
984+
then
985+
Expression.ARRAY(Type.INTEGER(), {Expression.INTEGER(dims[1]), Expression.INTEGER(dims[2])}, true);
986+
979987
else
980988
algorithm
981989
Error.assertion(false, getInstanceName() + ": failed to evaluate " + name, sourceInfo());

Compiler/Util/ModelicaExternalC.mo

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ function Strings_advanced_scanReal
9595
external "C" ModelicaStrings_scanReal(string,startIndex,unsigned,nextIndex,number) annotation(Library = "ModelicaExternalC");
9696
end Strings_advanced_scanReal;
9797

98-
9998
function Strings_advanced_skipWhiteSpace
10099
input String string;
101100
input Integer startIndex(min = 1) = 1;
@@ -104,5 +103,13 @@ function Strings_advanced_skipWhiteSpace
104103
external "C" nextIndex = ModelicaStrings_skipWhiteSpace(string,startIndex) annotation(Library = "ModelicaExternalC");
105104
end Strings_advanced_skipWhiteSpace;
106105

106+
function Streams_readMatrixSize
107+
input String fileName;
108+
input String matrixName;
109+
output Integer[2] dim;
110+
111+
external "C" ModelicaIO_readMatrixSizes(fileName, matrixName, dim) annotation(Library = {"ModelicaIO", "ModelicaMatIO", "zlib"});
112+
end Streams_readMatrixSize;
113+
107114
annotation(__OpenModelica_Interface="util");
108115
end ModelicaExternalC;

Compiler/boot/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ else
2020
OMENCRYPTIONLIBS=
2121
endif
2222

23-
LDFLAGS=-L. -L$(GEN_DIR) -L"$(OMHOME)/$(LIB_OMC)" $(LOMPARSE) $(LCOMPILERRUNTIME) -lOpenModelicaRuntimeC -lModelicaExternalC -lomantlr3 $(CORBALIBS) $(FMILIB_OR_BOOT) @RT_LDFLAGS@ @LIBSOCKET@ @LIBLPSOLVE55@ @OMC_LIBS@ @GRAPHLIB@ @LD_LAPACK@ -lzmq $(OMENCRYPTIONLIBS)
23+
LDFLAGS=-L. -L$(GEN_DIR) -L"$(OMHOME)/$(LIB_OMC)" $(LOMPARSE) $(LCOMPILERRUNTIME) -lOpenModelicaRuntimeC -lModelicaExternalC -lModelicaIO -lModelicaMatIO -lomantlr3 $(CORBALIBS) $(FMILIB_OR_BOOT) @RT_LDFLAGS@ @LIBSOCKET@ @LIBLPSOLVE55@ @OMC_LIBS@ @GRAPHLIB@ @LD_LAPACK@ -lzmq $(OMENCRYPTIONLIBS)
2424
LDFLAGS_SHARED_MAIN=-L"$(OMHOME)/$(LIB_OMC)" @RT_LDFLAGS_SHARED@
2525
ifeq (@WITH_FMIL@,yes)
2626
FMILIB = -L$(TOP_DIR)/3rdParty/FMIL/install/lib -lfmilib

Compiler/boot/Makefile.omdev.mingw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ OMENCRYPTIONLIBS=
2525
endif
2626
LDFLAGS=-L./ $(LOMPARSE) $(LCOMPILERRUNTIME) -L"$(OMHOME)/lib/omc" \
2727
-lOpenModelicaRuntimeC \
28-
-lModelicaExternalC -lm \
28+
-lModelicaExternalC -lModelicaIO -lModelicaMatIO -lm \
2929
-lomantlr3 -lregex -lwsock32 -llpsolve55 -luuid -lole32 -lws2_32 -limagehlp \
3030
-lRpcrt4 -lopenblas -fopenmp -lomcgc -lpthread $(FMILIB_OR_BOOT) -lshlwapi -liconv -lintl -lmetis \
3131
-Wl,--enable-stdcall-fixup -Bstatic -lstdc++ -Bdynamic -static-libgcc \

0 commit comments

Comments
 (0)