Silverfrost Forums

Welcome to our forums

Function not returning imaginary part of complex number

14 Oct 2017 3:01 #20430

Another one for you Paul, - at least its not related to the native %pl !

I had thought 64 bit had broken my conductor impedance calculation program, but after some work I generated some simple code which behaves differently between 32 and 64 bit.

The following code works fine in 32 bit and returns the expected function value (4 + j4).

program test
implicit none
complex(kind=2) z
complex(kind=2) i0 ; external i0
z = cmplx(4.d0,4.d0)
write(6,*) z, i0(z)
end program test

complex(kind=2) function i0(z)
implicit none
complex(kind=2), intent(in) :: z
  i0 = z
!  return        !## Uncomment this return statement and 64 bit works same as 32 
end function i0

64 bit returns the incorrect function value (4 + j0), i.e. the imaginary part of the complex number is incorrect. If the comment before the return statement in the function i0 is removed, 64 bit behaves as expected.

Regards

Ken

14 Oct 2017 11:45 #20436

I cannot reproduce the bug with the 8.10 compiler + DLLS13.

Please state which version of the compiler you used and the options that you specified.

15 Oct 2017 10:30 #20443

I was using windows 10, 8.10 compiler and DLL14. Checkmate 64 and Release 64 both generate the unexpected results.

Reverting back to DLL13 - I still see the same unexpected behaviour.

Interestingly if I change all the complex kinds from 2 to 1 the output is as expected (for DLL14).

http://www.tr5mx.co.uk/complex1.jpg

http://www.tr5mx.co.uk/complex2.jpg[/img]

15 Oct 2017 12:50 #20445

Perhaps there are some Plato settings that affect the compilation? This is what I see at the command window, with just /nocolour in my FTN95.CFG.

s:\FTN95>ftn95 ks.f90 /lgo
[FTN95/Win32 Ver. 8.10.0 Copyright (c) Silverfrost Ltd 1993-2017]
0003) complex(kind=2) z
COMMENT - Specifying the kind of the type COMPLEX with a constant is non-portable - 'SELECTED_REAL_KIND(15,307)' would be
    better
    NO ERRORS, 1 COMMENT  [<TEST> FTN95 v8.10.0]
    NO ERRORS  [<I0> FTN95 v8.10.0]
Creating executable: s:\FTN95\lgotemp@.exe
Program entered
  (4.00000000000,4.00000000000)  (4.00000000000,4.00000000000)

s:\FTN95>ftn95 ks.f90 /64 /lgo
[FTN95/x64 Ver. 8.10.0 Copyright (c) Silverfrost Ltd 1993-2017]
0003) complex(kind=2) z
COMMENT - Specifying the kind of the type COMPLEX with a constant is non-portable - 'SELECTED_REAL_KIND(15,307)' would be
    better
    NO ERRORS, 1 COMMENT  [<TEST> FTN95 v8.10.0]
    NO ERRORS  [<I0> FTN95 v8.10.0]
[SLINK64 v1.8, Copyright (c) Silverfrost Ltd. 2015-2017]
Loading s:\FTN95\lgotemp@.obj
Creating executable file s:\FTN95\lgotemp@.exe
Program entered
  (4.00000000000,4.00000000000)  (4.00000000000,4.00000000000)
15 Oct 2017 2:53 #20446

It's been a long time since I compiled Fortran from the command line, but it does not appear to be Plato that's causing the problem.

http://www.tr5mx.co.uk/complex3.jpg

15 Oct 2017 10:33 #20449

I have reproduced the error with two versions of 8.10.0: .dll (13?) dated 18/09/2017 .dll (orig) dated 11/02/2017

I used ftn95complex /64 /lgo /list

.lis reported Silverfrost FTN95/x64 Ver 8.10.0 complex.f90 Mon Oct 16 09:26:59 2017

Compiler Options in Effect: 64 COLOUR DELETE_OBJ_ON_ERROR ERROR_NUMBERS IMPLICIT_NONE INTL LGO LIST LOGL MINIMISE_REBUILD NO_QUIT NON_STANDARD SINGLE_THREADED

16 Oct 2017 10:33 #20467

I have made a note that this bug needs fixing.

16 Oct 2017 5:04 #20473

This has now been fixed for the next release.

Please login to reply.