HDTenEightyP/NetNews huggingface dataset:
From: roy@zooks.eng.mcmaster.ca (Roy Underhill)
Subject: Re: how to quit on an NaN result?
Summary: answer with SGI
Keywords: SGI,sigfpe,TRAP_FPE,NaN
Organization: Dept. of Mech. Eng., McMaster University
Date: Wed, 19 Aug 1992 18:32:08 GMT

>  I am debugging code which is still in the stage where many NaN results


On a Silicon Graphics machine there are a couple of ways to do this 
that have worked reliably for me.  The easiest is to set an
environment variable, TRAP_FPE, to a string that will govern what
action is taken.  For example

setenv TRAP_FPE "ALL=ABORT"

in the script that executes your program or by a system call within
your fortran program will cause a crash and burn for any floating
point exception - underflow, overflow, divide by zero or indeterminate
operation.  The alternative is that one can write a custom error
handler.  Mine is fairly simple; all it does it tell me what happened
and then it calls abort() to force a core dump.  All the gory details are
in <fsigfpe.h>.

	These are not standard and are system dependent.  BUT they do
work.  So I hope that that was of help to any SGI fortran developers.


Roy
-- 
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
  Roy Underhill,  (416) 525-9140 x4395   roy@zooks.eng.mcmaster.ca 
  Department of Mechanical Engineering,  McMaster University, 
  Hamilton,  Ontario,  Canada            L8S 4L7
Newsgroups: comp.lang.fortran
From: aswx266@chpc.utexas.edu (Michael Lemke)
Subject: Re: programming style question
Organization: The University of Texas System - CHPC
Date: Sat, 22 Aug 92 20:57:56 GMT

