|
|||
|
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 |
|
|
||||
|
||||
|
|
|
|||
|
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... -- |
|
|||
|
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. |
|
|||
|
|
|
|||
|
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 |
|
|||
|
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? |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
> > 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. |
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|