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

  1. Newsgroups: comp.lang.fortran
  2. Path: sparky!uunet!elroy.jpl.nasa.gov!nntp-server.caltech.edu!draco.macsch.com!convex.is.macsch.com!dnl
  3. From: dnl@convex.is.macsch.com (David Lombard)
  4. Subject: Re: How does one return a logical value...???
  5. Message-ID: <1992Nov19.161634.9841@draco.macsch.com>
  6. Sender: usenet@draco.macsch.com (Usenet Poster)
  7. Organization: MacNeal-Schwendler Corp.
  8. References: <BxwrJC.GME@cs.uiuc.edu>
  9. Date: Thu, 19 Nov 92 16:16:34 GMT
  10. Lines: 49
  11.  
  12. In article <BxwrJC.GME@cs.uiuc.edu> ctaylor@cs.uiuc.edu (Conrad W Taylor) writes:
  13. >         I have written a function which returns a logical
  14. >value, CheckActivity(previous, ROWS, COLS), previous is an
  15. >array.  I'm using it like this:
  16. >
  17. >        IF (CheckActivity(previous, ROWS, COLS) .EQ.  .TRUE.) THEN
  18. >          uncontrol = uncontrol + 1
  19. >        ENDIF
  20. >
  21. >My compiler says that I have mixed types when I use .TRUE. .  What
  22. >should I use I tried T instead of .TRUE. . It doesn't give errors
  23. >but it doesn't increment the uncontrol... it never goes into the
  24. >IF statement; skips it completely.  I'm new to FORTRAN and please
  25. >if anyone knows what I should do, let me know via e-mail.  Thanks
  26. >in advance to all that reply to my e-mail.
  27. >
  28.  
  29. I *assume* you have the declaration:
  30.  
  31.     logical CheckActivity
  32.  
  33. In such case, the result of the function is already a TRUE/FALSE value.
  34.  
  35. _You_do_not_compare_logicals_to_.TRUE._or_.FALSE._!!!!!!!!!!!!
  36.  
  37. You should just write:
  38.  
  39.     IF( CheckActivity( previous, ROWS, COLS ) ) THEN
  40.  
  41. Also, never, ever, write
  42.  
  43.     logvar = .FALSE.
  44.     if( _some_logical_expression_ ) logvar = .TRUE.
  45.  
  46. Instead write
  47.  
  48.     logvar = _some_logical_expression_
  49.  
  50. Say What You Mean!
  51.  
  52.  
  53. Regards,
  54. DNL
  55.  
  56.                  MY_COMMENTS = MY_OPINIONS = NOBODY_ELSES;
  57.  
  58. David N. Lombard    The first thing we do,         The MacNeal-Schwendler Corp
  59. dnl@macsch.com      Let's kill all the lawyers.    815 Colorado Blvd
  60. (213) 259-4911      II Henry VI, IV.ii             Los Angeles, CA  90041
  61.