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
> 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
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:
> 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
-- Frango ut patefaciam -- I break so that I may reveal
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.
On Thu, Jun 11, 2009 at 2:50 PM, Ted Stern<lgtedst...@gmail.com> wrote:
> 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:
>> 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
> --
> Frango ut patefaciam -- I break so that I may reveal
-- 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)
==================================================
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:
> 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
> On Thu, Jun 11, 2009 at 2:50 PM, Ted Stern<lgtedst...@gmail.com> wrote:
>> 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:
>>> 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
>> -- >> Frango ut patefaciam -- I break so that I may reveal
-- Frango ut patefaciam -- I break so that I may reveal
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?
On Thu, Jun 11, 2009 at 3:10 PM, Ted Stern<lgtedst...@gmail.com> wrote:
> 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:
>> 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
>> On Thu, Jun 11, 2009 at 2:50 PM, Ted Stern<lgtedst...@gmail.com> wrote:
>>> 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:
>>>> 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
>>> --
>>> Frango ut patefaciam -- I break so that I may reveal
> --
> Frango ut patefaciam -- I break so that I may reveal
-- 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)
==================================================
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?
On Thu, Jun 11, 2009 at 2:50 PM, Ted Stern<lgtedst...@gmail.com> wrote:
> 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:
>> 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
> --
> Frango ut patefaciam -- I break so that I may reveal
-- 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)
==================================================