Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
A Error Compare Logical(4) -- Help
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Shangshu Cai  
View profile  
 More options Jun 11, 12:44 pm
From: Shangshu Cai <shangshu....@gmail.com>
Date: Thu, 11 Jun 2009 09:44:45 -0700 (PDT)
Local: Thurs, Jun 11 2009 12:44 pm
Subject: A Error Compare Logical(4) -- Help
Dear All:

     I am totally a newbie to  Fortran and G95. I wrote a small
program.  The compiler gave me the error as followed:

g95 -o test test.f90 -L. ex.dll
In file test.f90:7

 IF (WFLG /= .FALSE.) r = 1
          1
Error: Operands of comparison operator '.ne.' at (1) are LOGICAL(4)/
LOGICAL(4)

      How to solve this problem?

Thanks.

Source Code:
program main
        integer i
        logical WFLG
        common /have/ r
        WFLG = .FALSE.
        IF (WFLG /= .FALSE.) r = 1
        r=1
        i = 6
        call ex(i)
        print *, i
end


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Funnell  
View profile  
 More options Jun 11, 1:21 pm
From: Robert Funnell <robert.funn...@mcgill.ca>
Date: Thu, 11 Jun 2009 13:21:14 -0400 (EDT)
Local: Thurs, Jun 11 2009 1:21 pm
Subject: Re: A Error Compare Logical(4) -- Help

On Thu, 11 Jun 2009, Shangshu Cai wrote:
>     I am totally a newbie to  Fortran and G95. I wrote a small
> program.  The compiler gave me the error as followed:

> g95 -o test test.f90 -L. ex.dll
> In file test.f90:7

> IF (WFLG /= .FALSE.) r = 1
>          1
> Error: Operands of comparison operator '.ne.' at (1) are LOGICAL(4)/
> LOGICAL(4)

Normally one would just say
   IF (WFLG) r = 1
  or
   IF (.NOT.WFLG) r = 1

- Robert


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shangshu Cai  
View profile  
 More options Jun 11, 3:38 pm
From: Shangshu Cai <shangshu....@gmail.com>
Date: Thu, 11 Jun 2009 12:38:33 -0700 (PDT)
Local: Thurs, Jun 11 2009 3:38 pm
Subject: Re: A Error Compare Logical(4) -- Help
Thanks.

shangshu

On Jun 11, 12:21 pm, Robert Funnell <robert.funn...@mcgill.ca> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ted Stern  
View profile  
 More options Jun 11, 3:50 pm
From: Ted Stern <lgtedst...@gmail.com>
Date: Thu, 11 Jun 2009 12:50:27 -0700
Local: Thurs, Jun 11 2009 3:50 pm
Subject: Re: A Error Compare Logical(4) -- Help
Several things here:

1) Common blocks have been deprecated for 30 years.  If you want to
   share memory, use a module.

   module have_mod
      real r
   end module have_mod

   program main
     use have_mod

     ! etc.

   end program main

   The advantage of this is encapsulation.  You can also put
   subroutines and functions in a module, and within the module scope,
   you don't need to declare the shared memory objects.

2) The symbolic operators ==, /=, >, < are for numbers, not logicals.

   For logicals, use .eqv. (equivalent) or  .neqv. (not equivalent)
   instead of the numeric relational operators.

   This is in fact the specific cause of your error.

3) As others have pointed out, since IF statements require a logical
   result, you don't even have to do a logical relation.

4) It would be better to have r's value be set within an entire IF
   block:

   IF (WFLG) THEN
      r = 1.
   ELSE
      r = 2.
   ENDIF

Ted

On 11 Jun 2009 09:44:45 -0700, Shangshu Cai wrote:

--
 Frango ut patefaciam -- I break so that I may reveal

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shangshu Cai  
View profile  
 More options Jun 11, 4:00 pm
From: Shangshu Cai <shangshu....@gmail.com>
Date: Thu, 11 Jun 2009 15:00:18 -0500
Local: Thurs, Jun 11 2009 4:00 pm
Subject: Re: A Error Compare Logical(4) -- Help
Hello, Ted:

        Thank you for your information. That's solve my problem.

         I am a really newbie Fortran programmer. Recently, I involved
in a project which needs to
compile a very old style Fortran project. The project is compiled by
Visual Compad Fortran successfully.
But it is failed to be compiled by g95.

         Based on your suggestions, I will go back to change some
lines in my program.

         Thanks again.

shangshu

--
Regards,
Sincerely,
shangshu
=================================================
Shangshu Cai
Dept. of Electrical and Computer Engineering
Mississippi State University
sc...@gri.msstate.edu
662-325-2065 (o)
662-617-4647 (c)
==================================================

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ted Stern  
View profile  
 More options Jun 11, 4:10 pm
From: Ted Stern <lgtedst...@gmail.com>
Date: Thu, 11 Jun 2009 13:10:53 -0700
Local: Thurs, Jun 11 2009 4:10 pm
Subject: Re: A Error Compare Logical(4) -- Help
Hi Shangshu,

In the past, I've had to maintain a 9000 file 700K-line Fortran
structural analysis program with roots that go back to 1962.  It can
be quite difficult.

Some newer compilers don't support the old structures.  I would
recommend looking up a list of deprecated and obsolescent features in
Fortran 77, Fortran 90, Fortran 95 and Fortran 2003 to get an idea of
language changes that might be causing problems for you.

Ted

On 11 Jun 2009 13:00:18 -0700, Shangshu Cai wrote:

--
 Frango ut patefaciam -- I break so that I may reveal

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shangshu Cai  
View profile  
 More options Jun 11, 4:32 pm
From: Shangshu Cai <shangshu....@gmail.com>
Date: Thu, 11 Jun 2009 15:32:31 -0500
Local: Thurs, Jun 11 2009 4:32 pm
Subject: Re: A Error Compare Logical(4) -- Help
Hi, Ted:

     9000 Files? My God. I cann't imagine how you did that.
200 files make me crazy.

     I found the style of the code of my project is Fortran 77.
However, An error is reported that unrecognized statement
name at "USE xxxx_mod" when I compile it by g77. Do you
have any suggestions about the website or links that I can find
the deprecated and obsolescent features about Fortran?

      Thanks.

shangshu

--
Regards,
Sincerely,
shangshu
=================================================
Shangshu Cai
Dept. of Electrical and Computer Engineering
Mississippi State University
sc...@gri.msstate.edu
662-325-2065 (o)
662-617-4647 (c)
==================================================

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shangshu Cai  
View profile  
 More options Jun 11, 5:08 pm
From: Shangshu Cai <shangshu....@gmail.com>
Date: Thu, 11 Jun 2009 16:08:58 -0500
Local: Thurs, Jun 11 2009 5:08 pm
Subject: Re: A Error Compare Logical(4) -- Help
Hello, Ted:

         I appreciate your replying. Since my project is very old, it
seems that I cann't correct all the logical
comparison to the .enq. or .enqv. . Does g95 have compile switch to force g95
allow me to comparison logical variables as: logicalA .en. LogicalB?

         Thanks,
Sincerely,
shangshu

--
Regards,
Sincerely,
shangshu
=================================================
Shangshu Cai
Dept. of Electrical and Computer Engineering
Mississippi State University
sc...@gri.msstate.edu
662-325-2065 (o)
662-617-4647 (c)
==================================================

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google