1212module init_io_demo_mod
1313
1414 use sci_assign_field_random_range_alg_mod, only: assign_field_random_range
15- use constants_mod, only : i_def, r_def
15+ use constants_mod, only : i_def, r_def, l_def
1616 use driver_modeldb_mod, only : modeldb_type
1717 use field_collection_mod, only : field_collection_type
1818 use field_mod, only : field_type
1919 use field_parent_mod, only : write_interface
20- use finite_element_config_mod, only : element_order_h, &
21- element_order_v
2220 use function_space_collection_mod, only : function_space_collection
21+ use function_space_mod, only : function_space_type
2322 use fs_continuity_mod, only : Wtheta
2423 use key_value_mod, only : abstract_value_type
2524 use log_mod, only : log_event, &
2625 LOG_LEVEL_TRACE, &
2726 LOG_LEVEL_ERROR
2827 use mesh_mod, only : mesh_type
29- use io_config_mod, only : write_diag, &
30- use_xios_io
3128 use lfric_xios_write_mod, only : write_field_generic
3229 use io_demo_constants_mod, only : create_io_demo_constants
3330 use random_number_generator_mod, only : random_number_generator_type
@@ -37,20 +34,21 @@ module init_io_demo_mod
3734 contains
3835
3936 ! > @details Initialises everything needed to run the io_demo miniapp
37+ ! > @param[in,out] modeldb The structure that holds model state
4038 ! > @param[in] mesh Representation of the mesh the code will run on
4139 ! > @param[in,out] chi The co-ordinate field
4240 ! > @param[in,out] panel_id 2d field giving the id for cubed sphere panels
43- ! > @param[in,out] modeldb The structure that holds model state
44- subroutine init_io_demo ( mesh , chi , panel_id , modeldb )
41+ subroutine init_io_demo (modeldb , mesh , chi , panel_id )
4542
4643 implicit none
4744
48- type (mesh_type), intent (in ), pointer :: mesh
45+ type (modeldb_type), intent (inout ) :: modeldb
46+ type (mesh_type), intent (in ), pointer :: mesh
4947
5048 ! Coordinate field
51- type (field_type), intent (inout ) :: chi(:)
52- type (field_type), intent (inout ) :: panel_id
53- type (modeldb_type), intent ( inout ) :: modeldb
49+ type (field_type), intent (inout ) :: chi(:)
50+ type (field_type), intent (inout ) :: panel_id
51+
5452 class(abstract_value_type), pointer :: abstract_value
5553 type (random_number_generator_type), pointer :: rng
5654 type (field_type) :: diffusion_field
@@ -59,8 +57,20 @@ subroutine init_io_demo( mesh, chi, panel_id, modeldb)
5957 real (kind= r_def), parameter :: min_val = 280.0_r_def
6058 real (kind= r_def), parameter :: max_val = 330.0_r_def
6159
60+ type (function_space_type), pointer :: fs
61+
62+ integer (i_def) :: order_h, order_v
63+ logical (l_def) :: write_diag
64+ logical (l_def) :: use_xios_io
65+
6266 call log_event( ' io_demo: Initialising miniapp ...' , LOG_LEVEL_TRACE )
6367
68+ order_h = modeldb% config% finite_element% element_order_h()
69+ order_v = modeldb% config% finite_element% element_order_v()
70+
71+ write_diag = modeldb% config% io% write_diag()
72+ use_xios_io = modeldb% config% io% use_xios_io()
73+
6474 ! seed the random number generator
6575 call modeldb% values% get_value(" rng" , abstract_value)
6676 select type (abstract_value)
@@ -76,10 +86,8 @@ subroutine init_io_demo( mesh, chi, panel_id, modeldb)
7686
7787 ! Create prognostic fields
7888 ! Creates a field in the Wtheta function space
79- call diffusion_field% initialise( vector_space = &
80- function_space_collection% get_fs(mesh, element_order_h, &
81- element_order_v, Wtheta), &
82- name= " diffusion_field" )
89+ fs = > function_space_collection% get_fs(mesh, order_h, order_v, Wtheta)
90+ call diffusion_field% initialise(fs, name= " diffusion_field" )
8391
8492 ! Set up field with an IO behaviour (XIOS only at present)
8593 if (write_diag .and. use_xios_io) then
@@ -98,7 +106,7 @@ subroutine init_io_demo( mesh, chi, panel_id, modeldb)
98106 ! Create io_demo runtime constants. This creates various things
99107 ! needed by the fem algorithms such as mass matrix operators, mass
100108 ! matrix diagonal fields and the geopotential field
101- call create_io_demo_constants(mesh, chi, panel_id)
109+ call create_io_demo_constants(modeldb, mesh, chi, panel_id)
102110
103111 call log_event( ' io_demo: Miniapp initialised' , LOG_LEVEL_TRACE )
104112
0 commit comments