Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!quintus!ok From: ok@quintus.uucp (Richard A. O'Keefe) Newsgroups: comp.lang.fortran Subject: Re: Fortran vs C for computations Message-ID: <368@quintus.UUCP> Date: 8 Sep 88 10:16:21 GMT References: <362@quintus.UUCP> <3292@lanl.gov> Sender: news@quintus.UUCP Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 49 In article <3292@lanl.gov> jlg@lanl.gov (Jim Giles) writes: >From article <362@quintus.UUCP>, by ok@quintus.UUCP (Richard A. O'Keefe): >> In article <3256@lanl.gov> jlg@lanl.gov (Jim Giles) writes: >>>Anything C can do portably with library routines, Fortran can also do >>>portably with library routines. >> >> I would like to see a more convincing proof of this. > >Ok. Take the C library. Write bridge routines through which Fortran >programs can call all the procedures in the C library. Fortran now has >a library with the same functionality as the C library. QED > >Obviously - Anything C can do portably with library routines, Fortran >can also do portably with library routines. This is because Fortran >and C can both use the _SAME_ library on any given machine. > Sorry, this proof won't go through. It is only the case that Fortran and C can use the same library if they use sufficiently compatible calling sequences and memory management strategies. There are quite a few other potential problems. For example, suppose the C library routines require that the program execute a C initialisation routine ("crt0.o") and Fortran requires a Fortran initialisation which is incompatible with the C one? This is not a theoretical case! There are far too many UNIX systems where mixing Fortran and C code *sometimes* works provided e.g. that you don't do any Fortran I/O if the main program is C. As an example of another kind of difficulty, consider the System V "ftw" function: int ftw(char *path, int (*fn)(char *, struct stat *, int), int depth) Because the function parameter can call ftw() itself, and because it can call longjmp(), I believe that it is impossible to write a bridging routine to permit Fortran to call this, unless you modify the C library. >> How come _the_ language for floating-point calculations doesn't have >> a portable way of catching or suppressing floating-point exceptions? > >Because no two machines have the same exception handling capabilities! >Fortran doesn't include [them] because there is no portable >way to implement them. If a machine doesn't provide a way of detecting and reporting floating- point exceptions (that is, if it insists on its right to produce incorrect answers without notice) why should I *care* about having Fortran on it? Or were the numerical analysts who contributed to the development of the IEEE 754 standard wrong in thinking this was important?