File: utils.F90

package info (click to toggle)
pnetcdf 1.14.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,812 kB
  • sloc: ansic: 85,298; f90: 10,707; fortran: 9,283; cpp: 8,864; makefile: 3,084; perl: 2,833; sh: 2,538; yacc: 1,227; lex: 216
file content (57 lines) | stat: -rw-r--r-- 1,647 bytes parent folder | download | duplicates (5)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
!
!  Copyright (C) 2015, Northwestern University and Argonne National Laboratory
!  See COPYRIGHT notice in top-level directory.
!
!     This is part of the PnetCDF package.
!
!     $Id$

    ! This function gets the executable name and output file name from the
    ! command line.
    integer function get_args(max_argc, cmd, filename, verbose, len)
#ifdef NAGFOR
        USE F90_UNIX_ENV, only : iargc, getarg
        implicit none
#else
        implicit none
        integer iargc
#endif
        integer max_argc, len
        character(len=*) cmd, filename
        logical verbose

        ! local variables
        integer argc
        character(len=16) quiet_mode, str

        get_args = 1
        call getarg(0, cmd)
        argc = IARGC()

        ! command-line arguments are optional
        if (argc .EQ. 0) return

        if (argc .GT. max_argc) then
            if (max_argc .EQ. 3) &
                print*,'Usage: ',trim(cmd),' [-q] [filename] [len]'
            if (max_argc .EQ. 2) &
                print*,'Usage: ',trim(cmd),' [-q] [filename]'
            get_args = 0
            return
        endif
        call getarg(1, quiet_mode)
        if (quiet_mode(1:2) .EQ. '-q') then
            verbose = .FALSE.
            if (argc .GE. 2) call getarg(2, filename)
            if (argc .EQ. 3) then
                call getarg(3, str)
                read (str,'(I10)') len
            endif
        else
            if (argc .GE. 1) call getarg(1, filename)
            if (argc .EQ. 2) then
                call getarg(2, str)
                read (str,'(I10)') len
            endif
        endif
    end function get_args