From owner-sc22wg5+sc22wg5-dom9=www.open-std.org@open-std.org  Wed Dec 11 17:38:23 2024
Return-Path: <owner-sc22wg5+sc22wg5-dom9=www.open-std.org@open-std.org>
X-Original-To: sc22wg5-dom9
Delivered-To: sc22wg5-dom9@www.open-std.org
Received: by www.open-std.org (Postfix, from userid 521)
	id EE835357070; Wed, 11 Dec 2024 17:38:22 +0100 (CET)
Delivered-To: sc22wg5@open-std.org
Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181])
	by www.open-std.org (Postfix) with ESMTP id 85649356D5C
	for <sc22wg5@open-std.org>; Wed, 11 Dec 2024 17:38:22 +0100 (CET)
Received: by mail-qk1-f181.google.com with SMTP id af79cd13be357-7b6ef047e9bso44909085a.1
        for <sc22wg5@open-std.org>; Wed, 11 Dec 2024 08:38:22 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=stevelionel.com; s=google; t=1733935101; x=1734539901; darn=open-std.org;
        h=in-reply-to:from:content-language:references:to:subject:user-agent
         :mime-version:date:message-id:from:to:cc:subject:date:message-id
         :reply-to;
        bh=XGuHJHFIwTKd0PdcoU26Caw0BgezE2N3ZONGLl6EjQw=;
        b=e+ubs8qq5QskAj5Rps6n2fyCidelhmySA9jKG2NJBx0XMw8PITyNMHNRpbkvQ0CgBi
         LQ3oOgYl/oAt5z/ns6pTWwdKOrakNMnSFCtJ/10G4AXabiDffROc9J8SiPcRl7lYDwzb
         59dRrvTTVFSKlZBNssF4R/Mj6P7JLvy1vzzwg=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1733935101; x=1734539901;
        h=in-reply-to:from:content-language:references:to:subject:user-agent
         :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject
         :date:message-id:reply-to;
        bh=XGuHJHFIwTKd0PdcoU26Caw0BgezE2N3ZONGLl6EjQw=;
        b=XBMIGhJQvZvMteqtGqvc6+GJSpn91TL3Y5hBLhoYPOTTVSWLwuwt9P5Oy10wOLrfs8
         DSXXjFYHLA4yj6OTgSFCJId46sO+4xeqGwkIwkp5OikYZG4HdEbxgFq6GZ432jZv4EHa
         f8FIkuWA5E3pnu16m8SDbf19DnLtIpcw7Ch43MZyPpy0xi4vTPeI3bXjPkIVJEKVYuZJ
         ghfQvW1FdRccuZUKMBrR2oWDyqXpKfn24RlQMgwnx058/7dl6nMM0S69ZFrlj8RV7XQL
         l7a3S4rhUC+jpa3i+5MQFg+UdQZ5ZAWDlxY2VYHk05FQeueuEauJz5ZebRDcgN0V12YO
         xAqw==
X-Gm-Message-State: AOJu0YzfICfIgrnn+1kbZrxnRtA0Dno6EOjc0D8VUnTHIG6mVnutDYy0
	7k8TMGIQmIESl4ieWK/yAvgD78sWNj3TO+uNBmN4QMNQUO2vZrlFjD6yCUdzVCWawg6xT28MnBG
	w
X-Gm-Gg: ASbGnctoOaZccm8UxRBaGfAu5FJzMkLGdbyjfdUwICc9kAVTNYfPgg6tiFlvElq6uFL
	8bEYCm9OiSiHCx9WfgYV/p4lQAbudCKwQD1VU82+Lwq11ZZN/YXA17srFnos6JW+fI3k+Mg7qqO
	/vimiwPe9VobH6GwIRElFpKjyEMYCUyBb4Y3MA27KD4e6fIW9SDeUVj0ROA3O6jQqaZVDgVPfjC
	lnTE/LUhavbal7wp4H2nIc/PjTXoIV4ZoAw/Bup0eJLC8dLoDp/KurhgOOMHpOJxRvZX/j0LNU=
X-Google-Smtp-Source: AGHT+IGpTsTgDieDeNUtzDHEIbI/5a0RNFCcVDAIfKmEDgAgaOV3Hb+noecymPznv2om3sDhyp02sw==
X-Received: by 2002:a05:620a:4241:b0:7b6:cf60:396d with SMTP id af79cd13be357-7b6ebc25ce0mr564892685a.1.1733935100993;
        Wed, 11 Dec 2024 08:38:20 -0800 (PST)
