12.07.2015 Views

CAD in Civil Engineering - Baustatik-Info-Server

CAD in Civil Engineering - Baustatik-Info-Server

CAD in Civil Engineering - Baustatik-Info-Server

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Page 38 Computer Languages for Eng<strong>in</strong>eer<strong>in</strong>g - SS 136768 c reel branch69 if (d .lt. 0.) goto 5507071 d = dsqrt(d)72 x1 = (-b +d)/(2.e0*a)73 x2 = (-b -d)/(2.e0*a)7475 write(*,*) ’quadratic case, reel values’76 write(*,*) ’ x1 = ’,x177 write(*,*) ’ x2 = ’,x27879 goto 6008081 c complex branch82 550 cont<strong>in</strong>ue8384 d = dsqrt(-d)85 x1r = -b/(2.e0*a)86 x2r = x1r87 x1i = d/(2.e0*a)88 x2i = -d/(2.e0*a)8990 write(*,*) ’quadratic case, complex values’91 write(*,*) ’ x1 = ’,x1r,’ +i ’,x1i92 write(*,*) ’ x2 = ’,x2r,’ +i ’,x2i9394 600 cont<strong>in</strong>ue95 end2.9.2.4 Quadratic Equation, Solver Implementation Fortran 90 likeThe follow<strong>in</strong>g code implements the solution of a quadratic equation (see equation 2.5) <strong>in</strong> a Fortran 90version. Note, that we are able to implement the case tree without any goto jumps, which were essential<strong>in</strong> an 66 approach.List<strong>in</strong>g 2.20: Implementation of a 90-Quad-Solver1 ! Solver for a quadratic equation2 ! Implementation <strong>in</strong> Fortran903 program quadequation45 implicit none ! only explicit declarations67 real(8)::a, b, c ! parameters of the equation8 real(8)::d ! discrim<strong>in</strong>ant9 real(8)::p ! precision10 real(8)::x1,x2 ! for the real solutions11 real(8)::x1r,x1i,x2r,x2i! for the complex solutions1213 ! setup the parameters for the quadratic equation14 a = 1.15 b = 0.16 c =-4.E. Baeck

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!