Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

fortran

60 views
Skip to first unread message

eng_moham...@yahoo.com

unread,
Apr 28, 2012, 2:08:15 PM4/28/12
to
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

Terence

unread,
Apr 28, 2012, 6:44:20 PM4/28/12
to
Well, you're getting there!
The next step should be

?=m*k*SQRT(1.0 -exp( (-?* ?) /(m* k) )**n )

But note that Fortran does not use greek symbols, but characters or words to
represent them. So you have to change these symbols
? comes "T" or TAU etc, as follows:-

?? Alpha ?? Nu
?? Beta ?? Xi
?? Gamma ?? Omicron
?? Delta ?? Pi
?? Epsilon ?? Rho
?? Zeta ??? Sigma
?? Eta ?? Tau
?? Theta ?? Upsilon
?? Iota ?? Phi
?? Kappa ?? Chi
?? Lambda ?? Psi
?? Mu ?? Omega

but I think you should check if the original expression has a double
exponentiation.


Terence

unread,
Apr 28, 2012, 6:49:50 PM4/28/12
to
H'm. I see this previous posting of mine looked OK to me, with all the greek
symbols present and correct BEFORE I posted (with Outlook Express), but it
seems there was a loss in content somewhere in the chain, when I get to see
waht ended up being posted. Why, and where did this happen?
(I may want to use my school-taught Greek sometime; the Latin still looks
OK).



Sjouke Burry

unread,
Apr 28, 2012, 6:57:57 PM4/28/12
to
"Terence" <tbwr...@bigpond.net.au> wrote in
news:mu_mr.6282$v14....@viwinnwfe02.internal.bigpond.com:
Try to define things in standard asci characters.
Lots of special charactors have the nasty habit of not
surviving the trip.
In a pinch: put things in a picture and provide a link to that.

glen herrmannsfeldt

unread,
Apr 28, 2012, 8:28:18 PM4/28/12
to
Terence <tbwr...@bigpond.net.au> wrote:

(snip)
> But note that Fortran does not use greek symbols, but characters
> or words to represent them. So you have to change these symbols
> ? comes "T" or TAU etc, as follows:-

Java allows greek letters, or any ohter Unicode letters for
variable names. Assuming you have a printer that can print them,
some look very similar to roman letters. Could be confusing.

-- glen

eng_moham...@yahoo.com

unread,
Apr 29, 2012, 7:48:52 AM4/29/12
to
On Apr 29, 1:28 am, glen herrmannsfeldt <g...@ugcs.caltech.edu> wrote:
Thank you very much for all,I am glad with your helping.

eng_moham...@yahoo.com

unread,
Apr 29, 2012, 8:22:49 AM4/29/12
to
On Apr 29, 1:28 am, glen herrmannsfeldt <g...@ugcs.caltech.edu> wrote:
I try to do it now as following but I find error, can you tell me what
the wrong step? thank you
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

dpb

unread,
Apr 29, 2012, 8:57:36 AM4/29/12
to
Add an

IMPLICIT NONE

into the subroutine (and your main program and every function/subroutine
you write).

NB that Fortran by default uses implicit type declarations and variables
whose initial (or only) letter is one of I thru N are INTEGER variables;
all others are by default REAL.

So your variables m,k,n,Mu are INTEGER; not what you intended/need for
the subroutine.

Also the relational statements are improper syntax -- I'm not sure what,
specifically, you're trying to do but you need something like an IF and
an action clause.

if( m>0.0 .AND. m<1.0) then
! do something here in that case
else
! do whatever else -- error maybe?
endif

Look through the tutorial information at the link I gave you as well as
the language reference manual for the compiler you're using for details
on syntax.

--

eng_moham...@yahoo.com

unread,
Apr 29, 2012, 9:50:29 AM4/29/12
to
On Apr 29, 1:57 pm, dpb <n...@non.net> wrote:
I only need to obtain the equation and defining that n ranging from 1
to 3 and m will be > than zero and lower than 1

glen herrmannsfeldt

unread,
Apr 29, 2012, 10:06:46 AM4/29/12
to
eng_moham...@yahoo.com <eng_moham...@yahoo.com> wrote:

(snip)

>> >         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

(snip)
>> NB that Fortran by default uses implicit type declarations
>> and variables whose initial (or only) letter is one of
>> I thru N are INTEGER variables; all others are by default REAL.

Do check this one. Some of those might not be integers.

(snip)
> I only need to obtain the equation and defining that n ranging
> from 1 to 3 and m will be > than zero and lower than 1

If the expression can't be evaluated in some cases, then you
should use an IF statement. You might need to return a different
value when m or K are zero.