In article <1992Aug21.184751.9673@draco.macsch.com> drd@macsch.com (Daniel R. Dawson) writes:
>>pm@katz.cc.univie.ac.at (Peter Marksteiner) writes:
>>>ecmtwhk@ccu1.aukuni.ac.nz (Thomas Koenig) writes: 
>>>
>>>>It's a real shame that Unix does not have standard way of attatching
>>>>FORTRAN units to file descriptors, that would make things much easier.
>>>>Does POSIX have anything to say about that?
>>>
>>>Try symbolic links. For example,
>>>
>>>    ln -s /whatever/pathname/you/want fort.3
>>>
>>>may not be as beautiful as
>>>
>>>//FT03F001  DD  DSN=REVOLTING.MVS.DATASET,DISP=NEW
>>>
>>>but it works almost as well. 
>>
>>Unfortunately `almost' is important here.  One of the nice features of
>>VMS (gargle) was the ability to use:
>>
>>$ define/user_mode 'P1'.dat for005
>>$ define/user_mode 'P1'.out for006
>>$ run myprog
>>
>>in a command procedure.  The advantage here is that you can have that
>>program running on at least two different sets of data in the same directory
>>at the same time.  The only way you can do this with symbolic links is to 
>>place the data files in different directories.  A royal pain if you are 
>>doing a lot of batch processing, which I suspect applies to most serious 
>>FORTRAN users.  A very bad design decision from a supposedly flexible 
>>operating system.
>>
>>I, and probably many others, get around the problem by passing the 
>>argument (P1, above) into the program using getarg, doing some string
>>handling to create the file names and using open explicitly.  Messy.
>>
>
>Forget about using links, man!
>
>Here's how I'd handle this problem for Unix boxes:
>
>(C-Shell script fragment similar to the DCL script fragment above)
>setenv FOR005 ${1}.dat
>setenv FOR006 ${1}.out
>myprog
>unsetenv FOR005
>unsetenv FOR006
>
>Then, in the Fortran, just use getenv() to get the filenames
>for the open statements.
>
>Easy as pie!

Except it is no standard Fortran anymore.  And it won't run on VMS 
anymore either.  Of course you can conconct a getenv function but that 
would have to be changed for the IBM again (can it be done?).

But the actual solution for this particular problem is terribly easy in 
Unix:

myprog <${1}.dat >${2}.out

or whatever variables you want to use.
-- 
Michael Lemke
Astronomy, UT Austin, Texas
(michael@io.as.utexas.edu or UTSPAN::UTADNX::IO::MICHAEL [SPAN])
From: jac@ds8.scri.fsu.edu (Jim Carr)
Newsgroups: comp.lang.fortran
Subject: Re: Welcome to HPFF
Keywords: HPFF, High Performance Fortran
Date: 14 Aug 92 14:50:30 GMT
Reply-To: jac@ds8.scri.fsu.edu (Jim Carr)
Organization: SCRI, Florida State University

In article <1992Aug14.092952.11572@ibr.cs.tu-bs.de> i2041101@rzphy1.rz.tu-bs.de (Paulini) writes:
> 
>         .......            A better way seems to me to design a comptetely
>new language or to use an existing better (like C, Ada, Modula or whatever).
                                    ^^^^^^  ^^^^    ^^^

You must be kidding.

Unless there has been a major breakthrough, the best Ada compilers produce 
code that runs several times slower than the equivalent Fortran code. 

I joke with my brother, who has to work with Ada, that it was the result 
of a KGB plot to eliminate our advantage in computer-assisted weapons 
systems by making all of our new code inefficient. 

--
J. A. Carr                                    |  "The New Frontier of which I  
jac@gw.scri.fsu.edu                           |  speak is not a set of promises
Florida State University  B-186               |  -- it is a set of challenges."
Supercomputer Computations Research Institute |   John F. Kennedy (15 July 60)
Newsgroups: comp.lang.fortran
From: chh2@rigel.uucp (22352-halevi)
Subject: imsl subroutine ggubs
Organization: Bellcore, Livingston, NJ
Date: Fri, 14 Aug 92 14:07:28 GMT
Keywords: imsl, ggubs


I have a short fortran program that was written by someone who was on 
a vms system.  It contains a subroutine called ggubs that is apparently 
an IMSL routine.  (I think it's some kind of gaussian random number 
generator.) I am on a unix system (SysV) that does not have access to
IMSL routines.  I would like to be able to run the program, either in its
current Fortran form or I might even rewrite it into C, but either way I
need to find out what ggubs is so I can rewrite it or include it or 
translate it.

So, anyone out there know what ggubs is, or if its just a short piece of
code could you send it to me (in either fortran or C incarnations).

Any other tips would be appreciated (because as you can tell I am not a
programmer!)

Cliff Halevi
chh2@rigel.cc.bellcore.com
Organisation: European Space Operation Centre (E.S.O.C)
Date: Friday, 21 Aug 1992 20:13:28 CET
From: <KCHAN@ESOC.BITNET>
Newsgroups: comp.lang.fortran
Subject: Re: programming style question
 <1992Aug16.221725.6760@ee.ubc.ca> <KHB.92Aug16161904@chiba.Eng.Sun.COM>
 <1992Aug17.170254.17530@ee.ubc.ca>

In article <1992Aug17.170254.17530@ee.ubc.ca>, davem@ee.ubc.ca (david michelson)
says:
>
> ... discussion on SAVE deleted ...
>
>This really points out the need for programming texts that fall somewhere
>between "10 statement Introductory Fortran" and the ANSI standard. If
>anyone would care to recommend any books on programming style in Fortran,
>I would be most interested.  Does a FAQ list exist for this group?  If so,
>is such a list included?
>
>Dave Michelson  "davem@ee.ubc.ca"
>
Two books which come to mind are (because I have them in the bookcase
right by my desk!):

"The Elements of Programming Style", Kernighan and Plauger,
McGraw-Hill 1978, isbn 0-07-034207-5
(not really about Fortran programming but programming in general, and
yes, it is the Kernighan of "C" fame)

"Effective Fortran 77", Metcalf, Oxford University Press 1985,
isbn 0-19-853709-3

-----
Khee Chan
PROFS: esoc(kchan)   BITNET/EARN: kchan@esoc   SPAN: jplsp::kchan
INTERNET: kchan@jplsp.jpl.nasa.gov             COMPUSERVE: 73750,1402
I speak for no-one, and no-one speaks for me, sometimes not even myself!
From: jsvrc@rc.rit.edu (J A Stephen Viggiano)
Newsgroups: comp.lang.fortran
Subject: Re: C versus FORTRAN debate
Date: 19 Aug 92 14:30:47 GMT
Article-I.D.: ultb.1992Aug19.143047.18550
Organization: RIT Research Corp

In article <py0mz+n@lynx.unm.edu> john@aquarius.unm.edu (John Prentice) writes:
. . . .
>Continuing to compare F77 to languages like C is a bit silly.  

As is comparing FORTRAN 90 to languages like C. (Sorry, no ":-)".)
From: cflatter@nrao.edu (Chris Flatters)
Newsgroups: comp.lang.fortran
Subject: Re: how to quit on an NaN result?
Date: 16 Aug 92 21:23:21 GMT
Reply-To: cflatter@nrao.edu
Organization: NRAO

In article 14024@samba.oit.unc.edu, Bruce.Scott@bbs.oit.unc.edu (Bruce Scott) writes:
>  I am debugging code which is still in the stage where many NaN results
>arise. The problem is that, beyond the waste of time in general,
>operations involving these critters are very slow. How can I check for
>NaN's and quit when one arises. Does one use
>        if (avar .eq. 'NaN') stop
>or is this illegal?

I assume that this refers to NaNs in a floating-point implementation that
conforms to IEEE-754.

1) It is legal to compare numbers that are unordered with respect to one
   another (ie. where one or more is a NaN) using .EQ. or .NE..

2) A NaN is not equal to any number even if that number is another NaN.
   A NaN is not even equal to itself.

It follows from this that we can test whether a floating-point variable
X contains a NaN as follows.

	IF (X.NE.X) THEN
C          X is a NaN
	ELSE
C	   X is not a NaN
	END IF

Note:
If you want to abort a program after an illegal operation it may be less
disruptive to install a trap handler for the invalid operation exception.
There is no standard way of doing this so you will have to consult your
local documentation.  Some IEEE-754 floating-point implementations do not
allow trap handlers to be installed: this is allowed by the standard but
implementations that do not allow the installation of trap handlers are
substandard IMHO.

	Chris Flatters
	cflatter@nrao.edu
Newsgroups: comp.lang.fortran
From: drd@macsch.com (Daniel R. Dawson)
Subject: Re: programming style question
Organization: The MacNeal-Schwendler Corporation
Date: Fri, 21 Aug 92 18:47:51 GMT

>pm@katz.cc.univie.ac.at (Peter Marksteiner) writes:
>>ecmtwhk@ccu1.aukuni.ac.nz (Thomas Koenig) writes: 
>>
>>>It's a real shame that Unix does not have standard way of attatching
>>>FORTRAN units to file descriptors, that would make things much easier.
>>>Does POSIX have anything to say about that?
>>
>>Try symbolic links. For example,
>>
>>    ln -s /whatever/pathname/you/want fort.3
>>
>>may not be as beautiful as
>>
>>//FT03F001  DD  DSN=REVOLTING.MVS.DATASET,DISP=NEW
>>
>>but it works almost as well. 
>
>Unfortunately `almost' is important here.  One of the nice features of
>VMS (gargle) was the ability to use:
>
>$ define/user_mode 'P1'.dat for005
>$ define/user_mode 'P1'.out for006
>$ run myprog
>
>in a command procedure.  The advantage here is that you can have that
>program running on at least two different sets of data in the same directory
>at the same time.  The only way you can do this with symbolic links is to 
>place the data files in different directories.  A royal pain if you are 
>doing a lot of batch processing, which I suspect applies to most serious 
>FORTRAN users.  A very bad design decision from a supposedly flexible 
>operating system.
>
>I, and probably many others, get around the problem by passing the 
>argument (P1, above) into the program using getarg, doing some string
>handling to create the file names and using open explicitly.  Messy.
>

