      PROGRAM DYNAPG
***********************************************************************
*                                                                     *
* PROGRAM :   DYNAPG                                                  *
*                                                                     *
* PURPOSE:    DYNAPG IS A WEIGHTED LEAST SQUARES ADJUSTMENT SOFTWARE  *
*             OF GEODYNAMIC HORIZONTAL AND INTERSITE VECTOR FIELD     *
*             OBSERVATIONS IN THE NATIONAL GEODETIC SURVEY DATA BASE  *
*             INPUT FORMATS (BLUE-BOOK).                              *
*             DYNAPG IS A (MAJOR) MODIFICATION OF THE DYNAP SOFTWARE. *
*             DYNAP WAS FIRST MODIFIED FROM ADJUST.                   *
*                                                                     *
* VERSION CODE:  1.1                                                  *
*                                                                     *
* VERSION DATE:  1-AUGUST-1996                                        *
*                                                                     *
*  DYNAPG AUTHORS: RICHARD A. SNAY                                    *
*                  C. RANDOLPH PHILIPP                                *
*                  CHRISTINE M. PUSKAS				      *
*                  NATIONAL GEODETIC SURVEY, NOS, NOAA                *
*	 	   1315 EAST-WEST HIGHWAY/ROOM 8112		      *
*                  SILVER SPRING, MARYLAND 20910                      *
*                  TEL: 301-713-3205 (ext. 155)                       *
*                  FAX: 301-713-4327				      *
*                  EMAIL: rich@ngs.noaa.gov                           *
*                                                                     *
*  DYNAP AUTHORS:  ALICE R. DREW                                      *
*                  RICHARD SNAY                                       *
*                                                                     *
*  ADJUST AUTHORS: WILLIAM G. KASS                                    *
*                  DENNIS G. MILBERT                                  *
*                                                                     *
*                                                                     *
*                  DISCLAIMER                                         *
*                                                                     *
*   THIS PROGRAM AND SUPPORTING INFORMATION IS FURNISHED BY THE       *
* GOVERNMENT OF THE UNITED STATES OF AMERICA, AND IS ACCEPTED AND     *
* USED BY THE RECIPIENT WITH THE UNDERSTANDING THAT THE UNITED STATES *
* GOVERNMENT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, CONCERNING THE  *
* ACCURACY, COMPLETENESS, RELIABILITY, OR SUITABILITY OF THIS         *
* PROGRAM, OF ITS CONSTITUENT PARTS, OR OF ANY SUPPORTING DATA.       *
*                                                                     *
*   THE GOVERNMENT OF THE UNITED STATES OF AMERICA SHALL BE UNDER NO  *
* LIABILITY WHATSOEVER RESULTING FROM ANY USE OF THIS PROGRAM.  THIS  *
* PROGRAM SHOULD NOT BE RELIED UPON AS THE SOLE BASIS FOR SOLVING A   *
* PROBLEM WHOSE INCORRECT SOLUTION COULD RESULT IN INJURY TO PERSON   *
* OR PROPERTY.                                                        *
*                                                                     *
*   THIS PROGRAM IS PROPERTY OF THE GOVERNMENT OF THE UNITED STATES   *
* OF AMERICA.  THEREFORE, THE RECIPIENT FURTHER AGREES NOT TO ASSERT  *
* PROPRIETARY RIGHTS THEREIN AND NOT TO REPRESENT THIS PROGRAM TO     *
* ANYONE AS BEING OTHER THAN A GOVERNMENT PROGRAM.                    *
*                                                                     *
***********************************************************************

*** SIMULTANEOUS NETWORK ADJUSTMENT OF BLUE BOOK (GPS)

*** PARAMETER STATEMENTS ARE SET-UP THRU OUT THE CODE ALLOCATING A
*** MAXIMUM NUMBER OF GPS VECTORS IN A GROUP(NVECS).  IF ONE NEEDS
*** TO INCREASE OR DECREASE NVECS, SEARCH FOR EVERY OCCURRENCE OF
*** 'PARAMETER( NVECS = 5 )' AND MAKE THE APPROPRIATE MODIFICATIONS.

      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
      IMPLICIT INTEGER (I-N)

