#!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: 7.50 # Date: 2018, September 10 # # Coded by: Vaclav Bucha and Ludek Klimes # Department of Geophysics, Charles University Prague, # Ke Karlovu 3, 121 16 Praha 2, Czech Republic, # http://sw3d.cz/staff/bucha.htm # http://sw3d.cz/staff/klimes.htm # # ...................................................................... # # Usage: # To compile Fortran source code 'prog.for', # Perl script 'f.pl' may be executed by command # perl f.pl prog # generating the output executable file whose name is system # dependent, usually 'prog' under Unix and Linux, and 'prog.exe' # under MSDOS and Windows. # Mostly also file 'prog.lst' containing accumulated compiler # messages is generated. # Note: # If 'prog.lst' is not generated, try to execute 'f.pl' by command # perl f.pl prog >name.lst 2>&1 # where 'name.lst' stands for arbitrary name of the file with # compiler messages, different from 'prog.lst'. # # ...................................................................... # # 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) # (option -m32 when compiling on 64-bit Linux is recommended) # (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 13000000 to link grdran2d.for) # (use option -stack 100000 to link green.for) # close(LU) || die "Error"; # Deleting $FILE.obj # unlink("$FILE.obj"); # # GNU gfortran 4.7.3 under Windows XP 32bit or Windows 10 64bit: # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Deleting executable $FILE.exe # unlink("$FILE.exe"); # Compiling $FILE.for to get executable $FILE # open(LU,"|gfortran -fno-sign-zero -o @FILEandOPTIONS $FILE.for>$FILE.lst"); # (option -fno-sign-zero is strongly recommended, otherwise gfortran # will produce zeros with minus sign on output, which violates the norm # of Fortran77) # close(LU) || die "Error"; # } # ====================================================================== # # # # 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; #