#!perl                                                      #<HTML><PRE>
#
# Perl script 'fv.pl' to perform network ray tracing in Fresnel volumes
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Usage:
#     perl fv.pl $-
# Parameters:
#     $-...   Prefix of the input data files.
# Input files required:
#     $-gri1.dat, $-net1.dat, $-net2.dat,
#     $-gri3.dat, $-net3.dat, $-net4.dat, $-net.h and files referred
#                                                 from them.
#     First  3 files correspond to the first iteration,
#     latter 3 files correspond to all subsequent iterations.
#     Inside all these files $-net.out, which will be created of
#     $-net.h, has to be referred as the SEP parameter file describing
#     the grid dimensions and numerical parameters.
# Note:
#     After each network ray tracing from the 1st (source) point to the
#     2nd (receiver) point, you may Quit the iterations.  Consecutive
#     network ray tracing in the opposite is not required during the
#     last iteration, which may be reported by program 'netind.for' or
#     indicated by a user.
# ======================================================================
# Input files required:
  $PREFIX=$ARGV[0];
  @ARGV=();
  require        'go.pl'             ;
# &CHK("net/"   ,"net.fs2"          ); # just in 2-D
# &CHK("net/"   ,"net.fs3"          ); # just in 3-D
  &CHK("net/fv/","${PREFIX}gri1.dat");
  &CHK("net/fv/","${PREFIX}net1.dat");
  &CHK("net/fv/","${PREFIX}net2.dat");
  &CHK("net/fv/","${PREFIX}gri3.dat");
  &CHK("net/fv/","${PREFIX}net3.dat");
  &CHK("net/fv/","${PREFIX}net4.dat");
  &CHK("net/fv/","${PREFIX}net.h"   );
# &CHK("net/fv/","${PREFIX}src.dat" ); # or whatever is referred
# &CHK("net/fv/","${PREFIX}rec.dat" ); # or whatever is referred
# &CHK("net/fv/","vgr-mod.dat"      ); # or whatever is referred
#
# Copy file $-net.h to $-net.out:
  &COPY("${PREFIX}net.h","${PREFIX}net.out");
#
# First iteration:
  &RUN("grid"  ,"'${PREFIX}net.out' '${PREFIX}gri1.dat' /");
  &ECHO(       ">>${PREFIX}net.out","  NET='${PREFIX}net1.dat'");
  &RUN("net"   ,"'${PREFIX}net.out' /");
  &ECHO(       ">>${PREFIX}net.out","  NET='${PREFIX}net2.dat'");
  &RUN("net"   ,"'${PREFIX}net.out' /");
  &RUN("netind","'${PREFIX}net.out' '${PREFIX}net1.dat' '${PREFIX}net2.dat' '${PREFIX}net3.dat' /");
#
# Next iterations:
FV:
  &RUN("grid"  ,"'${PREFIX}net.out' '${PREFIX}gri3.dat' /");
  &ECHO(       ">>${PREFIX}net.out","  NET='${PREFIX}net3.dat'");
  &RUN("net"   ,"'${PREFIX}net.out' /");
  print "Type Q[uit] to terminate iterations, RETURN to continue: ";
  $ans=<STDIN>;
  exit 0 if $ans=~ /^[Qq]/;
  &ECHO(       ">>${PREFIX}net.out","  NET='${PREFIX}net4.dat'");
  &RUN("net"   ,"'${PREFIX}net.out' /");
  &RUN("netind","'${PREFIX}net.out' '${PREFIX}net3.dat' '${PREFIX}net4.dat' '${PREFIX}net3.dat' /");
goto FV;
#
1;                                                               #</PRE>
