gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Issue with complex type import


From: Michael Riedl
Subject: Issue with complex type import
Date: Thu, 30 Nov 2023 23:42:06 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:102.0) Gecko/20100101 Thunderbird/102.11.0

Hallo Gaius,

here the real reason why I detected the issue with CMPLX / RE / IM in my last post.

Consider the following code (a part of my test codes reduced to just show the issue ... )

MODULE TstLibBlas;

FROM TypesFTN IMPORT INTEGER4,REAL8,COMPLEX16;
              IMPORT STextIO;
              IMPORT SLongIO;

PROCEDURE WrZVek2(    N    : INTEGER4;
                  VAR Z    : ARRAY OF COMPLEX16;
                      IncZ : INTEGER4;
                  VAR Q    : ARRAY OF COMPLEX16;
                      IncQ : INTEGER4);

          VAR i,iz,iq : INTEGER4;
              re,im : REAL8;
BEGIN
      IF (IncZ > 0) THEN iz := 0; ELSE iz := - (N-1)*IncZ; END;
      IF (IncQ > 0) THEN iq := 0; ELSE iq := - (N-1)*IncQ; END;
      STextIO.WriteLn;
      FOR i:=1 TO N DO
        re := RE(Z[iz]);
        im := IM(Z[iz]);
        SLongIO.WriteReal(re,12);
        SLongIO.WriteReal(im,12);
        INC(iz,IncZ); INC(iq,IncQ);
      END;
      STextIO.WriteLn;
END WrZVek2;

END TstLibBlas.

along with the following definition module

DEFINITION MODULE TypesFTN;

  (*   INTEGER4   = INTEGER*4        / ISO_FORTRAN_ENV:INT32            *)
  (*   REAL4      = REAL             / ISO_FORTRAN_ENV:REAL32           *)
  (*   REAL8      = DOUBLE PRECISION / ISO_FORTRAN_ENV:REAL64           *)
  (*   COMPLEX8   = COMPLEX          / 2 x ISO_FORTRAN_ENV:REAL32           *)   (*   COMPLEX16  = DOUBLE COMPLEX   / 2 x ISO_FORTRAN_ENV:REAL64           *)

IMPORT SYSTEM;

CONST Tag       = "Fortran types for GNU Modula-2";

TYPE  REAL4     = SHORTREAL;
      REAL8     = REAL;

      COMPLEX8  = SHORTCOMPLEX;
      COMPLEX16 = COMPLEX;

      INTEGER4  = SYSTEM.INTEGER32;
      INTEGER2  = SYSTEM.INTEGER16;
      INTEGER1  = SYSTEM.INTEGER8;

      CHAR1     = CHAR;

END TypesFTN.

The compiler claims:

gm2 -c -fiso -flibs=m2iso,m2pim,m2log -O1 -fscaffold-main TstLibBlas.mod
TstLibBlas.mod:20:24: error: In procedure 'WrZVek2': 'COMPLEX16' must be a COMPLEX type
   20 |         re := RE(Z[iz]);
      |                        ^
TstLibBlas.mod:21:24: error: 'COMPLEX16' must be a COMPLEX type
   21 |         im := IM(Z[iz]);
      |                        ^
TstLibBlas.MAK:35: recipe for target 'TstLibBlas.o' failed
make: *** [TstLibBlas.o] Error 1

which, in my view, is not correct. If I replace COMPLEX16 by COMPLEX without the imported type all is fine, but I need these definitions to be sure to map Fortran and Modula-2 types exactly.

Gruß / regards

Michael




reply via email to

[Prev in Thread] Current Thread [Next in Thread]