What does the [REFERENCE] tag do in an argument declaration?

China☆狼群 提交于 2020-01-11 11:42:49

问题


I am writing an custom callback function in Fortran for a piece of software (example here) that includes the following argument declaration

SUBROUTINE CONTACT_FORCE(TIME,UPAR,NPAR,PEN,RVEL,JFLAG,IFLAG,RESULT)
!DEC$ ATTRIBUTES DLLEXPORT,C::CONTACT_FORCE
...
DOUBLE PRECISION RESULT[REFERENCE](6)   !Compiles ok

Which compiles fine with Compaq Visual Fortran 6. So my question is what does the [REFERENCE] tag do? I thought that Fortran passes everything by reference (and not by value). Of course there nothing in the compiler help about this, and searching online is difficult because the word reference is used so much with respect to Fortran that I don't know how to narrow it down.

Edit the above must be identical to

SUBROUTINE CONTACT_FORCE(TIME,UPAR,NPAR,PEN,RVEL,JFLAG,IFLAG,RESULT)
!DEC$ ATTRIBUTES DLLEXPORT,C::CONTACT_FORCE
!DEC$ ATTRIBUTES REFERENCE::RESULT
...
DOUBLE PRECISION RESULT(6)   !Compiles ok

回答1:


I'm assuming MS products here. Fortran can be made to pass by value or by reference if the C or STDCALL attribute is used. See here:

http://msdn.microsoft.com/en-us/library/aa294334(v=vs.60).aspx



来源:https://stackoverflow.com/questions/7560927/what-does-the-reference-tag-do-in-an-argument-declaration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!