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 

Interesting EXP(X) problem Invalid Floating Point Operation
Goto page Previous  1, 2
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
rrobe71907



Joined: 26 Sep 2014
Posts: 10
Location: Tamaqua PA

PostPosted: Fri Nov 14, 2014 9:18 pm    Post subject: D/FORTRAN interfacing - COMPLEX variables update Reply with quote

Update on Real/Imaginary swapping when D main program calls FORTRAN subprogram I mentioned in a previous post.

The real and imaginary parts of a complex variable only swap positions when
returned from a FORTRAN COMPLEX FUNCTION, *not* from a subroutine call.

The following swaps on return to a DMD D main program:
C Compute the Equivalent Impedance for branch circuits
COMPLEX FUNCTION IMPDNCEQV (N, Z) RESULT (ZEQV)
INTEGER*2 N, I
COMPLEX Z(N), ZEQV, ZPROD, ZSUM

ZPROD = Z(1)
ZSUM = Z(1)
IF (N.EQ.1) GOTO 100
DO 100 I=2,N
ZPROD = ZPROD * Z(I)
ZSUM = ZSUM + Z(I)
100 CONTINUE
ZEQV = ZPROD / ZSUM
RETURN
END FUNCTION IMPDNCEQV

The following does *not* swap on return to a DMD D main program:
C NB : Number of circuit branches
C L : Inductance array
C R : Resitance array
C C : Capacitance array
C Z : Impedance array
C ZEQ : Equivalent Impedance
SUBROUTINE IMPDNC10 (NB, L, R, C, Z, ZEQV, OMEGA, IERR)
INTEGER*2 NB, IERR, I
REAL L(NB), R(NB), C(NB), OMEGA
COMPLEX Z(NB), ZEQV, ZLOAD, IMPDNCEQV

IERR = 0
DO 100 I=1,NB
Z(I) = ZLOAD (R(I), L(I), C(I), OMEGA)
100 CONTINUE
ZEQV = IMPDNCEQV (NB, Z)
RETURN
END
_________________
Rodney Roberts
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
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