Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

Parallel

Porting Fortran Programs From Minis to PCs


SEP90: PORTING FORTRAN PROGRAMS FROM MINIS TO PCS

PORTING FORTRAN PROGRAMS FROM MINIS TO PCS

A method to prevent software madness

John L. Bradberry

John is senior research engineer with the Georgia Tech Research Institute, specializing in radar and antenna research. He is also development manager for Scientific Concepts, where he can be reached at 2359 Windy Hill Road, Suite 201-J, Marietta, Georgia 30067.


Improvements in personal computer hardware, operating systems, and compilers have placed PCs in a competitive role in applications traditionally dominated by mainframe computers. Developers of scientific applications such as radar and antenna software have traditionally defined "state of the art" in the digital world at all levels of electronic instrumentation. Historically, PCs were limited in clock speed, extended precision computing power, and compiler sophistication. As a result, the scientific community restricted PC uses to intelligent terminals, word processors, and spreadsheets. In only the past few years, these limitations have almost been completely resolved and PCs are rapidly becoming viable options in all levels of problem solving.

This article addresses issues related to porting large-scale software from mainframes to the PC. Issues related to compilers, programming techniques, ANSI standards, and some PC software resources will also be examined. For the purposes of example, the structure of Microplots, a Fortran-based graphics system, is used to illustrate a structured programming design approach. Microplots was ported successfully from a minicomputer to the PC using Microsoft Fortran 5.0.

Minicomputer Operating Systems Versus PC Development Environments

For many years, the most popular minicomputer operating systems and compilers were products offered by the hardware vendors. VMS from Digital Equipment Corp. is a good example. VMS maintains widespread support as a good solution to problems involving huge arrays for 32- to 64-bit number crunching problems. Although the real-time responsiveness of VMS has often been questioned, DEC made many improvements to Fortran 77, and its customers responded with millions of lines of code dedicated to VAX Extended Fortran. Much of this resulted in code with virtually no chance of portability.

Another example is RTUX from Hewlett Packard. Over the last two years, HP has adopted a modified version of real-time Unix (RTUX). As a Unix-based operating system, RTUX offers virtual memory management and additional connectivity options. However, Fortran development is at best secondary in most Unix environments.

With DOS-based PC architectures, third-party clone vendors created a potpourri of hardware and software to steadily increase the PC's feasibility as a scientific problem solver. The single-task nature of DOS not withstanding, the increase in clock speed and development support software proved to be irresistible to the scientific community. However, full-featured minicomputer development environments still offer features not easily addressed under PC DOS. Some of these features include:

  • Virtual memory access (>640K) transparent to the process.
  • Full featured system services libraries such as spawning child processes from within a program shell, direct keyboard/memory operations with or without wait, and I/O such as IEEE and 8- to 16-bit Digital Control and DMA (Direct Memory Access) Channels.
  • Symbolic debuggers extended to source level with access to user and system library modules.
  • User-controlled global variable space with inter-process communication capability (memory based!).
It should be noted that some of these issues have been addressed in OS/2 and to a limited extent with 386/486 development utilities (DesqView for example). However, the vast majority of DOS applications and the scope of this article is limited to DOS 3.x and 4.x versions.

Converting Software from Minicomputers to PC Platforms

In an ideal world, application portability from one machine to another would simply involve moving the source code from machine to machine, then recompiling and linking all program modules. Unfortunately, only a small number of relatively simple programs ever make this a reality. The main reasons for this phenomenon are readily apparent: CPU and compiler-dependent code grows in direct proportion to the size and complexity of an application. Inexperienced programmers and program managers are often unaware or unconcerned about portability. In addition, issues of portability sometimes surface after hardware or software obsolescence becomes imminent. (See the accompanying text box for some Do's and Don'ts of developing portable software.)

In the rest of this article, I'll discuss porting a large graphics application from a mainframe computer architecture to a PC. The application, called "Microplots," is a collection of scientific plotting routines for two-dimensional and three-dimensional data files. The Microplots routines contain over 11 algorithms originally designed for VAX and other minicomputers. (For a demo disk of the Microplots system, contact the author at the address at the beginning of this article.)

The compiler chosen for porting Microplots to the PC was Microsoft's Version 5.0 of Fortran 77. It was chosen primarily because:

  • System service features such as command line access, child process spawning, and programmable operating system functions were desired.
  • Mixed language calls were necessary for unsupported system services utilities such as keyboard peeks (read_without_wait). Microsoft supplies a full compliment of mixed language support for C, Assembler, and Basic.
  • Fortran calls to lower-level graphics primitives were essential for this application.
  • ANSI Fortran 77 extension support.

Designing for Portability

A structured design approach can be essential as preventative maintenance for software support. The term "top-down" software design has become a cliche over the years. In reality, thetop-down programming approach is usually complimented with a "bottom up" implementation. The resultant layering of software will ultimately result in the form of an inverted pyramid, as illustrated in the Figure 1.

Figure 1: Topdown software design

  Top Level: Microplots Graphics Application Software

    Contour Plot - Polar Plot - Linear Plot ... Other Plots

      Layer 4: Graphics Macros

  Rect Grid - Circle - Arc - Frame - Box - Label ... Other Macros

      Layer 3: Graphics Primitives

    Move - Draw - Ginit - Scale - Pen ... Other Primitives

      Layer 2: Graphics Device Drivers

  HPGL - IBM PC - TEKTRONIX - DEC VTxx ... Other Devices

      Layer 1: Graphics Device Interface

  CRT - Disk - Digital Plotter ... Other Devices

Lower layers represent the device and CPU-specific implementations of key functions. At the device driver level (layer 2 in the figure) other third-party vendor software can be merged for completeness. The following features of this structure readily support efforts in the port process:

  • As the tree is implemented, the top two levels maintain a fairly generic Fortran 77 form. All code at these levels exists in a form virtually application and CPU independent.
  • Each layer provides virtually unlimited expansion of capability by the easy addition of plot algorithms or graphics devices with little impact on existing code.
  • As suggested by the pyramid structure, the software most affected by changes in CPU or graphics devices represents the smallest amounts of code in the entire system. Of the approximately 100K lines of source code in Microplots, less than three percent (the bottom of the pyramid) is device or CPU dependent.

Source Code Port Example

The plot program that generates the globe shown in Figure 2 is shown in Listing One (page 80). Prior to the port, the globe program contained many poor programming practices that made the port process cumbersome. For example, most variables were not typed (IMPLICIT NONE eliminates guessing and mistakes automatically when porting code). Also, program loops and structures were not indented (non-indented loops and logic clauses make code more difficult to interpret). Added to this, extended use was made of non-descriptive variable names. (Be sure to spell out variable names when practical to clarify usage and meaning.)

Hard coded logical unit specifics were implemented using WRITE(6,*) ... which makes pointing to other devices or terminals difficult without modifying all occurrences of output and enter statements. (Global device specifics simplified this process.) Furthermore, the program used improper program context definition. (You should use consistent program and subroutine headers throughout the code so that you can tell at a glance where one module ends and the next one begins.)

Because different machines use different default storage functions, you should pass constants as formal parameters to subroutines or functions. Integer constants passed as formal parameters may default to 16 or 32 bits of storage depending on the compiler or machine.

The minicomputer versions of the program also made excessive use of line numbers. When designing a program that might be ported, you should eliminate line numbers when possible. Not only does the code look less cluttered, but porting to another language is often much easier without line numbers. Finally, DO loops that shared the same CONTINUE termination statement and multiple entry and exit points made the program confusing.

In Listing One, most of the problems have been removed while still keeping the code 100 percent compatible with Microsoft Fortran. Note, however, that almost all of the device- and compiler-specific issues are more isolated.

While this program is complete, it does not make allowances for other graphics devices. Therefore, the last changes made before adding the globe program to the Microplots system required expanding the graphics devices supported to include devices in the structure pyramid of Figure 1. To accomplish this goal, the program fragments in Listing Two (page 82) illustrate the further layering of the device initialization process to include other drivers.

The top level of the globe program makes a call to initialize the current graphics device. As in the case of all of the top-level routines, the device specific details are left to lower-level macros, in this case GINIT.

