forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Function not returning imaginary part of complex number

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> 64-bit
View previous topic :: View next topic  
Author Message
Kenneth_Smith



Joined: 18 May 2012
Posts: 159
Location: Glasgow, Scotland.

PostPosted: Sat Oct 14, 2017 4:01 pm    Post subject: Function not returning imaginary part of complex number Reply with quote

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).

Code:
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
Back to top
View user's profile Send private message Visit poster's website
mecej4



Joined: 31 Oct 2006
Posts: 739

PostPosted: Sun Oct 15, 2017 12:45 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Kenneth_Smith



Joined: 18 May 2012
Posts: 159
Location: Glasgow, Scotland.

PostPosted: Sun Oct 15, 2017 11:30 am    Post subject: Reply with quote

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).



[/img]
Back to top
View user's profile Send private message Visit poster's website
mecej4



Joined: 31 Oct 2006
Posts: 739

PostPosted: Sun Oct 15, 2017 1:50 pm    Post subject: Reply with quote

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.

Code:
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)
Back to top
View user's profile Send private message
Kenneth_Smith



Joined: 18 May 2012
Posts: 159
Location: Glasgow, Scotland.

PostPosted: Sun Oct 15, 2017 3:53 pm    Post subject: Reply with quote

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.

Back to top
View user's profile Send private message Visit poster's website
JohnCampbell



Joined: 16 Feb 2006
Posts: 1835
Location: Sydney

PostPosted: Sun Oct 15, 2017 11:33 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 5043
Location: Salford, UK

PostPosted: Mon Oct 16, 2017 11:33 am    Post subject: Reply with quote

I have made a note that this bug needs fixing.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 5043
Location: Salford, UK

PostPosted: Mon Oct 16, 2017 6:04 pm    Post subject: Reply with quote

This has now been fixed for the next release.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> 64-bit All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group