Deutsch   English   Français   Italiano  
<vdmbml$3p2dv$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!3.eu.feeder.erje.net!feeder.erje.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu>
Newsgroups: comp.lang.fortran
Subject: Re: Is there a way in Fortran to designate an integer value as
 integer*8 ?
Date: Thu, 3 Oct 2024 15:02:45 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <vdmbml$3p2dv$1@dont-email.me>
References: <vdict2$339ak$1@dont-email.me> <vdir24$35104$1@dont-email.me>
	<vdk718$3bulb$1@dont-email.me> <vdl6fi$3jra3$2@dont-email.me>
	<vdlfpl$3l0f5$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 03 Oct 2024 17:02:45 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="40482caeff8303161f195d236ec38fea";
	logging-data="3967423"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+kC7Uk+5YhKQql1iewMiAP"
User-Agent: Pan/0.145 (Duplicitous mercenary valetism; d7e168a
 git.gnome.org/pan2)
Cancel-Lock: sha1:Llr6JEWm5rVzutxDxYswkfeCImw=
Bytes: 3263

On Thu, 03 Oct 2024 02:06:28 -0500, Lynn McGuire wrote:

> On 10/2/2024 11:27 PM, Steven G. Kargl wrote:
>> On Wed, 02 Oct 2024 14:30:48 -0500, Lynn McGuire wrote:
>> 
>>> On 10/2/2024 2:00 AM, Lawrence D'Oliveiro wrote:
>>>> On Tue, 1 Oct 2024 21:58:40 -0500, Lynn McGuire wrote:
>>>>
>>>>> I need many of my integers to be integer*8 in my port to 64 bit.  In
>>>>> C/C++ code, I can say 123456L to mean a long long value, generally 64
>>>>> bit.  Is there a corresponding way to do this in Fortran ...
>>>>
>>>>       integer(kind = 8), parameter :: bigval = 9223372036854775807_8
>>>>       print *, bigval
>>>>
>>>> prints
>>>>
>>>>       9223372036854775807
>>>
>>> Thanks !
>>>
>>> I was afraid of that.  I will have to put _8 in about 100,000 lines of
>>> my F77 code.  And the future conversion to C++ will need special handling.
>>>
>> 
>> If you 100,000 lines of C++ without a trailing 'L', you would
>> need to add 'L' to get a long int.  You also only need to add
>> '_8' (or 'L') to those values that would exceed huge(1) in
>> magnitude as integer*4 is a proper subset of integer*8 and
>> Fortran does conversion when required.
> 
> If Fortran does an automatic conversion from I*4 to I*8, why does the 
> compiler gripe at me that the integer constant does not match the 
> subroutine argument type ?

Well, to begin, you were talking about numeric literal constants.
I doubt you add '_8' (or 'L') to all entities declared as 'integer*4'
(or long int).

integer*8 i ! 42 is integer*4 and automatically converted to integer*8
i = 42      ! on assignment.
i = 3_8 * 2 ! Mixed-mode math.  2 is magically converted to integer*8

The compiler is not complaining.  It is informing you of an mismatch
between an actual argument and the dummy argument.  If one is 'integer*4'
and the other 'integer*8', you have 32 undefined bits.

As the person who gave gfortran the -fdefault-integer-8 option, I hope
your XXX kloc of code uses neither equivalence nor common blocks.

-- 
steve