Forget about using links, man!

Here's how I'd handle this problem for Unix boxes:

(C-Shell script fragment similar to the DCL script fragment above)
setenv FOR005 ${1}.dat
setenv FOR006 ${1}.out
myprog
unsetenv FOR005
unsetenv FOR006

Then, in the Fortran, just use getenv() to get the filenames
for the open statements.

Easy as pie!

   Dan Dawson
   The MacNeal-Schwendler Corporation
From: orszak@cfa.harvard.edu (Jeff Orszak)
Newsgroups: comp.lang.fortran
Subject: FORTRAN 90
Date: 13 Aug 92 15:26:36 GMT
Organization: Smithsonian Astrophysical Observatory, Cambridge, MA,  USA


Hello,

I am interested in updates on FORTRAN 90.  In my world, where I have
to keep up with both software progress and astronomy progress, I
sometimes fall behind in both.

I would like to know if the FORTRAN 90 standard is "frozen", and if so
what are the best reference to what will be in FORTRAN 90.  Also, what
progress is being made in make compilers that follow the standard?
Because having compilers available will really make it a standard.

Please e-mail to me as I do not get a regular opportunity to check the
net.  I will post a summary.

Thanks, Jeff
From: john@aquarius.unm.edu (John Prentice)
Newsgroups: comp.lang.fortran
Subject: Re: C versus FORTRAN debate
Date: 18 Aug 92 17:46:46 GMT
Organization: Dept. of Physics & Astro, University of New Mexico, Albuquerque