But otherwise you don't give conditions like that.

If, for example, this is in a minimization routine or root
finder, you can't just put restrictions like that one the values.

The subroutine is called and has to return some value.

-- glen

dpb

unread,
Apr 29, 2012, 10:13:02 AM4/29/12
to
On 4/29/2012 8:50 AM, eng_moham...@yahoo.com wrote:
...

> I only need to obtain the equation and defining that n ranging from 1
> to 3 and m will be> than zero and lower than 1

I'd deal w/ that by ensuring the calling routine only calls the
SUBROUTINE w/ the proper values, _NOT_ by adding a condition in the
SUBROUTINE itself (unless the correlation is known to be bounded by
those ranges; then it would make some sense to include that).

Still, the syntax has to match a valid Fortran construct; you can't just
use a relational expression on its own.

You've given no hint as to the compiler you're using, but it's bound to
have at a minimum a language reference manual and hopefully a
programmers' guide or somesuch to go with it.

If you don't know where to find same, it's highly likely there's
somebody here that will know where they are if you give the information.

--


eng_moham...@yahoo.com

unread,
Apr 29, 2012, 11:03:05 AM4/29/12
to
On Apr 29, 3:13 pm, dpb <n...@non.net> wrote:
I want to obtain the fortran code of Friction equation as
subroutine.The equation as follow:
Tau =m*k*SQRT(1.0-EXP((-Sigma*Mu)/(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
Only I want to obtain the fortran code for the equation in order to
implement it into DEFORM Program.
Thank You,

eng_moham...@yahoo.com

unread,
Apr 29, 2012, 11:28:12 AM4/29/12
to
On Apr 29, 4:03 pm, "eng_mohamedrama...@yahoo.com"
<eng_mohamedrama...@yahoo.com> wrote:
> On Apr 29, 3:13 pm, dpb <n...@non.net> wrote:
>
>
>
>
>
>
>
> > On 4/29/2012 8:50 AM, eng_mohamedrama...@yahoo.com wrote:
> > ...
>
> > > I only need to obtain the equation and defining that n ranging from 1
> > > to 3 and m will be>  than zero and lower than 1
>
> > I'd deal w/ that by ensuring the calling routine only calls the
> > SUBROUTINE w/ the proper values, _NOT_ by adding a condition in the
> > SUBROUTINE itself (unless the correlation is known to be bounded by
> > those ranges; then it would make some sense to include that).
>
> > Still, the syntax has to match a valid Fortran construct; you can't just
> > use a relational expression on its own.
>
> > You've given no hint as to the compiler you're using, but it's bound to
> > have at a minimum a language reference manual and hopefully a
> > programmers' guide or somesuch to go with it.
>
> > If you don't know where to find same, it's highly likely there's
> > somebody here that will know where they are if you give the information.
>
> > --
>
> I want to obtain the fortran code of Friction equation as
> subroutine.The equation as follow:
>  Tau =m*k*SQRT(1.0-EXP((-Sigma*Mu)/(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
> Only I want to obtain the fortran code for the equation in order to
> implement it into DEFORM Program.
> Thank You,

Sorry, Tau : frictional stress
Sigma : noramal stress
m : friction factor, 0<m<1
Mu : friction coefficient

eng_moham...@yahoo.com

unread,
Apr 29, 2012, 11:25:47 AM4/29/12
to
> On Apr 29, 3:13 pm, dpb <n...@non.net> wrote:
>
>
>
>
>
>
>
> > On 4/29/2012 8:50 AM, eng_mohamedrama...@yahoo.com wrote:
> > ...
>
> > > I only need to obtain the equation and defining that n ranging from 1
> > > to 3 and m will be>  than zero and lower than 1
>
> > I'd deal w/ that by ensuring the calling routine only calls the
> > SUBROUTINE w/ the proper values, _NOT_ by adding a condition in the
> > SUBROUTINE itself (unless the correlation is known to be bounded by
> > those ranges; then it would make some sense to include that).
>
> > Still, the syntax has to match a valid Fortran construct; you can't just
> > use a relational expression on its own.
>
> > You've given no hint as to the compiler you're using, but it's bound to
> > have at a minimum a language reference manual and hopefully a
> > programmers' guide or somesuch to go with it.
>
> > If you don't know where to find same, it's highly likely there's
> > somebody here that will know where they are if you give the information.
>
> > --
>
> I want to obtain the fortran code of Friction equation as
> subroutine.The equation as follow:
>  Tau =m*k*SQRT(1.0-EXP((-Sigma*Mu)/(m*K))**n)
> Where,
> Tau  : frictional stress
> Sigma  : noramal stress
> m : friction factor,  0<m<1
> Mu : friction coefficient

dpb

unread,
Apr 29, 2012, 11:40:41 AM4/29/12
to
On 4/29/2012 10:03 AM, eng_moham...@yahoo.com wrote:
...

> Only I want to obtain the fortran code for the equation in order to
> implement it into DEFORM Program.

I have no idea what DEFORM is, but the rules for Fortran syntax are what
they are. Expecting somebody to simply write a working piece of code
for you is not what clf is about.

As you've seen, you put in some effort, folks will help coach along but
repeatedly repeating the same request will only result in antagonizing
and eventually being ignored.

You've been told what your initial code needs as fixes; follow up on
that first.

--

dpb

unread,
Apr 29, 2012, 12:06:43 PM4/29/12
to
On 4/29/2012 10:40 AM, dpb wrote:
> On 4/29/2012 10:03 AM, eng_moham...@yahoo.com wrote:
> ....
>
>> Only I want to obtain the fortran code for the equation in order to
>> implement it into DEFORM Program.
>
> I have no idea what DEFORM is, but the rules for Fortran syntax are what
> they are. Expecting somebody to simply write a working piece of code for
> you is not what clf is about.
...

BTW, if you're using another program that expects/uses Fortran
expressions as an extension to its facilities, there will certainly be
documentation for that program that describes the rules needed to make
that interface.

Is it interpreting source code or does it want/need a compiled linkable
routine or as a user-supplied library or dll or what?

Does it want/need a complete working subroutine or does it "know" about
various variables and simply expect/allow one to write an expression
with those that is evaluated? (I guess the former given the form of the
question but w/o the information on the specific program that's sorta' a
presumption).

There's more to the story here than has been revealed to us as yet as
well as simply getting the code working. At the risk of sounding
excessively preachy I'll again refer to the point made earlier that if
you're using a program such as this and want/need the facility to use
Fortran code with it, you need to learn sufficient Fortran to cope
rather than expect others to do your work for you. Folks at clf are
exceedingly helpful in coaching but "not so much" in aiding what can be
interpreted as "freeloading" much as in the "do my homework assignment
for me". /Preach mode ended :) /

--

eng_moham...@yahoo.com

unread,
Apr 29, 2012, 12:36:29 PM4/29/12
to
On Apr 29, 5:06 pm, dpb <n...@non.net> wrote:
Thank you,got your point. Thanks again for your time and for every one
present help for me. Hoping all of you are OK.

glen herrmannsfeldt

unread,
Apr 29, 2012, 1:07:12 PM4/29/12
to
dpb <no...@non.net> wrote:
> On 4/29/2012 10:03 AM, eng_moham...@yahoo.com wrote:

>> Only I want to obtain the fortran code for the equation in order to
>> implement it into DEFORM Program.

> I have no idea what DEFORM is, but the rules for Fortran syntax are what
> they are. Expecting somebody to simply write a working piece of code
> for you is not what clf is about.

There are a variety of integration and optimization routines
where one supplies a function (usually) or subroutine to be
called at the appropriate time.

In that case, it is possible that someone who doesn't otherwise
know Fortran will need to know how to write such a routine.

Still, time to learn at least a little more Fortran.

-- glen

dpb

unread,
Apr 29, 2012, 1:29:53 PM4/29/12
to
On 4/29/2012 12:07 PM, glen herrmannsfeldt wrote:
...

> There are a variety of integration and optimization routines
> where one supplies a function (usually) or subroutine to be
> called at the appropriate time.
>
> In that case, it is possible that someone who doesn't otherwise
> know Fortran will need to know how to write such a routine.

Well, yes, but... :)

W/O knowing at least a rudimentary bit, it's quite possible that one
such user could supply a program unit to such an interface that seems to
work just fine but is, in fact, just simply wrong.

The example of OP's code earlier would compile and run w/ only a modicum
of change as it was written but certainly w/ integer variables as it
presently is constructed the answers may be in the range of where
they're expected to be so isn't completely obvious that they're bogus.

> Still, time to learn at least a little more Fortran.

My thinking is that unless the OP does, he's skating on such thin ice
trying to use anything he adds to the DEFORM program (which appears to
be a nonlinear stress package ("DEFORMation" <www.deform.com>) that it's
too spooky to consider where he'd go next...

--

dpb

unread,
Apr 29, 2012, 1:36:49 PM4/29/12
to
On 4/29/2012 11:36 AM, eng_moham...@yahoo.com wrote:
...

> Thank you,got your point. Thanks again for your time and for every one
> present help for me. Hoping all of you are OK.

OK, good...I'm not trying to beat you up just for the fun of it; there's
a good possibility you could make a serious error either now or in the
future if you don't understand what it is your routine is doing at such
a rudimentary level.

As far as going forward, you need at a minimum a floating point
declaration for each variable. Whether it should/needs to be default
REAL or higher precision is one of those things the DEFORM documentation
will outline (although one can assume default is ok, can't tell w/o
further information than have for sure).

As for the logic on the bounding of the various variables, as noted by
another poster, it may be that the program will expect a result for any
possible input; there may be some other way to signal an error if a
value is out of bounds. Again, that'll be part of the interface
documentation.

--

Gary Scott

unread,
Apr 29, 2012, 1:59:18 PM4/29/12
to
On 4/29/2012 11:06 AM, dpb wrote:

>
> There's more to the story here than has been revealed to us as yet as
> well as simply getting the code working. At the risk of sounding
> excessively preachy I'll again refer to the point made earlier that if
> you're using a program such as this and want/need the facility to use
> Fortran code with it, you need to learn sufficient Fortran to cope
> rather than expect others to do your work for you. Folks at clf are
> exceedingly helpful in coaching but "not so much" in aiding what can be
> interpreted as "freeloading" much as in the "do my homework assignment
> for me". /Preach mode ended :) /
>
> --

Not fully understanding the procedure (and not having tried all that
hard), might it be better written as a function than as a subroutine?

dpb

unread,
Apr 29, 2012, 2:12:24 PM4/29/12
to
On 4/29/2012 12:36 PM, dpb wrote:
> On 4/29/2012 11:36 AM, eng_moham...@yahoo.com wrote:
> ....
OK, given the previous caveats, and on the assumption you can/will
figure out some way to verify the results are as expected, the following
would have at least a chance of working...and this is not intended as a
tutorial of how I might code such a routine; only that this should work
(w/ the assumption of default REALs being correct) and a F77-level
compiler. NB: Fortran is _not_ case-sensitive (so Tau and TAU and tau
are all seen internally to the compiler as "TAU") and F77 didn't include
lowercase at all. But, afaik there is no F77 compiler that doesn't
include accepting lowercase in source code so I've not modified your
typing in that regards.

Note I've switched the logic

SUBROUTINE ADD(Tau,m,k,Sigma,Mu,n)
IMPLICIT NONE
REAL Tau,m,k,Sigma,Mu,n

Tau =m*k*SQRT(1.0-EXP((-Sigma*Mu)/(m*K))**n)
RETURN
END

At a minimum, that should work and as before I'm not sure I'd put the
constraints in here but instead expect the routine to be called where I
knew them to be within reasonable bounds. But, since this is a packaged
program it may not be that you can control that and do need to deal with
it. I'd think there would be a defined error interface; if so you
should use it. If not, the following will stop the application; crude
but effective.

SUBROUTINE ADD(Tau,m,k,Sigma,Mu,n)
IMPLICIT NONE
REAL Tau,m,k,Sigma,Mu,n

IF(m.LE.0.0 .OR. m.GE.1.0 .OR. n.LT.1.0 .OR.n.GT.3.0) STOP

Tau =m*k*SQRT(1.0-EXP((-Sigma*Mu)/(m*K))**n)
RETURN
END

Note I've turned the logic around; hopefully I did so w/o a
transcription error.

--

dpb

unread,
Apr 29, 2012, 2:14:18 PM4/29/12
to
On 4/29/2012 12:59 PM, Gary Scott wrote:
...

> Not fully understanding the procedure (and not having tried all that
> hard), might it be better written as a function than as a subroutine?

That'll depend on whether the DEFORM application has that as an option
or not...another detail we don't know about. :)

--

Ron Shepard

unread,
Apr 29, 2012, 2:43:28 PM4/29/12
to
In article <jnk0ac$33m$1...@speranza.aioe.org>, dpb <no...@non.net>
wrote:

> But, afaik there is no F77 compiler that doesn't
> include accepting lowercase in source code so I've not modified your
> typing in that regards.

This is largely true, but there were f77 compilers that, by default,
would take lower case characters and treat them as distinct from
upper case (i.e. following the C language conventions).

Although there have been numerous discussions about this here in
c.l.f over the past 20 years, the above is generally regarded as an
extension of the f77 language. On the other hand, treating lower
and upper case as indistinguishable was *not* an extension to the
language, but rather falls into the category of source code
transcription, which is explicitly mentioned as something that is
not covered by the standard. F90 and later specified that lower and
upper case characters should be indistinguishable (except for
character strings, of course); this is compatible with the f77
standard, but obviously not with those with the extension that
treated lower and upper case as distinct.

$.02 -Ron Shepard

Gary Scott

unread,
Apr 29, 2012, 2:59:20 PM4/29/12
to
Yuk, an egregious error on that vendor's part...

dpb

unread,
Apr 29, 2012, 3:06:37 PM4/29/12
to
On 4/29/2012 1:43 PM, Ron Shepard wrote:
I've used in the past compilers that didn't accept lowercase as well as
those that did; to the best of knowledge I've never before heard of a
FORTRAN compiler that was case-retentive. (I'm not looking at archives
of clf to find the discussion I've forgotten, though... :) )

--

eng_moham...@yahoo.com

unread,
Apr 29, 2012, 3:17:40 PM4/29/12
to
Thank you so much, I try it and it worked good and I understand the
steps good now.Dont worry I have f95, again a lot of thanks for you.

dpb

unread,
Apr 29, 2012, 3:41:08 PM4/29/12
to
On 4/29/2012 2:17 PM, eng_moham...@yahoo.com wrote:
...

> Thank you so much, I try it and it worked good and I understand the
> steps good now.Dont worry I have f95, again a lot of thanks for you.

OK, it worked "well"... :) (+)

Just don't forget the more general lessons learned.

(+) BTW, your English is, overall, quite good (not "well"). :)
Just one more small lesson, "good" is an adjective and "well" is an
adverb. "It would be a good subroutine that worked well."

--

Gib Bogle

unread,
Apr 29, 2012, 5:31:44 PM4/29/12
to
On 30/04/2012 12:57 a.m., dpb wrote:

> Also the relational statements are improper syntax -- I'm not sure what,
> specifically, you're trying to do but you need something like an IF and
> an action clause.
>
> if( m>0.0 .AND. m<1.0) then
> ! do something here in that case
> else
> ! do whatever else -- error maybe?
> endif
>
> Look through the tutorial information at the link I gave you as well as
> the language reference manual for the compiler you're using for details
> on syntax.
>
> --

I think you are doing a lazy person's assignment for him.

dpb

unread,
Apr 29, 2012, 6:25:03 PM4/29/12
to
On 4/29/2012 4:31 PM, Gib Bogle wrote:
...

> I think you are doing a lazy person's assignment for him.

Perhaps, but this doesn't smell too much like actual homework but more
like work assignment (altho might well be grad/undergrad research).

But, he did enough and was pleasant enough to accept some criticism and
preaching graciously so I'm happy...hopefully some of it will "take" for
longer term.

--

glen herrmannsfeldt

unread,
Apr 29, 2012, 7:10:44 PM4/29/12
to
eng_moham...@yahoo.com <eng_moham...@yahoo.com> wrote:

(snip)
> I try to do it now as following but I find error, can you
> tell me what the wrong step? thank you

> 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

Without knowing where this is going to be used, it isn't
so easy to say. As it is hard to call a subroutine with an
unknown number of arguments, often such a routine is called
with an array instead. In that case, you need array elements
in place of each of the variables.

To be sure that you understand, an assignment like:

> Tau =m*k*SQRT(1.0-EXP((-Sigma*Mu)/(m*K))**n)

computes the value of the expression on the right side of
the equals sign, and assigns it to the variable on the left.

That is different from the mathematical meaning of equals.

-- glen

Gib Bogle

unread,
Apr 29, 2012, 8:44:40 PM4/29/12
to
You are a very kind TA ;-)

Dick Hendrickson

unread,
Apr 30, 2012, 11:34:40 AM4/30/12
to
For what little it's worth, the F programming language required that
names always be cased as they were declared. If XYZ was the declared
name, then xyz couldn't be used. This possibly wasn't the wisest
choice; but it seemed like the thing to do at the time.

Dick Hendrickson

dpb

unread,
Apr 30, 2012, 2:49:02 PM4/30/12
to
On 4/30/2012 10:34 AM, Dick Hendrickson wrote:
...

> For what little it's worth, the F programming language required that
> names always be cased as they were declared. If XYZ was the declared
> name, then xyz couldn't be used. This possibly wasn't the wisest choice;
> but it seemed like the thing to do at the time.
...

That I can see some merit in, actually; sometimes consistency does have
merit if for no other reason than itself. :)

The old Visual Basic IDE had a peculiar idiosyncrasy--it enforced the
consistency in case by simply changing it globally to match the typed-in
version instead of enforcing a previous use.

But a Fortran compiler that retained case for symbols by default would
truly be diabolical, indeed (other than the extensions for forcing
symbol-matching conventions for mixed-programming reasons, etc., of course).

--
0 new messages