*** IF THIS PROGRAM NEEDS ADDITIONAL STORAGE ALLOCATION, ONLY THE
*** NEXT PARAMETER STATEMENT NEEDS TO BE INCREASED.  UNFORTUNATELY,
*** ONE MUST THEN RE-COMPILE AND LINK BEFORE EXECUTING.
*** THE MAXIMUM VALUE FOR LENA ON DYNA (16MBytes RAM) IS SOMEWHERE BETWEEN
*** LENA = 6,000,000 AND LENA = 7,000,000

      PARAMETER(LENA = 7000000)
      PARAMETER(LENIW = LENA+LENA)
      DIMENSION IW(LENIW),A(LENA)
      EQUIVALENCE ( A(1),IW(1) )
      COMMON /CONST/ PI,PI2,RAD,RADSEC,TWOPI
      COMMON /PAGEIT/ MAXLIN,IPAGE,ILINE
      COMMON /ALICE/ IPRSZ
      COMMON /STRUCT/ NSTA,NAUX,NUNK,IDIM,NSTAS,NOBS,NCON,NZ,NCD

*** THE FOLLOWING COMMON BLOCK IS HERE TO CIRCUMVENT
*** STORAGE RESTRICTIONS

      COMMON /BLOCK/ A

      LNWORK = LENIW
      LAWORK = LENA

*** DEFINE CONSTANTS

      PI2 = 2.D0 * DATAN(1.D0)
      PI = 2.D0 * PI2
      RAD = 180.D0 / PI
      RADSEC = RAD * 3600.D0
      TWOPI = 2.D0 * PI

*** DEFINE SCRATCH FILES

      IUO = 8
      OPEN (IUO,FORM='UNFORMATTED',STATUS='SCRATCH')
      IUO2 = 9
      OPEN (IUO2,FORM='UNFORMATTED',STATUS='SCRATCH')
      REWIND IUO
      ENDFILE IUO
      REWIND IUO
      REWIND IUO2
      ENDFILE IUO2
      REWIND IUO2

*** SET PAGE PARAMETERS AND PRINT FIRST HEADING

      MAXLIN = 58
      IPAGE = 1
      CALL HEAD

*** SET IPRSZ=1 TO PRINT THE OF LNWORK AND LAWORK ARRAY LEFT

      IPRSZ = 0
      IF (IPRSZ.EQ.1) THEN
        WRITE (6,2) LAWORK
    2   FORMAT ('0',I10,' TOTAL DOUBLE PRECISION WORDS REQUESTED')
      ENDIF

*** INITIALIZE SIZE OF GRID (THERE IS A GRID ONLY IF A "GR" CARD
*** EXISTS IN THE AFILE

      NCD = 0

*** READ ADJUSTMENT FILE AND ECHO OPTIONS

      CALL AFILE (A)
      CALL AFPRNT

*** FIRST PASS OF DATA

      CALL FIRST (A)

*** ALLOCATE STORAGE

      CALL ALOCAT (ID1,ID2,ID3,II4,ID5,LAWORK,LNWORK)

*** READ ADJUSTMENT FILE AGAIN FOR REMAINING RECORDS

      CALL AFILE2

*** PERFORM ADJUSTMENT

      CALL ADJST (A(1),A(ID1+1),A(ID2+1),A(ID3+1),IW(II4+1),A(ID5+1),
     &            LAWORK,LNWORK,IUO,IUO2)

*** END OF ADJUSTMENT

      CALL LINE (3)
      WRITE (6,3)
    3 FORMAT ('0END OF DYNAP PROCESSING',/,' HAVE A NICE DAY!')
      CLOSE (IUO)
      CLOSE (IUO2)
      STOP
      END
