#!perl #
#
# Perl script to modify the effective elastic parameters (harmonic
# averages of elastic parameters) for 2-D elastic finite differences
#
# Version: 5.20
# Date: 1998, October 8
#
#=======================================================================
#
  require 'sep.pl';
#
# Reading main input data from the command line:
  $SEP=$ARGV[0];
#
# Reading input SEP header file:
  &RSEP1($SEP);
  &RSEP3('N1',$N1,1);
  &RSEP3('N3',$N3,1);
  &RSEP3('A13' ,$A13 ,' ');
  &RSEP3('A31' ,$A31 ,' ');
  &RSEP3('AA13',$AA13,' ');
  &RSEP3('B13' ,$B13 ,' ');
  &RSEP3('B31' ,$B31 ,' ');
  &RSEP3('BB13',$BB13,' ');
  &RSEP3('C13' ,$C13 ,' ');
  &RSEP3('C31' ,$C31 ,' ');
  &RSEP3('CC13',$CC13,' ');

# Creating temporary SEP header file for grdcal.for:
  $n1=$N1-1;
  $n3=$N3-1;
  open (LU,'>sep.tmp');
  print LU "N1=$n1 N3=$n3\n";
  close(LU) || die "Error";

# Creating temporary command file for grdcal.for:
  open (LU,'>newpar.tmp');
  print LU 'A=$1+$2 ',"\n";
  print LU '$3=0.5*A',"\n";
  print LU 'A=$4+$5 ',"\n";
  print LU '$6=0.5*A',"\n";
  print LU 'A=$7+$8 ',"\n";
  print LU '$9=0.5*A',"\n";
  close(LU) || die "Error";

# Running grdcal.for:
  open (LU,'|grdcal');
  print LU "'sep.tmp' 'newpar.tmp' ",
           "'$A13' '$A31' '$AA13' ",
           "'$B13' '$B31' '$BB13' ",
           "'$C13' '$C31' '$CC13' /";
  close(LU) || die "Error";
#=======================================================================
1;                                                               #