Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.* 1 > Newsgroup comp.lang.fortran

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 04-28-2012, 05:19 PM
eng_mohamedramadan@yahoo.com
Guest
 
Posts: n/a
Default subroutine

Hello every one,
I want to obtain the fortran code of an equation as subroutine.Please
can compile the following equation¨:
τ=m k√[1-e^(-(μ σ /m k)^n ) ]
Where,
Ï„ : frictional stress
σ : noramal stress
m : friction factor, 0<m<1
μ : friction coefficient
k : shear flow stress
n : friction law exponent, ranging between 1 and about 3
Thank you very much for your time,
Best regards,
Mohamed
Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 04-28-2012, 06:01 PM
dpb
Guest
 
Posts: n/a
Default Re: subroutine

On 4/28/2012 12:19 PM, yahoo.com">eng_mohamedramadan@yahoo.com wrote:
> Hello every one,
> I want to obtain the fortran code of an equation as subroutine.Please
> can compile the following equation¨:
> τ=m k√[1-e^(-(μ σ /m k)^n ) ]

....

Seems too trivial for a posting; what's the _real_ question?

Choose names for the variables (remember to declare them) of the
appropriate type.

Pass them as arguments to let the routine receive specific values for
each invocation.

Multiplication is "*", exponentiation is "**" and division is "/"
The intrinsics for square root and the exponential are SQRT and EXP,
respectively.

Grouping of operations to get the proper associativity is simply
multiple parentheses as written other than the square brackets will have
to also be parens.

Have a go at it; bound to be good practice if are just beginning...

--
Reply With Quote
  #3 (permalink)  
Old 04-28-2012, 06:14 PM
eng_mohamedramadan@yahoo.com
Guest
 
Posts: n/a
Default Re: subroutine

On Apr 28, 7:01Â*pm, dpb <n...@non.net> wrote:
> On 4/28/2012 12:19 PM, eng_mohamedrama...@yahoo.com wrote:> Hello every one,
> > I want to obtain the fortran code of an equation as subroutine.Please
> > can compile the following equation¨:
> > Ï„=m k√[1-e^(-(μ σ /m Â*k)^n ) ]

>
> ...
>
> Seems too trivial for a posting; what's the _real_ question?
>
> Choose names for the variables (remember to declare them) of the
> appropriate type.
>
> Pass them as arguments to let the routine receive specific values for
> each invocation.
>
> Multiplication is "*", exponentiation is "**" and division is "/"
> The intrinsics for square root and the exponential are SQRT and EXP,
> respectively.
>
> Grouping of operations to get the proper associativity is simply
> multiple parentheses as written other than the square brackets will have
> to also be parens.
>
> Have a go at it; bound to be good practice if are just beginning...
>
> --


Thank you, yes according to your words, it is seem trivial. Sorry, but
I dont study fortran before.
Reply With Quote
  #4 (permalink)  
Old 04-28-2012, 07:43 PM
dpb
Guest
 
Posts: n/a
Default Re: subroutine

On 4/28/2012 1:14 PM, yahoo.com">eng_mohamedramadan@yahoo.com wrote:
....

> Thank you, yes according to your words, it is seem trivial. Sorry, but
> I dont study fortran before.


Well, no time like the present...

<http://francesa.phy.cmich.edu/people/fornari/pdf/f90tutor.pdf>

--

Reply With Quote
  #5 (permalink)  
Old 04-28-2012, 07:45 PM
Dick Hendrickson
Guest
 
Posts: n/a
Default Re: subroutine

On 4/28/12 1:14 PM, yahoo.com">eng_mohamedramadan@yahoo.com wrote:
> On Apr 28, 7:01 pm, dpb<n...@non.net> wrote:
>> On 4/28/2012 12:19 PM, eng_mohamedrama...@yahoo.com wrote:> Hello every one,
>>> I want to obtain the fortran code of an equation as subroutine.Please
>>> can compile the following equation¨:
>>> τ=m k√[1-e^(-(μ σ /m k)^n ) ]

>>
>> ...
>>
>> Seems too trivial for a posting; what's the _real_ question?
>>
>> Choose names for the variables (remember to declare them) of the
>> appropriate type.
>>
>> Pass them as arguments to let the routine receive specific values for
>> each invocation.
>>
>> Multiplication is "*", exponentiation is "**" and division is "/"
>> The intrinsics for square root and the exponential are SQRT and EXP,
>> respectively.
>>
>> Grouping of operations to get the proper associativity is simply
>> multiple parentheses as written other than the square brackets will have
>> to also be parens.
>>
>> Have a go at it; bound to be good practice if are just beginning...
>>
>> --

