@@ -633,8 +633,7 @@ template simulationFile_exo(SimCode simCode)
633633 <% functionCallExternalObjectDestructors(extObjInfo, modelNamePrefix(simCode))%>
634634 #if defined(__cplusplus)
635635 }
636- #endif
637- <%\n%>
636+ #endif<%\n%>
638637 >>
639638 /* adrpo: leave a newline at the end of file to get rid of the warning */
640639 end match
@@ -660,8 +659,7 @@ template simulationFile_nls(SimCode simCode)
660659
661660 #if defined(__cplusplus)
662661 }
663- #endif
664- <%\n%>
662+ #endif<%\n%>
665663 >>
666664 /* adrpo: leave a newline at the end of file to get rid of the warning */
667665 end match
@@ -687,8 +685,7 @@ template simulationFile_lsy(SimCode simCode)
687685
688686 #if defined(__cplusplus)
689687 }
690- #endif
691- <%\n%>
688+ #endif<%\n%>
692689 >>
693690 /* adrpo: leave a newline at the end of file to get rid of the warning */
694691 end match
@@ -711,8 +708,7 @@ template simulationFile_set(SimCode simCode)
711708
712709 #if defined(__cplusplus)
713710 }
714- #endif
715- <%\n%>
711+ #endif<%\n%>
716712 >>
717713 /* adrpo: leave a newline at the end of file to get rid of the warning */
718714 end match
@@ -738,8 +734,7 @@ template simulationFile_evt(SimCode simCode)
738734
739735 #if defined(__cplusplus)
740736 }
741- #endif
742- <%\n%>
737+ #endif<%\n%>
743738 >>
744739 /* adrpo: leave a newline at the end of file to get rid of the warning */
745740 end match
@@ -768,8 +763,7 @@ template simulationFile_inz(SimCode simCode)
768763
769764 #if defined(__cplusplus)
770765 }
771- #endif
772- <%\n%>
766+ #endif<%\n%>
773767 >>
774768 /* adrpo: leave a newline at the end of file to get rid of the warning */
775769 end match
@@ -791,8 +785,7 @@ template simulationFile_dly(SimCode simCode)
791785
792786 #if defined(__cplusplus)
793787 }
794- #endif
795- <%\n%>
788+ #endif<%\n%>
796789 >>
797790 /* adrpo: leave a newline at the end of file to get rid of the warning */
798791 end match
@@ -816,8 +809,7 @@ template simulationFile_spd(SimCode simCode)
816809
817810 #if defined(__cplusplus)
818811 }
819- #endif
820- <%\n%>
812+ #endif<%\n%>
821813 >>
822814 /* adrpo: leave a newline at the end of file to get rid of the warning */
823815 end match
@@ -841,8 +833,7 @@ template simulationFile_bnd(SimCode simCode)
841833
842834 #if defined(__cplusplus)
843835 }
844- #endif
845- <%\n%>
836+ #endif<%\n%>
846837 >>
847838 /* adrpo: leave a newline at the end of file to get rid of the warning */
848839 end match
@@ -887,8 +878,7 @@ template simulationFile_asr(SimCode simCode)
887878
888879 #if defined(__cplusplus)
889880 }
890- #endif
891- <%\n%>
881+ #endif<%\n%>
892882 >>
893883 /* adrpo: leave a newline at the end of file to get rid of the warning */
894884 end match
@@ -904,9 +894,7 @@ template simulationFile_mix(SimCode simCode, Text &header)
904894 /* Mixed Systems */
905895 <%simulationFileHeader(simCode.fileNamePrefix)%>
906896 #include "<%simCode.fileNamePrefix%>_11mix.h"
907- <%functionSetupMixedSystems(initialEquations, initialEquations_lambda0, parameterEquations, allEquations, jacobianMatrices, &header, modelNamePrefixStr)%>
908-
909- <%\n%>
897+ <%functionSetupMixedSystems(initialEquations, initialEquations_lambda0, parameterEquations, allEquations, jacobianMatrices, &header, modelNamePrefixStr)%><%\n%>
910898 >>
911899 /* adrpo: leave a newline at the end of file to get rid of the warning */
912900 end match
@@ -923,9 +911,7 @@ template simulationFile_jac(SimCode simCode)
923911 #include "<%fileNamePrefix%>_12jac.h"
924912 #include "simulation/jacobian_util.h"
925913 #include "util/omc_file.h"
926- <%functionAnalyticJacobians(jacobianMatrices, modelNamePrefix(simCode), simCode.fileNamePrefix)%>
927-
928- <%\n%>
914+ <%functionAnalyticJacobians(jacobianMatrices, modelNamePrefix(simCode), simCode.fileNamePrefix)%><%\n%>
929915 >>
930916 /* adrpo: leave a newline at the end of file to get rid of the warning */
931917 end match
@@ -940,8 +926,7 @@ template simulationFile_jac_header(SimCode simCode)
940926 /* Jacobians */
941927 static const REAL_ATTRIBUTE dummyREAL_ATTRIBUTE = omc_dummyRealAttribute;
942928
943- <%symJacDefinition(jacobianMatrices, modelNamePrefix(simCode))%>
944- <%\n%>
929+ <%symJacDefinition(jacobianMatrices, modelNamePrefix(simCode))%><%\n%>
945930 >>
946931 /* adrpo: leave a newline at the end of file to get rid of the warning */
947932 end match
@@ -963,7 +948,7 @@ template simulationFile_opt(SimCode simCode)
963948 <% optimizationComponents(classAttributes, simCode, modelNamePrefixStr)%>
964949 #if defined(__cplusplus)
965950 }
966- #endif
951+ #endif<%\n%>
967952 >>
968953 /* adrpo: leave a newline at the end of file to get rid of the warning */
969954 end match
@@ -987,7 +972,7 @@ template simulationFile_opt_header(SimCode simCode)
987972 int <% symbolName(modelNamePrefixStr," getTimeGrid" )%> (DATA *data, modelica_integer * nsi, modelica_real**t);
988973 #if defined(__cplusplus)
989974 }
990- #endif
975+ #endif<%\n%>
991976 >>
992977 /* adrpo: leave a newline at the end of file to get rid of the warning */
993978 end match
@@ -1032,8 +1017,7 @@ template simulationFile_lnz(SimCode simCode)
10321017 %>
10331018 #if defined(__cplusplus)
10341019 }
1035- #endif
1036- <%\n%>
1020+ #endif<%\n%>
10371021 >>
10381022 /* adrpo: leave a newline at the end of file to get rid of the warning */
10391023 end match
@@ -1077,15 +1061,14 @@ template simulationFile_dae_header(SimCode simCode)
10771061 /* auxiliary variable define for daeMode */
10781062 <%auxiliaryVars |> var =>
10791063 defineSimVarArray(var, "auxiliaryVars")
1080- ;separator="\n"%>
1064+ ;separator="\n"%><%\n%>
10811065 >>
10821066 /* adrpo: leave a newline at the end of file to get rid of the warning */
10831067 case simCode as SIMCODE(__) then
10841068 <<
10851069 #ifndef <%fileNamePrefix%>_16DAE_H
10861070 #define <%fileNamePrefix%>_16DAE_H
1087- #endif
1088- <%\n%>
1071+ #endif<%\n%>
10891072 >>
10901073 end match
10911074end simulationFile_dae_header;
@@ -5654,15 +5637,15 @@ template genVector(String name, String num, Integer numI, Integer flag) "templat
56545637 end match
56555638end genVector;
56565639
5657- template functionAnalyticJacobians(list<JacobianMatrix > JacobianMatrices,String modelNamePrefix, String fileNamePrefix) "template functionAnalyticJacobians
5640+ template functionAnalyticJacobians(list<JacobianMatrix > JacobianMatrices, String modelNamePrefix, String fileNamePrefix) "template functionAnalyticJacobians
56585641 This template generates source code for all given jacobians."
56595642::=
5660- let initialjacMats = (JacobianMatrices |> JAC_MATRIX(columns=mat, seedVars=vars, matrixName=name, sparsity=sparsepattern, coloredCols=colorList, maxColorCols=maxColor ) =>
5661- initialAnalyticJacobians(mat, vars, name, sparsepattern, colorList, maxColor , modelNamePrefix, fileNamePrefix); separator="\n")
5662- let jacMats = (JacobianMatrices |> JAC_MATRIX(columns=mat, seedVars=vars, matrixName=name, partitionIndex=partIdx, crefsHT=crefsHT ) =>
5663- generateMatrix(mat, vars, name, partIdx , crefsHT, modelNamePrefix) ;separator="\n")
5664- let jacGenericCalls = (JacobianMatrices |> jac as JAC_MATRIX() => genericCallBodies(jac.generic_loop_calls, createJacContext(jac.crefsHT)) ;separator="\n")
5665-
5643+ let initialjacMats = (JacobianMatrices |> JAC_MATRIX() =>
5644+ initialAnalyticJacobians(columns, seedVars, matrixName, sparsity, coloredCols, maxColorCols , modelNamePrefix, fileNamePrefix); separator="\n")
5645+ let jacMats = (JacobianMatrices |> JAC_MATRIX() =>
5646+ generateMatrix(columns, seedVars, matrixName, partitionIndex , crefsHT, modelNamePrefix) ;separator="\n")
5647+ let jacGenericCalls = (JacobianMatrices |> JAC_MATRIX() =>
5648+ genericCallBodies(generic_loop_calls, createJacContext(crefsHT)) ;separator="\n")
56665649 <<
56675650 <%jacMats%>
56685651
@@ -5683,21 +5666,18 @@ match sparsepattern
56835666 int <%symbolName(modelNamePrefix,"initialAnalyticJacobian")%><%matrixname%>(DATA* data, threadData_t *threadData, JACOBIAN *jacobian)
56845667 {
56855668 TRACE_PUSH
5686- TRACE_POP
56875669 jacobian-> availability = JACOBIAN_NOT_AVAILABLE;
5670+ TRACE_POP
56885671 return 1;
56895672 }
56905673 >>
56915674 case _ then
5692- let &eachCrefParts = buffer ""
5693- let sp_size_index = lengthListElements(unzipSecond(sparsepattern))
5675+ let sp_size_index = lengthListElements(unzipSecond(sparsepattern))
56945676 let sizeleadindex = listLength(sparsepattern)
5695- let fileName = '<%fileNamePrefix%>_Jac<%matrixname%>.bin'
5696- let colorString = readSPColors(colorList, "jacobian->sparsePattern->colorCols", sizeleadindex)
56975677 let availability = if SimCodeUtil.jacobianColumnsAreEmpty(jacobianColumn) then 'JACOBIAN_ONLY_SPARSITY' else 'JACOBIAN_AVAILABLE'
5698- let sizeRows = (jacobianColumn |> JAC_COLUMN(numberOfResultVars=nRows ) => '<%nRows%>'; separator="\n")
5699- let tmpvarsSize = (jacobianColumn |> JAC_COLUMN(columnVars=vars ) => listLength(vars); separator="\n")
5700- let constantEqns = (jacobianColumn |> JAC_COLUMN(constantEqns=constantEqns ) =>
5678+ let sizeRows = (jacobianColumn |> JAC_COLUMN() => numberOfResultVars; separator="\n")
5679+ let tmpvarsSize = (jacobianColumn |> JAC_COLUMN() => listLength(columnVars); separator="\n")
5680+ let constantEqns = (jacobianColumn |> JAC_COLUMN() =>
57015681 match constantEqns case { } then 'NULL' case _ then '<%symbolName(modelNamePrefix,"functionJac")%><%matrixname%>_constantEqns'
57025682 ;separator="")
57035683 let evalColumn = '<%symbolName(modelNamePrefix,"functionJac")%><%matrixname%>_column'
@@ -5709,7 +5689,7 @@ match sparsepattern
57095689 TRACE_PUSH
57105690 size_t count;
57115691
5712- FILE* pFile = openSparsePatternFile(data, threadData, " <%fileName%> " );
5692+ FILE* pFile = openSparsePatternFile(data, threadData, " <%fileNamePrefix%>_Jac<%matrixname%>.bin " );
57135693
57145694 initJacobian(jacobian, <% sizeCols%> , <% sizeRows%> , <% tmpvarsSize%> , <% evalColumn%> , <% constantEqns%> , NULL);
57155695 jacobian-> sparsePattern = allocSparsePattern(<% sizeleadindex%> , <% sp_size_index%> , <% maxColor%> );
@@ -5728,7 +5708,7 @@ match sparsepattern
57285708 }
57295709
57305710 /* write color array */
5731- <%colorString %>
5711+ <%readSPColors(colorList, "jacobian->sparsePattern->colorCols", sizeleadindex) %>
57325712
57335713 omc_fclose(pFile);
57345714
@@ -5801,7 +5781,6 @@ template functionJac(list<SimEqSystem> jacEquations, list<SimEqSystem> constantE
58015781 "This template generates functions for each column of a single jacobian.
58025782 This is a helper of generateMatrix."
58035783::=
5804- let constantEqns2 = generateConstantEqns(constantEqns, matrixName, modelNamePrefix)
58055784 <<
58065785 /* constant equations */
58075786 <%(constantEqns |> eq hasindex sub_idx =>
@@ -5810,7 +5789,7 @@ template functionJac(list<SimEqSystem> jacEquations, list<SimEqSystem> constantE
58105789 <%(jacEquations |> eq hasindex sub_idx =>
58115790 equation_impl(base_idx, sub_idx, eq, createJacContext(jacHT), modelNamePrefix, false); separator="\n")%>
58125791
5813- <%constantEqns2 %>
5792+ <%generateConstantEqns(constantEqns, matrixName, modelNamePrefix) %>
58145793
58155794 int <%symbolName(modelNamePrefix,"functionJac")%><%matrixName%>_column(DATA* data, threadData_t *threadData, JACOBIAN *jacobian, JACOBIAN *parentJacobian)
58165795 {
@@ -6999,7 +6978,6 @@ end simulationParModelicaKernelsFile;
69996978 }
70006979 #endif
70016980 #endif<%\n %>
7002- <%\n %>
70036981 >>
70046982 /* adrpo: leave a newline at the end of file to get rid of the warning */
70056983end simulationFunctionsHeaderFile;
0 commit comments