Fortran Coder

查看: 10836|回复: 9
打印 上一主题 下一主题

[文件读写] simply Fortran批量读取文件

[复制链接]

490

帖子

4

主题

0

精华

大宗师

F 币
3298 元
贡献
1948 点

水王勋章元老勋章热心勋章

楼主
发表于 2017-12-28 22:17:58 | 显示全部楼层
gfortran的在线帮助文档写得很清楚了呀!
https://gcc.gnu.org/onlinedocs/g ... 05fCOMMAND_005fLINE
9.100 EXECUTE_COMMAND_LINE — Execute a shell command
Description:
EXECUTE_COMMAND_LINE runs a shell command, synchronously or asynchronously.

The COMMAND argument is passed to the shell and executed, using the C library’s system call. (The shell is sh on Unix systems, and cmd.exe on Windows.) If WAIT is present and has the value false, the execution of the command is asynchronous if the system supports it; otherwise, the command is executed synchronously.

The three last arguments allow the user to get status information. After synchronous execution, EXITSTAT contains the integer exit code of the command, as returned by system. CMDSTAT is set to zero if the command line was executed (whatever its exit status was). CMDMSG is assigned an error message if an error has occurred.

Note that the system function need not be thread-safe. It is the responsibility of the user to ensure that system is not called concurrently.

Standard:
Fortran 2008 and later

Class:
Subroutine

Syntax:
CALL EXECUTE_COMMAND_LINE(COMMAND [, WAIT, EXITSTAT, CMDSTAT, CMDMSG ])

Arguments:
COMMAND        Shall be a default CHARACTER scalar.
WAIT        (Optional) Shall be a default LOGICAL scalar.
EXITSTAT        (Optional) Shall be an INTEGER of the default kind.
CMDSTAT        (Optional) Shall be an INTEGER of the default kind.
CMDMSG        (Optional) Shall be an CHARACTER scalar of the default kind.
Example:
program test_exec
  integer :: i

  call execute_command_line ("external_prog.exe", exitstat=i)
  print *, "Exit status of external_prog.exe was ", i

  call execute_command_line ("reindex_files.exe", wait=.false.)
  print *, "Now reindexing files in the background"

end program test_exec
Note:
Because this intrinsic is implemented in terms of the system function call, its behavior with respect to signaling is processor dependent. In particular, on POSIX-compliant systems, the SIGINT and SIGQUIT signals will be ignored, and the SIGCHLD will be blocked. As such, if the parent process is terminated, the child process might not be terminated alongside.

See also:
SYSTEM

490

帖子

4

主题

0

精华

大宗师

F 币
3298 元
贡献
1948 点

水王勋章元老勋章热心勋章

沙发
发表于 2017-12-29 10:17:42 | 显示全部楼层
辞觉 发表于 2017-12-28 19:48
谢谢大神的回复,问题已经解决了,还想请教一下读文件的时候判断文件到末尾用的eof函数,在simply fortra ...

传送门
https://gcc.gnu.org/onlinedocs/g ... _005fIOSTAT_005fEND
9.154 IS_IOSTAT_END — Test for end-of-file value
Description:
IS_IOSTAT_END tests whether an variable has the value of the I/O status “end of file”. The function is equivalent to comparing the variable with the IOSTAT_END parameter of the intrinsic module ISO_FORTRAN_ENV.

Standard:
Fortran 2003 and later

Class:
Elemental function

Syntax:
RESULT = IS_IOSTAT_END(I)

Arguments:
I        Shall be of the type INTEGER.
Return value:
Returns a LOGICAL of the default kind, which .TRUE. if I has the value which indicates an end of file condition for IOSTAT= specifiers, and is .FALSE. otherwise.

Example:
PROGRAM iostat
  IMPLICIT NONE
  INTEGER :: stat, i
  OPEN(88, FILE='test.dat')
  READ(88, *, IOSTAT=stat) i
  IF(IS_IOSTAT_END(stat)) STOP 'END OF FILE'
END PROGRAM
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-5-10 18:12

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表