>
> Thank you, yes according to your words, it is seem trivial. Sorry, but
> I dont study fortran before.

OK, why don't you try something and post it here, somebody will be
willing to help.

As a hint, Fortran is pretty tricky with parenthesis and operator
ordering (precedence) in expressions.

There's a big difference between
-( (Sigma*Mu)/(M*K) )**N and (I think this is what you want)
-( (Sigma*Mu)/ M*K )**N and
- (Sigma*Mu)/(M*K) **N

Dick Hendrickson
Reply With Quote
  #6 (permalink)  
Old 04-28-2012, 08:53 PM
Gary Scott
Guest
 
Posts: n/a
Default Re: subroutine

On 4/28/2012 2:45 PM, Dick Hendrickson wrote:
> On 4/28/12 1:14 PM, yahoo.com">eng_mohamedramadan@yahoo.com wrote:
>> On Apr 28, 7:01 pm, dpb<n...@non.net> wrote:
>>> On 4/28/2012 12:19 PM, eng_mohamedrama...@yahoo.com wrote:> Hello
>>> every one,
>>>> I want to obtain the fortran code of an equation as subroutine.Please
>>>> can compile the following equation¨:
>>>> τ=m k√[1-e^(-(μ σ /m k)^n ) ]
>>>
>>> ...
>>>
>>> Seems too trivial for a posting; what's the _real_ question?
>>>
>>> Choose names for the variables (remember to declare them) of the
>>> appropriate type.
>>>
>>> Pass them as arguments to let the routine receive specific values for
>>> each invocation.
>>>
>>> Multiplication is "*", exponentiation is "**" and division is "/"
>>> The intrinsics for square root and the exponential are SQRT and EXP,
>>> respectively.
>>>
>>> Grouping of operations to get the proper associativity is simply
>>> multiple parentheses as written other than the square brackets will have
>>> to also be parens.
>>>
>>> Have a go at it; bound to be good practice if are just beginning...
>>>
>>> --

>>
>> Thank you, yes according to your words, it is seem trivial. Sorry, but
>> I dont study fortran before.

> OK, why don't you try something and post it here, somebody will be
> willing to help.
>
> As a hint, Fortran is pretty tricky with parenthesis and operator
> ordering (precedence) in expressions.
>
> There's a big difference between
> -( (Sigma*Mu)/(M*K) )**N and (I think this is what you want)
> -( (Sigma*Mu)/ M*K )**N and
> - (Sigma*Mu)/(M*K) **N
>
> Dick Hendrickson

Why tricky? Isn't it pretty much standard mathematics?
Reply With Quote
  #7 (permalink)  
Old 04-29-2012, 12:30 PM
eng_mohamedramadan@yahoo.com
Guest
 
Posts: n/a
Default Re: subroutine

On Apr 28, 9:53Â*pm, Gary Scott <garylsc...@sbcglobal.net> wrote:
> On 4/28/2012 2:45 PM, Dick Hendrickson wrote:
>
>
>
>
>
>
>
> > On 4/28/12 1:14 PM, eng_mohamedrama...@yahoo.com wrote:
> >> On Apr 28, 7:01 pm, dpb<n...@non.net> wrote:
> >>> On 4/28/2012 12:19 PM, eng_mohamedrama...@yahoo.com wrote:> Hello
> >>> every one,
> >>>> I want to obtain the fortran code of an equation as subroutine.Please
> >>>> can compile the following equation¨:
> >>>> τ=m k√[1-e^(-(μ σ /m k)^n ) ]

>
> >>> ...

>
> >>> Seems too trivial for a posting; what's the _real_ question?

>
> >>> Choose names for the variables (remember to declare them) of the
> >>> appropriate type.

>
> >>> Pass them as arguments to let the routine receive specific values for
> >>> each invocation.

>
> >>> Multiplication is "*", exponentiation is "**" and division is "/"
> >>> The intrinsics for square root and the exponential are SQRT and EXP,
> >>> respectively.

>
> >>> Grouping of operations to get the proper associativity is simply
> >>> multiple parentheses as written other than the square brackets will have
> >>> to also be parens.

>
> >>> Have a go at it; bound to be good practice if are just beginning...

>
> >>> --

>
> >> Thank you, yes according to your words, it is seem trivial. Sorry, but
> >> I dont study fortran before.

> > OK, why don't you try something and post it here, somebody will be
> > willing to help.

>
> > As a hint, Fortran is pretty tricky with parenthesis and operator
> > ordering (precedence) in expressions.

>
> > There's a big difference between
> > -( (Sigma*Mu)/(M*K) )**N and (I think this is what you want)
> > -( (Sigma*Mu)/ M*K )**N and
> > - (Sigma*Mu)/(M*K) **N