Received: from [192.168.1.203] ([216.212.3.233])
        by smtp.gmail.com with ESMTPSA id af79cd13be357-7b6e23e2b91sm154522685a.9.2024.12.11.08.38.20
        for <sc22wg5@open-std.org>
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Wed, 11 Dec 2024 08:38:20 -0800 (PST)
Content-Type: multipart/alternative;
 boundary="------------Zs8MZTEGV0zoBCEQ6K5tw8rF"
Message-ID: <ce658f62-5058-4ec4-b9c6-385292bae710@stevelionel.com>
Date: Wed, 11 Dec 2024 11:38:19 -0500
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: [J3] [SC22WG5.6658] Question on the implementation of LOGICAL
To: WG5 List <sc22wg5@open-std.org>
References: <IA1PR12MB6065A69389852A81F579EAB9CB3E2@IA1PR12MB6065.namprd12.prod.outlook.com>
 <20241211115033.05913357070@www.open-std.org>
 <SJ1PR12MB6073E1EFC28CFD75357BE3E7CB3E2@SJ1PR12MB6073.namprd12.prod.outlook.com>
Content-Language: en-US
From: Steve Lionel <steve@stevelionel.com>
X-Clacks-Overhead: GNU Terry Pratchett
In-Reply-To: <SJ1PR12MB6073E1EFC28CFD75357BE3E7CB3E2@SJ1PR12MB6073.namprd12.prod.outlook.com>
Sender: owner-sc22wg5@open-std.org
Precedence: bulk

This is a multi-part message in MIME format.
--------------Zs8MZTEGV0zoBCEQ6K5tw8rF
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Of course, I wrote that post in 2000, before C interop was a thing. 
F2003 says that the C _Bool type is interoperable with LOGICAL(C_BOOL). 
I think this was a mistake, but we're stuck with it, and this is why 
Intel made -standard-semantics include -fpscomp logicals. (-fpscomp 
selects options for compatibility with Microsoft Fortran Powerstation, 
in case you didn't know.) I once tried to get Intel to add some sort of 
conditionalization to ISO_C_BINDING such that C_BOOL was -1 unless 
-fpscomp logicals was in effect, but was unsuccessful.

While the main point of my post holds, that being you should not use 
integer operations nor tests for equality on LOGICAL values, if you 
interoperate with C, or something that works like C, you will need to 
make sure that your Fortran code treats LOGICAL values the same way. For 
MPI, I assume that its kind value for bools would be derived from C_BOOL 
in ISO_C_BINDING.

Steve

On 12/11/2024 11:01 AM, Jeff Hammond wrote:
>
> Thanks, Steve.  That helps.  I misremembered the VAX behavior.
>
> I used C to set logicals to integers - probably not conforming, but it 
> works.  The behavior is amusing, but of course, consistent with your 
> blog and the notion that incorrect programs may produce nonsensical 
> results.
>

--------------Zs8MZTEGV0zoBCEQ6K5tw8rF
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">Of course, I wrote that post in 2000,
      before C interop was a thing. F2003 says that the C _Bool type is
      interoperable with LOGICAL(C_BOOL). I think this was a mistake,
      but we're stuck with it, and this is why Intel made
      -standard-semantics include -fpscomp logicals. (-fpscomp selects
      options for compatibility with Microsoft Fortran Powerstation, in
      case you didn't know.) I once tried to get Intel to add some sort
      of conditionalization to ISO_C_BINDING such that C_BOOL was -1
      unless -fpscomp logicals was in effect, but was unsuccessful.<br>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">While the main point of my post holds,
      that being you should not use integer operations nor tests for
      equality on LOGICAL values, if you interoperate with C, or
      something that works like C, you will need to make sure that your
      Fortran code treats LOGICAL values the same way. For MPI, I assume
      that its kind value for bools would be derived from C_BOOL in
      ISO_C_BINDING.</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">Steve</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">On 12/11/2024 11:01 AM, Jeff Hammond
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:SJ1PR12MB6073E1EFC28CFD75357BE3E7CB3E2@SJ1PR12MB6073.namprd12.prod.outlook.com">
      <p class="MsoNormal"><span style="font-size:12.0pt">Thanks,
          Steve.  That helps.  I misremembered the VAX behavior.<o:p></o:p></span></p>
      <p class="MsoNormal"><span style="font-size:12.0pt"><o:p> </o:p></span></p>
      <p class="MsoNormal"><span style="font-size:12.0pt">I used C to
          set logicals to integers - probably not conforming, but it
          works.  The behavior is amusing, but of course, consistent
          with your blog and the notion that incorrect programs may
          produce nonsensical results.</span></p>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>

--------------Zs8MZTEGV0zoBCEQ6K5tw8rF--
