Cim is a compiler for the programming language Simula (except unspecified parameters to formal or virtual procedures (see item %nocomment in See section Implementation dependent characteristics, for how portable code for formal procedures can be written)). It offers a class concept, separate compilation with full type checking, interface to external C routines, an application package for process simulation and a coroutine concept.

Cim is a Simula compiler whose portability is based on the C programming language. The compiler and the run-time system is written in C, and the compiler produces C code, that is passed to a C compiler for further processing towards machine code.

Cim is copyrighted by Sverre Hvammen Johansen, Stein Krogdahl and Terje Mjs, Department of Informatics, University of Oslo.

Cim is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Mail bug reports for Cim to Please include the Cim version number and the system type, which you can get by running cim --version.


The system is distributed as a compressed tar file. Take the following actions to install the software:

  1. Uncompress the compressed tar file with the gunzip command:
    %gunzip cim-version.tar.gz
    where version is the version number.
  2. Extract the file with the tar command:
    %tar xf cim-version.tar
  3. `cd' to the created directory containing the source code for cim and execute configure with `sh':
    %cd cim-version
    %sh configure
  4. Edit the created files `Makefile' and `config.h' if needed and compile the system by running make.
  5. Install the system by entering super user and make install:
    %make install
  6. A simple check of the installation can be made by make installcheck:
    %make installcheck
    mkdir tmptest; cp ./test.sim tmptest
    cd tmptest; /usr/local/bin/cim ./test -r
    Compiling: ./test.sim
    cc -c test.c
    cc -o test test.o /usr/local/lib/libcim.a -lm
    Executing test:
    Installation: No errors found
    rm -rf tmptest
  7. You can now remover the program binaries and object files from the source directory:
    %make clean

More details about installation can be found in the file INSTALL that comes with the distribution.

A simple example

We show in this chapter a simple example of a SIMULA program and how to compile and run it.

Create a SIMULA program with a text editor, and give it a name with extension `sim'. In this example we name it `doesit.sim':

    Outtext("Simula does it in C");

You can now compile the program with the cim command:

%cim doesit
Compiling: doesit.sim
cc -w -c doesit.c 
cc -o doesit doesit.o /usr/local/lib/libcim.a -lm

The compiler will produce C code that is further processed towards machine code with a standard C compiler. All produced files have the same name as the input file, but with different extensions. The compiled and linked program can be invoked by entering:

Simula does it in C


Cim is a Simula compiler that first compiles the source code into C. The C code will then be compiled with cc, and linked with other modules.

The Cim command will accept one Simula program and other non-Simula modules. The specified Simula program will be compiled and linked with the modules. If a main Simula program is compiled, it will automatic be linked with the necessary Simula modules. If a separate Class or Procedure is compiled, then the linking will be suppressed.

The diagnostics produced by the Simula compiler are intended to be self-explanatory.


The following options are accepted by the cim command:

Try to produce an `atr'-file even if an error occurs. Compare the produced atr-file with the atr-file produced from previous compilation and if they differ return an error status code. With use of this option it is possible to have external modules with circular dependencies. You will then need to compile all the modules with this option until no error status codes are returned. Then you should do a final compilation with option -p or option -d. To get this to work it is important that the topmost external head does not contain any external declaration that is part of the circular dependency. Such external declarations must be placed in an external head that comes after the first class- or procedure decraration.
The argument will be passed to the C compiler.
The argument will be passed to the link-command.
Suppress linking of the complete program.
Set the name of the C compiler.
Compare the produced c code with the code produced from previous compilation and if they are equal then touch the object-file instead of compiling the c code.
Define a symbol name.
Run only the preprocessor and output the result to standard output.
Make the C compiler produce debugging information. This option is useful for debugging the generated code.
Use the Simula include file located in directory dir instead of the standard directory. This information may also be given by setting the environment variable CIMINCLUDEDIR.
Omit line number information in the compiled program. This will make the program smaller and faster.
Search for `.atr'-files and link with object library library. This option is passed to the link-command. If a `.atr'-file can not be found as an ordinary file, then the specified libraries are searched and if the file is still not found then the standard cim library is searched. This option may also be used for searching Simula include files.
Add directory dir to the list of directories to be searched for -l. This option is passed to the link-command. The standard system directory is searched first and then the specified directories are searched. The standard system directory may be given by setting the environment variable CIMLIBDIR.
The memory pool size may be set at runtime by an option -mn.
Set the initial memory pool size to n mega bytes.
Set the maximal memory pool size to n mega bytes.
Set the name of the Simula source file. This option allows a Simula source file to have a name with an illegal extension or no extension at all.
The argument file is the name of the output executable file.
Optimize. This option is simply passed to the C compiler.
Recompile the module using the same timestamp.
Only link the specified files.
Run the compiler in quiet mode.
Run the program after compilation.
Only C compile and link the specified files.
Compile into C code but do not start the C compiler.
Do not remove temporary files. If a main program is compiled with option -r, then the executable file will be removed unless this option or option -T is specified.
Do not remove the executable file.
Remove any initial definition of the symbol name (Inverse of the -D option).
Run the compiler in verbose mode.
Print the version number of Cim and exit.
Do not print warnings.
Trace execution for this module.


The following arguments are accepted by the Cim command:

Library of object files and attribute files. Include this simula library when compiling and linking. The simula library is created with ar(1V) and ranlib(1).
Object file of other non-Simula modules.
Simula source file. A file name without an extension is assumed to be shorthand notation for the corresponding Simula file.


The following files are related to a Cim compilation:

Executable file.
Library of source files, attribute files and object files. Include this simula library when compiling and linking. The simula library is created with ar(1V) and ranlib(1). All source and .atr files should be placed before .o files in the archive.
Object file.
Simula-compiler output file.
Output file that is included in file.c.
Simula source file.
File names without an extension are assumed to be shorthand notation for the corresponding `.sim'-file.
Simula library that contains the environment, Run Time System and class Simset and Simulation. The source code to Simset and Simulation is also included, so these parts can be compiled using compiler directive %include.
Include file for the produced C code.

Implementation Aspects

Language restrictions

A formal or virtual procedure must be specified with respect to its type, and type, kind and transmission mode of its parameters (see item %nocomment in See section Implementation dependent characteristics, for how portable code for formal procedures can be written).

Allowed implementation restrictions

Implementation dependent characteristics

Implementation defined characteristics

Capacity limitations

The compiler have the following logical limitations:

Extension to the environment

The following procedures are added to the Simula environment and may be called directly from Simula:

The garbage collector is called when the dynamic storage exceeds an implementation dependent limit. The garbage collector traverse and moves all the accessible objects, and leaves the free space as one area initialized to zero. The garbage collector may be called explicitly through the procedure Gbc.
Returns the number of command-line arguments that the program was invoked with.
Returns a pointer to an array of character strings (in C fashion) that contains the arguments.
PROCEDURE Dump(t);TEXT t;...;
Dump the state of the Simula-program to file. Before a call on Dump all files except sysin, sysout and syserr should be closed.
PROCEDURE UnDump(t);TEXT t;...;
Read a previously stored state from file and start the program in that state. To get these procedures to work, they should be compiled into the same program. The program may not be re-compiled between a call on Dump and UnDump.
REF(PrintFile) PROCEDURE SysErr;...;
Returns the file object associated with standard error.