FORTRAN 95:是否可以共享模块而不共享源代码? [英] FORTRAN 95: is it possible to share a module without sharing the source code?

查看:96
本文介绍了FORTRAN 95:是否可以共享模块而不共享源代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够共享FORTRAN 95模块而不共享其源代码.是否可以这样做(也许通过共享.MOD文件)?如果这是相关的,我将在Plato上使用Silverfrost FTN95编译器.到目前为止,我仅设法通过使用外部模块的源代码来完成这项工作.这是一个示例:

I would like to be able to share a FORTRAN 95 module without sharing its source code. Is it possible to do so (maybe by sharing the .MOD file)? In case this is relevant, I use Silverfrost FTN95 compiler on Plato. So far, I only manage to make this work by using the source code of the external module. Here is an example:

文件:module_test.f95

file: module_test.f95

module TEST
contains

  subroutine 1
  code...

end module TEST


文件:main_program.f95


file: main_program.f95

include "module_test.f95"
program MAIN_PROGRAM
use TEST
implicit none

code...

end program MAIN_PROGRAM


那么,有人可以在没有我的文件module_test.f95或主代码中没有include "module_test.f95"行的情况下使用我的模块TEST吗?


So, would it be possible for someone to use my module TEST without having my file module_test.f95 nor the line include "module_test.f95" on the main code?

非常感谢!

推荐答案

您可以提供两件事. 1)编译的目标代码,可能是库形式.缺点是,这将取决于编译器,操作系统(也许是编译器版本),因此支持负担可能很大. 2)您可以编写例程的等效接口描述,而不是提供源代码以使其他人可以使用use模块.至少,这是在源代码级别,并且不会依赖于编译器.如果您更改了任何过程的参数,则需要编写一些工作,并且必须对其进行维护.

You could provide two things. 1) Compiled object code, possibly in library form. The disadvantage is that this would depend on compiler, OS, perhaps compiler version, and so could be large burden to support. 2) Instead of providing the source code so that others could use the module, you could write equivalent interface descriptions of your routines. This, at least, is at the source code level and would not be compiler dependent. It would some work to write and would have to be maintained if you changed the arguments of any of your procedures.

这篇关于FORTRAN 95:是否可以共享模块而不共享源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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