Also found in: Dictionary, Thesaurus, Medical, Legal, Acronyms, Wikipedia.


a section of a computer program that is stored only once but can be used when required at several different points in the program, thus saving space



the part of a computer program that is used to solve similar-type problems. A subroutine usually describes a separate step in the computation process and can be used more than once in one or several different programs. Typical subroutines are used to compute elementary functions, such as sin x, In x, and e-x, to solve systems of equations, and to remove the results of computations in various forms. If it becomes necessary to use the subroutine during the running of the basic program, the subroutine is called at the appropriate place in the program, and after it has been run, control is transferred back to the main program. A subroutine can call on another.

A subroutine should have the following characteristics: it should be subject to standardized access rules that make it possible to call the subroutine from the main program by means of one or more instructions; it should be able to work with a broad range of initial data, for example, independent variables of a function; it should be relocatable, that is, it should be possible to place and run it in various parts of the computer memory. Subroutines are often arranged in subroutine libraries. So-called standard subroutines satisfying rigid conditions are used in automatic programming.

The use of subroutines is one way to save time and effort in writing computer programs. Subroutines form the basis of modular programming.


Lavrov, S. S. Vvedenie v programmirovanie. Moscow, 1973. (Bibliography.)



(computer science)
A body of computer instruction (and the associated constants and working-storage areas, if any) designed to be used by other routines to accomplish some particular purpose.
A statement in FORTRAN used to define the beginning of a closed subroutine (first definition).


(Or "procedure") A sequence of instructions for performing a particular task. Most programming languages, including most machine languages, allow the programmer to define subroutines. This allows the subroutine code to be called from multiple places, even from within itself (in which case it is called recursive). The programming language implementation takes care of returning control to (just after) the calling location, usually with the support of call and return instructions at machine language level.

Most languages also allow arguments to be passed to the subroutine, and one, or occasionally more, return values to be passed back.

A function is often very similar to a subroutine, the main difference being that it is called chiefly for its return value, rather than for any side effects.


A group of instructions that perform a specific task. A large subroutine might be called a "module" or "procedure." Subroutine is somewhat of a dated term, but it is still quite valid.
References in periodicals archive ?
Concretely, one can use a jsr p instruction to push the next address as the return address onto the stack and to jump to subroutine p.
The first time the subroutine is executed, a single question mark will be placed in the cell named ques.
All data locations are specified by the user, never predetermined by the subroutines.
The number of subroutine calls is reduced; advantage is taken of a manufacturer-provided subroutine; and for machines that tend to optimize inner loops but not two-level loops, the inner and outer loops are interchanged so that inner vector lengths are longer.
A type loophole could be created by allowing a subroutine and the caller of that subroutine to exchange references to uninitialized objects in certain situations.
In addition to the search macro, several other macros and subroutines are used in conjunction with {FOR} commands.
The most efficient way is to program the system "from the top down"--that is, by delineating the major steps necessary to reach the goal, and then writing subroutines to reach the end point of each major step.
It contains a possible result of compiling the method bar into JVML, putting the finally code in a subroutine in lines 13-16.
This approach used by Kapoor [14] disassembles the entire program, but it does attempt to identify subroutine boundaries.
Software modules and subroutine libraries, for example, can be deployed at specific user sites and from user servers.
In order to be able to read the data, the Compass Module used a program that follows a subroutine named Compass_Get_Axes (Lidsay, 2006) that returns the x and y magnetic field strength values.
In the course of running the code, we discovered that a specific subroutine did not work.