-
Notifications
You must be signed in to change notification settings - Fork 34
Testing Program
As a practical example of FLAP usage a testing program named test_basic is provided. You can compile with Fortran compiler supporting modern standards (2003+). Note that the dependency hierarchy of modules USE statement must be respected in order to successfully compile the program. If you are tired by frustrating usage of makefiles & co. you can try FoBiS.py for building the program. A fobos file is provided with FLAP, see the Compiling instructions.
After the testing program has been compiled, try it without arguments, i.e. from FLAP root directory type
./tests/test_basic
You should read something like
test_basic: error: named option "--string" is required!
Usage: test_basic [value] --string value [--integer_ex value] [--integer value] [--real value] [--boolean] [--boolean_val value] [--integer_list value#1 value#2 value#3] [--env value] [--man_file value] [--varying_listR8P [value#1 value#2 value#3...]] [--varying_listR4P [value#1 value#2 value#3...]] [--varying_listI8P [value#1 value#2 value#3...]] [--varying_listI4P [value#1 value#2 value#3...]] [--varying_listI2P [value#1 value#2 value#3...]] [--varying_listI1P value#1 [value#2 value#3...]] [--varying_listBool [value#1 value#2 value#3...]] [--varying_listChar [value#1 value#2 value#3...]] [--help] [--version]
Toy program for testing FLAP
Required switches:
--string value, -s value
String input
Optional switches:
value
1-th argument
default value 1.0
Positional real input
--integer_ex value, -ie value
default value -1
mutually exclude "--integer"
Exclusive integer input
--integer value, -i value, value in: (1,3,5)
default value 1
mutually exclude "--integer_ex"
Integer input with fixed range
--real value, -r value
default value 1.0
Real input
--boolean, -b
default value .false.
Boolean input
--boolean_val value, -bv value
default value .true.
Valued boolean input
--integer_list value#1 value#2 value#3, -il value#1 value#2 value#3
default value 1 8 32
Integer list input
--env value, -e value
environment variable name "FLAP_NUM_INT"
default value -1
Environment input
--man_file value
default value test_basic.1
Save manual into man_file
--varying_listR8P [value#1 value#2...], -vlR8P [value#1 value#2...]
default value 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0
Varying size real R8P list input
--varying_listR4P [value#1 value#2...], -vlR4P [value#1 value#2...]
default value 1.0 2.0 3.0 4.0
Varying size real R4P list input
--varying_listI8P [value#1 value#2...], -vlI8P [value#1 value#2...]
default value 1 2 3 4 5 6 7 8
Varying size integer I8P list input
--varying_listI4P [value#1 value#2...], -vlI4P [value#1 value#2...]
default value 1 2 3 4
Varying size integer I4P list input
--varying_listI2P [value#1 value#2...], -vlI2P [value#1 value#2...]
default value 1 2
Varying size integer I2P list input
--varying_listI1P value#1 [value#2...], -vlI1P value#1 [value#2...]
default value 1
Varying size integer I1P list input
--varying_listBool [value#1 value#2...], -vlBool [value#1 value#2...]
default value T F T T F
Varying size boolean list input
--varying_listChar [value#1 value#2...], -vlChar [value#1 value#2...]
default value foo bar baz
Varying size character list input
--help, -h
Print this help message
--version, -v
Print version
Notice that an error is echoed: the signature of the program CLI require at least one argument! As a matter of fact, the --string value
argument is not enclosed into brackets thus means that it a required argument. Now run the program with at least the --string
argument
./tests/test_basic --string 'Hi all!' -i 3
You should read something like
test_basic has been called with the following arguments values:
String input = Hi all!
Real input = +0.100000000000000E+001
Integer input = +3
Exclusive integer input = -1
Environment integer input = -1
Boolean input = F
Valued boolean input = T
Positional real input = +0.100000000000000E+001
Integer list inputs:
Input(1) = +1
Input(2) = +140734962074288
Input(3) = +140373011605160
Varying size real R8P list inputs:
Input(1) = +0.100000000000000E+001
Input(2) = +0.200000000000000E+001
Input(3) = +0.300000000000000E+001
Input(4) = +0.400000000000000E+001
Input(5) = +0.500000000000000E+001
Input(6) = +0.600000000000000E+001
Input(7) = +0.700000000000000E+001
Input(8) = +0.800000000000000E+001
Varying size real R4P list inputs:
Input(1) = +0.100000E+01
Input(2) = +0.200000E+01
Input(3) = +0.300000E+01
Input(4) = +0.400000E+01
Varying size integer I8P list inputs:
Input(1) = +1
Input(2) = +2
Input(3) = +3
Input(4) = +4
Input(5) = +5
Input(6) = +6
Input(7) = +7
Input(8) = +8
Varying size integer I4P list inputs:
Input(1) = +1
Input(2) = +2
Input(3) = +3
Input(4) = +4
Varying size integer I2P list inputs:
Input(1) = +1
Input(2) = +2
Varying size integer I1P list inputs:
Input(1) = +1
Varying size boolean list inputs:
Input(1) = T
Input(2) = F
Input(3) = T
Input(4) = T
Input(5) = F
Varying size character list inputs:
Input(1) = foo
Input(2) = bar
Input(3) = baz
Now let us test some interesting features. What happen if we pass a wrong value for the --integer
argument?
./tests/test_basic --string 'I am wrong integer!' -i 2
You should read something like
test_basic: error: value of named option "--integer" must be chosen in: (1,3,5) but "+2" has been passed!
Nice!
Home | About | Getting Started Guide | Usage | Copyright © 2016 szaghi