[comp.lang.fortran] Non-VMS like behaviour of "f77 -vms ..."

antek@bioch.tamu.edu (11/04/90)

Hi! 

I'm trying to port a Fortran program written for a VAX to a MIPS UNIX BSD4.3
environment. There is quite pure F77 code inside, no VAX system calls etc., 
but two things are strange: 

1) During the execution of such a code: 
	CHARACTER*10 ANSWER
	WRITE (6,'(''$Enter your answer: '')')	! The "$" to suppress <CR>
	READ (5,'(A10)') ANSWER
a user have to hit the <RETURN> key TWICE, regardless of the length of the 
string s/he enters. I tried 3 different positions of the $ sign and several
options (-vms, -systype bsd43, etc.) but the problem remains unchanged or
the "$" is not interpreted at all. 
NUMERICAL input is ok, only the "A" format is giving troubles. 

2) Ordinary divisions by zero and SQRT of a negative doesn't produce any run-
   time errors, instead they set the NaN value to a number, or a zero: 
Pseudocode: 
	r = 0.0;	i = 0;		rneg = -1.0;
	r = 1.0/r;	i = 1/i;	rneg = SQRT(rneg);
	write (6,*) r, i, rneg

Answer: NaN     0     0.00000          (1.0 / NaN gives 0.0 again)

Great, errors don't break the program (what I wanted anyway), but I would
rather like them to create an interrupt which I can catch in a handler. 
And in the debuging phase I believe I AM writing parts of the code wrong,
so nonsense values should be reported, I can't write out *everything* or
go step-by-step with a debuger through 10000 lines of the program.

Any suggestions ?                                  Antek @ Bioch.Tamu.Edu

pittman@mwk.uucp (V. Darrell Pittman, M.W. Kellogg, KT26, 713-753-4410) (11/07/90)

In article <9811@helios.TAMU.EDU>, antek@bioch.tamu.edu writes:

> 1) During the execution of such a code: 
> 	CHARACTER*10 ANSWER
> 	WRITE (6,'(''$Enter your answer: '')')	! The "$" to suppress <CR>
> 	READ (5,'(A10)') ANSWER
> a user have to hit the <RETURN> key TWICE, regardless of the length of the 
> string s/he enters.


You might try
	WRITE( 6, '(''Enter your answer: '',$)' )
or
	WRITE( 6, '(1X,A,$)' ) 'Enter your answer: '	!1x for ANSI prt. ctrl.

This method works under VAX FORTRAN.  May or may not be supported by
your compiler.

Can't help you with question (2).

Hope this helps...    Darrell

--------------------------------------------------------------------------------
V. Darrell Pittman	The M. W. Kellogg Co.	   Email:	pittman@mwk.uucp
Sr. Systems Programmer	601 Jefferson Ave, KT26    CompuServe:	72277,3146
			Houston, TX 77002	   Phone:	(713) 753-4410
						   Fax:		(713) 753-5353

The opinions expressed herein are my own, not necessarily those of my employer
or any other third party.
--------------------------------------------------------------------------------

calvin@dinkum.wpd.sgi.com (Calvin H. Vu) (11/09/90)

Since the -vms option sounds like a MIPS-based compiler option I tried
to compile the following test program with -vms on an SGI machine:

	CHARACTER*10 ANSWER
C  The blank is added before 'Enter' to keep 'E' from being interpreted
C  as a carriage control character
        WRITE( 6, '('' Enter your answer: '',$)' )
	READ(5,'(A10)') ANSWER
	print *, answer
	end

when I ran it I got:
Enter your answer: hello
hello     

which is probably what you're looking for.  BTW, I know '$' can be used
as a format editing character (i.e. above usage) but I've never heard that
it can be used as a carriage control character (i.e. below usage) and effects
the NEXT INPUT line:
        WRITE( 6, '(''$Enter your answer: '')' ) ! Sure you can do this ?

Oh well, if you are using a MIPS based computer, at least now you know one
way to make it work :-).

- calvin
--
-----------------------------------------------------------------------------
Calvin H. Vu			   | "We are each of us angels with only one
Silicon Graphics Computer Systems  | wing.  And we can only fly embracing
calvin@sgi.com   (415) 962-3679	   | each other."

rbr4@troi.cc.rochester.edu (Roland Roberts) (11/10/90)

In article <1990Nov9.012631.13152@odin.corp.sgi.com>
  calvin@dinkum.wpd.sgi.com (Calvin H. Vu) writes: 
>...BTW, I know '$' can be used as a format editing character (i.e.
>above usage) but I've never heard that it can be used as a carriage
>control character (i.e. below usage) and effects the NEXT INPUT line:
>
>        WRITE( 6, '(''$Enter your answer: '')' ) ! Sure you can do this ?
>
At least on VAXen, the C Run-Time library claims that RMS translates
fortran carraige control files in this fashion.  Page 1-15 (section
1.3.2) says:

character           output
NULL		--> <record>
0		--> \n\n<record>\r
1		--> \f<record>\r
+		--> <record>\r
$		--> \n<record>
all others	--> \n<record>\r

`\r' is carraige return, `\n' is newline, `\f' is formfeed.

roland
--
Roland Roberts,  University of Rochester   BITNET: roberts@uornsrl
  Nuclear Structure Research Lab         INTERNET: rbr4@cc.rochester.edu
  271 East River Road                        UUCP: rochester!ur-cc!rbr4
  Rochester, NY  14267                       AT&T: (716) 275-8962