In the fragment of level 3, the subroutine GINIT makes the appropriate call to a device driver pointed to by the symbol DEVICETYPE. The symbol DEVICETYPE is an integer constant set to a number representing one of the many devices defined by the system. A match is searched for in the body of the IF-THEN structure and the specific lower-level driver is called.

In level 2, the CPU and compiler-specific code for the various devices is selected. If and only if the current device happens to be of the IBM PC variety, the IBMPCINIT driver is called. IBMPCINIT contains specific references to the graphics library routines supplied with Microsoft 5.0 Fortran. If and only if the current device is of the VAXstation variety, the VAXSTAINIT driver is called. This driver contains symbols and library references known only to the VAX compiler and CPU.

As illustrated by this test case, the code least portable is isolated to "well-defined" driver modules at the lowest levels of the graphics library. As a result, the graphics routines can be ported to virtually any CPU with minimal effort. In addition, an unlimited number of additional graphics devices and plotting algorithms can be added to the Microplots system.

This approach is not without some minor compromise in performance and flexibility in a few areas. However, when faced with the options of porting code riddled with CPU and compiler-specific options or changing a few low-level drivers, the compromises can save many man months of coding and debug efforts.

It is interesting to note here that the top-down approach used for the graphics design can also be used in other scientific application areas such as file, signal processing, and I/O libraries.

Future Considerations for PC Fortran 77 Development

Efforts of most Fortran suppliers have made porting large-scale programs to the PC quite practical. However, Fortran's use on PCs for development of new software may continue to be phased out in the future. Until more system services and features are added to the language and supported (will Fortran 8x ever be released?), mixed-language calls to Assembler or C will continue to be a necessary evil. As C becomes more object oriented and Fortran standards continue to stagnate, the notion of using Fortran for reasons other than performing complex math functions may prove impossible to defend in the future.

More Details.

The DO's and DON'Ts of Writing Portable Fortran Code

When faced with the task of writing portable software, you may wonder how to assess the quality of your code and a plan of attack. Here are some Do's and Don'ts for system design that may make this task easier. Although these issues are concentrated on Fortran, some of them apply to any programming language or operating system.

The Do's

Define every variable explicitly in each module. Use Integer*2 or Real*4 for example. Default word sizes vary from machine to machine.

The ANSI extension of IMPLICIT NONE should be universally adopted. An amazingly large number of debug nightmares and spelling errors can be avoided by this simple statement included at the beginning of each subroutine and function.

Indent all loop bodies and IF clauses.

Use one variable per line and a trailing descriptive clause if possible. The ANSI comment extension allowing the ! trailer is useful for this purpose.

Use the ANSI extended DO-END DO and DO WHILE-END DO to avoid line numbers and continue statements for better code readability.

Use a compiler that allows the MIL-standard ANSI extensions to Fortran 77 if possible.

Use batch or command files for all phases of program compiling and linking. Command-line parameters are usually only remembered by the person writing the module. In time, even the original author may forget which switches to use!

The Don'ts

Do not use computed GOTOs.

Do not use the DIMENSION statement (explicit typing of variables should be used).

Do not use non-integer parameters in do loops or shared termination statements.

Do not use alternate RETURN statements.

Do not use non-descriptive variable names such as XXX and YYY.

Do not use long subprograms performing many tasks with multiple exits. Do not pass constants as formal parameters to subroutines.

Do not embed compiler or machine-dependent directives in source code.

-- J.L.B.

_PORTING FORTAN PROGRAMS FROM MINIS TO PCS_ by John L. Bradberry

[LISTING ONE]

<a name="01d1_000d">

C
C    >**************************************************************
      PROGRAM GLOBE
C     **************************************************************
C     PROGRAM TO DRAW A GLOBE AT A USER SPECIFIED ANGLE ON A GRAPHICS
C     SURFACE. INPUTS ALSO INCLUDE LOCATION OF GRATING LOBES REFERENCED
C     TO LONGITUDE AND LATITUDE.
      AUTHOR: SCIENTIFIC CONCEPTS
C     --------------------------------------------------------------
      IMPLICIT NONE