>
> > Dick Hendrickson

>
> Why tricky? Â*Isn't it pretty much standard mathematics?


I try to do it as following but I find error, can you help me?
SUBROUTINE ADD(Tau,m,k,Sigma,Mu,n)
Tau =m*k*SQRT(1.0-EXP((-Sigma*Mu)/(M*K))**N)
M>0.0.AND.M<1.0
N>=1.0.AND.N<=3.0
RETURN
END
Reply With Quote
  #8 (permalink)  
Old 04-29-2012, 02:52 PM
Dick Hendrickson
Guest
 
Posts: n/a
Default Re: subroutine

On 4/28/12 3:53 PM, Gary Scott wrote:
> On 4/28/2012 2:45 PM, Dick Hendrickson wrote:
>> On 4/28/12 1:14 PM, yahoo.com">eng_mohamedramadan@yahoo.com wrote:
>>> On Apr 28, 7:01 pm, dpb<n...@non.net> wrote:
>>>> On 4/28/2012 12:19 PM, eng_mohamedrama...@yahoo.com wrote:> Hello
>>>> every one,
>>>>> I want to obtain the fortran code of an equation as subroutine.Please
>>>>> can compile the following equation¨:
>>>>> τ=m k√[1-e^(-(μ σ /m k)^n ) ]
>>>>
>>>> ...
>>>>
>>>> Seems too trivial for a posting; what's the _real_ question?
>>>>
>>>> Choose names for the variables (remember to declare them) of the
>>>> appropriate type.
>>>>
>>>> Pass them as arguments to let the routine receive specific values for
>>>> each invocation.
>>>>
>>>> Multiplication is "*", exponentiation is "**" and division is "/"
>>>> The intrinsics for square root and the exponential are SQRT and EXP,
>>>> respectively.
>>>>
>>>> Grouping of operations to get the proper associativity is simply
>>>> multiple parentheses as written other than the square brackets will
>>>> have
>>>> to also be parens.
>>>>
>>>> Have a go at it; bound to be good practice if are just beginning...
>>>>
>>>> --
>>>
>>> Thank you, yes according to your words, it is seem trivial. Sorry, but
>>> I dont study fortran before.

>> OK, why don't you try something and post it here, somebody will be
>> willing to help.
>>
>> As a hint, Fortran is pretty tricky with parenthesis and operator
>> ordering (precedence) in expressions.
>>
>> There's a big difference between
>> -( (Sigma*Mu)/(M*K) )**N and (I think this is what you want)
>> -( (Sigma*Mu)/ M*K )**N and
>> - (Sigma*Mu)/(M*K) **N
>>
>> Dick Hendrickson

> Why tricky? Isn't it pretty much standard mathematics?


OK, maybe tricky is too strong. But, the OP is a beginner and in his
expression
(μ σ /m k)
you can't translate that without being careful with "k"

Dick Hendrickson
Reply With Quote
  #9 (permalink)  
Old 04-29-2012, 11:55 PM
Terence
Guest
 
Posts: n/a
Default Re: subroutine

> > On 4/28/12 1:14 PM, eng_mohamedrama...@yahoo.com wrote:

I try to do it as following but I find error, can you help me?
SUBROUTINE ADD(Tau,m,k,Sigma,Mu,n)
Tau =m*k*SQRT(1.0-EXP((-Sigma*Mu)/(M*K))**N)
M>0.0.AND.M<1.0
N>=1.0.AND.N<=3.0
RETURN
END

Now you have a new problem.

But first, YOU MUST READ A MANUAL on Fortran programming!
The subroutine you wrote before, and this new version, show that you do not
understand the first elements of programming in a mathematical language.

You can start with this subroutine that you have shown us, as an expression
of the ideas you have about how to solve the physical or mathematical
problem you are facing.
Then having written the conditions and basic formula connecting the known
variables (those on the right of the equals sign) to obtain the unknown
variable (Tau), seen on the left of the equals sign, you can proceed to turn
this into a problem-solving program..

But you still have to obtain, or provide, the values of the variables m,k,
Sigma,Mu, and N.
Not that 'm' is the same as 'M' and 'k' is the same as 'K' since Fortran
does not take any notice of the case of the names of the variables.
Also, you have noted that some variables (M.N) are only known to be within
certain ranges, (or else you want to explore the resulting values of Tau
within this two-dimensional domain of M,N as they are varied.

Now, find a book of Fortran programming (it can be a very old one on
Fortran77, or later F90 or F95), but everything you need will be there, and
any Fortran compiler of today can compile and run code written within the
simple limitations you will need.





Reply With Quote
 
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 09:33 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.