The length argument may be combined with a deferred length character variable, such as in the following example. If there is some other difficulty retrieving the argument the value of stat will be some positive number (and arg will consist entirely of blanks). The value of stat will be -1 if the first argument exists and has length greater than 5. For example, with character(5) argĬall get_command_argument(number=1, value=arg, status=stat) Use of get_command_argument may be extended beyond the above example with the length and status arguments. As these are non-standard, the corresponding compiler documentation should be consulted. Many compilers also offer non-standard intrinsics (such as getarg) to access command line arguments. If the value is 0 then the command name is supplied (if supported). Launched programs will appear in a separate console window. After saving and building an appropriate project, the resulting executable can be launched via the Launch entry in the Build menu or, alternatively, from the Build submenu of the project pane’s popup menu. The number argument in get_command_argument usefully ranges between 0 and the result of command_argument_count. Projects that result in executable files can be launched from within the Simply Fortran environment. READ(num1char,*)num1 !then, convert them to REALs WRITE(*,*)'ERROR, TWO COMMAND-LINE ARGUMENTS REQUIRED, STOPPING'ĬALL GET_COMMAND_ARGUMENT(1,num1char) !first, read in the two values !First, make sure the right number of inputs have been provided #Simply fortran write to console codeAs an example, this simple code sums the two numbers provided at the command line: PROGRAM cmdlnsum The command_argument_count intrinsic provides a way to know the number of arguments provided at the command line.Īll command-line arguments are read in as strings, so an internal type conversion must be done for numeric data. These reserved words cannot be used as identifiers or names.Where command line arguments are supported they can be read in via the get_command_argument intrinsic (introduced in the Fortran 2003 standard). Keywords are special words, reserved for the language. It must be composed of alphanumeric characters (all the letters of the alphabet, and the digits 0 to 9) and underscores (_).įirst character of a name must be a letter. A name in Fortran must follow the following rules − IdentifierĪn identifier is a name used to identify a variable, procedure, or any other user-defined item. A token could be a keyword, an identifier, a constant, a string literal, or a symbol. Tokens are made of characters in the basic character set.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |