c************
c  Description: Common xmidas block shared between all primitives
c               Defines runtime environment variables
c
c  JC4: Note that the structures should be aligned to 8-byte boundaries
c       to avoid issues with some platforms/compilers.
c
c
c  Author:      Taken from X-Midas (with a few minor mods)
c
c************
        integer*4 L_MAXSPA_
        parameter (L_MAXSPA_=16)        ! max scalars per atom

        integer*4 L_auxs                ! max size of read auxilary list
        parameter (L_auxs = 64)

        integer*4 L_cmd_chars	        ! max chars in command line
        parameter (L_cmd_chars = 2048)
        integer*4 L_gsw_chars	        ! max global switch chars
        parameter (L_gsw_chars = 2048)

        integer*4 L_shrmask     ! shared section mask - bits 3,4,5
        parameter (L_shrmask = 56)

        integer*4 LS_midas
        parameter (LS_midas = 1)
        integer*4 LS_tables
        parameter (LS_tables = 2)
        integer*4 LS_results
        parameter (LS_results = 3)
        integer*4 LS_messages
        parameter (LS_messages = 4)
        integer*4 LS_dictionary
        parameter (LS_dictionary = 5)
        integer*4 LS_macrostack
        parameter (LS_macrostack = 6)
        integer*4 LS_pipe_headers
        parameter (LS_pipe_headers = 7)
        integer*4 LS_pipe_buffers
        parameter (LS_pipe_buffers = 8)
        integer*4 LS_cntrl_widgets
        parameter (LS_cntrl_widgets = 9)
        integer*4 LS_ds_structs
        parameter (LS_ds_structs = 10)
        integer*4 LS_user_offset
        parameter (LS_user_offset = 10)
        integer*4 LS_user1
        parameter (LS_user1 = 11)
        integer*4 LS_user2
        parameter (LS_user2 = 12)
        integer*4 LS_user3
        parameter (LS_user3 = 13)
        integer*4 LS_pname
        parameter (LS_pname = 14)

! M$DISPATCH flags
        integer*4 LD_wait
        parameter (LD_wait = 1)
        integer*4 LD_subshell
        parameter (LD_subshell = 2)
        integer*4 LD_smart
        parameter (LD_smart = 4)
        integer*4 LD_symbols
        parameter (LD_symbols = 8)
        integer*4 LD_noinput
        parameter (LD_noinput = 16)

        structure /COLORTYPE/
          integer*2 table(4, 7)
        end structure

        STRUCTURE /MCOMMON/
          integer*4       number_parameters       ! Number of cmd parameters
          integer*4       verify                  ! verify flag

          integer*4       debug                   ! debug flag
          logical*4       break                   ! control-C break flag

          logical*4       beep                    ! prim completion beep flag
          integer*4       status                  ! primitive return status
          integer*4       count                   ! primitive count (for pipes)
          integer*4       mode                    ! 0-norm 1,2,3

          character*4     OS_type                 ! Operating system (VMS, UNIX)
          character*4     OS_name                 ! Specific to vendor (OSF, SUN)

          character*4     machine                 ! Machine data representation
          character*16    hostname                ! Host name
          real*4          pause                   ! Wait time for polling loops

          integer*4       seed                    ! Random number seed
          real*4          tolerance               ! equivalence tolerance

          character*4     nformat
          integer*4       sysunlock

          character*40    command_name            ! name of command
          character*1     command_support         ! name of command
          integer*1       engine
          integer*2       fill

          character*256   home_path               ! current HOME path
          character*60    login_path              ! path for HISTORY FILES
          character*60    write_id                ! current write ID string
          character*60    read_id                 ! current read ID string
          character*8     user_id                 ! User identification string
          integer*4       write_aux               ! current write aux number
          integer*4       read_auxs               ! # currently active read auxs
          integer*4       read_aux(L_auxs)        ! read aux table

          character*40 plot_node                  ! X-Windows screen designator
          character*40 plot_node2                 ! secondary screen designator
          integer*4 left                          ! default X-WIndows left
          integer*4 top                           ! default X-Windows top
          integer*4 width                         ! default X-Windows width
          integer*4 height                        ! default X-Windows height
          integer*4 window_id                     ! X-Windows window ID
          integer*2 window_w                      ! X-Window actual width (pixels)
          integer*2 window_h                      ! X-Window actual hght (pixels)
          record /COLORTYPE/ colormap(4)          ! colormap environments

          integer*4 visClass                ! default /VISCLASS
          integer*4 visDepth                ! default /VISDEPTH
          integer*4 visID                   ! default /VISUALID

        END STRUCTURE

c these need to be unique in spawned tasks
        STRUCTURE /MUNIQUE/
          integer*4     id                      ! primitive ID
          logical*4     verbose                 ! inv state of QUIET switch
          logical*4     warn                    ! inv state of NOWARN switch
          logical*4     alert                   ! inv state of NOALERT switch
          integer*4     spawn                   ! Spawned task flag
          integer*4     files                   ! number of open files
          real*8        todo                    ! counter for M$DO,etc
          character*40  command_name            ! local copy of command name
          integer*4     messagelog              ! message /ID of error logger
          logical*4     okio                    ! IO status
        END STRUCTURE
c
        record /MCOMMON/ Mc
        pointer (pMc,Mc)
        common /M$COMMON/ pMc

        integer*4 M_ppid, M_spid, M_shrmask

        record /MUNIQUE/ Mu
        pointer (pMu,Mu)
        common /M$UNIQUE/ pMu

