Fortran 77 可变大小字符串数组?
我是 Fortran 77 中的傻瓜,一直是 C++ 编码员,但我必须修改多年前的代码...... 我想创建一个可变大小的字符串数组,但我无法在网上找到如何在 Fortran 77 中执行此操作。 理想情况下,它应该是两个维度都可变的数组,但如果不可能,我可以修复字符串的长度,但我需要有可变数量的字符串。
我尝试过:
CHARACTER*32 STR1*(VAR1)
...
WRITE(6,*) STR1(10)
但这不起作用......
I am a dummy in Fortran 77 and have always been a C++ coder, but I have to modify a code from years long ago...
I want to create a variable size array of strings and I cannot find online how to do this in Fortran 77.
Ideally, it should be array with both dimensions variable but if it is not possible, length of the string I can fix, but I need to have variable number of strings.
I tried this:
CHARACTER*32 STR1*(VAR1)
...
WRITE(6,*) STR1(10)
But this does not work...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然FORTRAN 77不支持动态内存分配。
您可以尝试在 ac 程序中分配内存并将结果传递回 FORTRAN 例程。
正如这里所做的那样
http://owen.sj.ca.us/~rk /howto/FandC/FandC.mem.html
或者更清楚 - 使用某种 Interop 来调用 ac 方法
从
https://engineering.purdue.edu/ECN/Support/KB/Docs/CallingCFromFortran
Apparently FORTRAN 77 does not support dynamic memory allocation .
You could try allocating memory in a c program and passing the result back to the FORTRAN routine.
As done here
http://owen.sj.ca.us/~rk/howto/FandC/FandC.mem.html
Or more clearly - using some kind of an Interop to call a c method
from
https://engineering.purdue.edu/ECN/Support/KB/Docs/CallingCFromFortran