public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Newbie to gfortran needs a little help
       [not found] <46835D054D115449BBE84934E2F200090C1E827E@ARLEXCHVS02.lst.link.l-3com.com>
@ 2013-01-16 17:36 ` Mark Hounschell
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Hounschell @ 2013-01-16 17:36 UTC (permalink / raw)
  To: jimmie.davis; +Cc: tprince, gcc-help

On 01/15/2013 04:27 PM, jimmie.davis@l-3com.com wrote:
>           integer*4 val
>
>           character*4 cval
>
>           equivalence (val,cval)
>
>           cval = 'ABCD'
>
> 20    format('val = 0x',Z8)
>
>            write(6,20) val
>
>           end
>
>
>
>
>
> Not sure of what you were trying to accomplish.    Does the equivalence
> do anything for you ?
>

What I'm trying to accomplish is to port this old code to Linux. For 
this particular example, Equivalence does the same thing. That was my 
first thing to try. I can only assume this is an Endian issue and I will 
have to deal with it some other way and would have seen it sooner or 
later even if gfortran did allow me to do it with "val = 'ABCD'. Some of 
these variables are seen on other machines that are big endian, some are 
not.

Thanks
Mark

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Newbie to gfortran needs a little help
  2013-01-15  9:41 ` Tim Prince
@ 2013-01-15 18:24   ` Mark Hounschell
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Hounschell @ 2013-01-15 18:24 UTC (permalink / raw)
  To: tprince; +Cc: Tim Prince, gcc-help

On 01/14/2013 05:22 PM, Tim Prince wrote:
> On 1/14/2013 1:16 PM, Mark Hounschell wrote:
>> I hope this is the correct list to ask. I'm porting a bunch of old
>> fortran code and am getting thousands of these warnings I don't
>> understand. Most all are doing some sort of add or subtract on
>> integer*2 variables. This is just an example.
>>
>>       program test
>>       implicit none
>>
>>       integer*2 val/10/
>>
>>       val = val - 1
>>
>>       write(6,10)val
>>  10  format('val = ',I2)
>>       stop
>>       end
>>
>>
>> compiled with:
>>
>> f77 -std=legacy -Wall test.f
>> test.f:6.12:
>>
>>       val = val - 1
>>                1
>> Warning: Possible change of value in conversion from INTEGER(4) to
>> INTEGER(2) at (1)
>>
>> Thanks
>> Mark
>>
> Probably innocuous in the case you show.  Your constant "1" is
> integer(4) (probably 32-bit, depending on your platform).  You could
> change it to 1_2, or, preferably define a parameter constant for this
> purpose, giving it the value 2 for constants to be used in integer(2)
> arithmetic.  Use of integer(2) is quite rare in the last 15 years in my
> experience.
> f77 often refers to use of the obsolete f2c method which translates to
> C, or it may be (possibly an alias to) another old Fortran compiler,
> such as g77, which hasn't been maintained for several years.  gfortran
> is the current Fortran compiler companion to gcc.
> Tim
>

Thanks for the pointer. I am running on standard x86 32 bit hardware 
running Linux. This code I'm porting is actually well over 15 years old. 
Back then we used interger*2 when ever we could to save precious space. 
FYI, my 'f77' above is just a link to gfortran. The original compiler 
was an f77 though. That does get rid of the warning BTW. But how would 
you do the same this for a function that returns an integer*4 like 
INDEX, as follows.

        integer*2 val
        val = INDEX(TXTBUFF, 'SOMETEXT')

Would this be the best way or is there an '_2' method for that also?

        val = TRANSFER(INDEX(BUFF,'EVENT'), val)



I ran across the "TRANSFER" Intrinsic while searching for a way to get 
rid of what turns out be be an error to gfortran. The old compiler would 
let you do this without complaining:

        integer*4 val
        val = 'ABCD'
        write(6,20)val
  20   format('val = 0x'Z8,)

The above would put 0x41424344' into val. But when I use the Intrinsic 
"TRANSFER"

        val = TRANSFER ("ABCD", val)

the contents of val is X'44434241', so I can't really use it in all 
cases because some of these variables are reflected via reflective 
memory to other 32 bit computers (big endian) not being touched.


Another question is assigning a value such as X'FF000000' to an 
integer*4. It thinks X'FF000000' must be an integer*8 and I get the error:

Error: Arithmetic overflow converting INTEGER(8) to INTEGER(4) at (1). 
This check can be disabled with the option -fno-range-check.

This just seems wrong to me but is there a way other than 
-fno-range-check for this sort of thing?

Thanks and Regards
Mark

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Newbie to gfortran needs a little help
  2013-01-14 22:23 Mark Hounschell
@ 2013-01-15  9:41 ` Tim Prince
  2013-01-15 18:24   ` Mark Hounschell
  0 siblings, 1 reply; 4+ messages in thread
From: Tim Prince @ 2013-01-15  9:41 UTC (permalink / raw)
  To: gcc-help

On 1/14/2013 1:16 PM, Mark Hounschell wrote:
> I hope this is the correct list to ask. I'm porting a bunch of old 
> fortran code and am getting thousands of these warnings I don't 
> understand. Most all are doing some sort of add or subtract on 
> integer*2 variables. This is just an example.
>
>       program test
>       implicit none
>
>       integer*2 val/10/
>
>       val = val - 1
>
>       write(6,10)val
>  10  format('val = ',I2)
>       stop
>       end
>
>
> compiled with:
>
> f77 -std=legacy -Wall test.f
> test.f:6.12:
>
>       val = val - 1
>                1
> Warning: Possible change of value in conversion from INTEGER(4) to 
> INTEGER(2) at (1)
>
> Thanks
> Mark
>
Probably innocuous in the case you show.  Your constant "1" is 
integer(4) (probably 32-bit, depending on your platform).  You could 
change it to 1_2, or, preferably define a parameter constant for this 
purpose, giving it the value 2 for constants to be used in integer(2) 
arithmetic.  Use of integer(2) is quite rare in the last 15 years in my 
experience.
f77 often refers to use of the obsolete f2c method which translates to 
C, or it may be (possibly an alias to) another old Fortran compiler, 
such as g77, which hasn't been maintained for several years.  gfortran 
is the current Fortran compiler companion to gcc.
Tim


-- 
Tim Prince

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Newbie to gfortran needs a little help
@ 2013-01-14 22:23 Mark Hounschell
  2013-01-15  9:41 ` Tim Prince
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Hounschell @ 2013-01-14 22:23 UTC (permalink / raw)
  To: gcc-help

I hope this is the correct list to ask. I'm porting a bunch of old 
fortran code and am getting thousands of these warnings I don't 
understand. Most all are doing some sort of add or subtract on integer*2 
variables. This is just an example.

       program test
       implicit none

       integer*2 val/10/

       val = val - 1

       write(6,10)val
  10  format('val = ',I2)
       stop
       end


compiled with:

f77 -std=legacy -Wall test.f 

test.f:6.12:

       val = val - 1
                1
Warning: Possible change of value in conversion from INTEGER(4) to 
INTEGER(2) at (1)

Thanks
Mark

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-01-15 21:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <46835D054D115449BBE84934E2F200090C1E827E@ARLEXCHVS02.lst.link.l-3com.com>
2013-01-16 17:36 ` Newbie to gfortran needs a little help Mark Hounschell
2013-01-14 22:23 Mark Hounschell
2013-01-15  9:41 ` Tim Prince
2013-01-15 18:24   ` Mark Hounschell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).