#!perl #
#
# Perl script to display the colour saturation of the snapshots
#
# Version: 5.20
# Date: 1998, October 8
#
# Usage:
#     perl fdmax.pl SEP DIV ROT PS
# Parameters:
#     SEP...  Name of the history file.
#     DIV...  Filename of the 4-D data cube of the "normalized" wavefield
#             divergence (P waves).
#     ROT...  Filename of the 4-D data cube of the X2 component of the
#             "normalized" wavefield rotation (S waves).
#     PS...   Output PostScript figure to be displayed and edited.
#             Refer to 'print' commands at the end of this file.
#
# ======================================================================
#
  @ARGVsave=@ARGV;
  @ARGV=();
  require 'go.pl';
  &CHK("forms/","sep.pl");
  require 'sep.pl';
  @ARGV=@ARGVsave;
#
  &CHK("fd/","fdmax.pro");
  &CHK(""   ,"$ARGV[0]" );
  &CHK(""   ,"$ARGV[1]" );
  &CHK(""   ,"$ARGV[2]" );
#
  &RSEP1($ARGV[0]);
  &RSEP3("N4"   ,$N4   ,1);
  &RSEP3("D4"   ,$D4   ,1);
  &RSEP3("SAMP" ,$SAMP ,1);
  &RSEP3("VSAT" ,$VSAT ,1);
  &RSEP3("VSAT4",$VSAT4,0);
#
  &ECHO( ">$ARGV[3]","%!");
  &ECHO(">>$ARGV[3]","/N4    $N4    def");
  &ECHO(">>$ARGV[3]","/D4    $D4    def");
  &ECHO(">>$ARGV[3]","/SAMP  $SAMP  def");
  &ECHO(">>$ARGV[3]","/VSAT  $VSAT  def");
  &ECHO(">>$ARGV[3]","/VSAT4 $VSAT4 def");
  &ECHO( ">grdnorm.tmp","N1=1  N2=1  N3=1");
  &ECHO(">>grdnorm.tmp","GNORM=999.      ");
  &RUN("grdnorm","'$ARGV[0]' 'grdnorm.tmp' '$ARGV[1]' 'fdmax.tmp' /");
  &APPEND("$ARGV[3]","fdmax.tmp");
  &RUN("grdnorm","'$ARGV[0]' 'grdnorm.tmp' '$ARGV[2]' 'fdmax.tmp' /");
  &APPEND("$ARGV[3]","fdmax.tmp");
  &APPEND("$ARGV[3]","fdmax.pro");
#
  print "-----------------------------------------------------------------\n";
  print "Display and edit file '$ARGV[3]' to adjust the colour saturation!\n\n";
  print "Black line in figure '$ARGV[3]' corresponds to the maximum colour\n";
  print "saturation, green dots to P waves and blue dots to S waves.\n";
  print "Change SAMP to amplify S waves with respect to P waves,\n";
  print "VSAT to adjust the initial level of the saturation line and\n";
  print "VSAT4 to adjust its exponential decay.\n\n";
  print "When figure '$ARGV[3]' is OK, modify SAMP, VSAT and VSAT4 in the\n";
  print "history file accordingly!\n";
# ======================================================================
1;                                                               #