C
C
      INTEGER*2         I               !LOOP COUNTER
      INTEGER*2         J               !LOOP COUNTER
      INTEGER*2         PMOVE           !PEN CONTROL MOVE COMMAND
      INTEGER*2         PDRAW           !PEN CONTROL DRAW COMMAND
      INTEGER*2         PENC            !PEN CONTROL: 2=DRAW,3=MOVE
      INTEGER*2         TLU             !TERMINAL LOGICAL UNIT NUMBER
      INTEGER*2         ROW             !TEXT ROW POSITION
      INTEGER*2         COLUMN          !TEXT COLUMN POSITION
      INTEGER*2         NUMLOBES        !NUMBER OF GRATING LOBES REQUESTED
C
      REAL*8            GRLOBEX(10)     !X LOCATION FOR GRATING LOBE
      REAL*8            GRLOBEY(10)     !Y LOCATION FOR GRATING LOBE
      REAL*8            XPOS            !HORIZONTAL PIXEL POSITION
      REAL*8            YPOS            !VERTICAL PIXEL POSITION
      REAL*8            HORIZONTAL      !CALCULATED HORIZONTAL PIXEL POSITION
      REAL*8            VERTICAL        !CALCULATED VERTICAL PIXEL POSITION
      REAL*8            RADIUS          !RADIUS OF GLOBE CIRCLE
      REAL*8            TILT            !TILT ANGLE FOR GLOBE
      REAL*8            PI              !PI CONSTANT
      REAL*8            COSCONVER       !COS CONVERSION OF TILT IN RADIANS
      REAL*8            SINCONVER       !SIN CONVERSION OF TILT IN RADIANS
      REAL*8            ELEVATION       !CALCULATED LONGITUDE POSITION
      REAL*8            AZIMUTH         !CALCULATED LATITUDE POSITION
      REAL*8            GLOBEINC        !GRATING LOBE INCREMENT (RADIANS)
C
      CHARACTER         STEMP*8         !TEMPORARY STRING
C
C
      PARAMETER         (PMOVE=3,PDRAW=2)
C
      TLU=6
      NUMLOBES=0
      PI=3.14159265
C
C
C     HORIZONTAL,VERTICAL ARE COORDINATES OF ORIGIN
C
      WRITE(TLU,*)'ENTER ORIGIN COORDINATES (TRY 300,200 FOR EGA/VGA)'
      READ(TLU,*)HORIZONTAL,VERTICAL
C
      WRITE(TLU,*)'ENTER RADIUS OF CIRCLE (TRY 160 FOR EGA/VGA)'
      READ(TLU,*)RADIUS
C
      WRITE(TLU,*)'ENTER TILT ANGLE IN DEGREES (TRY 30)'
      READ(TLU,*)TILT
C
      WRITE(TLU,*)'HOW MANY GRATING LOBES (MAXIMUM=10) ? '
      READ(TLU,*)NUMLOBES
C
      IF (NUMLOBES.GT.10) THEN
        WRITE(TLU,*)' ERROR: TOO MANY GRATING LOBES REQUESTED!'
        STOP
      ELSE IF (NUMLOBES.GT.0) THEN
        DO I=1,NUMLOBES
          WRITE(TLU,*)'ENTER (X,Y) COORDINATES FOR POINT ',I
          READ(TLU,*)GRLOBEX(I),GRLOBEY(I)
        END DO
      ENDIF
C
C     INITIALIZE IBM PC TO MAXIMUM RESOLUTION ...
C
      CALL GINIT(TLU)
C
C     DRAW '+' AT ORIGIN
C
      XPOS=HORIZONTAL-4.5
      CALL PLOT(XPOS,VERTICAL,PMOVE)
      XPOS=HORIZONTAL+4.5
      CALL PLOT(XPOS,VERTICAL,PDRAW)
      YPOS=VERTICAL-3.6
      CALL PLOT(HORIZONTAL,YPOS,PMOVE)
      YPOS=VERTICAL+3.9
      CALL PLOT(HORIZONTAL,YPOS,PDRAW)