If we are going to debate Fortran versus *any* other language, let's at
least debate the merits of Fortran 90 (or variants like HPF or Fortran D).
Continuing to compare F77 to languages like C is a bit silly.  

John
-- 
Dr. John K. Prentice                      
Partner, Quetzal Computational Associates    
3200 Carlisle N.E., Albuquerque, NM   87110-1664; 505-889-4543
john@unmfys.unm.edu -or- jkprent@cs.sandia.gov -or- prentice@rufous.cs.unm.edu
Xref: sparky comp.lang.c:12292 comp.bugs.4bsd:202
From: gwyn@smoke.brl.mil (Doug Gwyn)
Newsgroups: comp.lang.c,comp.bugs.4bsd
Subject: Re: rand()
Date: 3 Aug 92 18:32:18 GMT
Followup-To: comp.lang.c
Organization: U.S. Army Ballistic Research Laboratory, APG, MD.

In article <1992Aug2.191241.21023@athena.mit.edu> scs@adam.mit.edu (Steve Summit) writes:
>Let's get the vendors to fix the deficient rand() implementations.

Several UNIX standards (XPG, SVID, OSG) specify the algorithm to be used
by rand().  The C standard almost did, but it was demoted to the status
of an example in the final standard.

Most people who really care about the statistical properties of pseudo-
random sequences supply their own generators as part of their applications.
(There is no such thing as a pseudo-random sequence generator that is
optimum for all possible applications.)
From: Aurelius@cup.portal.com (Mark Christian Barnes)
Newsgroups: comp.lang.c
Subject: Re: Help with function typedef.
Date: 15 Aug 92 07:06:50 GMT
Distribution: ba
Organization: The Portal System (TM)

Hi Jim,

 I think that you've made a mistake as follows:

| typedef CLI_RETURN_CODE (*CLI) (int, char **);
|
| /* prototype */
| CLI cli_help;
| 

 This previous statement is not a function prototype. It declares a
variable. cli_help is a pointer to a function taking two arguments
( an int and a handle to char ) and returning one argument.

| CLI_Command_Table cli_command_table[] = {
|    "help",   "List available commands",  cli_help
| };
| 

 And here you define a function called cli_help. This is a totally
different animal then before. About the only thing they have in common
is that the address of the function cli_help could be assigned to the
variable cli_help. But of course there is a name conflict.

| CLI_RETURN_CODE cli_help (int argc, char **argv) {
| 
|   /* nothing yet */
|     
| }   

 Try using a proper prototype and you'll be ok.

			Aurelius@cup.portal.com
From: kevin@sherman.pas.rochester.edu (kevin mcfadden)
Newsgroups: comp.lang.c
Subject: Managing Unix Files with C
Date: 17 Aug 92 18:54:26 GMT
Distribution: na
Organization: University of Rochester

This is probably a very easy question but here goes anyway:

	I would like to know if anybody has some pre-written functions
that allows one to manage files in a Unix enviroment.  To be more precise
I would like to be able to delete a file and check to see if it has been
updated (by either checking to see if it is there (if it has been deleted)
or by checking its last update time).

Replies to kevin@sherman.pas.rochester.edu


Thanks a lot,

