c***********************************************************************
      SUBROUTINE read_flags(n1,n2,n3)
c***
      INCLUDE 'undefined.h'
      INCLUDE 'flags.h'
      INTEGER n1,n2,n3
      INTEGER GP_IFETCH
      EXTERNAL GP_IFETCH
c***
c     read_stdin obsolete for Getpar 1.5 (with MPI) 
c***
c      call read_stdin
c***
c     get dimensions from input file
c***
      n1 = GP_IFETCH('n1',0,'DEFAULT')
      if (n1 .eq. 0) n1 = GP_IFETCH('nx',0,'SEVERE')
      n2 = GP_IFETCH('n2',0,'DEFAULT')
      if (n2 .eq. 0) n2 = GP_IFETCH('ny',0,'SEVERE')
      n3 = GP_IFETCH('n3',0,'DEFAULT')
      if (n3 .eq. 0) n3 = GP_IFETCH('nz',0,'SEVERE')
c***
c     get temporal steps
c***
      tmax = GP_IFETCH('final_step_number',0,'SEVERE')
      tstore_c = GP_IFETCH('tstore',0,'WARNING')
      tcheck = GP_IFETCH('check_every_steps',0,'WARNING')
      tdump = GP_IFETCH('tstore',0,'WARNING')
c***
      return
      end
c***********************************************************************
      SUBROUTINE read_physics()
c***
      INCLUDE 'undefined.h'
      INCLUDE 'dimension.h'
      INCLUDE 'physics.h'
      INCLUDE 'algorithms_controllers.h'
      DOUBLE PRECISION tau_SI, timescale, lengthscale, length_SI, 
     %     rho1_SI, rho2_SI, visc1_SI, visc2_SI,sigma_SI, grav_SI, 
     %     lengthsize, numer, denom, grav1_SI
      DOUBLE PRECISION GP_DFETCH
      INTEGER GP_IFETCH
      EXTERNAL GP_DFETCH, GP_IFETCH
c***
c     read necessary parameters
c***
      tau_SI = GP_DFETCH('time_step', 0.0d0,'SEVERE')
      timescale = GP_DFETCH('timescale', 1.0d0,'SEVERE')
c***
      length_SI = GP_DFETCH('length', 0.0d0,'SEVERE')
      lengthscale = GP_DFETCH('lengthscale',1.0d0,'WARNING')
c***
      rho1_SI = GP_DFETCH('fluid_density_1', 0.0d0,'SEVERE')
      rho2_SI = GP_DFETCH('fluid_density_2', 0.0d0,'SEVERE')
c***
      visc1_SI = GP_DFETCH('fluid_viscosity_1', 0.0d0,'SEVERE')
      visc2_SI = GP_DFETCH('fluid_viscosity_2', 0.0d0,'SEVERE')
c***
c     read optional parameters 
c***
      sigma_SI = GP_DFETCH('surface_tension',0.0d0,'WARNING')
      grav_SI  = GP_DFETCH('gravity',0.0d0,'WARNING')
c	write ( *, *) 'gravSI', grav_SI
      grav1_SI  = GP_DFETCH('gravity1',0.0d0,'DEFAULT')
c***
c     now derive adimensional physical variables to be stored in
c     the common physics, (be sure time in sec and length in meters)
c***
      numer = tau_SI
      denom = timescale
      tau = numer/denom
c***
      numer = length_SI
      denom = lengthscale
      lengthsize = numer/denom
      h = 1.d0/(nx-2)
c***
      numer = rho2_SI
      denom = rho1_SI
      rho1  = 1.d0
      rho2  = numer/denom
c***
      denom = rho1_SI * lengthsize**2 / timescale 
      numer = visc1_SI
      mu1 = numer/denom
      numer = visc2_SI
      mu2   =  numer/denom
c***
      numer = sigma_SI
      denom = rho1_SI * lengthsize**3 / timescale**2
      sigma = numer/denom
c***
      numer = grav_SI
      denom = lengthsize / timescale**2
      g = numer/denom

      numer = grav1_SI
      denom = lengthsize / timescale**2
      g1 = numer/denom
c***
c     factor to adimensionalize velocity field
c***
      vscale = lengthsize / timescale
c***
      return
      end
c***********************************************************************
      SUBROUTINE printdata()
c***
      INCLUDE 'undefined.h'
      INCLUDE 'dimension.h'
      INCLUDE 'flags.h'
      INCLUDE 'physics.h'
      INCLUDE 'algorithms_controllers.h'
c***
      write (*,*)
      write (*,*) '*** input/output files ***'
      write (*,*)
c***
      write (*,*)
      write (*,*) '*** grid and temporal data ***'
      write (*,*)
      write (*,*) 'grid point along x axis = ', nx
      write (*,*) 'grid point along y axis = ', ny
      write (*,*) 'grid point along z axis = ', nz
      write (*,*) 'initial step            = ', t0
      write (*,*) 'final step              = ', tmax
      write (*,*) 'storing velocity rate   = ', tstore_v
      write (*,*) 'storing pressure rate   = ', tstore_p
      write (*,*) 'storing vol. frac. rate = ', tstore_c
      write (*,*) 'checking rate           = ', tcheck
      write (*,*) 'dumping rate            = ', tdump
c***
      write (*,*)
      write (*,*) '*** adimensional physics parameters ***'
      write (*,*)
c***
      write (*,*) 'time step         =', tau
      write (*,*) 'grid size         =', h
      write (*,*) 'density fluid 1   =', rho1
      write (*,*) 'density fluid 2   =', rho2
      write (*,*) 'viscosity fluid 1 =', mu1
      write (*,*) 'viscosity fluid 2 =', mu2
      write (*,*) 'surface tension   =', sigma
      write (*,*) 'gravity           =', g

      return
      end