C
C     LABEL FIGURE WITH PARAMETERS
C
      ROW=24
      COLUMN=26
      WRITE(STEMP,'(F6.2)')TILT
      CALL TEXTLABEL(ROW,COLUMN,'TILT ANGLE (DEGREES)='//STEMP)
C
C     DRAW OUTER CIRCLE
C
      CALL PLOT(HORIZONTAL+RADIUS,VERTICAL,PMOVE)
      DO I=1,100
        XPOS=HORIZONTAL+RADIUS*COS(I*2*PI/100)
        YPOS=VERTICAL+RADIUS*SIN(I*2*PI/100)
        CALL PLOT(XPOS,YPOS,PDRAW)
      END DO
C
C     DRAW LATITUDES
C
      TILT=TILT*PI/180.0
      COSCONVER=COS(TILT)
      SINCONVER=SIN(TILT)
C
      DO I=1,12
        ELEVATION=PI/2-PI/12*I
        XPOS=HORIZONTAL
        YPOS=VERTICAL+RADIUS*(SIN(ELEVATION)*COSCONVER
     +       -COS(ELEVATION)*SINCONVER)
        CALL PLOT(XPOS,YPOS,PMOVE)
        PENC=2
        DO J=1,100
          AZIMUTH=J*2*PI/100.0
          IF (SIN(ELEVATION)*SINCONVER+COS(ELEVATION)*
     +        COS(AZIMUTH)*COSCONVER.GE.0.) THEN
            XPOS=HORIZONTAL+RADIUS*COS(ELEVATION)*SIN(AZIMUTH)
            YPOS=VERTICAL+RADIUS*(SIN(ELEVATION)*COSCONVER
     +           -COS(ELEVATION)*COS(AZIMUTH)*SINCONVER)
            CALL PLOT(XPOS,YPOS,PENC)
            PENC=2
          ELSE
            PENC=3
          END IF
        END DO
      END DO
C
C     DRAW LONGITUDES
C
      DO I=1,12
        AZIMUTH=I*PI/12
        YPOS=VERTICAL+RADIUS*COSCONVER
        CALL PLOT(HORIZONTAL,YPOS,PMOVE)
        PENC=2
        DO J=1,100
          ELEVATION=PI/2-J*2*PI/100
          IF (SIN(ELEVATION)*SINCONVER+COS(ELEVATION)*
     +        COS(AZIMUTH)*COSCONVER.GE.0.) THEN
            XPOS=HORIZONTAL+RADIUS*COS(ELEVATION)*SIN(AZIMUTH)
            YPOS=VERTICAL+RADIUS*(SIN(ELEVATION)*COSCONVER
     +           -COS(ELEVATION)*COS(AZIMUTH)*SINCONVER)
            CALL PLOT(XPOS,YPOS,PENC)
            PENC=2
          ELSE
            PENC=3
          END IF
        END DO
      END DO
C
C
C     DRAW GRATING LOBES
C
      IF (NUMLOBES.GT.0) THEN
        DO I=1,NUMLOBES
          XPOS=HORIZONTAL+GRLOBEX(I)+RADIUS
          YPOS=VERTICAL+GRLOBEY(I)
          CALL PLOT(XPOS,YPOS,PMOVE)
C
          DO J=1,100
            GLOBEINC=J*PI/50
            XPOS=HORIZONTAL+GRLOBEX(I)+RADIUS*COS(GLOBEINC+.04)
            YPOS=VERTICAL+GRLOBEY(I)+RADIUS*SIN(GLOBEINC+.04)
            IF((GRLOBEX(I)+RADIUS*COS(GLOBEINC))**2+
     +         (GRLOBEY(I)+RADIUS*SIN(GLOBEINC))**2.LT.RADIUS**2) THEN
              CALL PLOT(XPOS,YPOS,PDRAW)
            ELSE
              CALL PLOT(XPOS,YPOS,PMOVE)
            END IF
          END DO
        END DO
      END IF
C
C
C     PREPARE TO EXIT GRAPHICS AND RETURN TO NORMAL VIDEO ...
C
      CALL EXITGRAPHICS(TLU)
C
      END
C
C
      INCLUDE 'FGRAPH.FI'
C
C
C    >**************************************************************
      SUBROUTINE TEXTLABEL(ROW,COLUMN,STRING)
C     **************************************************************
C     SUBROUTINE TO WAIT FOR USER SIGNAL AND EXIT GRAPHICS MODE. TERMINAL
C     IS RESTORED TO PRE-VIDEO CONDITIONS...
C     --------------------------------------------------------------
      IMPLICIT NONE
C
      INCLUDE 'FGRAPH.FD'
C
      INTEGER*2         ROW             !TEXT ROW POSITION
      INTEGER*2         COLUMN          !TEXT COLUMN POSITION
C
      CHARACTER         STRING*(*)      !TEXT STRING FOR LABEL
C
      RECORD /RCCOORD/ CURPOS
C
C
C     OUTPUT USER SUPLIED STRING AT ROW,COLUMN ...
C
      CALL SETTEXTPOSITION(ROW,COLUMN,CURPOS)
      CALL OUTTEXT(STRING)
C
      RETURN
      END
C
C
C    >**************************************************************
      SUBROUTINE EXITGRAPHICS(TLU)
C     **************************************************************
C     SUBROUTINE TO WAIT FOR USER SIGNAL AND EXIT GRAPHICS MODE. TERMINAL
C     IS RESTORED TO PRE-VIDEO CONDITIONS...
C     --------------------------------------------------------------
      IMPLICIT NONE
C
      INCLUDE 'FGRAPH.FD'
C
      INTEGER*2         TLU             !TERMINAL LOGICAL UNIT NUMBER
      INTEGER*2         DUMMY           !DUMMY FUNCTION ARGUMENT
      INTEGER*2         ROW             !TEXT ROW POSITION
      INTEGER*2         COLUMN          !TEXT COLUMN POSITION
C
      ROW=25
      COLUMN=28
C
C
C     OUTPUT PROMPT AND WAIT FOR ENTER KEY ...
C
      CALL TEXTLABEL(ROW,COLUMN,'PRESS ENTER TO CONTINUE')
      READ(TLU,*)
C
C     RESET VIDEO MODE AND STOP
C
      DUMMY=SETVIDEOMODE($DEFAULTMODE)
C
      RETURN
      END
C
C
C    >**************************************************************
      SUBROUTINE GINIT(TLU)
C     **************************************************************
C     SUBROUTINE TO INITIALIZE IBM PC GRAPHICS MODE TO MAXIMUM
C     AVAILABLE RESOLUTION ...
C     --------------------------------------------------------------
      IMPLICIT NONE
C
      INCLUDE 'FGRAPH.FD'
C
      INTEGER*2         ERRC            !ERROR CODE RETURNED
      INTEGER*2         TLU             !TERMINAL LOGICAL UNIT NUMBER
      INTEGER*2         DUMMY           !DUMMY FUNCTION ARGUMENT
C
      LOGICAL*2         WINDINVERT      !INVERT WINDOW COORDINATES IF TRUE
C
      REAL*8            LOWERX          !LOWER X AXIS CORNER OF WINDOW
      REAL*8            LOWERY          !LOWER Y AXIS CORNER OF WINDOW
      REAL*8            UPPERX          !UPPER X AXIS CORNER OF WINDOW
      REAL*8            UPPERY          !UPPER Y AXIS CORNER OF WINDOW
C
C
C
C     INITIALIZE VIDEO MODE TO MAXIMUM RESOLUTION AVAILABLE
C
      ERRC=SETVIDEOMODE($MAXRESMODE)
      IF (ERRC.EQ.0) THEN
        WRITE(TLU,*)' ERROR: CANNOT SET VIDEO MODE'
        STOP
      END IF
C
      LOWERX=-3.0
      LOWERY=3.0
      UPPERX=-3.0
      UPPERY=3.0
      WINDINVERT=.TRUE.
      DUMMY=SETWINDOW(WINDINVERT,LOWERX,LOWERY,UPPERX,UPPERY)
C
      RETURN
      END
C
C
C    >**************************************************************
      SUBROUTINE PLOT(XPOS,YPOS,PENC)
C     **************************************************************
C     SUBROUTINE TO DRAW OR MOVE TO THE USER SPECIFIED POSITION 'XPOS,
C     YPOS' WITH PEN CONTROL AS DESIGNATED BY 'PENC'.
C     --------------------------------------------------------------
      IMPLICIT NONE
C
      INCLUDE 'FGRAPH.FD'
C
      INTEGER*2         DUMMY           !DUMMY FUNCTION ARGUMENT
      INTEGER*2         PENC            !PEN CONTROL: 2=DRAW,3=MOVE
C
      REAL*8            XPOS            !HORIZONTAL PIXEL POSITION
      REAL*8            YPOS            !VERTICAL PIXEL POSITION
C
      RECORD /WXYCOORD/ XY
C
      IF (PENC.EQ.2) THEN
        DUMMY=LINETO_W(XPOS,YPOS)
      ELSE
        CALL MOVETO_W(XPOS,YPOS,XY)
      END IF
C
      RETURN
      END




<a name="01d1_000e"><a name="01d1_000e">
<a name="01d1_000f">
[LISTING TWO]
<a name="01d1_000f">
                       Top Level Fragment


C    >**********************************************************
      PROGRAM GLOBE
C     **********************************************************
C
C PROGRAM TO DRAW A GLOBE AT A USER SPECIFIED ANGLE ON A GRAPHICS
C SURFACE. INPUTS ALSO INCLUDE LOCATION OF GRATING LOBES REFERENCED
C TO LONGITUDE AND LATITUDE.
C AUTHOR: SCIENTIFIC CONCEPTS
C
--------------------------------------------------------------
.
.
.
      CALL GINIT         !INITIALIZE GRAPHICS DEVICE
.
.
.
      END

                    Layer 3: Graphics Primitives

C*******************************************************C
      SUBROUTINE GINIT
C*******************************************************C
C     PURPOSE: INITIALIZE GRAPHICS DEVICE CURRENTLY
C              SET BY GLOBAL VARIABLE 'DEVICETYPE' ...
.
.
.
      IF (DEVICETYPE.EQ.HPGL) THEN         !HP GRAPHICS DEVICE
        CALL HPGLINIT
      ELSE IF (DEVICETYPE.EQ.IBMPC) THEN   !IBM MODES CGA-VGA
        CALL IBMPCINIT
      ELSE IF (DEVICETYPE.EQ.TEK) THEN     !TEKTRONIX DEVICES
        CALL TEKINIT
      ELSE IF (DEVICETYPE.EQ.DECVT) THEN   !DEC VT340
        CALL DECVTINIT
      ELSE IF (DEVICETYPE.EQ.VAXSTA) THEN  !DEC VAXSTATION 2000
        CALL VAXSTAINIT
.
.
.     ELSE
        CALL INITERROR
      END IF

               Layer 2: Graphics Device Drivers

C*******************************************************C
      SUBROUTINE IBMPCINIT
C*******************************************************C
C     PURPOSE: INITIALIZE CURRENT IBM PC GRAPHICS MODE
C              COLORS, RESOLUTION ETC ...
.
.
.

C
      IF (IBMMODE.EQ.EGACOLOR) THEN
        DUMMY=SETVIDEOMODE($ERESCOLOR)
      ELSE IF (IBMMODE.EQ.HERCULES) THEN
        DUMMY=SETVIDEOMODE($HERCMONO)
.
.
.
      END IF
C
      RETURN
      END
C
C*******************************************************C
      SUBROUTINE VAXSTAINIT
C*******************************************************C
C     PURPOSE: INITIALIZE VAXSTATION 200 GRAPHICS DEVICE
C              MODE, VIEWPORT ...
.
.
.
C
      LOWLX=1.0             !LOWER LEFT X COORDINATE
      LOWLY=1.0             !LOWER LEFT Y COORDINATE
      UPPRX=20.0            !UPPER RIGHT X COORDINATE
      UPPRY=20.0            !UPPER RIGHT Y COORDINATE
      DISPWIDTH=20.0
      DISPHEIGHT=20.0
C
      VD_ID=UIS$CREATE_DISPLAY(LOWLX,LOWLY,UPPRX,UPPRY,
     +                           DISPWIDTH,DISPHEIGHT)
      WD_ID=UIS$CREATE_WINDOW(VD_ID,'SYS$WORKSTATION')
C
.
.
.
      RETURN
      END
C
C










Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.