Photran的用法(转载自eclipse官网)

Getting Started with Managed Make

If your system has the GNU gfortran compiler installed, try this.

  1. File | New | Fortran Project
  2. Call it whatever
  3. Choose the Executable (Gnu Fortran) from the project type list   注:对于Ubuntu 8.10系统已经不再提供G77支持了,因此,编译器一定要选gfortran,即GNU Fortran
  4. Choose GCC Toolchain from the toolchain list (you may need to uncheck the "Show project types..." check box at the bottom of the window)
  5. Click Next
  6. Click on Advanced Settings
  7. Expand C/C++ Build in the list on the left, and click on Settings
  8. 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.
  9. Click on the Error Parsers tab. Check the error parser(s) for the Fortran compiler(s) you will use.
  10. Click OK
  11. Click Finish
  12. Click File | New | Source File
  13. Call it hello.f90; click Finish
  14. Type the standard "Hello, World" program, and click File | Save.

    program hello
        print *, "Hello World"
        stop
    end program hello
  15. Open the Console view, and make sure "make" ran OK and compiled your program
  16. In the Fortran Projects view, expand the Binaries entry, and click on your executable (e.g., "whatever - [x86le]") 这个设计很好很强大到让人摸不着头脑,因为用M$的V$已经用惯了。。。
  17. Run | Run As | Run Local C/C++ Application (yeah, I know, it should say "Fortran Application", but it doesn't)
  18. Choose GDB Debugger (Cygwin GDB Debugger if you're under Windows)
  19. 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).

  1. File | New | Fortran Project
  2. Call it whatever
  3. Choose Makefile Project from the project type list (it has a folder icon; do not expand it)
  4. Choose "-- Other Toolchain --" from the toolchain list <--li>Click Next
  5. Click on Advanced Settings
  6. Expand C/C++ Build in the list on the left, and click on Settings
  7. 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.
  8. Click on the Error Parsers tab. Check the error parser(s) for the Fortran compiler(s) you will use.
  9. Click OK
  10. Click Finish
  11. File | New | File
  12. Call it Makefile
  13. Click Finish
  14. 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:

  15. File | New | Source File
  16. Call it hello.f90
  17. Click Finish
  18. Type the standard "Hello, World" program.

    program hello
        print *, "Hello World"
        stop
    end program hello
  19. Project | Clean; then click OK
  20. Open the Console view, and make sure "make" ran OK and compiled your program
  21. In the Fortran Projects view, expand the Binaries entry, and click on your executable (e.g., "whatever - [x86le]")
  22. Run | Run As | Run Local C/C++ Application (yeah, I know, it should say "Fortran Application", but it doesn't)
  23. Choose GDB Debugger (Cygwin GDB Debugger if you're under Windows)
  24. 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 连接变量和对话框

对话框必须连接到变量上。变量的类型是

type(dialog)

并且定义在IFLOGM.F90模块中。(CFC是定义在DIALOGM模块中)具体的连接方式如下:

use iflogm
include 'resource.fd' !默认的资源文件头
type(dialog) dlg
logical retlog
retlog = DlgInit(IDD_WINDOW, dlg)

6 使用对话框的一般过程

  1. 建立TYPE(dialog)型变量,并调用DlgInitDlgInitWithResourceHandle函数连接对话框。
  2. DlgSet等手段,赋予控件初始值。
  3. 使用DlgSetSub函数,规定控件响应回调程序。
  4. 显示对话框。模态可用DlgModal,无模态情况下用DlgModeless函数调用,并在消息处理例程中增加DLGISDLGMESSAGE事件。
  5. DlgGet等手段取用控件值。
  6. 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)支持十五种控件:

  1. Button
  2. Check box
  3. Combo box
  4. Edit box
  5. Group box
  6. List box
  7. Picture
  8. Progress bar
  9. Radio button
  10. Scroll bar (horizonal)
  11. Scroll bar (vertical)
  12. Slider
  13. Spin control
  14. Static text
  15. Tab control

2 控件值的取用: DLGGET()

注意,该东西是个函数,返回逻辑型(.true.对应“成功”,.false.对应“成仁”)。需要什么,应该写成参数。写法是

逻辑值 = DlgGet(对话框变量, 控件ID, 存放值的变量, 需要的值的名称)

比如

retlog = DlgGet(dlg, IDC_SCROLLBAR_TEMPERATURE, slidepos, DLG_POSITION)

需要注意的是,读EDIT控件只能读字符串,存到字符串(一般可用txt之类的名字)中。需要数值时再用read读数值:

double precision :: tol

...

retlog = DlgGet(dlg, IDC_EDIT_TOL, text)
!因为Edit的默认属性就是框里的内容
read (text, *) tol

3 将H文件转化为FD文件

IFC提供DEFTOFD程序。是不是自动的,没试,不敢说。

4 主程序要求

必须

use iflogm

也必须包含.fd文件,如

include 'resource.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.

 

[edit] References in popular culture

  • 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.

 

[edit] References in popular culture

  • 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手记之三 风格、选择与效果

 

implicit none

 

 

以绕过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,……如果要避免这个副作用,就得写

 

function xxoo(...)
    ...
    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手记之三 风格、选择与效果

 

implicit none

 

 

以绕过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,……如果要避免这个副作用,就得写

 

function xxoo(...)
    ...
    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开发。