3 Compiling, linking and running a simple ADAM program

An ADAM application which simply writes the message ‘Hello’ is considered below. The first surprise for the new ADAM programmer is that the application consists merely of a subroutine, HELLO.FOR, and an associated interface file, HELLO.IFL. The application code, HELLO.FOR is as follows:

        SUBROUTINE HELLO (STATUS)
        INTEGER STATUS
  
  *   Output Hello message.
        WRITE(*,*) ’Hello’
        END

And the interface file, HELLO.IFL:

  interface hello
  endinterface

All ADAM applications comprise a ‘main’ subroutine with the single integer STATUS argument. The program which calls the subroutine is automatically generated and compiled at the ADAM LINK stage. The files thus created, APPMAIN.FOR and APPMAIN.OBJ are automatically deleted when the executable file (named after the application subroutine) is created.

Each application also has an associated interface file. As the name suggests, the interface file is used to provide a flexible and powerful interface to ADAM programs. The primary purpose of interface files is to facilitate the passing of values between the user and the program. ADAM programs do not normally use Fortran READ statements (see Section 9 for an exception). Instead, values which are input to a program are accommodated by parameters. Usually an interface file comprises a list of such parameters together with information associated with each parameter. For example, the program in the next section has a single parameter called INPUT, and the interface file indicates that this parameter should be prompted for with the string ‘Input NDF structure’. The interface file is automatically processed when the associated program runs. In the case of the HELLO program, there are no parameters, so the interface file just contains the two lines shown above. This subject of interface files is considered in more detail in Section 7.

N.B. The program HELLO.FOR is presented only to illustrate the structure of an ADAM application and is deficient in many respects. For example, the WRITE statement would not be used in a proper ADAM program (see Section 5).

Before compiling and linking ADAM programs it is necessary to issue the following commands:

  $ ADAMSTART
  $ ADAMDEV

These commands set up many symbols, logical names etc. such as the special ADAM link command ALINK. It may be convenient to include them in your LOGIN.COM.

To produce an executable file, the source files ADAM_EXAMPLES:HELLO.FOR, HELLO.IFL can be copied and the procedure below followed:3

  $ FORTRAN HELLO                                       ! Produces HELLO.OBJ
  $ ALINK HELLO                                         ! Produces HELLO.EXE

The HELLO program can now be tested:

  $ RUN HELLO
  Hello

3To link with the debug option add “ /DEBUG” at the end of the link command line.