Kevin
Newsgroups: comp.lang.c,comp.unix.questions
From: fortony@sonne.cso.uiuc.edu
Subject: user-extensible functions under C and UNIX
Originator: fortony@murphy
Summary: the author wonders how to do something slightly grotesque
Followup-To: fortony@sonne.cso.uiuc.edu
Organization: Roue Text and Steel
Date: Sat, 22 Aug 1992 23:24:40 GMT
Keywords: unix, ar


Greets,

I'm trying to write a program which accepts char *functionname
and then calls the appropriate function, which would be
contained in blahblah.a.  The end result of this would be to
let users write their own functions, add them to blahblah.a,
and then call them from within an editor.

Assume that the parameters for all the functions are constant.
Assume also that the functions can be forced to comply with
whatever makes this problem easier in terms of naming
conventions, number per object file, etc.
Assume also that the editor must not be recompiled or relinked
with each added function.

Under LISP, this would be reasonably simple.  Even under UNIX
and C, it's reasonably simple iff I write it to be completely
nonportable (using system() and somesuch).  But the trick is
that I want the solution to be as portably standard-c as possible.

Please don't view this as an attempt to get the net to write
my code; I'm just wondering if there's a standardly accepted
way of converting pointer to char into pointer to function
named by string pointed to by pointer to char.

For the extremely curious, this is part of an attempt to make
an extensible editor which doesn't rely on an internal language.

Thanks in advance for any posts, e-mails, etc. on the subject.

Felix
-- 
a b c d e f g h i j k l m n o p q r s t u v w x y z
Felix Sebastian Ortony	fortony@murphy.gis.uiuc.edu
From: jbc@hpcuhe.cup.hp.com (Jeff Caldwell)
Date: Sat, 15 Aug 1992 01:25:24 GMT
Subject: Re: How can a program know where it was invoked?
Organization: Hewlett Packard, Cupertino
Newsgroups: comp.lang.c

