我想知道以下 FORTRAN 77 代码的作用

发布于 2024-07-24 23:30:19 字数 1042 浏览 6 评论 0原文

在 .f 文件中,有这样的代码:

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

Bob 看起来是一个函数,但它在文件开头被声明为实数。

然后有一个 .d 文件引用了 Bob。 我也知道 avar 持有一个看起来是插值的值,问题是插值并不总是正确的。

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 

这都是遗留代码。 不是我写的。 我正在努力修复它。 我的问题包括以下内容:

这是做什么的以及如何做的? 什么是 .d 文件?

我认为它正在尝试插值,但我不认为你可以用 FORTRAN 77 做到这一点(以这种方式)。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

晨与橙与城 2024-07-31 23:30:19

看起来 Bob 是一个函数,它获取传递给它的实数 8.3,并返回存储在 avar 中的实数。 但这就是从您发布的代码中可以收集到的全部内容。

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.

云之铃。 2024-07-31 23:30:19

看起来 .d 文件包含一些接近线性的数据。 看起来像实验数据。 35 是您拥有的点数,然后是 x,然后是 y。

Bob 和 John 看起来就像某种字符串标记或标识符。 它们可能在代码中的某个地方使用来决定如何处理数据,或者它们代表什么类型的数据。

鲍勃似乎是一个函数。 请注意,有两种声明函数的方法。

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

一种是显式情况 (foo),您通过分配给名为函数本身的变量来返回值。
另一种情况是“隐式”(不知道正式名称),参见吧。 您将其声明为“数组”,然后表达它的行为方式。 虽然很少见到,但写得非常紧凑。

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.

慕巷 2024-07-31 23:30:19

对困惑感到抱歉。 答案是系统正在使用专有的宏 c 到 FORTRAN 程序来进行插值。 这发生在 make 文件中。 我通过查看一些晦涩的文档发现了这一点。 感谢大家的意见。 再次为它的简洁感到抱歉。 我并不想变得困难。 我所看到的也让我感到困惑。 有时,使用从其他公司购买的 30 年前的遗留代码会很困难。 我是 FORTRAN 新手,所以我认为我没有看到我应该看到的东西,比如我不熟悉的语言功能。 我觉得自己很愚蠢。 它确实引导我更深入地挖掘。 学过的知识。

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.

孤凫 2024-07-31 23:30:19

.d 文件可能是某些人对 .dat 的缩写。 多出来的两个字他懒得打。 以前的程序员就是这样。

看起来您在图表上有一个简单的插值函数,其中“Bob”是从 -17 到 +17 的 X 轴,“John”是与 Bob 点对应的 Y 方向上的一组值。 (不知道 35 的用途,因为只显示了 32 个点。)

代码询问:对于 X 轴上的值 8.3,Y 方向上的插值是多少。 在线性形式中,它将返回 1.413 和 1.479 之间差值的 0.3 倍。 它可能是一个更高阶的插值器,但你没有显示代码,所以我假设最简单的。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文