Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29362 Discussions

Need help about some change in fortran code

hamid_mosaddeghi
Beginner
548 Views
Dear intel users

I need to change this code for calculate one peroperties in two dimensions (xy plan) not in three dimensions (xyz), in first step I changed in line 218:

rsq=rmsx**2+rmsy**2+rmsz**2 ----> rsq=rmsx**2+rmsy**2


but I get output data that is wrong.

please help me.
0 Kudos
2 Replies
mecej4
Honored Contributor III
548 Views
It stands to reason that changing an expression in the source code changes the results of the subroutine that you showed.

As for "data that is wrong", you have given us no background as to what is "right" and what is "wrong". It is unlikely that one can answer your question without more information about the problem since, based on what you have displayed, everything appears to be in fine fettle!
0 Kudos
SergeyKostrov
Valued Contributor II
548 Views
Do you want tocalculate a length of a vector in 2-D?

If No, please provide more details about your problem.

If Yes, from equations you provided I can see that:


- Original expression looks like a squared length of a vector in 3-D. In another form:

If an origin of a vector is P1(X1,Y1,Z1) and end of a vector is P2(X2,Y2,Z2), then squared length is

d^2 = dX^2 + dY^2 + dZ^2 = (X2-X1)^2 + (Y2-Y1)^2 + (Z2-Z1)^2,


- Modified expression looks like a squared length of a vector in 2-D. In another form:

If an origin of a vector is P1(X1,Y1) and end of a vector is P2(X2,Y2), then squared length is

d^2 = dX^2 + dY^2 = (X2-X1)^2 + (Y2-Y1)^2.


Try these simple test-cases:

- 3-D: P1(2,-1,-5) and P2(4,-3,1) ->

d^2 = (4-2)^2 + (-3+1)^2 + (1+5)^2 = 4 + 4 + 36 = 44 => d = 44^1/2 = 2 * 11^1/2 = 6.6332...

- 2-D: P1(2,-1) and P2(4,-3) ->

d^2 = (4-2)^2 + (-3+1)^2 = 4 + 4 = 8 => d = 8^1/2 = 2 * 2^1/2 = 2.8284...

Best regards,
Sergey
0 Kudos
Reply