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

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!cs.uoregon.edu!ogicse!flop.ENGR.ORST.EDU!gaia.ucs.orst.edu!umn.edu!noc.msc.net!uc.msc.edu!shamash!ems!ems.cdc.com!mstemper
  2. From: mstemper@ems.cdc.com (Michael Stemper)
  3. Newsgroups: comp.lang.fortran
  4. Subject: Re: How does one return a logical value...???
  5. Message-ID: <30476@nntp_server.ems.cdc.com>
  6. Date: 18 Nov 92 19:17:20 GMT
  7. Article-I.D.: nntp_ser.30476
  8. References: <BxwrJC.GME@cs.uiuc.edu>
  9. Sender: sys@ems.ems.cdc.com
  10. Reply-To: mstemper@ems.cdc.com
  11. Organization: Empros Systems International, a division of Ceridian
  12. Lines: 56
  13. Nntp-Posting-Host: kirk.ems.cdc.com
  14.  
  15. In article <BxwrJC.GME@cs.uiuc.edu>, ctaylor@cs.uiuc.edu (Conrad W Taylor) writes:
  16.  
  17. >         I have written a function which returns a logical
  18. >value, CheckActivity(previous, ROWS, COLS), previous is an
  19. >array.  I'm using it like this:
  20. >
  21. >        IF (CheckActivity(previous, ROWS, COLS) .EQ.  .TRUE.) THEN
  22. >          uncontrol = uncontrol + 1
  23. >        ENDIF
  24. >
  25. >My compiler says that I have mixed types when I use .TRUE.
  26.  
  27. Does this module contain a declaration:
  28.  
  29.       LOGICAL CheckActivity
  30.  
  31. If not, it thinks that CheckActivity is of type REAL, which would
  32. certainly be mixed types.
  33.  
  34. One comment on style.
  35.  
  36.       .EQ.
  37.  
  38. is a logical operator that returns either .TRUE. or .FALSE.
  39. For instance,
  40.  
  41.       (J .EQ. 3)
  42.  
  43. Is a logical expression. It has a value of either .TRUE. or .FALSE.
  44. depending on the value of J.
  45.  
  46. The IF statement has the form
  47.  
  48.       IF (lexpr) THEN
  49.  
  50. Where lexpr is a logical expression. Since CheckActivity is a logical
  51. function (or it will be after you declare it), you can simply say:
  52.  
  53.       IF ( CheckActivity(...) ) THEN
  54.  
  55. rather than:
  56.  
  57.       IF ( CheckActivity(...) .EQ. .TRUE. ) THEN
  58.  
  59. This latter usage is leagl but redundant, just like
  60.  
  61.       IF ( (J.EQ.3) .EQ. .TRUE. ) THEN
  62.  
  63. would be.
  64.       
  65.  
  66. -- 
  67. #include <Standard_Disclaimer.h>
  68. Michael F. Stemper
  69. Power Systems Consultant
  70. mstemper@ems.cdc.com
  71.