构建 FORTRAN 程序时出错

发布于 2024-12-11 02:35:25 字数 1567 浏览 0 评论 0原文

这是我在 fortran 程序中的一个子例程

subroutine selfile(name)

  ! call Window dialog to select file

  use dfwin

type T_OPENFILENAME
sequence
real lStructSize,hwndOwner,hInstance,lpstrFilter,lpstrCustomFilter,nMaxCustFilter,nFilterIndex,lpstrFile,nMaxFile,nMaxFileTitle
real lpstrInitialDir,lpstrTitle,Flags,lpstrDefExt,lpfnHook,lpTemplateName
 end type T_OPENFILENAME





  type(T_OPENFILENAME):: ofn
  character*100 filter_spec
  character*512 file_spec
  integer status
  character*(*)name

  ! set filter specification and string to return the file specification.

  file_spec=''C
  filter_spec = 'Data Files'C//'*.dat'C// &
                'Text Files'C//'*.txt'C// &
                'All files'C//'*'C//''C
  ofn%lStructSize = SIZEOF(ofn)
  ofn%hwndOwner = NULL
  ofn%hInstance = NULL
  ofn%lpstrFilter = loc(filter_spec)
  ofn%lpstrCustomFilter = NULL
  ofn%nMaxCustFilter = 0
  ofn%nFilterIndex = 1
  ofn%lpstrFile = loc(file_spec)
  ofn%nMaxFile = sizeof(file_spec)
  ofn%nMaxFileTitle = 0
  ofn%lpstrInitialDir = NULL
  ofn%lpstrTitle = loc('D Y N S I M'C)
  ofn%Flags = OFN_PATHMUSTEXIST
  ofn%lpstrDefExt = loc('dat'C)
  ofn%lpfnHook = NULL
  ofn%lpTemplateName = NULL
  end 
  ! Call GetOpenFileName and check status

  status = GetOpenFileName(ofn)
  if (status == 0) then
     name=''
  else
     name=file_spec
  endif
end subroutine selfile

,但我收到了类似的错误。

Illegal use of constant "D Y N S I M"
Illegal number or type of arguments to loc 
Illegal use of constant "dat"
Unmatched ENDSUBROUTINE statement

this is my one subroutine in fortran program

subroutine selfile(name)

  ! call Window dialog to select file

  use dfwin

type T_OPENFILENAME
sequence
real lStructSize,hwndOwner,hInstance,lpstrFilter,lpstrCustomFilter,nMaxCustFilter,nFilterIndex,lpstrFile,nMaxFile,nMaxFileTitle
real lpstrInitialDir,lpstrTitle,Flags,lpstrDefExt,lpfnHook,lpTemplateName
 end type T_OPENFILENAME





  type(T_OPENFILENAME):: ofn
  character*100 filter_spec
  character*512 file_spec
  integer status
  character*(*)name

  ! set filter specification and string to return the file specification.

  file_spec=''C
  filter_spec = 'Data Files'C//'*.dat'C// &
                'Text Files'C//'*.txt'C// &
                'All files'C//'*'C//''C
  ofn%lStructSize = SIZEOF(ofn)
  ofn%hwndOwner = NULL
  ofn%hInstance = NULL
  ofn%lpstrFilter = loc(filter_spec)
  ofn%lpstrCustomFilter = NULL
  ofn%nMaxCustFilter = 0
  ofn%nFilterIndex = 1
  ofn%lpstrFile = loc(file_spec)
  ofn%nMaxFile = sizeof(file_spec)
  ofn%nMaxFileTitle = 0
  ofn%lpstrInitialDir = NULL
  ofn%lpstrTitle = loc('D Y N S I M'C)
  ofn%Flags = OFN_PATHMUSTEXIST
  ofn%lpstrDefExt = loc('dat'C)
  ofn%lpfnHook = NULL
  ofn%lpTemplateName = NULL
  end 
  ! Call GetOpenFileName and check status

  status = GetOpenFileName(ofn)
  if (status == 0) then
     name=''
  else
     name=file_spec
  endif
end subroutine selfile

but i am getting error like..

Illegal use of constant "D Y N S I M"
Illegal number or type of arguments to loc 
Illegal use of constant "dat"
Unmatched ENDSUBROUTINE statement

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

洋洋洒洒 2024-12-18 02:35:25

loc() 函数是非标准的,但简短的搜索告诉我它的参数不能是文字常量。

The loc() function is nonstandard, but a short search tells me that its argument can not be a literal constant.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文