From owner-freebsd-fortran@FreeBSD.ORG Thu Jul 11 23:49:50 2013 Return-Path: Delivered-To: fortran@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 37B3BEA1 for ; Thu, 11 Jul 2013 23:49:50 +0000 (UTC) (envelope-from mexas@bristol.ac.uk) Received: from eu1sys200aog110.obsmtp.com (eu1sys200aog110.obsmtp.com [207.126.144.129]) by mx1.freebsd.org (Postfix) with ESMTP id B54B51E02 for ; Thu, 11 Jul 2013 23:49:48 +0000 (UTC) Received: from mail-ee0-f41.google.com ([74.125.83.41]) (using TLSv1) by eu1sys200aob110.postini.com ([207.126.147.11]) with SMTP ID DSNKUd9EmBpuoFeyr90nVzjIZR6QGzv6Qah1@postini.com; Thu, 11 Jul 2013 23:49:48 UTC Received: by mail-ee0-f41.google.com with SMTP id d17so5968763eek.28 for ; Thu, 11 Jul 2013 16:49:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:date:from:message-id:to:subject:cc:reply-to:in-reply-to :x-gm-message-state; bh=/81rGeKi6nS6i8bQRjtWV7lLlV1A1E8p/DGUbmbteyc=; b=p3Vs/P3SDPq7YWkzbnDMoCXlktSLUIZolGxUZotFCLiQSEBcccBU/eLsVMnBEnDrHs o9SMTjvOTRQm67jdUMu4bImG8f6Hkrh+bsKg2iZuf8gAcUyC5MRrNLKWQLM/K1XJCukI PsJnGrTJ8u2rGgfreJyBceyOaBFRCRIWQL3eMFtEqT7FoYBEYjDZmqrId6Fy53QzV1YO ZO+uCM7unfrfRRYL0mO6oCcH/AC/Md9RWQRzgYapUYQyNtXa6KsntIaBid75Zwej8+FE 0ObpdgmWn/OoHxcMdQ0gy1I8dQIGM8TZBIPJl2DTr03hO4BmA1O9PYMyUdQf0hIfpQyV saoA== X-Received: by 10.15.64.68 with SMTP id n44mr39579059eex.73.1373586127372; Thu, 11 Jul 2013 16:42:07 -0700 (PDT) X-Received: by 10.15.64.68 with SMTP id n44mr39579052eex.73.1373586127274; Thu, 11 Jul 2013 16:42:07 -0700 (PDT) Received: from mech-cluster241.men.bris.ac.uk (mech-cluster241.men.bris.ac.uk. [137.222.187.241]) by mx.google.com with ESMTPSA id i2sm73363535eeu.4.2013.07.11.16.42.05 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 11 Jul 2013 16:42:06 -0700 (PDT) Sender: Anton Shterenlikht Received: from mech-cluster241.men.bris.ac.uk (localhost [127.0.0.1]) by mech-cluster241.men.bris.ac.uk (8.14.7/8.14.6) with ESMTP id r6BNg3L3090241 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 12 Jul 2013 00:42:04 +0100 (BST) (envelope-from mexas@mech-cluster241.men.bris.ac.uk) Received: (from mexas@localhost) by mech-cluster241.men.bris.ac.uk (8.14.7/8.14.6/Submit) id r6BNg32L090240; Fri, 12 Jul 2013 00:42:03 +0100 (BST) (envelope-from mexas) Date: Fri, 12 Jul 2013 00:42:03 +0100 (BST) From: Anton Shterenlikht Message-Id: <201307112342.r6BNg32L090240@mech-cluster241.men.bris.ac.uk> To: mexas@bristol.ac.uk, sgk@troutmask.apl.washington.edu, thierry@FreeBSD.org Subject: Re: gfortran46: Error: Type of argument 'z' in call to 'dimag' at (1) should be COMPLEX(16), not COMPLEX(8) In-Reply-To: <20130711172542.GA67029@troutmask.apl.washington.edu> X-Gm-Message-State: ALoCoQlUXF0znMIcVHBHLNC3MaG06aPvjlukPH2hAJ6AQK15KaKLtpkUKeIIux1a7fouOeZL35lhrI+WZqL56Li0xT4gqdtqhFcfBvVDbxscQOpYrB+C2CHiZbKoxymCETHbYLPiL1fcFeXBkqvqIfBvok88wioKmw== Cc: fortran@freebsd.org X-BeenThere: freebsd-fortran@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: mexas@bristol.ac.uk List-Id: Fortran on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jul 2013 23:49:50 -0000 >From sgk@troutmask.apl.washington.edu Thu Jul 11 18:32:18 2013 >> >>The correct fixes are to properly declare the variables via Fortran's >>kind type parameter and to use generic intrinsic functions. > >Please fix the quoting mechanism of your email client to >NOT use tab characters. It leads to alot of wasted screen >real estate. > >>$ cat dcargu.f >> FUNCTION DCARGU(C) >> IMPLICIT REAL*8 (A-H,O-Z) >> REAL*8 DCARGU >> COMPLEX*16 C > >> IF (DIMAG(C).GT.0.D0) THEN > >I suspect you are being hit by -fdefault-real-8 or >similar option. If this is the case, you may want >to ask the ASTER developers if they know what that >option actually does. (cc to thierry@ - the maintainer) It's actually in the port's Makefile: .if ${ARCH} == "i386" FLAGARCH= -DP_LINUX -DLINUX FFLAGARCH= .else FLAGARCH= -DLINUX64 FFLAGARCH= -fdefault-integer-8 -fdefault-real-8 .endif Anyway, please correct my analysis if it's wrong. complex*16 is the same as complex(kind=8), meaning 16 bytes total, or two 8-byte reals. The effect of -fdefault-real-8 is to make DIMAG expect not complex(8) but complex(16), but *only* on platforms where complex(16) is supported. And on ia64 is does not seem to be supported, and -fdefault-real8 has no effect on ia64: $ uname -a FreeBSD mech-cluster241.men.bris.ac.uk 10.0-CURRENT FreeBSD 10.0-CURRENT #5 r252055: Fri Jun 21 15:57:18 BST 2013 root@mech-cluster241.men.bris.ac.uk:/usr/obj/usr/src/sys/TZAV ia64 $ cat z.f90 complex*16 :: z z = (1,2) write (*,*) dimag(z) end $ gfortran46 -Wall z.f90 $ ./a.out 2.0000000000000000 $ gfortran46 -Wall -fdefault-real-8 z.f90 $ ./a.out 2.0000000000000000 $ In contract, on amd64, -fdefault-real-8 makes DIMAG expect complex(16), but complex(8) is given. And changing the declaration to complex(16) makes the code compile and work as expected, i.e. increase the number of significant digits roughly by a factor of 2: $ cat z.f90 complex*16 :: z z = (1,2) write (*,*) dimag(z) end $ gfortran46 z.f90 $ ./a.out 2.0000000000000000 $ gfortran46 -fdefault-real-8 z.f90 z.f90:3.18: write (*,*) dimag(z) 1 Error: Type of argument 'z' in call to 'dimag' at (1) should be COMPLEX(16), not COMPLEX(8) $ sed s/\*16/\(kind=16\)/g z.f90 > zz.f90 $ cat zz.f90 complex(kind=16) :: z z = (1,2) write (*,*) dimag(z) end $ gfortran46 zz.f90 zz.f90:3.18: write (*,*) dimag(z) 1 Error: Type of argument 'z' in call to 'dimag' at (1) should be COMPLEX(8), not COMPLEX(16) $ gfortran46 -fdefault-real-8 zz.f90 $ ./a.out 2.0000000000000000000000000000000000 $ Anyway, it is important to know that -fdefault-real-8 does not affect the complex declarations. I agree with you that this routine from the Aster code is not very well written, i.e. is not written with portability in mind. However, code_Aster is massive and I don't think it likely the developers will want to fix issues like this. I'm not sure what to do about this. Anton