c
c     Copyright (c) 1999,2000, Compaq Computer Corporation
c
c     See the file "license.terms" for information on usage and redistribution
c     of this file, and for a DISCLAIMER OF ALL WARRANTIES.
c
      subroutine init_common
      implicit none
c
      include 'const.h'
      include 'sysdep.cmn'
      include 'mesh.cmn'
      include 'data.cmn'
      include 'io.cmn'
      include 'plot.cmn'
      include 'compare.cmn'
      include 'compare_2d.cmn'
      include 'units.cmn'
      include 'annotations.cmn'
      include 'defaults.cmn'
      include 'save.cmn'
      include 'callable.cmn'
      include 'user.cmn'
      include 'incore.cmn'
      include 'version.cmn'
      include 'title.cmn'
      include 'surf.cmn'
      include 'analytical.cmn'
c
      integer i
      logical lfirst
      data    lfirst/.TRUE./
      save    lfirst
c
c     Only initialize once
      if( lfirst ) then
         lfirst = .FALSE.
      else
         return
      endif
c
c     Logical unit numbers
      luttyi  = PM_LU_STDIN
      luttyo  = PM_LU_STDOUT
      luprint = 8
      binfil  = 9
      asciifil= 10 
      notefil = 11
      savefil = 15
c
      binfilename = ' '
      user_1d_asciifile = ' '
      lplotfile = .FALSE.
      given_plotfilename = 'POSTMINI.PLT'
      savefilename = 'POSTMINI.PMI'
      binfiletype = DT_MINIMOS
      binfile_convert_type = BINFILE_TYPE_DEFAULT
      lfirst_read = .TRUE.
      lbatch = .FALSE.
      lrestore = .FALSE.
      lsavefile_read = .FALSE.
      medici_solution_file = ' '
c
      plane_type = 0
c
c     Plot variables
      gks_is_open            = .FALSE.
c
c     MAJOR CHANGE. Motif workstation type is now the default!!
c     IOR with bit mask that says "use 16 color maps entries"
c     instead of GKS default (64 entries). This allows us to open more than
c     three windows without making the other windows go 'technicolor'.
c
c     Use /device (-device) commmand line option to change default plot
c     device.
      plot_device            =  IOR(GKS$K_MOTIF,'00100000'X)
      previous_plot_device   =  IOR(GKS$K_MOTIF,'00100000'X)
c
c     It's important that hardcopy_device starts out different
c     from plot_device.
      hardcopy_device        =  GKS$K_POSTSCRIPT 
      hardcopy_colormap      =  COLORMAP_NONE
      default_hc_name        =  PM_DEF_HC_NAME 
      plot_scale_factor      =  PM_DEF_WS_WINDOW_SIZE
      hc_scale               =  1.0 
      hc_aspect_ratio        =  0.77
      hc_xoffset             =  0.0
      hc_yoffset             =  0.0
      hc_is_landscape        =  .TRUE. 
      temp_plot_file_name    =  PM_TEK_TEMP_FILE
      plot_file_name         =  'POSTMINI.PLT'
      plot_title             =  ' ' 
      current_window_id      =  -1 
c
      datafile_loaded = .FALSE.
c
c     Comparison plot initialization
      n_cuts= 0
      do 100 i=1,MULTI_SIZE
        slot_index(i) = -1
100   continue
      do 110 i=1,MULTI_SIZE
         in_use(i) = .FALSE.
110   continue
c
c     Length units
      pm_scale_plot2cm = MU2CM
      pm_scale_cm2plot = CM2MU
      pm_length_unit   = 'microns'
c
c     GKS default font id's
      default_font_id = -9
      ps_font_id      = -107
c
c     User definable plot defaults
c     Some of these are obsolete now that we can modify these parameters
c     via save/restore or new menu user interface.
      l_x_axis_label= .FALSE.
      l_y_axis_label= .FALSE.
      l_z_axis_label= .FALSE.
      l_x_axis_min= .FALSE.
      l_x_axis_max= .FALSE.
      l_y_axis_min= .FALSE.
      l_y_axis_max= .FALSE.
      l_z_axis_min= .FALSE.
      l_z_axis_max= .FALSE.
      l_threed_view= .FALSE.
      l_z_colormap_min= .FALSE.
      l_z_colormap_max= .FALSE.
      l_autoscale     = .FALSE.
      l_oxide_fill    = .TRUE.
      l_gray_scale    = .FALSE.
      l_inv_gray_scale= .FALSE.
      l_write_pmifile = .TRUE.
      l_curv          = .FALSE.
c
      left_unit_delim  = '('
      right_unit_delim = ')'
c
      global_text_scale =  1.0 
      use_solid_lines  = .FALSE.
      global_linewidth_scale = 1.0
      hidden_line_method = HIDDEN_LINES_WITH_HORIZON_FCN
