- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
In the following snippet, Term1 is part of a larger equation:
real(4) :: Term1, T, Twb, Tref T = Twb Tref = 273.15 Term1 = ((2501.6 - 2.3263*(Twb-Tref)) / 2501.6 + 1.8577*(T-Tref) - 4.184*(Twb-Tref))
With the temps equal to each other, this term should go to 1. In fact, by inspecting the form of the equation, it's obvious that it should go to 1.
However, in IVF - when I pause in debug - Term1 is evaluated as -63.62723
Here's the puzzler part:
When I sweep out the numerator w/ my cursor, it's evaluated as 2436.999
When I sweep out the denominator w/ my cursor, it's evaluated as 2436.999
Thus, Term1 should be evaluated very close to 1.0
But it's not!
What the deuce?
- Marcas:
- Intel® Fortran Compiler
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
in other words, your equation for Term1 should be
Link copiado
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Parentheses in the eye of the beholder... Let us rewrite your expression using different pairs of parentheses, braces and brackets.
[{2501.6 - 2.3263*(Twb-Tref)} / 2501.6 + 1.8577*(T-Tref) - 4.184*(Twb-Tref)]
We can remove the [..] since they are the first and last characters, and are therefore superfluous. Thus, what you actually have is X1 + X2, where
X1 = {2501.6 - 2.3263*(Twb-Tref)} / 2501.6
and
X2 = 1.8577*(T-Tref) - 4.184*(Twb-Tref)
Even when T = Twb, X1 need not equal 1 - X2. In fact, if T > Tref, and Twb = T, X1 is less than 1 and X2 is negative, so the sum of X1 and X2 is less than 1 by a larger amount.
The denominator has only the number 2501.6 and nothing else. Everything else is "upstairs". To see that, rewrite the whole expression in built-up display form rather than single-line. When you select just "2501.6 + 1.8577" with your mouse, I doubt that the debugger's expression evaluator knows that the first number is in the denominator and the second in the numerator!
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
in other words, your equation for Term1 should be
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
The outer parentheses were retained when I lifted it from the larger equation. Let's remove them, as you suggest:
Term1 = 2501.6 - 2.3263*(Twb-Tref) / 2501.6 + 1.8577*(T-Tref) - 4.184*(Twb-Tref)
Now it got even crazier. The left-hand side (via debug pause) is 2436.999
The right-hand side is 2436.999
Term1 is evaluates as: 2436.973
This just doesn't make sense.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Now you have mangled the expression further. There were two right parentheses before '/' in #1 and #3, and I had ')}' in #2. By removing one of the parentheses, you changed the expression. Elementary algebra books give fail-safe recipes for processing expressions with nested parentheses and brackets (e.g., G. Chrystal, http://djm.cc/library/Algebra_Elementary_Text-Book_Part_I_Chrystal_edited.pdf ).
David gave you the correct expression. Please try it.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
This was subtle. I have it now. Thank you.

- Subscrever fonte RSS
- Marcar tópico como novo
- Marcar tópico como lido
- Flutuar este Tópico para o utilizador atual
- Marcador
- Subscrever
- Página amigável para impressora