在fortran中的等效语句 [英] equivalence statements in fortran

查看:145
本文介绍了在fortran中的等效语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如果我输入了cast,我可能会丢失这个数据类型数据还是应该作为字节数组传递?

解决方案

您必须完全理解旧的FORTRAN代码。 EQUIVALENCE共享内存而不转换不同数据类型之间的值。也许程序员通过重叠数组来节省内存,而这些数组并没有在同一时间使用,并且等价性可以被忽略。也许他们正在做一些非常棘手的事情,根据特定平台的二进制表示形式,你需要弄清楚他们在做什么。



没有什么理由在现代Fortran中使用EQUIVALENCE。在大多数情况下,需要将位从一种类型转换为另一种类型而不进行转换,应该使用TRANSFER内部函数。


I am porting application from fortran to JAVA.I was wondering how to convert if equivalence is between two different datatypes.

If I type cast,i may loose the data or should I pass that as byte array?

解决方案

You have to fully understand the old FORTRAN code. EQUIVALENCE shares memory WITHOUT converting the values between different datatypes. Perhaps the programmer was conserving memory by overlapping arrays that weren't used at the same time and the EQUIVALENCE can be ignored. Perhaps they were doing something very tricky, based on the binary representation of a particular platform, and you will need to figure out what they were doing.

There is extremely little reason to use EQUIVALENCE in modern Fortran. In most cases where bits need to be transferred from one type to another without conversion, the TRANSFER intrinsic function should be used instead.

这篇关于在fortran中的等效语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