Main Page
Basics, Building SPICE Applications (FORTRAN)

Table of Contents

      Note About HTML Links
      Environment Set-up
         Unix/Linux
         Windows
      A simple example program
         Unix/Linux
         Windows


May 25, 2007



Top

Note About HTML Links




The HTML version of this lesson may contain links pointing to various HTML documents provided with the Toolkit. All of these links are relative and, in order to function, require this document to be in a certain location in the Toolkit HTML documentation directory tree.

In order for the links to be resolved, create a subdirectory called ``lessons'' under the ``doc/html'' directory of the Toolkit tree and copy this document to that subdirectory before loading it into a Web browser.



Top

Environment Set-up






Top

Unix/Linux



Assume SPICELIB is installed at /naif/toolkit/. The corresponding path for the SPICELIB library being /naif/toolkit/lib/spicelib.a.



Top

Windows



Assume SPICELIB is installed at C:\naif\toolkit\. The corresponding path for the SPICELIB library being C:\naif\toolkit\lib\SPICELIB.LIB.



Top

A simple example program




This program calls the SPICELIB subroutine 'TKVRSN' then outputs the VERSN return argument.

File tk_ver.f:

         PROGRAM TK_VER
 
         CHARACTER*(20) VERSN
 
         CALL TKVRSN ( 'TOOLKIT', VERSN )
 
         WRITE(*,*) 'Toolkit version: ', VERSN
 
         END


Top

Unix/Linux



This example uses the GNU FORTRAN 9X compiler (gfortran):

   skynet 35: gfortran tk_ver.f -o tk_ver /naif/toolkit/lib/spicelib.a
 
   skynet 36: ./tk_ver
    Toolkit version: N0061
SPICE library naming does not conform to the UNIX convention of libname.a for use with the -L/path_to_libs/ -lname_of_lib compile option.

A FORTRAN compiler may require an additional flag "-lU77" when linking against SPICELIB. A link failure due to an unresolved symbol "_exit" occurs when a link requires -lU77.



Top

Windows



This example uses the Digital FORTRAN compiler (df):

   > df tk_ver.f C:\naif\toolkit\lib\SPICELIB.LIB
 
   > tk_ver
    Toolkit version: N0061