c
c     Save/restore data
      save_plot_type= PLOT_NULL_COMMAND
      num_curves  = 0
      num_titles  = 0
      num_boxes   = 0
      num_lines   = 0
      num_text    = 0
      num_markers = 0
      num_ellipses= 0
c
c     Sticky information
      comp_lfirst  = .TRUE.
      oned_lfirst  = .TRUE.
      twod_lfirst  = .TRUE.
      threed_lfirst= .TRUE.
c
c     Callable interface
      callable_loaded = .FALSE.
      callable_axis_is_set = .FALSE.
      callable_num_sidelabels = 0
      callable_num_titles = 0
c
c     Flag to determine whether dynamic arrays used in processing
c     3D binary files have been allocated
      incore_allocated = .FALSE.
c
c     Version string
      version_string = 'V9.2-000'
c
c     Dynamic allocation array sizes
      arrdat_size = 0
      work_size   = 0
c
c     Color name definitions
c
      call pm_reset_colornames
c
c     Symbol names
      symbol_names(0) = 'none'
      symbol_names(1) = 'circle'
      symbol_names(2) = 'square'
      symbol_names(3) = 'triangle_up'
      symbol_names(4) = 'triangle_down'
      symbol_names(5) = 'solid_circle'
      symbol_names(6) = 'solid_square'
      symbol_names(7) = 'solid_tri_up'
      symbol_names(8) = 'solid_tri_down'
      symbol_names(9) = 'dot'
      symbol_names(10) = 'plus'
      symbol_names(11) = 'asterisk'
      symbol_names(12) = 'cross'
      symbol_names(13) = 'bowtie'
      symbol_names(14) = 'hourglass'
      symbol_names(15) = 'diamond'
      symbol_names(16) = 'solid_bowtie'
      symbol_names(17) = 'solid_hourglass'
      symbol_names(18) = 'solid_diamond'
c
c     Linetype names
      line_names(0) = 'none'
      line_names(1) = 'solid'
      line_names(2) = 'dashed'
      line_names(3) = 'dotted'
      line_names(4) = 'dash_dot'
      line_names(5) = 'dash_2_dot'
      line_names(6) = 'dash_3_dot'
      line_names(7) = 'long_dash'
      line_names(8) = 'long_short_dash'
      line_names(9) = 'spaced_dash'
      line_names(10) = 'spaced_dot'
      line_names(11) = 'double_dot'
      line_names(12) = 'triple_dot'
      line_names(13) = 'undefined1'
      line_names(14) = 'undefined2'
      line_names(15) = 'undefined3'
c
c     GUI flag
      lgui = .FALSE.
c
c     Expression strings
      twod_expression      = ' '
      threed_expression    = ' '
      user_1d_x_expression = ' '
      user_1d_y_expression = ' '
      user_1d_z_expression = ' '
c
c     Grapes pointers
      grapes_file = 0
      grapes_data = 0
c
c     SPICE3 pointers
      spice3_file = 0
      spice3_data = 0
c
c     User data pointers
      user_1d_data_ptr   = 0
      user_1d_coord_ptr  = 0
      user_1d_zval_ptr   = 0
      user_1d_array_size = 0
c
c     Analytical data pointers
      analytical_nx        = 0
      analytical_xval_ptr  = 0
      analytical_yval_ptr  = 0
      analytical_zval_ptr  = 0
      analytical_array_size = 0
c
c     Set pointers in compare structures to 'disassociated' status
      do i=1,MULTI_SIZE
         nullify(multi_1d(i)%data)
         nullify(multi_1d(i)%coord)
         nullify(multi_1d(i)%zval)
         nullify(multi_1d(i)%raw_data)
         nullify(multi_1d(i)%raw_coord)
         nullify(multi_1d(i)%raw_zval)
      end do
c
c     Set pointers in compare_2d structures to 'disassociated' status
      do i=1,MULTI_SIZE
         nullify(multi_2d(i)%x)
         nullify(multi_2d(i)%y)
         nullify(multi_2d(i)%raw_x)
         nullify(multi_2d(i)%raw_y)
         nullify(multi_2d(i)%cord)
         nullify(multi_2d(i)%cord_raw)
         nullify(multi_2d(i)%imat)
         nullify(multi_2d(i)%tri2reg)
         nullify(multi_2d(i)%nop)
         nullify(multi_2d(i)%tri_nextel)
         nullify(multi_2d(i)%data)
         nullify(multi_2d(i)%raw_data)
         nullify(multi_2d(i)%net_doping)
      end do
c
c     Set pointers in surf_curve structure to 'disassociated' status
      nullify(surf_curve%xposition)
      nullify(surf_curve%yposition)
      nullify(surf_curve%zposition)
      nullify(surf_curve%scaled_xposition)
      nullify(surf_curve%scaled_yposition)
      nullify(surf_curve%scaled_zposition)
      nullify(surf_curve%nop)
      nullify(surf_curve%tri_clip)
c
      return
      end
