A computer-implemented method for generating source code from one or more blocks of a block diagram comprising at least two non-virtual blocks, i.e., processing blocks, for calculating an output value and/or for making an assignment to at least parts of a signal, and at least one signal connection between two non-virtual blocks, the generating of source code comprising a transformation (S2) of the block diagram into an intermediate representation, a successive optimization (S8) of the intermediate representation, and a translation (S9) of the optimized intermediate representation into source code, the transformation (S2) of a non-virtual block comprising creating a reference to a block output variable, characterized in that , for a first block having an access to a multicomponent variable, the transforming (S2) comprises checking (S4) whether a pair of blocks comprising said block and an adjacent block comprises an equal-value assignment, wherein the multicomponent variable is a vector comprising a plurality of variables of the same data type, a matrix comprising a plurality of vectors, a structure comprising a plurality of variables of any data type, or a vector of structures or a matrix of structures, wherein the pair of blocks consists either of the first block and the predecessor thereof or of the first block and the successor thereof, depending on the type of the first block, wherein an equal-value assignment is present if at least a part of the multi-component variable of one block of the block pair is copied unchanged into a part of the multi-component variable of the other block of the block pair, wherein a replacement (S6) of variable references takes place if an equal-value assignment is present, in which either a reference to the part of the variable of the one block of the block pair is replaced by a reference to the corresponding part of the variable of the other block of the block pair or the reference to an output variable of the first block is replaced by the reference to a data memory variable and wherein the transforming comprises a removal (S7) of such assignments in which there is a reference to the same variable on both sides, wherein, despite the presence of an equal-value assignment between a first variable and a second variable of a block pair, no replacement (S6) of a reference to the first variable by a reference to the second variable takes place if one or more of the reasons for exclusion (S5) mentioned below are present, wherein, in the case of an equal-value assignment existing only for portions of the first and second variables, only said portions are also considered in the reasons for exclusion (S5): • the first and second variables have a different dimension, • at least one element of the first variables has a different data type than the corresponding element of the second variables, • the first variable is specified as necessary, • the signal flow branching and/or execution sequence of the connected blocks results in an unpredictable data flow. • the first and second variables have a different dimension, • at least one element of the first variables has a different data type than the corresponding element of the second variables, • the first variable is specified as necessary, • the signal flow branching and/or execution sequence of the connected blocks results in an unpredictable data flow. <EOS>