#!/usr/bin/env bash
# @(#) s1 Demonstrate gfortran.
# Infrastructure details, environment, commands for forum posts.
# Uncomment export command to run script as external user.
# export PATH="/usr/local/bin:/usr/bin:/bin"
set +o nounset
pe() { for i;do printf "%s" "$i";done; printf "\n"; }
pl() { pe;pe "-----" ;pe "$*"; }
LC_ALL=C ; LANG=C ; export LC_ALL LANG
pe ; pe "Environment: LC_ALL = $LC_ALL, LANG = $LANG"
pe "(Versions displayed with local utility \"version\")"
c=$( ps | grep $$ | awk '{print $NF}' )
version >/dev/null 2>&1 && s=$(_eat $0 $1) || s=""
[ "$c" = "$s" ] && p="$s" || p="$c"
version >/dev/null 2>&1 && version "=o" $p printf gfortran
set -o nounset
pe
FILE=${1-hello.f}
# Display sample of data file, with head & tail as a last resort.
pe " || start [ first:middle:last ]"
specimen $FILE \
|| { pe "(head/tail)"; head -n 5 $FILE; pe " ||"; tail -n 5 $FILE; }
pe " || end"
pl " Results:"
gfortran -ffree-form $FILE
exit 0
producing:
% ./s1
Environment: LC_ALL = C, LANG = C
(Versions displayed with local utility "version")
OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution : Debian GNU/Linux 5.0
GNU bash 3.2.39
printf - is a shell builtin [bash]
gfortran GNU Fortran (Debian 4.3.2-1.1) 4.3.2
|| start [ first:middle:last ]
Whole: 5:0:5 of 9 lines in file "hello.f"
program hello
PARAMETER(a=100)
integer a
write(*,*)'value ', a
end program hello
|| end
-----
Results:
hello.f:5.11:
integer a
1
Error: Symbol 'a' at (1) already has basic type of REAL
The error message seems clear and suggests a solution: declare the symbol type before the first use.