前程's profilezqc的共享空间PhotosBlogLists Tools Help

Blog


    April 22

    找到了需要的函数

    一直想知道fortran怎么调用外部可执行文件,今天终于通过一个人的网页的一篇文章中得到了一些信息,后来找了fortran的help:

    SYSTEM

    Portability Function: Sends a command to the shell as if it had been typed at the command line.

    Module: USE DFPORT

    Syntax

    result = SYSTEM (string)

    string
    (Input) Character*(*). Operating system command.

    Results:

    The result is of type INTEGER(4). The result is the exit status of the shell command. If -1, use IERRNO to retrieve the error. Errors can be one of the following:

    • E2BIG: The argument list is too long.
    • ENOENT: The command interpreter cannot be found.
    • ENOEXEC: The command interpreter file has an invalid format and is not executable.
    • ENOMEM: Not enough system resources are available to execute the command.

    On WNT systems, the calling process waits until the command terminates. On W9* systems, the calling process does not currently wait in all cases; however, this may change in future implementations. To insure compatibility and consistent behavior, an image can be invoked directly by using the Win32 API CreateProcess( ) in your Fortran code.

    Commands run with the SYSTEM routine are run in a separate shell. Defaults set with the SYSTEM function, such as current working directory or environment variables, do not affect the environment the calling program runs in.

    The command line character limit for the SYSTEM function is the same limit that your operating system command interpreter accepts.

    Compatibility

    CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB

    See Also: SYSTEMQQ

    Example

       USE DFPORT
       INTEGER(4) I, errnum
       I = SYSTEM("dir > file.lst")
       If (I .eq. -1) then
         errnum = ierrno( )
         print *, 'Error ', errnum
       end if
       END
    还有在fortran内部给外部文件改名字:
    integer(4) function RENAME( from , to )
    改變檔案名稱,改名成功時傳回0。
    character*(*) from 原始檔名
    character*(*) to 新檔名
    程式執行時,可以經由函式SYSTEM 再去呼叫另外一個程式來執行。

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://zqc2007.spaces.live.com/blog/cns!8658008FAA391D7!109.trak
    Weblogs that reference this entry
    • None