afivo-streamer 1.1
1D/2D/3D streamer simulations with AMR
Loading...
Searching...
No Matches
example_2.f90
Go to the documentation of this file.
2 use m_config
3
4 integer, parameter :: dp = kind(0.0d0)
5 type(cfg_t) :: my_cfg
6
7 ! Some dummy variables
8 integer :: my_int
9
10 print *, "Testing m_config.f90 (test 2)"
11 print *, "This program reads its arguments as configuration files"
12 print *, "Try running it like this:"
13 print *, "./example_2"
14 print *, "./example_2 example_2_input.cfg -array%int='13 37'"
15 print *, ""
16
17 call cfg_update_from_arguments(my_cfg)
18
19 call cfg_add(my_cfg, "scalar%real", 1.0_dp, "my_real")
20 call cfg_add(my_cfg, "scalar%logic", .true., "my_logic")
21
22 print *, "Using CFG_add_get you can immediately get the value"
23 print *, "that previously has been read in, for example:"
24 my_int = 5
25 call cfg_add_get(my_cfg, "scalar%int", my_int, "my_int")
26 print *, "scalar%int: ", my_int
27 print *, ""
28
29 call cfg_add(my_cfg, "scalar%string", "a string", "my_string")
30 call cfg_add(my_cfg, "array%real", [1.0_dp, 2.0_dp], "my_reals", dynamic_size=.true.)
31 call cfg_add(my_cfg, "array%logic", [.true., .true.], "my_logics", dynamic_size=.true.)
32 call cfg_add(my_cfg, "array%int", [1, 2], "my_ints", dynamic_size=.true.)
33 call cfg_add(my_cfg, "array%string", ["A", "B"], "my_strings", dynamic_size=.true.)
34
35 call cfg_write(my_cfg, "stdout", custom_first=.true.) ! Write to screen
36 call cfg_write(my_cfg, "example_2_output.cfg") ! Write to file
37 call cfg_write_markdown(my_cfg, "example_2_output.md") ! Write markdown file
38
39end program test_m_config2
program test_m_config2
Definition example_2.f90:1
Interface to get variables from the configuration.
Definition m_config.f90:102
Interface to add variables to the configuration.
Definition m_config.f90:86
Module that allows working with a configuration file.
Definition m_config.f90:5
subroutine, public cfg_write(cfg_in, filename, hide_unused, custom_first)
This routine writes the current configuration to a file with descriptions.
Definition m_config.f90:480
subroutine, public cfg_write_markdown(cfg_in, filename, hide_unused)
This routine writes the current configuration to a markdown file.
Definition m_config.f90:615
subroutine, public cfg_update_from_arguments(cfg, ignore_unknown)
Read command line arguments. Both files and variables can be specified, for example as: ....
Definition m_config.f90:146
The configuration that contains all the variables.
Definition m_config.f90:79