>>
>>One rudimentary method is to use "system".  Compile the following and run it:
>>
>>     #include <stdlib.h>
>>     
>>     main(argc, argv)
>>      int argc;
>>      char     *argv[];
>>     {
>>        char string[20];
>>        sprintf(&string, "which %s", argv[0]);
>                 ^
>                 |
>No need for `&' here.

Your obviously correct.  A typo.  Thanks for the correction.

>>        system(string);
>>     }
>
>This, of course, has a multitude of problems.  Foremost amoung them being
>that it is perfectly legal that argc == 0, and argv contain nothing at all.
>(A program launched from a GUI environment might legitimately do this, for
>example).

Correct again.

>
>Also, if there is something in argv[0], it may only be the program name,
>and not the full path it was invoked by.  If you try this with a such a
>system on a program that isn't on the user's path, it will fail.
>
>This code also assumes that the system contains `which'...
>

Correct again.

>The only answer to this question is that there is simply no portable
>way to do it.
>

Correct again.  Notice the program was prefaced with the comment
"One rudimentary method".  This is clearly not portable, anyone making
claims to that effect would be quite confused.


			-Jeff Caldwell
Newsgroups: comp.lang.c
From: bcschu@skws02.monsanto.com (Brett Schultz)
Subject: Re: Convert float to a string ?
Organization: Monsanto Company
Date: Wed, 19 Aug 1992 20:44:17 GMT

KSZ@VM.NRC.CA writes:
: Suppose I have a float a=12.4567, how can I convert it into a string including
: 8 characters? i.e. What I want is
:                  char *b="12.34567";
: One way may be writing the float into a temp file then load it as a string.
:  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:  KAIJUN S. ZHAN                          || (613) 990 - 0734 (voice)
:  Internet:ksz@vm.nrc.ca                  ||
:  Internet:kzhan@sgi1.mathstat.uoguelph.ca|| "Three generates everything".
:  Internet:gilwf16@vm.uoguelph.ca         ||
:  Bitnet:ksz@nrcvm01                      ||      -- Lao Zhi
:  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Use sprintf..

main()
{
   float a = 12.4567;
   char b[10];

   sprintf(b,"%f\0",a);
}


That'll do it.

Brett
Newsgroups: comp.lang.c
From: patrick@blmc46.QE.Bell.CA (Patrick Seynave)
Subject: getc() with timeout
Organization: Bell Canada -- OD Information Architectures
Distribution: na
Date: Wed, 12 Aug 1992 18:08:53 GMT

I need to read characters coming in through a serial port on a Sun running 4.1.1.  The characters have to be read until a certain string is received.  I wrote a little routine that does the trick by reading a character with getc(), inserting that character in a buffer, and checking if the buffer contains the string.  If it doesn't, I read the next character, and so on...
The problem is that when there is noise on the line I'm reading, the string is never received properly and the function never returns (instead, it keeps on trying to read characters and getc() never returns).
What I need is a way to read a character through a serial port that will return that character or return nothing (NULL or whatever) if no character has come in for a certain time (some kind of getc() with a timeout).
Does anyone have any ideas ?
From: pynq@quads.uchicago.edu (George Jetson)
Newsgroups: comp.lang.c
Subject: Re: Question about lex
Date: 13 Aug 92 16:33:07 GMT
Article-I.D.: midway.1992Aug13.163307.21298
Reply-To: pynq@midway.uchicago.edu
Organization: D. J. Dougherty & Associates

In article <1992Aug13.145803.3008@ccd.harris.com> djs@controls.ccd.harris.com (Dan J. Smith) writes:
>
>
>I'm trying to call the lex output functions generated by two different lex input
>files from the same program. But, they both generate output functions called
>yylex and have the same global variables so this does not work.

FLEX has this one sussed.  It has the ability to create "re-entrant parsers",
which don't use global variables.  It also has, I believe, the ability
to create multiple parsers with subtley different global variable names.

************************************************************************
Please don't drink the battery acid, it tastes bad and will hurt you.
Also, don't bite the tyres, especially when the bike is moving.
(Our lawyers made us put this in this manual.)

	- pynq@quads.uchicago.edu, who is still costing the net
	  hundreds, if not thousands, of dollars, every time he posts -
************************************************************************
From: robert@isgtec.com (Robert Osborne)
Newsgroups: comp.lang.c
Subject: Re: Macros for ANSI prototypes
Date: 13 Aug 92 16:49:39 GMT

dave@cs.arizona.edu (Dave Schaumann) writes:
> In stead of obfuscating your code with macros that turn on and off
> functio prototypes as the particular compiler requires, wouldn't it be
> better to simply include one of the tools freely available to
> automatically massage prototyped code into K&R acceptability.

What if the code needs to be compiled simultaneously on eight
architecutures; 4 K&R and 4 ANSI?

> The ability to write clear, easily understandable code should be a primary
> goal of every programmer.  Macro-izing away prototypes for compilers that
> can't deal with them is a poor solution to a problem that is far better
> dealt with by a program that requires no special changes to the code.

Prototype checking is a great debugging tool;  I'd hate to lose it
just because one of my architectures is K&R.

Rob.
--
Robert A. Osborne   ...!uunet.ca!isgtec!robert or robert@isgtec.com
Newsgroups: comp.lang.c
From: twpierce@amhux1.amherst.edu (Tim Pierce)
Subject: Re: sort routines
Organization: Amherst College, Amherst MA
Date: Sat, 15 Aug 1992 16:19:11 GMT

In article <1992Aug13.181541.26041@news.uit.no> tomg@stud.cs.uit.no (Tom Grydeland) writes:

>As far as I know, the best solution for sorting a single linked list is the
>mergesort. It's a recursion-based sorting which follows the general solution:
>
>0) If the list is just one element, it's sorted, return.
>
>1) If not, split your list in two approximately equal sublists.
>
>2) Mergesort (here's the recursion!) each one separately.
>
>3) Merge the two sorted sublists, and you have a sorted list to return.

An addendum: insertion and selection sort tend to work pretty well on
very short lists (the cutoff is around seven-element lists, in my
experience).  I've been able to improve recursive sorts from time to
time by ending the recursion early and using one of these sorts for
the last little bits.

-- 
____ Tim Pierce                / "Bisexual just means you pay for it."
\  / twpierce@amherst.edu      /  
 \/ (BITnet: TWPIERCE@AMHERST) /   -- Rock Hudson
Newsgroups: comp.lang.c