views:

252

answers:

4

In a .f file there is code that does this:

real Bob, avar
...
avar = Bob( 8.3 )
...

Bob appears to be a function but it is declared at the beginning of the file as a real.

Then there is a .d file that has a reference to Bob. Also I know avar holds a value that appears is interpolated, The problem is the interpolation is not always right.

Bob    John      35
-17.     -16.     -15.     -14.     -13.     -12.     -11.     -10.     -9.      -8.  
-7.      -6.      -5.      -4.      -3.      -2.      -1.       0.       1.       2.5  
 3.       4.       5.       6.5      7.       8.       9.       10.      11.      12.  
 13.      14.      15.      16.      17.  
 0.001    0.001    0.041    0.098    0.155    0.213    0.27     0.327    0.384    0.441   
 0.499    0.556    0.613    0.670    0.728    0.785    0.844    0.904    0.965    1.058   
 1.089    1.152    1.216    1.314    1.347    1.413    1.479    1.543    1.609    1.670   
 1.733    1.799    1.860    1.925    1.937

This is all legacy code. I did not write it. I am trying to fix it. My question consists of the following:

What is this doing and how? What is a .d file?

I think it is trying to interpolate but I did not think you could do this (in this way) with FORTRAN 77.

+1  A: 

It looks like Bob is a function, that is getting the real value 8.3 passed to it, and is returniung a real that is stored in avar. But that's all that can be gleaned from the code you have posted.

anon
what is a .d file?
Paul
Bob is not declared using syntax like real function bob(something)
Paul
A file with the extension .d? I'd take a wild guess it is a data file. F77 does not require or expect any specific file extensions.
anon
Bob is not declared as function IN THE CODE YOU POSTED - this is why we are all saying you need to post more code.
anon
There is no code file that declares bob as a function hence my puzzlement. I looked at the whole UNIX box for any file that did that and came up empty. So you have all the info I have. I am looking at other possibilities at the moment.
Paul
Any USE statements in there, by any chance? Also, don't take this the wrong way or anything, but is there a specific (or not so specific reason) why you can't just post the whole thing somewhere ? Licence, security issues ? The process would go a lot faster than just guessing like this.
ldigas
+1  A: 

Looks like the .d file contains some data that is nearly linear. Looks like experimental data. 35 is the number of points you have, then you have the x, and then the y.

Bob and John seems to be like some kind of string markers, or identifiers. They are probably used somewhere in the code to decide what to do with the data, or what kind of data they represent.

Bob seems like a function. Please note that you have two ways of declaring a function.

real function foo(a)
    implicit none
    real, intent(in) :: a
    foo = 3.0+a
end function

program test
   implicit none
   real foo, bar, a, b
   bar(b) = b+5.0

   a=foo(5.3)
   print *, a, bar(2.3)
end program

One is the explicit case (foo), where you return the value by assign to the variable named as the function itself. The other case is "implicit" (don't know the formal name), see bar. You declare it as an "array" and then express how it should behave. Seen it very rarely, but it's a very compact writing.

Stefano Borini
I agree with all except no were in the code does it do that.I am perplexed ... I will dig and get back.
Paul
Are you absolutely sure that the .d file has been created through that program? people leave a lot of garbage around.
Stefano Borini
I found the reason ... thanks ... see my answer to the question. I feel foolish.
Paul
A: 

Sorry for the confusion. The answer is the system is using a proprietary macro c to FORTRAN program that does interpolation. This happens in the make file. I found by looking at some obscure documentation . Thanks everyone for their input. Sorry again for the terseness of it. I was not trying to be difficult. It was confusing to me with what I saw as well. It is sometimes difficult working with 30 year old legacy code bought from a different company. I am new to FORTRAN so I thought I was not seeing something I should have been seeing like a language feature I was unfamiliar with. I feel foolish. It did lead me to dig deeper. Lesson learned.

Paul
Shouldn't there have been some calling interface in the fortran program, then ?
ldigas
Man, how wild. I love that stuff. I'm starting to envy you. :-)
Nosredna
The calling code is created by the make file that calls a C program. It made a Bob_() function. Can not seem to find that yet. :) The code itself is run as part of another system. There is a lot of CRAP I have yet to figure out. Yes Nosrenda it is Fun :).
Paul
A: 

A .d file is probably some dope's way of abreviating .dat. He was too lazy to type the two extra characters. Old time programmers were like that.

It looks like you've got a simple interpolation function on a graph where "Bob" is the X axis spanning from -17 to +17 and "John" is a set of values in the Y direction corresponding to the Bob points. (Don't know what the 35 is for, since only 32 points are shown.)

The code is asking: for a value on the X axis, 8.3, what would be the interpolated value in the Y direction. In the linear form it would return .3 times the difference between 1.413 and 1.479. It could be a higher order interpolator but you don't show the code, so I assume the simplest.