From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) by sourceware.org (Postfix) with ESMTPS id EB7503858D37 for ; Thu, 27 Jul 2023 18:21:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EB7503858D37 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=troutmask.apl.washington.edu Authentication-Results: sourceware.org; spf=none smtp.mailfrom=troutmask.apl.washington.edu Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.17.1/8.17.1) with ESMTPS id 36RIL6D5029685 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO) for ; Thu, 27 Jul 2023 11:21:06 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.17.1/8.17.1/Submit) id 36RIL6AN029684 for fortran@gcc.gnu.org; Thu, 27 Jul 2023 11:21:06 -0700 (PDT) (envelope-from sgk) Date: Thu, 27 Jul 2023 11:21:05 -0700 From: Steve Kargl To: Allin Cottrell via Fortran Subject: Re: Compile antiquated fortran? Message-ID: Reply-To: sgk@troutmask.apl.washington.edu References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, Jul 27, 2023 at 01:36:46PM -0400, Allin Cottrell via Fortran wrote: > I have old fortran source code (not my own work) for a specialized > statistical program that I and others find quite useful. > > A few years ago I was able to compile it on Linux using gfortran with > std=legacy (and also cross-compile it for Windows an Mac). Now I'd like to > rebuild it, but with recent gfortran (I've tried 12.2.1 on Fedora and 13.1.1 > on Arch) it's a no-go. I get lots of errors of the following sort: > > ansub9.f:151:44: > > 151 | INTEGER ITYPE,INIT,LAM,IMEAN,IP,ID,Q,BP,BD,BQ,SQG,MQ,L,M, > | 1 > Error: Symbol ‘q’ at (1) already has basic type of REAL > > I can understand this complaint. The code contains this sort of thing within > a given subroutine: > > IMPLICIT REAL*8 (A-H,O-Z) > > then some lines later on: > > INTEGER ITYPE,INIT,LAM,IMEAN,P,D,Q,... > > I guess the author was assuming that an explicit type-assignment just > overrides an implicit one. Older gfortran apparently played along with that. > > My question: Given that I'm already using -std=legacy, are there any other > flags that I could add to get the code to compile? > > (I know I could tackle this by renaming a bunch of variables, but in context > that would be an extremely fiddly job.) > I'm afraid we'll need to see some actual code. The following compiles without a problem. SUBROUTINE FOO(Q) IMPLICIT REAL*8 (A-H,O-Z) INTEGER Q Q = 1 END Hmmm, are DATA statements in the code? SUBROUTINE FOO IMPLICIT REAL*8 (A-H,O-Z) DATA Q/1/ INTEGER Q Q = 1 END % gfortran12 -c -Wall a.f a.f:4:16: 4 | INTEGER Q | 1 Error: Symbol 'q' at (1) already has basic type of REAL gfortran is correct to complain here. The DATA statement give Q a REAL type due to the implicit statement. Q can only appear in a later declaration statement that re-affirms that type. -- Steve