home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / fortran / 4348 < prev    next >
Encoding:
Text File  |  1992-11-18  |  1.9 KB  |  50 lines

  1. Newsgroups: comp.lang.fortran
  2. Path: sparky!uunet!sun-barr!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!jvnc.net!darwin.sura.net!news.udel.edu!perelandra.cms.udel.edu!mccalpin
  3. From: mccalpin@perelandra.cms.udel.edu (John D. McCalpin)
  4. Subject: Re: How does one return a logical value...???
  5. Message-ID: <Bxx13D.L74@news.udel.edu>
  6. Sender: usenet@news.udel.edu
  7. Nntp-Posting-Host: perelandra.cms.udel.edu
  8. Organization: College of Marine Studies, U. Del.
  9. References: <BxwrJC.GME@cs.uiuc.edu>
  10. Date: Wed, 18 Nov 1992 14:18:49 GMT
  11. Lines: 37
  12.  
  13. In article <BxwrJC.GME@cs.uiuc.edu> ctaylor@cs.uiuc.edu (Conrad W Taylor) writes:
  14. >         I have written a function which returns a logical
  15. >value, CheckActivity(previous, ROWS, COLS), previous is an
  16. >array.  I'm using it like this:
  17. >
  18. >        IF (CheckActivity(previous, ROWS, COLS) .EQ.  .TRUE.) THEN
  19. >          uncontrol = uncontrol + 1
  20. >        ENDIF
  21. >
  22. >My compiler says that I have mixed types when I use .TRUE. 
  23.  
  24. This is a very common mistake.  The FORTRAN-77 standard only allows
  25. numeric and string operands for the .EQ. operator.   You must use
  26. the .EQV. operator for logical operands.   
  27.  
  28. Of course, there is no need for an operator at all here, since you can
  29. just omit the predicate and use:
  30.  
  31.     IF (CheckActivity(previous, ROWS, COLS)) THEN
  32.         uncontrol = uncontrol + 1
  33.     ENDIF
  34.  
  35.  
  36. The use of .EQ. for logical operands is a fairly common extension.
  37. Sun and Silicon Graphics allow it.  IBM (xlf) disallows it with a
  38. surprisingly clear error message.  Cray (cft77) disallows it with
  39. a rather obscure error message.
  40.  
  41.  
  42. P.S. Conrad, you should get your news posting software fixed!
  43. Your e-mail address ctaylor@cs.uiuc.edu is not recognized by
  44. cs.uiuc.edu.
  45. -- 
  46. --
  47. John D. McCalpin                        mccalpin@perelandra.cms.udel.edu
  48. Assistant Professor                     mccalpin@brahms.udel.edu
  49. College of Marine Studies, U. Del.      John.McCalpin@mvs.udel.edu
  50.