- #1
polka129
- 43
- 0
Mod note: Added code tags and formatted code.
hello...i have been given an assignment which needs to be done on fortran90...i have come up with my code but it isn't working for me..
there are four parrts each specifying the values of M1 and angle for which M2 is to be calculated using SECANTS method..
here is the codde with simplified comments
all well in compiling but gives the following eror when i build it
Linking...
sec.obj : error LNK2001: unresolved external symbol _X@4
sec.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
sec.exe - 2 error(s), 0 warning(s)
WHERE HAVE I GONE WRONG?
please help
thank you
i have attached the question paper for your reference
hello...i have been given an assignment which needs to be done on fortran90...i have come up with my code but it isn't working for me..
there are four parrts each specifying the values of M1 and angle for which M2 is to be calculated using SECANTS method..
here is the codde with simplified comments
Code:
!here i have declared the arrays
!note that there are four parts of this question so i have declared two variables with four values each therefore combinining those parts
!the dimensions of Function f,values of initial gueses x1,x2 and x3 have been declared arbitarily since i do not know the number of iterations needed to come up with the final solution
dimension m1(1:4),rad(1:4),theeta(1:4),f(1:20),x1(1:20),x2(1:20),x3(1:20)
data (m1(i),i=1,4)/1.0,1.0,1.5,1.5/
data (theeta(i),i=1,4)/10.0,20.0,10.0,20.0/
do i=1,4
rad(i)=theeta(i)*3.142/180
enddo
! here i have started the outer loop so that for each set of M1 and Rad the inner loop shouldd run and calculate the value of M2(taken as x3)
!for e.g for M1=1.0 and rad=10.0 this code should calculate the value for M2 but since i do not know how many iterations will be done i have assigned an arbitary value of 10 in the inner loop
do i=1,4
do j=1,20
!here i have set the tolerance
tol=.00001
!here is the function
F(x)=rad(i)-(6.**(1./2.))*(atan((((x(j))**2.)-1.)/6.)**(1./2.))-((atan((((m1(i))**2.)-1.)/6.)**(1./2.)))+(atan((((x(j))**2.)-1.)**(1./2.))-(atan((((m1(i))**2.)-1.)**(1./2.))))
! here are the two values of initial guesses(which will keep interchanging at each iteration..which i have set as 10 as a guess)
x1(j)=2.0
x2(j)=1.5
!here is secants formula
10 x3(j)=(x1(j)*f(x2(j))-x2(j)*f(x1(j)))/(f(x2(j))-f(x1(j)))
print*,'m1',m1(i),'rad',rad(i),'x1',x1(j),'x2',x2(j),'x3',x3(j)
x1(j)=x2(j)
x2(j)=x3(j)
if (abs (x1(j)-x2(j)).lt.tol) goto 20
goto 10
20 print*,'The value of m2 for part(a) is',x3(j)
end do
end do
end
all well in compiling but gives the following eror when i build it
Linking...
sec.obj : error LNK2001: unresolved external symbol _X@4
sec.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
sec.exe - 2 error(s), 0 warning(s)
WHERE HAVE I GONE WRONG?
please help
thank you
i have attached the question paper for your reference
Last edited: