File: demo16.f90

package info (click to toggle)
fortran-cli2 3.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 25,856 kB
  • sloc: f90: 6,172; javascript: 3,423; makefile: 188; sh: 25
file content (31 lines) | stat: -rwxr-xr-x 1,281 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
program demo16
!> @(#) unnamed to numbers
!! The default for inums, rnums, ... is to convert all unnamed argument values in "unnamed"
use, intrinsic :: iso_fortran_env, only : stderr=>ERROR_UNIT, stdin=>INPUT_UNIT, stdout=>OUTPUT_UNIT
use M_CLI2,  only : set_args, sget, igets, rgets, dgets
implicit none
character(len=*),parameter :: all='(1x,*(g0,1x))'
   call set_args('-type test')
   select case(sget('type'))
   case('i','int','integer');  print all, igets()
   case('r','real');           print all, rgets()
   case('d','double');         print all, dgets()
   case('test')
      print *,'demo16: convert all arguments to numerics'
      ! positive BOZ whole number values are allowed
      ! e-format is allowed, ints(3f) truncates
      call runit('-type i 10 b10 o10 z10 14.1 14.5 14.999 45.67e3')
      call runit('-type r 10 b10 o10 z10 14.1 14.5 14.999 45.67e3')
      call runit('-type d 10 b10 o10 z10 14.1 14.5 14.999 45.67e3')
   case default
      print all,'unknown type'
   end select
contains
subroutine runit(string)
character(len=*),intent(in) :: string
character(len=4096) :: cmd
   call get_command_argument(0,cmd)
   write(stdout,*)'RUN:',trim(cmd)//' '//string
   call execute_command_line(trim(cmd)//' '//string)
end subroutine runit
end program demo16