使用模块中除一个以外的所有变量-是否存在“仅"的相反含义? [英] Using all variables in a module, except for one - is there an opposite of "only"?

查看:53
本文介绍了使用模块中除一个以外的所有变量-是否存在“仅"的相反含义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有全局变量的模块,其中有很多变量.对于一个特定的子例程,我想使用其中的所有变量,除了1.

I have a module with global variables, there are a lot of variables in it. For a specific subroutine I would like to use all variables in it except for 1.

我可以做到的一种方法是

One way I could do this is

use Global_Variables, only : item1,...item50,item52,...item100

但是写出要使用的99个项目非常痛苦,正好在此示例中,我可以跳过item51.

but that is incredibly painful to write out 99 items to use, just so in this example I can skip item51.

我也可以将此特定项目放在单独的Global_Variables2模块中,但这很麻烦.

I could also put this specific item in a seperate Global_Variables2 module, but that is unwieldy.

是否有一个except子句可以与only子句类似但相反地使用?

Is there an except clause that can be used similarly but oppositely of the only clause?

推荐答案

您可以将变量重命名为显然不应该使用的变量

You can rename the variable to something that obviously should not be used

 use mod, disabled => item

除了Fortran 2008外,没有其他内容.还要考虑该变量是否真的需要公开.

There is no except in Fortran 2008. Also think if that variable really needs to be public.

这篇关于使用模块中除一个以外的所有变量-是否存在“仅"的相反含义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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