Please note: The FAQ pages at the HPCVL website are continuously being revised. Some pages might pertain to an older configuration of the system. Please let us know if you encounter problems or inaccuracies, and we will correct the entries.

This is a short FAQ on programming in Pascal on the Sun Fire cluster. Pascal is not supported as a native programming language on either AIX or Solaris 9. Instead, we have the publi domain GNU Pascal compiler installed on both machines.

Why use Pascal?

Pascal is a computer language that was designed for teaching purposes. It makes extensive use of function and subroutine calls and allows code do be written in a very "readable" manner. Pascal is one of the precursors of the arguably most successful programming language C. Many people learned programming with Pascal, and a good deal of code exists that was written in this language. In recent times, Pascal has been extended a great deal, and with those extensions, the language can compete with more modern programming languages such as C/C++ or Java. We provide a Pascal compiler to enable those of our users who have "legacy code" in Pascal, or want to use modern programming techniques without having to learn a new programming language. However, Pascal is not supported as such by Sun/Solaris or IBM/AIX, i.e. there is no native Pascal compiler for our systems. Instead we use a portable public-domain compiler.

What is the Pascal compiler used on HPCVL machines?

The Pascal compiler installed on the Sun Fire system of HPCVL is the Gnu Pascal Compiler (GPC). This is a public-domain compiler that has a great deal of extensions and compatibility features built into it, and is designed to be very portable. The versions are at present:

GNU Pascal version 20000707, based on gcc-2.95.2 19991024 (for SUN Sun Fire).

This compiler supports ISO-7185 Standard Pascal and ISO-10206 Extended Pascal, as well as Borland Pascal 7.0 and parts of Pascal-SC. For more detailed specifications which features are available, see the the language specification page of GPC. GPC is located in the /usr/local directory hierarchy. It makes use of some features of the Gnu C Compiler (GCC) and therefore needs access to libraries and header files from that distribution. Its close relationship with GCC also enables it (to some degree) to use the GNU debugger (How do I debug my Pascal programs?).

How do I run gpc?

This FAQ is not meant as a manual for the GNU Pascal Compiler. The usage of the compiler is very straightforward, though. The command gpc is used both for compiling and linking the programs. For linking, it will invoke the system-supplied ld feature with the appropriate switches and environment variables. To use GPC you have to have to have "/usr/local/bin" in your PATH. It might in some cases be necessary to set the system environment variable LD_LIBRARY_PATH to "/usr/local/lib:/usr/lib" in order for your executable to find the proper dynamic libraries at runtime. GPC uses command-line options to guide the compilation. These options are often very standard, such as -c to avoid linking and produce only object files, -O# to specify optimization levels, -o to specify the name of the output (executable of object) file. Almost all options are documented in HTML format. For a complete list, obtain the GNU Pascal Manual . There are no useful Unix man pages for this compiler. Because of its close relationship with the GNU C-compiler GCC, almost all of the options that are available for the latter are also part of the Pascal compiler command set. Another effect of this is that there is usually no problems with using C-routines in conjunction with the Pascal compiler. This comes in handy when you are trying to compile Pascal programs to run in parallel mode on a multi-processor system (see question below).

How do I debug my Pascal programs?

In any cases where your program is longer than a few hundred lines, you will need to be able to run it through a debugger. Pascal programs compiled with GPC can be debugged via the GNU debugger dbg which we have installed on our Sun Fire system. However, the debugger is designed for C-code, and is rather kloncky if used with Pascal. But it is the only debugger available that works with GPC.
To be able to use the debuuger with your Pascal code, you have to include the -g option in your compilation. Since this option and optimization of the code (i.e. the -O options) are mutually exclusive, you will have to remove any -O directives from your compile command lines. Then you can start the debugger by typing "gdbname_of_executable". The debugger is operated by typing in commands such as
run Start the program from the beginning
stop Stop the program from executing
break Insert a break at a given line of the code, or in a specific subroutine or function
cont Continue from the present position in the code until the next break is encountered
list List the code around the present break point
print Show the value of a variable

Since the debugger has trouble handling Pascal code instead of C-code, the following command lines should be typed in as sson as the debugger was entered (you can copy-and-paste them onto the dgb command line):
break init_pascal_main_program
break pascal_main_program
break '_p_runfinalizers'
This will enable the debugger to display the current lines in Pascal code.
The documentation for this debugger is available online or in PDF format for printing .

Is there a way to run my Pascal programs in parallel?

There is indeed, but it's not going to be easy. One way of "parallelizing" your programs is to include "message passing" in the code. Different portions of the code are thereby executed by different processors, and information is shared by passing messages between the processors. The most widely used method to do this is called Message Passing Interface (MPI), and is available in the form of libraries on the SUN Fire muti-processor machines of HPCVL. However, MPI works only with FORTRAN and C directly. The libraries consist of subroutines that can be called from code written in those two languages. In order to write parallel code in Pascal, you therefore have to do the following things.

    • Write your code in a "single code multiple data" manner by inserting calls to message-passing functions. The interface with these functions will have to be designed by you.
    • Implement the message-passing functions in C and use the C-bindings of the MPI library inside of those functions.
    • Compile your Pascal routines with GPC, and your C-routines with the native C-compiler to produce object code. Include the proper header files in the C functions via the "-I" option. Collect the C-functions in a library using the ar command.
    • Link the object code with GPC, including the C-functions in the form of a library. MPI is linked in by specifying "-l", "-L", "-R", and "-I" options.

You can read our Parallel Programming FAQ to make yourself familiar with the usage of the native C compiler on the Sun systems. You will also need to follow up some of the links in that file to make yourself familiar with usage of MPI. 

Where can I get further help?

The GNU Pascal Project is your first address on help with Pascal on our machines. The people associated with it are extremely dedicated, and operate a variety of help facilities, including an FAQ and an archive .
For help with the debugger, you can check out the web page , and the manual . The GDB people also run several mailing lists to help you with concrete problems.
For the interfacing of Pascal and C-programs, and for the usage of MPI to parallelize your code, you can get some initial ideas from our parallel programming FAQ . Many of the link therein are also useful, in particular the one to the Sun Documentation Site (assuming you're doing what you're doing on Sun machines). HPCVL also provides user support. If you can't get it to run by reading manuals, contact us and we can make an appointment and try to sort it out. In case we cannot help, we might be able to put you in touch with someone who can.