AMBER Archive (2007)

Subject: Re: AMBER: mdfil.f

From: Robert Duke (rduke_at_email.unc.edu)
Date: Mon Apr 16 2007 - 12:02:28 CDT


Okay, I have really not looked back at the code, but I took the issue to be
whether or not the expression was strictly correct because there is not
"short circuit evaluation" in fortran like there is in C. So the code below
could create an error if when ie > iend there is an memory addressing error
associated with looking at groupbuffer(ie+1:ie+1) (so fortran will merrily
evaluate 100 .and. expressions in a conditional (if statement) even if the
first one it looks at evaluates false). Breaking this into two conditionals
avoids this; I did not bother to respond earlier because 1) the user, as far
as I could tell did not indicate he hit an error but was simply picking nits
over more proper use of the language, and 2) I presumed that if this
actually did not work, it must be a pretty darn rare occurrence, and maybe
not even possible due to the way the buffers are laid out; there are enough
alligators in my swamp that I tend to worry mostly about the ones that still
have their teeth...
Regards - Bob

----- Original Message -----
From: "Ross Walker" <ross_at_rosswalker.co.uk>
To: <amber_at_scripps.edu>
Sent: Monday, April 16, 2007 12:43 PM
Subject: RE: AMBER: mdfil.f

>I think it is your compiler here that is busted and not the expression.
>
> The expression in question is:
>
> do while ( ie <= iend .and. groupbuffer(ie:ie) /= ' ' )
> ie = ie + 1
> end do
>
> Which consists of two relational operators and a logical operator. The do
> while expression must evaluate to true for the loop to iterate hence the
> value of ie cannot be updated until both relational expressions involving
> ie
> have been evaluated as true.
>
> The Fortran standard asserts that arithmetic operators have a higher
> priority than any relational operators which have a higher priority than
> any
> logical operators. Thus the following three statements are logically
> equivalent:
>
> (((x+3)<=y) .AND. (y<=z))
> ((x+3<=y) .AND. (y<=z))
> (x+3<=y .AND. y<=z)
>
> I refer you to Ellis, Philips, Lahey, "Fortran 90 Programming",
> Addison-Wesley, 1994, Chapter 5.
>
> Hence your compiler is not implementing the Fortran standard correctly.
> Hence this is most likely a compiler bug. This is strange since I have not
> seen this problem before in any mainstream compiler. What compiler and
> version are you using?
>
> /\
> \/
> |\oss Walker
>
> | HPC Consultant and Staff Scientist |
> | San Diego Supercomputer Center |
> | Tel: +1 858 822 0854 | EMail:- ross_at_rosswalker.co.uk |
> | http://www.rosswalker.co.uk | PGP Key available on request |
>
> Note: Electronic Mail is not secure, has no guarantee of delivery, may not
> be read every day, and should not be used for urgent or sensitive issues.
>
>> -----Original Message-----
>> From: owner-amber_at_scripps.edu
>> [mailto:owner-amber_at_scripps.edu] On Behalf Of Peljidiyn Genden
>> Sent: Saturday, April 14, 2007 00:43
>> To: amber_at_scripps.edu
>> Subject: AMBER: mdfil.f
>>
>> Jagshemash! [sacred Mongolian word meaning "Hello
>> everybody, nice to meet you again!"]
>>
>> it is well known here in Mongolia that FORTRAN is a
>> unique language
>> in many ways; in particular, FORTRAN (unlike any other
>> language in
>> the visible part of our Universe) does not evaluate
>> boolean
>> expressions is some definite order; therefore there
>> are (at least)
>> 2 (more) errors in mdfil.f submodule of SANDER module
>> of AMBER; see below
>>
>> --- src/sander/mdfil.f
>> +++ src/sander/mdfil.f
>> @@ -299,8 +299,9 @@ integer function iargc_wrap()
>> else
>> is = istart
>> ie = istart
>> - do while ( ie <= iend .and. &
>> - groupbuffer(ie:ie) /= ' ' )
>> + do while ( ie <= iend)
>> + if (groupbuffer(ie:ie) == ' ' ) &
>> + exit
>> ie = ie + 1
>> end do
>> ia = ia + 1
>> @@ -349,8 +350,9 @@ subroutine getarg_wrap(iarg, arg)
>>
>> is = istart
>> ie = istart
>> - do while ( ie <= iend .and. &
>> - groupbuffer(ie:ie) /= ' ' )
>> + do while ( ie <= iend )
>> + if (groupbuffer(ie:ie) == ' ') &
>> + exit
>> ie = ie + 1
>> end do
>> ia = ia + 1
>>
>> Excuse me please for the so brief message - I have to
>> run - Mongolian
>> born Kazaki superstar Korki Buchek sings today in the
>> Mongolian
>> national academie theater of opera and ballet
>> (Ulaanbaatar, Mongol Uls).
>>
>> Yours,
>> Peljidiyn Genden
>>
>>
>> sef w==@$@# =@$3 23 @#$@= 234@# ++ 234 24
>> --))(()((-==wqer
>>
>> Peljidiyn Genden, Ph. D., MD, FD, and OP
>> Ministry Of FORTRAN Affairs
>> Ulaanbaatar, Mongol Uls
>>
>> [phone/fax are prohibited in our department to
>> prevent
>> us from spreading the insanity over the wires]
>>
>> 966 0wr wer er == ___ 34 r5234 === 2345 2=--- 234
>> ---=====
>>
>>
>> __________________________________________________
>> Do You Yahoo!?
>> Tired of spam? Yahoo! Mail has the best spam protection around
>> http://mail.yahoo.com
>>
>> --------------------------------------------------------------
>> ---------
>> The AMBER Mail Reflector
>> To post, send mail to amber_at_scripps.edu
>> To unsubscribe, send "unsubscribe amber" to majordomo_at_scripps.edu
>>
>
>
> -----------------------------------------------------------------------
> The AMBER Mail Reflector
> To post, send mail to amber_at_scripps.edu
> To unsubscribe, send "unsubscribe amber" to majordomo_at_scripps.edu
>

-----------------------------------------------------------------------
The AMBER Mail Reflector
To post, send mail to amber_at_scripps.edu
To unsubscribe, send "unsubscribe amber" to majordomo_at_scripps.edu