LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Closed Thread
  Search this Thread
Old 12-27-2011, 09:17 AM   #1
mamatu
LQ Newbie
 
Registered: Dec 2011
Posts: 6

Rep: Reputation: Disabled
can function subprograms have arrays?.spot the error


here is the code..please help



!hello..this is a questions of newton iteration
!in this i need to generate the first 10 roots of the given equation F=theeta*(1/(1-(a*h/sigma)))

!as you can see that the equation is a function of theeta and i also been given an equation for theeta

! theeta=(1-1/(((n-0.5)**2)*(3.142**2)*(k**2)))*3.142*(n-0.5)

!annd now you can see that theeta is a function of n..that is the number of roots..for for the first root.i have n=1 and so on..10

!also i need to have the derivative of the function because it will be needed for the newton iteration

!DF=1/(cos(theeta**2)) as u c that it depends on theeta as well

! so u see that i need to have the roots(theeta) for each value of n..and all these values of rooots need to be stored in an array

!then having done all this..these values of roots will be needed to calculate the values of the fnal equation which i have ommited for now

! i have made three function subprograms for these equations that i have mentioned.and this subroutine..but i am getting errors and warnings

!please make corrections and add comments for identification so that i can know my mistakes




PROGRAM NEWTON

real theeta(10),f(100),df(100),eps

theeta(1)=0.1
EPS=0.00001

CALL NEWT(theeta,X,EPS)
STOP
END

!-------------------------------------------------!

SUBROUTINE NEWT(theeta,X,EPS)
real theeta(10),f(100),df(100)



integer L

do L=1,10

X=theeta(L)-(F(theeta(L))/DF(theeta(L)))




DO WHILE(ABS(X-theeta(L)) .GT. EPS)
theeta(L)=X
X=theeta(L)-(F(theeta(L))/DF(theeta(L)))
END DO
end do

RETURN
END




!--------------------------------

function theeta(n)

integer n(10)

real k,a,h,sigma,theeta
dimension theeta(10)

a=0.1
h=23.0
sigma=46.0


k=1-(a*h/sigma)

do i=1,10

theeta(i)=(1-1/(((i-0.5)**2)*(3.142**2)*(k**2)))*3.142*(i-0.5)


end do



return

end

!-------------------------------------------------------------------------


FUNCTION F(theeta)

real a,h,sigma,f(9),theeta(9)

integer m

a=0.1
h=23.0
sigma=46.0




do m=2,10

F(m)=theeta(m)*(1/(1-(a*h/sigma)))
enddo


WRITE(6,10)theeta,F
10 FORMAT(22X,F16.7,4X,F16.7)
RETURN
END

!-------------

FUNCTION DF(theeta)
real df(9),theeta(9)

integer j

do j=2,10

DF(j)=1/(cos(theeta(j)**2))

end do

RETURN
END
 
Old 12-28-2011, 02:56 AM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Please use the CODE tags when posting code, plus it would be helpful if you state which language your question is about -preferably in the thread title.
 
Old 12-28-2011, 12:55 PM   #3
mamatu
LQ Newbie
 
Registered: Dec 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
sir i am very sorry...please teach me how to use tags...i am unaware of them..secondly...this is fortran programming..please help
 
Old 12-28-2011, 01:21 PM   #4
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
At the end of your code put this: [/CODE]
At the start of your code put this: [CODE]
I can't show you with the CODE tag first because then the forum software thinks I am inserting code and the examp,etags disappear. You can edit your original post and insert those tags so that it will be easier to read. I haven't had good luck in the past editing the title of my threads, but maybe that has changed. If you can edit the title put [FORTRAN] in there so any FORTRAN gurus can easily see what language you are working in.
 
Old 12-28-2011, 02:17 PM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
gnashly: you can demonstrate the use of code tags thusly:
[NOPARSE][CODE]#define SOMECODE 1[/CODE][/NOPARSE],
and then it just shows up as
[CODE]#define SOMECODE 1[/CODE]

See also the link in my sig for help on posting with tags.
--- rod.

Last edited by theNbomr; 12-28-2011 at 02:18 PM.
 
Old 12-28-2011, 02:22 PM   #6
mamatu
LQ Newbie
 
Registered: Dec 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
heres the new thread i have made.with all due corrections you suggested

http://www.linuxquestions.org/questi...15#post4560315
 
Old 12-28-2011, 03:13 PM   #7
Proud
Senior Member
 
Registered: Dec 2002
Location: England
Distribution: Used to use Mandrake/Mandriva
Posts: 2,794

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by theNbomr View Post
See also the link in my sig for help on posting with tags.
--- rod.
...
If you have posted source code, please help yourself by using BB Code tags
Except that:
Quote:
Fatal error: Call to undefined function handle_bbcode_drupal() in /home/httpd/linuxquestions/questions/includes/class_bbcode.php on line 1337
mamatu, please just edit your post in this thread, your new one's likely to be locked.

Last edited by Proud; 12-28-2011 at 03:15 PM.
 
Old 12-28-2011, 04:08 PM   #8
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by Proud View Post
Except that:
Fatal error: Call to undefined function handle_bbcode_drupal() in /home/httpd/linuxquestions/questions/includes/class_bbcode.php on line 1337
Not sure where you get that. Everything works for me. Perhaps a bug report is in order...
Sorry to take this off-topic.

--- rod.
 
Old 12-28-2011, 04:31 PM   #9
Proud
Senior Member
 
Registered: Dec 2002
Location: England
Distribution: Used to use Mandrake/Mandriva
Posts: 2,794

Rep: Reputation: 116Reputation: 116
jeremy was already PMed and fixed it before you posted
This still doesn't seem to have bought the OP time to edit their post.
 
Old 12-29-2011, 10:50 PM   #10
mamatu
LQ Newbie
 
Registered: Dec 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
its urgent plss
 
Old 12-30-2011, 11:21 PM   #11
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
Please follow the discussion here:

http://www.linuxquestions.org/questi...-arays-920935/
 
  


Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can you spot the error in my tar command? just a man Linux - Newbie 12 12-17-2009 07:16 AM
subprograms for bash shell-script soujiro777 Linux - Newbie 4 02-22-2008 08:53 PM
Passing bidimensional arrays to function in C pittopitto Programming 5 05-18-2006 09:31 AM
qmail (LWQ) installation error *spot the n00b* dannyboynslu2 Linux - Software 1 07-30-2005 11:00 AM
Can anyone spot the error in this cron file? Pcghost Linux - Software 6 07-23-2003 02:50 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration