#!perl #
#
# Perl script 'f.pl' to compile a single Fortran 77 source code file
#
# Editing this file enables to very simply compile and link all Fortran
# programs of package FORMS and related packages (like MODEL, CRT, NET,
# ANRAY and FD) using system-independent Perl scripts.
#
# Version: 5.40
# Date: 1999, September 21
#
# Coded by: Vaclav Bucha and Ludek Klimes
#     Department of Geophysics, Charles University Prague,
#     Ke Karlovu 3, 121 16 Praha 2, Czech Republic,
#     E-mails: bucha@seis.karlov.mff.cuni.cz
#              klimes@seis.karlov.mff.cuni.cz
#
# ......................................................................
#
# This file consists of the following PERL subroutines:
#     COMPILE... Subroutine designed to compile a single Fortran 77
#             source code file.
#             COMPILE
#     Main script designed to compile single Fortran 77 source code
#             file by means of invocation of subroutine COMPILE
#             if its name is specified at the command line.
#             F
#
# ======================================================================
#
# 
#
# Subroutine COMPILE($FILE[,$OPTIONS])
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Subroutine designed to compile a single Fortran 77 source code file.
#
# Input:
#     $FILE...String containing the name of the Fortran 77 source code
#             file without extension '.for'.
#     $OPTIONS... Optional command-line arguments for the compiler.
#
# No output.
#
# Note: Uncomment and modify commands for your compiler.  After that,
#       comment the following line:
        die "Uncomment and modify commands for your compiler.  Error";
#
# ----------------------------------------------------------------------
#
  sub COMPILE {
    $FILE=$_[0];
    @FILEandOPTIONS=@_;
    print "---------- Compiling ${FILE}.for ----------\n";
#
#   Linux compiler g77:
#   ~~~~~~~~~~~~~~~~~~~
#   Compiling $FILE.for to get executable $FILE
    # open(LU,"|g77 -o @FILEandOPTIONS $FILE.for>$FILE.lst");
#   (option -O is not recommended)
#   (option -O cannot be used to compile mtt.for and anray.for)
#   (rounding errors on a PC sometimes resemble RISC computers)
    # close(LU) || die "Error";
#
#   Linux compiler fort77:
#   ~~~~~~~~~~~~~~~~~~~~~~
#   Copying $FILE.for to $FILE.f
    # symlink("$FILE.for","$FILE.f");
#   Compiling $FILE.f to get executable $FILE
    # open(LU,"|fort77 -Nc40 -O -o @FILEandOPTIONS $FILE.f");
#   (option -Nc40 is necessary to compile grdcal.for)
#   (do not use option -O to compile mtt.for)
#   (program green.for does not work properly)
#   (cannot compile package RMATRIX)
    # close(LU) || die "Error";
#   Deleting $FILE.f
    # unlink("$FILE.f");
#
#   HP-Unix compiler fort77:
#   ~~~~~~~~~~~~~~~~~~~~~~~~
#   Copying $FILE.for to $FILE.f
    # symlink("$FILE.for","$FILE.f");
#   Compiling $FILE.f to get executable $FILE
    # open(LU,"|fort77 -o @FILEandOPTIONS $FILE.f");
#   (use option -K to compile grdran2d.for)
#   (subroutine SIGNAL in ss.for must be renamed)
    # close(LU) || die "Error";
#   Deleting $FILE.f
    # unlink("$FILE.f");
#
#   MS-DOS Lahey compliler F77L3 and linker 386LINK:
#   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#   Compiling $FILE.for to get $FILE.obj
    # open(LU,"|F77L3 @FILEandOPTIONS >$FILE.lst");
    # close(LU) || die "Error";
#   Linking $FILE.obj to get executable $FILE.exe
    # open(LU,"|386LINK @FILEandOPTIONS -lib GRAPH3 -symbol");
#   (use option -stack ... to link grdran2d.for)
    # close(LU) || die "Error";
#   Deleting $FILE.obj
    # unlink("$FILE.obj");
  }
# ======================================================================
#
# 
#
# Main script
# ~~~~~~~~~~~
# Usage:
#     perl f.pl [$FILE [options]]
# Parameters:
#     $FILE...String containing the name of the Fortran 77 source code
#             file without extension '.for'.
#             If $FILE is not specified, no action is done.
#
# ----------------------------------------------------------------------
#
  if (scalar(@ARGV)>0) {&COMPILE(@ARGV)};
#
# ======================================================================
1;                                                               #