1 新建项目
这里更多内容可以参考:http://fcode.cn/
1.1 项目
这里的Empty Project 和 Main Program Code 没有太大的差别,只是后者会由工程向导为你生成简单的主程序。
1.2 文件夹解释
工程下面,VS 默认会为我们创建三个文件夹。分别用于存放头文件( Header Files),资源文件( Resource Files) 和源代码文件( Source Files)。
一般来说,Header Files 用来存放一些函数库的信息部分(较少使用)。如果不是做windows界面开发的话,Resource Files 也不需要使用。
源代码文件,存放在 Source Files 下面既可。实际上,这三个文件夹的规定并不需要严格遵守。
另外,我们也可以自己创建分类,例如上图中的“计算相关代码”,我们还把 source3.f90 源代码放入其中。
2 数据可视化
现在是黑乎乎控制台,有很多数据需要直观显示,怎么办?
导出数据,用Python、MatLab处理;
或者用相关插件,封装相关的包…
后续讨论
3 编辑器的一些调整
3.1 字体与背景
- 字体:
工具 -> 选项 -> 环境->字体和颜色
选择Consolas,这个字体可以明显看出来中英文标点和半角圆角符号。 - 主题:
工具 -> 选项 ->环境 -> 常规->颜色主题->深色
3.2 代码的折叠
3.2.1设置方法:
工具(Tools),选项(Option),文本编辑器(Text Editor),Fortran,Advanced,Enable Outlining
3.2.2参考资料:https://envsafe.cn/bbs/forum.php?mod=viewthread&tid=247
在VS中配置智能的Intel Fortran IDE环境
Visual Studio 2012 SP1
Intel Visual Fortran Composer XE 2013
安装完Intel Fortran编译器后,可以使用VS编写Fortran程序,但你会发现此时编译器不够“智能”,例如无法查找定义、引用等,导致编程效率低下。
其实IVFC已经提供相当多的智能功能,只不过在默认情况下这些功能没有开启。
要开启这些功能,在Visual Studio的工具->选项窗口中,浏览到“文本编辑器->Fortran->Advanced”,可以看到英文选项,列举如下:
选项 | 默认值 | 说明 |
---|---|---|
Browsing/Navigation | ||
Collect Call/Callers graph information | false | Enable or disable information collection for Call/Callers graph. |
Collect Object Browser information | false | Enable or disable information collection for Object Browser. |
Disable Database | false | Disable all use of code browsing database. The Database will not be opened or created. |
Enable Find All References | false | Enable or disable “Find all references” menu item in context menu. |
Enable Go To Definition | false | Enable or disable “Go To Definition” menu item in context menu. |
Scan system includes | false | Scan standard compliler modules. |
Intrinsics | ||
Enable Intrinsic Parameter Info | false | Displays the signature of an intrinsic in a tooltip when a user types the parameter list start character. |
Enable Intrinsic Quick Info | false | Displays intrinsic signatures and descriptions when a user moves the pointer over an intrinsic name. |
Miscellaneous | ||
Enumerate Comment Tasks | true | Scan open source files for TODO, HACK, etc…and report them in the Task List window. |
Highlight Matching Tokens | false | Highlight enclosing braces or syntax when the cursor touches one of the set. |
Outlining | ||
Enable Outlining | true | Enter outlining mode when files open. |
Outline Statement Blocks | false | Enable automatic outlining of statement blocks. |
除了Disable Database选项应置为false之外,其他选项均可调整为true以启用相应功能。
启用之后可以看到右键菜单的变化,悬停提示以及高亮等。
3.2.3设置完之后,进行一次重启。
重启之后,就可以导航函数、带有折叠
4 代码的自动对齐
调整完之后,进行如下快捷键:
Ctrl-A —— Ctrl K —— Ctrl F
5 一些代码技巧
- 1 Fortran的控制台运行完毕就没有,加一个读取
print *, 'Dnoe...'
pause