Photran的用法(转载自eclipse官网)
Getting Started with Managed Make
If your system has the GNU gfortran compiler installed, try this.
- File | New | Fortran Project
- Call it whatever
- Choose the Executable (Gnu Fortran) from the project type list 注:对于Ubuntu 8.10系统已经不再提供G77支持了,因此,编译器一定要选gfortran,即GNU Fortran
- Choose GCC Toolchain from the toolchain list (you may need to uncheck the "Show project types..." check box at the bottom of the window)
- Click Next
- Click on Advanced Settings
- Expand C/C++ Build in the list on the left, and click on Settings
- Click on the Binary Parsers tab. Check the appropriate parsers for your platform. If you are using Windows, check PE Windows Parser and/or Cygwin PE Parser; if you are using Linux, check Elf Parser; if you are using Mac, check Mach-O parser.
- Click on the Error Parsers tab. Check the error parser(s) for the Fortran compiler(s) you will use.
- Click OK
- Click Finish
- Click File | New | Source File
- Call it hello.f90; click Finish
- Type the standard "Hello, World" program, and click File | Save.
program hello
print *, "Hello World"
stop
end program hello
- Open the Console view, and make sure "make" ran OK and compiled your program
- In the Fortran Projects view, expand the Binaries entry, and click on your executable (e.g., "whatever - [x86le]") 这个设计很好很强大到让人摸不着头脑,因为用M$的V$已经用惯了。。。
- Run | Run As | Run Local C/C++ Application (yeah, I know, it should say "Fortran Application", but it doesn't)
- Choose GDB Debugger (Cygwin GDB Debugger if you're under Windows)
- Check the Console view, and make sure Hello World appeared.
Getting Started with Standard Make
To get started, try this. If you're under Windows, you need to be running Cygwin, c:\cygwin\bin and c:\cygwin\usr\bin should be in your system path, and the g95 libraries need to be copied into /usr/lib (to make things easier for yourself, at least).
- File | New | Fortran Project
- Call it whatever
- Choose Makefile Project from the project type list (it has a folder icon; do not expand it)
- Choose "-- Other Toolchain --" from the toolchain list <--li>Click Next
- Click on Advanced Settings
- Expand C/C++ Build in the list on the left, and click on Settings
- Click on the Binary Parsers tab. Check the appropriate parsers for your platform. If you are using Windows, check PE Windows Parser and/or Cygwin PE Parser; if you are using Linux, check Elf Parser; if you are using Mac, check Mach-O parser.
- Click on the Error Parsers tab. Check the error parser(s) for the Fortran compiler(s) you will use.
- Click OK
- Click Finish
- File | New | File
- Call it Makefile
- Click Finish
- We assume you're familiar with how to format a Makefile. Something like this will work for now. Remember to start the g95 line with a tab, not spaces. The -g switch instructs g95 to include debugging symbols in the generated executable so that it can be debugged later.
all:
g95 -g hello.f90
clean:
- File | New | Source File
- Call it hello.f90
- Click Finish
- Type the standard "Hello, World" program.
program hello
print *, "Hello World"
stop
end program hello
- Project | Clean; then click OK
- Open the Console view, and make sure "make" ran OK and compiled your program
- In the Fortran Projects view, expand the Binaries entry, and click on your executable (e.g., "whatever - [x86le]")
- Run | Run As | Run Local C/C++ Application (yeah, I know, it should say "Fortran Application", but it doesn't)
- Choose GDB Debugger (Cygwin GDB Debugger if you're under Windows)
- Check the Console view, and make sure Hello World appeared.
ubuntu 8.10平台eclipse + photran部署成功
要点
先装cdt. 一定要和eclipse主程序的版本对上。
再装对应版本的photran(从achieve里找)。万勿追最新版,切记!特别是eclipse是从源里装的情况下。
所有的安装不要直接从压缩包里装,应该解压。解压的文件夹中应该包括两个子文件夹feature和plugins。然后,从Help - Software Updates里开,选New features to install 下一步,找到文件夹装上。
ubuntu 8.10平台eclipse + photran部署成功
要点
先装cdt. 一定要和eclipse主程序的版本对上。
再装对应版本的photran(从achieve里找)。万勿追最新版,切记!特别是eclipse是从源里装的情况下。
所有的安装不要直接从压缩包里装,应该解压。解压的文件夹中应该包括两个子文件夹feature和plugins。然后,从Help - Software Updates里开,选New features to install 下一步,找到文件夹装上。
Viktor的Fortran手记之五 IFC可视化设计(二)
5 连接变量和对话框
对话框必须连接到变量上。变量的类型是
并且定义在IFLOGM.F90模块中。(CFC是定义在DIALOGM模块中)具体的连接方式如下:
include 'resource.fd' !默认的资源文件头
type(dialog) dlg
logical retlog
retlog = DlgInit(IDD_WINDOW, dlg)
6 使用对话框的一般过程
- 建立TYPE(dialog)型变量,并调用DlgInit或DlgInitWithResourceHandle函数连接对话框。
- 用DlgSet等手段,赋予控件初始值。
- 使用DlgSetSub函数,规定控件响应回调程序。
- 显示对话框。模态可用DlgModal,无模态情况下用DlgModeless函数调用,并在消息处理例程中增加DLGISDLGMESSAGE事件。
- 用DlgGet等手段取用控件值。
- 用DlgUninit释放对话框。(必要!)
7 Edit和Static
这些都是最普通的控件,使用时,没有必要附加属性指定,因为得以存取的,无非是字串(对应字串型)。DlgGet与DlgSet是重载函数。如果用逻辑型变量存取,修改的是Enabled属性。IFC Documentation给出了一个内部读写的例子,插在事件处理回调程序中:
character(256) text !按Viktor的习惯还是写character(len=256)好
logical retlog
select case (control_name)
case (IDC_EDIT_CELSIUS)
retlog = DlgGet(dlg, IDC_EDIT_CELSIUS, text) !将Edit内容装入text中
read (text, *, iostat = retint) cel !所谓“内部读取”,其实是数据转化过程
if (retint .eq. 0) then !成功,以免没有读到正确的值
far = (cel - 0.0) * (212.0 - 32) / 100.0 + 32.0 !为什么不化简?
write (text, *) far !内部输出。不用判断了。
retlog = DlgSet(dlg, IDC_EDIT_FAR, trim(adjustl(text))) !左对齐好看
end if
!下略
end select case
Viktor的Fortran手记之四 IFC可视化设计(一)
呵呵……原来在日文版的浏览器下FCKEditor也会变日文版的……很好很强大……
下列内容根据Intel(R) Visual Fortran Compiler Documentation编译。
1 控件类型支持
除ActiveX外,Intel Visual Fortran Compiler(以下简称IFC)支持十五种控件:
- Button
- Check box
- Combo box
- Edit box
- Group box
- List box
- Picture
- Progress bar
- Radio button
- Scroll bar (horizonal)
- Scroll bar (vertical)
- Slider
- Spin control
- Static text
- Tab control
2 控件值的取用: DLGGET()
注意,该东西是个函数,返回逻辑型(.true.对应“成功”,.false.对应“成仁”)。需要什么,应该写成参数。写法是
比如
需要注意的是,读EDIT控件只能读字符串,存到字符串(一般可用txt之类的名字)中。需要数值时再用read读数值:
...
retlog = DlgGet(dlg, IDC_EDIT_TOL, text)
!因为Edit的默认属性就是框里的内容
read (text, *) tol
3 将H文件转化为FD文件
IFC提供DEFTOFD程序。是不是自动的,没试,不敢说。
4 主程序要求
必须
也必须包含.fd文件,如
抄一堆Fortran语录 ZZ
CITED FROM http://en.wikipedia.org/wiki/Fortran#FORTRAN_quotations
FORTRAN quotations
For a programming language with a half-century legacy, FORTRAN not surprisingly has accumulated its share of jokes and folklore.
[edit] From the historical record
- God is Real, unless declared Integer. J. Allan Toogood, FORTRAN programmer.[15]
- FORTRAN, the infantile disorder, by now nearly 20 years old, is hopelessly inadequate for whatever computer application you have in mind today: it is now too clumsy, too risky, and too expensive to use. —Edsger Dijkstra, circa 1970.
- "The sooner the world forgets that FORTRAN ever existed, the better." (imputed to Joseph Weizenbaum)
- "95 percent of the people who programmed in the early years would never have done it without Fortran." — Ken Thompson, circa 2005[16]
- "The primary purpose of the DATA statement is to give names to constants; instead of referring to pi as 3.141592653589793 at every appearance, the variable PI can be given that value with a DATA statement and used instead of the longer form of the constant. This also simplifies modifying the program, should the value of pi change." —Early FORTRAN manual for Xerox Computers[17]
- "Consistently separating words by spaces became a general custom about the tenth century A.D., and lasted until about 1957, when FORTRAN abandoned the practice." —Sun FORTRAN Reference Manual
- "People are very flexible and learn to adjust to strange surroundings — they can become accustomed to read Lisp and Fortran programs, for example." —Art of PROLOG, Leon Sterling and Ehud Shapiro, MIT Press
- "Warning: Go directly to Jail. Do not pass GO. Do not collect $200." — Easter egg in the SDS/Xerox Sigma 7 FORTRAN compiler, when the statement
GO TO JAIL
was encountered. The message is from a Chance card in Monopoly.
- "A computer without COBOL and FORTRAN is like a piece of chocolate cake without ketchup or mustard." — a fortune cookie from the Unix program fortune.
- "The determined Real Programmer can write FORTRAN programs in any language." — Real Programmers Don't Use Pascal, Ed Post, 1982
[edit] References in popular culture
- In the pilot episode of the Futurama series, the robot Bender drinks a bottle of Olde FORTRAN Malt Liquor (alluding to "Olde English" malt liquor)
- Computer folklore has incorrectly attributed the loss of the Mariner 1 space probe to a typographical error in a Fortran program. For example, "Recall the first American space probe to Venus, reportedly lost because Fortran cannot recognize a missing comma in a DO statement…"[18].
- In 1982, 10,000 Maniacs released a song named "Planned Obsolescence" that includes the repeated line — "Science [is] truth for life, in Fortran tongue the answer".
抄一堆Fortran语录 ZZ
CITED FROM http://en.wikipedia.org/wiki/Fortran#FORTRAN_quotations
FORTRAN quotations
For a programming language with a half-century legacy, FORTRAN not surprisingly has accumulated its share of jokes and folklore.
[edit] From the historical record
- God is Real, unless declared Integer. J. Allan Toogood, FORTRAN programmer.[15]
- FORTRAN, the infantile disorder, by now nearly 20 years old, is hopelessly inadequate for whatever computer application you have in mind today: it is now too clumsy, too risky, and too expensive to use. —Edsger Dijkstra, circa 1970.
- "The sooner the world forgets that FORTRAN ever existed, the better." (imputed to Joseph Weizenbaum)
- "95 percent of the people who programmed in the early years would never have done it without Fortran." — Ken Thompson, circa 2005[16]
- "The primary purpose of the DATA statement is to give names to constants; instead of referring to pi as 3.141592653589793 at every appearance, the variable PI can be given that value with a DATA statement and used instead of the longer form of the constant. This also simplifies modifying the program, should the value of pi change." —Early FORTRAN manual for Xerox Computers[17]
- "Consistently separating words by spaces became a general custom about the tenth century A.D., and lasted until about 1957, when FORTRAN abandoned the practice." —Sun FORTRAN Reference Manual
- "People are very flexible and learn to adjust to strange surroundings — they can become accustomed to read Lisp and Fortran programs, for example." —Art of PROLOG, Leon Sterling and Ehud Shapiro, MIT Press
- "Warning: Go directly to Jail. Do not pass GO. Do not collect $200." — Easter egg in the SDS/Xerox Sigma 7 FORTRAN compiler, when the statement
GO TO JAIL
was encountered. The message is from a Chance card in Monopoly.
- "A computer without COBOL and FORTRAN is like a piece of chocolate cake without ketchup or mustard." — a fortune cookie from the Unix program fortune.
- "The determined Real Programmer can write FORTRAN programs in any language." — Real Programmers Don't Use Pascal, Ed Post, 1982
[edit] References in popular culture
- In the pilot episode of the Futurama series, the robot Bender drinks a bottle of Olde FORTRAN Malt Liquor (alluding to "Olde English" malt liquor)
- Computer folklore has incorrectly attributed the loss of the Mariner 1 space probe to a typographical error in a Fortran program. For example, "Recall the first American space probe to Venus, reportedly lost because Fortran cannot recognize a missing comma in a DO statement…"[18].
- In 1982, 10,000 Maniacs released a song named "Planned Obsolescence" that includes the repeated line — "Science [is] truth for life, in Fortran tongue the answer".
Viktor的Fortran手记之三 风格、选择与效果
- 用
以绕过I--N规则。(呵呵,一句名言,"God is Real until claimed as Integer. "嗯……然则min一类习惯的名字就要小心了……)
- 在subroutine和function里,所有的local var.都默认是STORE的。什么意思呢?比如说,
function xxoo(...)
...
integer :: ooxx = 1
...
ooxx = ooxx + 1
...
end function xxoo
只有第一次xxoo(...)的时候,ooxx才是1.以后就会变成2,3,4,5,……如果要避免这个副作用,就得写
...
integer :: ooxx
...
ooxx = 1 !Here to initialize ooxx
...
end function xxoo
C里面可是默认全都毁掉的,不要混了……
- 有的地方说inout要写成in out,goto要写成go to,然则得视编译器而定。
- 注释写感叹号,续行就用&,从第9列写起(兼容Tab和古典FORTRAN格式)。第5列(按一个Tab)写行号的个位。第6列一定要让它空着!除非续行的时候,可以写&。需要兼容性的时候,这是必须的。
- 虽然新Fortran支持长名字,然则还是写6字符以内的短名比较好。小猫见过hankei和takasa之类诡异的名字……
- 循环里严格禁止改循环变量:
do i = 1, n
i = exFlag !Compile error!
...
end do - 最应该记住的,是调用function的时候得事先在块中声明……
- module是个好东西,声明什么的都可以往里装。还可以用它实现运算符重载和多态函数……C++用的是类,这里用的就是TYPE……
Viktor的Fortran手记之三 风格、选择与效果
- 用
以绕过I--N规则。(呵呵,一句名言,"God is Real until claimed as Integer. "嗯……然则min一类习惯的名字就要小心了……)
- 在subroutine和function里,所有的local var.都默认是STORE的。什么意思呢?比如说,
function xxoo(...)
...
integer :: ooxx = 1
...
ooxx = ooxx + 1
...
end function xxoo
只有第一次xxoo(...)的时候,ooxx才是1.以后就会变成2,3,4,5,……如果要避免这个副作用,就得写
...
integer :: ooxx
...
ooxx = 1 !Here to initialize ooxx
...
end function xxoo
C里面可是默认全都毁掉的,不要混了……
- 有的地方说inout要写成in out,goto要写成go to,然则得视编译器而定。
- 注释写感叹号,续行就用&,从第9列写起(兼容Tab和古典FORTRAN格式)。第5列(按一个Tab)写行号的个位。第6列一定要让它空着!除非续行的时候,可以写&。需要兼容性的时候,这是必须的。
- 虽然新Fortran支持长名字,然则还是写6字符以内的短名比较好。小猫见过hankei和takasa之类诡异的名字……
- 循环里严格禁止改循环变量:
do i = 1, n
i = exFlag !Compile error!
...
end do - 最应该记住的,是调用function的时候得事先在块中声明……
- module是个好东西,声明什么的都可以往里装。还可以用它实现运算符重载和多态函数……C++用的是类,这里用的就是TYPE……
Viktor的Fortran手记之二 从FORTRAN到Fortran
(接上回……)
话说搞到了编译器之后,才发现全是F90的编译器。而且在科学界使Fortran的人也不少。据说Fortran在数值算法里也比C快一点。从77改成90吧。大字的FORTRAN也改成了小字的Fortran.
编译器嘛,是IFC和CFC。CFC太老了,95年的,很怀旧,但是在Vista下好歹还能正常工作,除了没办法运行和调试之外。IFC要嵌入到VS里用。Compaq也出过一版VFC,那个要嵌到VS 6里的,偶没装VS 6,当然要报错啦……
续行一律用&。什么第6列用+的办法,恐怕已经土偶了吧……
所谓Vector Subscription和Segment很有意思。然则CFC对Segment的处理不是很好。
do 9, **** 之类的文法已经obsolute了……同样还有character*9之类。
比C省事的地方是数组可以整个处理。还有Implied DO,也是个很好的特性。
其实VB的一些特性和Fortran是相通的。比如块结构的IF。
做C太久了,写if的时候总是忘then.
还有C里{}搞定的东西在Fortran中却要有专门的符号……
搞来了编译器,做了课本上的几个题目。要尝试一下Windows开发。