[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
961226: Known problem with PROMULA FORTRAN
- Subject: 961226: Known problem with PROMULA FORTRAN
- Date: Thu, 26 Dec 96 12:03:15 -0700
George,
>Date: Fri, 20 Dec 1996 19:27:16 -0500
>From: "George E. Juras" <address@hidden>
>Organization: PROMULA Development Corporation
>To: Steve Emmerson <address@hidden>
>Subject: Re: 961212: Known problem with PROMULA FORTRAN
>Keywords: 199612121831.AA26117
In the above message you wrote:
> Earlier today I found some time to make netcdf on an HP/UX workstation so
> that I can test our translation/compilation of ftest.f, with which PROMULA
> FORTRAN was supposed to have problems.
>
> I used to distribution make files to make the netcdf framework (libraries,
> etc.) and then I translated/compiled/linked ftest.f by hand to do the test,
> as shown in the log below.
>
> As you can see, the translation of ftest.f to ftest.c is clean and the
> subsequent compilation/linking with cc generates an executable which appears
> to run without errors.
>
> I didn't find anything wrong with our treatment of BLOCK DATA -- or anything
> else for that matter.
Fantastic!
>
> I don't know enough about make files to add pfc to the many FORTRAN
> compilers that the netcdf distribution supports.
>
> The compilation of a fortran program with pfc is a two-step process:
>
> pfc file.for opt1 opt2 opt2 ...[Ofile.c]
> cc -c file.c
>
> where file.for (or file.f or file.ftn) is the FORTRAN source
> opt1 opt2 ... is a list of optional flags that you may add to the
> translation
> file.c is the default output of the translation
>
> Your scripts assume a single command line for a FORTRAN compiler, via the
> variable FC. Can you tell me how to edit your configure and make-make files
> to add pfc properly in the make process?
I should modify the build procedures here since that's my baby.
I think the easiest way to incorporate PROMULA FORTRAN into the build
process is to create a shell script that performs the translation *and*
then invokes the C compiler -- though the exact behavior will have to
depend on the options that the script is given (e.g. `-c' to compile;
otherwise link). This shell script can then be invoked by a one-line
command just like the other FORTRAN compiler currently are.
I've enclosed a first-try at such a script. To test it, try the
following:
1. Put the enclosed script in the top-level source directory in a
file named `promula'.
2. Set the execution bit on the script.
3. Go to the top-level source directory.
4. Execute the command `make distclean'.
5. Set the environment variable FC to the following string:
`pwd`/promula
(Note the command substitution in the above. The idea is to
set the FC variable to the the absolute pathname of the script.)
6. Execute the `configure' script.
7. Execute the command `make'.
8. Execute the command `make test'.
You'll probably have to modify the script to get it to work. When
you get it working, send me back a copy and I'll include it in the
distribution.
>
> Let me know if you need more information to remove the "Known Problem with
> pfc" reference in your Web page.
>
> Thanks.
>
> George E. Juras
> =============================================================================
> Script started on Fri Dec 20 18:16:27 1996
> /netcdf/netcdf-2.4.3/src/fortran:
>
> Translating ftest.f to ftest.c with the PROMULA FORTRAN to C Translator
>
> /netcdf/netcdf-2.4.3/src/fortran:pfc ftest.f V2
> PROMULA.FORTRAN to C V6.04 (05/01/96) (c) 1988-96 PROMULA Development Corp.
> Compiling source file: ftest.f
> Processing subprogram: ftest
> Including source file: netcdf.inc
> Processing subprogram: tncacpy
> Including source file: netcdf.inc
> Processing subprogram: tncadel
> Including source file: netcdf.inc
> Processing subprogram: tncagt
> Including source file: netcdf.inc
> Processing subprogram: tncapt
> Including source file: netcdf.inc
> Processing subprogram: ftnblkd
> Processing subprogram: tncddef
> Including source file: netcdf.inc
> Processing subprogram: tncinq
> Including source file: netcdf.inc
> Processing subprogram: tncredf
> Including source file: netcdf.inc
> Processing subprogram: tncvdef
> Including source file: netcdf.inc
> Processing subprogram: tncvgt
> Including source file: netcdf.inc
> Processing subprogram: tncvgt1
> Including source file: netcdf.inc
> Processing subprogram: tncvpt
> Including source file: netcdf.inc
> Processing subprogram: tncvpt1
> Including source file: netcdf.inc
> Processing subprogram: tfills
> Including source file: netcdf.inc
> /netcdf/netcdf-2.4.3/src/fortran:
>
> Compiling ftest.c and linking with ../libsrc/libnetcdf.a and the pfc FORTRAN
> runtime
> library libpfc.a to make the executable ftest.
>
> /netcdf/netcdf-2.4.3/src/fortran: cc -o ftest ftest.c -L../libsrc -lnetcdf
> -lpfc -lm -Aa
> /netcdf/netcdf-2.4.3/src/fortran:
> /netcdf/netcdf-2.4.3/src/fortran:ls -lt ftest*
> -rwxr-xr-x 1 root sys 242337 Dec 20 18:18 ftest
> -rw-r--r-- 1 root sys 50234 Dec 20 18:18 ftest.c
> -rw-r--r-- 1 root sys 37853 Dec 20 17:50 ftest.f
> -rw-rw-r-- 1 1136 2010 38088 Feb 26 1996 ftest.src
> /netcdf/netcdf-2.4.3/src/fortran:
>
>
> Running ftest. It looks like it passes all tests.
>
> /netcdf/netcdf-2.4.3/src/fortran: ./ftest
> *** Testing nccre ...
> *** Testing ncddef ...
> *** Testing ncvdef ...
> *** Testing ncapt, ncaptc ...
> *** Testing ncclos ...
> *** Testing ncvpt1 ...
> *** Testing ncvgt1 ...
> *** Testing ncvpt ...
> *** Testing ncopn, ncinq, ncdinq, ncvinq, ncanam, ncainq ...
> *** Testing ncvgt, ncvgtc ...
> *** Testing ncagt, ncagtc ...
> *** Testing ncredf, ncdren, ncvren, ncaren, ncendf ...
> *** Testing ncacpy ...
> *** Testing ncadel ...
> *** Testing fill values ...
Yup. The above indicates that there were no problems.
> /netcdf/netcdf-2.4.3/src/fortran:
> /netcdf/netcdf-2.4.3/src/fortran:exit
--------
Steve Emmerson <address@hidden>
--------Begin `promula' script
# Script for emulating a FORTRAN utility using the PROMULA `pfc'
# FORTRAN-to-C translator.
# Customizations. Modify as necessary.
#
translator=pfc
compiler=cc
# Print a message to standard error.
#
# Internal function.
#
errmsg()
{
echo 1>&2 $arg0: "$@"
}
# Print a usage message.
#
# Internal function.
#
usage()
{
errmsg "\
Usage:
$arg0 file_or_option ..."
}
# Translate and compile a file.
#
translate_and_compile()
{
file=$1
if eval $translator $tflags $file; then
name=`basename $file .f`
if eval $compiler -c $cflags $outopt $name.c; then
rm $name.c
else
errmsg "Unable to compile $file"
exit 1
fi
else
errmsg "Unable to translate $file"
exit 1
fi
}
# Decode the arguments.
#
arg0=$0
compile_only=0
outopt=
files=
tflags=
cflags=
for arg do
case $1 in
-c)
compile_only=1
;;
-o)
outopt="-o $2"
shift
;;
-*)
usage
;;
*)
files="$files $1"
;;
esac
shift
done
# Perform the action.
#
case $compile_only in
0)
objs=
for file in "$files"; do
case $file in
*.f)
if eval translate_and_compile $file; then
objs="$objs `basename $file .f`.o"
else
break
fi
;;
*)
objs="$objs $file"
esac
done
case $? in
0)
$compiler $cflags $outopt $objs
;;
esac
;;
*)
for file in "$files"; do
case $file in
*.f)
name=`basename $file .f`
if eval translate_and_compile $file; then
: true
else
break
fi
;;
*)
if eval $compiler -c $cflags $outopt $file; then
: true
else
errmsg "Unable to compile $file"
break
fi
;;
esac
done
;;
esac
exit