diff --git a/applications/coupled/source/coupled.f90 b/applications/coupled/source/coupled.f90 index b1e4f280a..a74455853 100644 --- a/applications/coupled/source/coupled.f90 +++ b/applications/coupled/source/coupled.f90 @@ -41,27 +41,23 @@ program coupled call parse_command_line( filename, component_name=cpl_component_name ) call modeldb%values%initialise( 'values', 5 ) - - call modeldb%configuration%initialise( program_name, table_len=10 ) call modeldb%config%initialise( program_name ) - - write(log_scratch_space,'(A)') & - 'Application built with '// trim(precision_real) // & - '-bit real numbers.' - call log_event( log_scratch_space, log_level_trace ) + call modeldb%values%add_key_value('cpl_name', cpl_component_name) modeldb%mpi => global_mpi - call modeldb%values%add_key_value('cpl_name', cpl_component_name) call init_comm( "coupled", modeldb ) - - call init_config( filename, & - coupled_required_namelists, & - configuration=modeldb%configuration, & + call init_config( filename, coupled_required_namelists, & config=modeldb%config ) call init_logger( modeldb%mpi%get_comm(), & program_name//"_"//cpl_component_name ) + + write(log_scratch_space,'(A)') & + 'Application built with '// trim(precision_real) // & + '-bit real numbers.' + call log_event( log_scratch_space, log_level_trace ) + call init_collections() call init_time( modeldb ) deallocate( filename ) diff --git a/applications/coupled/source/driver/coupled_driver_mod.f90 b/applications/coupled/source/driver/coupled_driver_mod.f90 index 2f525142c..550e405f1 100644 --- a/applications/coupled/source/driver/coupled_driver_mod.f90 +++ b/applications/coupled/source/driver/coupled_driver_mod.f90 @@ -120,7 +120,7 @@ subroutine initialise( program_name, modeldb, calendar ) ! Create the required meshes stencil_depth = 1 apply_partition_check = .false. - call init_mesh( modeldb%configuration, & + call init_mesh( modeldb%config, & modeldb%mpi%get_comm_rank(), & modeldb%mpi%get_comm_size(), & base_mesh_names, extrusion, & diff --git a/applications/io_demo/source/algorithm/io_demo_constants_mod.x90 b/applications/io_demo/source/algorithm/io_demo_constants_mod.x90 index 52d3d640b..71fd3cb46 100644 --- a/applications/io_demo/source/algorithm/io_demo_constants_mod.x90 +++ b/applications/io_demo/source/algorithm/io_demo_constants_mod.x90 @@ -17,7 +17,6 @@ module io_demo_constants_mod ! Infrastructure use constants_mod, only: i_def, r_def, l_def, & str_def, str_short - use driver_modeldb_mod, only: modeldb_type use field_collection_mod, only: field_collection_type use field_mod, only: field_type use fs_continuity_mod, only: W2 @@ -49,16 +48,14 @@ module io_demo_constants_mod contains !> @brief Subroutine to create the finite element constants - !> @param[in] modeldb Application state object !> @param[in] mesh The prime model mesh !> @param[in] chi Coordinate fields !> @param[in] panel_id Panel_id field - subroutine create_io_demo_constants(modeldb, mesh, chi, panel_id) + subroutine create_io_demo_constants(mesh, chi, panel_id) implicit none ! Arguments - type(modeldb_type), intent(in) :: modeldb type(mesh_type), pointer, intent(in) :: mesh type(field_type), target, intent(in) :: chi(:) type(field_type), target, intent(in) :: panel_id diff --git a/applications/io_demo/source/driver/init_io_demo_mod.F90 b/applications/io_demo/source/driver/init_io_demo_mod.F90 index 0be601260..9cafc6cc1 100644 --- a/applications/io_demo/source/driver/init_io_demo_mod.F90 +++ b/applications/io_demo/source/driver/init_io_demo_mod.F90 @@ -106,7 +106,7 @@ subroutine init_io_demo(modeldb, mesh, chi, panel_id) ! Create io_demo runtime constants. This creates various things ! needed by the fem algorithms such as mass matrix operators, mass ! matrix diagonal fields and the geopotential field - call create_io_demo_constants(modeldb, mesh, chi, panel_id) + call create_io_demo_constants(mesh, chi, panel_id) call log_event( 'io_demo: Miniapp initialised', LOG_LEVEL_TRACE ) diff --git a/applications/io_demo/source/driver/io_demo_driver_mod.f90 b/applications/io_demo/source/driver/io_demo_driver_mod.f90 index 73fd63c24..2b59171da 100644 --- a/applications/io_demo/source/driver/io_demo_driver_mod.f90 +++ b/applications/io_demo/source/driver/io_demo_driver_mod.f90 @@ -155,7 +155,7 @@ subroutine initialise(program_name, modeldb) ! --------------------------------------------------------- stencil_depth = 1 check_partitions = .false. - call init_mesh( modeldb%configuration, & + call init_mesh( modeldb%config, & modeldb%mpi%get_comm_rank(), & modeldb%mpi%get_comm_size(), & base_mesh_names, extrusion, & diff --git a/applications/io_demo/source/io_demo.f90 b/applications/io_demo/source/io_demo.f90 index 7f5d7d5db..601702c87 100644 --- a/applications/io_demo/source/io_demo.f90 +++ b/applications/io_demo/source/io_demo.f90 @@ -10,7 +10,8 @@ program io_demo use cli_mod, only : parse_command_line use driver_collections_mod, only : init_collections, final_collections - use constants_mod, only : precision_real + use constants_mod, only : precision_real,l_def, & + str_max_filename use driver_comm_mod, only : init_comm, final_comm use driver_config_mod, only : init_config, final_config use driver_log_mod, only : init_logger, final_logger @@ -25,46 +26,45 @@ program io_demo use io_demo_mod, only: io_demo_required_namelists use io_demo_driver_mod, only: initialise, step, finalise use timing_mod, only: init_timing, final_timing - use io_config_mod, only: timer_output_path - use namelist_mod, only: namelist_type implicit none ! The technical and scientific state - type(modeldb_type) :: modeldb - character(*), parameter :: program_name = "io_demo" - character(:), allocatable :: filename - type(namelist_type), pointer :: io_nml - logical :: lsubroutine_timers - integer, parameter :: default_seed = 123456789 + type(modeldb_type) :: modeldb + character(*), parameter :: program_name = "io_demo" + character(:), allocatable :: filename + integer, parameter :: default_seed = 123456789 + type(random_number_generator_type), pointer :: rng + character(str_max_filename) :: timer_output_path + logical(l_def) :: subroutine_timers + call parse_command_line( filename ) - call modeldb%values%initialise() - call modeldb%configuration%initialise( program_name, table_len=10 ) call modeldb%config%initialise(program_name) + call modeldb%values%initialise() + + modeldb%mpi => global_mpi + + call init_comm(program_name, modeldb) + call init_config(filename, io_demo_required_namelists, & + config=modeldb%config) + + call init_logger( modeldb%mpi%get_comm(), program_name ) write(log_scratch_space,& '("Application built with ", A, "-bit real numbers")') & trim(precision_real) call log_event( log_scratch_space, log_level_trace ) - modeldb%mpi => global_mpi - call init_comm(program_name, modeldb) - call init_config(filename, & - io_demo_required_namelists, & - configuration=modeldb%configuration, & - config=modeldb%config) + subroutine_timers = modeldb%config%io%subroutine_timers() + timer_output_path = modeldb%config%io%timer_output_path() + call init_timing( modeldb%mpi%get_comm(), subroutine_timers, & + program_name, timer_output_path ) - deallocate( filename ) - - call init_logger( modeldb%mpi%get_comm(), program_name ) - io_nml => modeldb%configuration%get_namelist('io') - call io_nml%get_value('subroutine_timers', lsubroutine_timers) - call init_timing( modeldb%mpi%get_comm(), lsubroutine_timers, program_name, timer_output_path ) - nullify( io_nml ) call init_collections() call init_time(modeldb) + deallocate( filename ) allocate(rng, source=random_number_generator_type(default_seed)) call modeldb%values%add_key_value("rng", rng) diff --git a/applications/lbc_demo/source/driver/lbc_demo_driver_mod.f90 b/applications/lbc_demo/source/driver/lbc_demo_driver_mod.f90 index 45880fcbd..7372357eb 100644 --- a/applications/lbc_demo/source/driver/lbc_demo_driver_mod.f90 +++ b/applications/lbc_demo/source/driver/lbc_demo_driver_mod.f90 @@ -186,7 +186,7 @@ subroutine initialise( program_name, modeldb) stencil_depth = 1 check_partitions = .false. - call init_mesh( modeldb%configuration, & + call init_mesh( modeldb%config, & modeldb%mpi%get_comm_rank(), & modeldb%mpi%get_comm_size(), & base_mesh_names, extrusion, & diff --git a/applications/lbc_demo/source/lbc_demo.f90 b/applications/lbc_demo/source/lbc_demo.f90 index 50612d273..1500ada59 100644 --- a/applications/lbc_demo/source/lbc_demo.f90 +++ b/applications/lbc_demo/source/lbc_demo.f90 @@ -37,22 +37,16 @@ program lbc_demo integer :: geometry, topology call parse_command_line( filename ) + call modeldb%config%initialise( program_name ) - write(log_scratch_space, '(A)') & - 'Application built with ' // trim(precision_real) // '-bit real numbers' - call log_event( log_scratch_space, log_level_trace ) - - ! The technical and scientific state modeldb%mpi => global_mpi - call modeldb%configuration%initialise( program_name, table_len=10 ) - call modeldb%config%initialise( program_name ) call init_comm(program_name, modeldb) - - call init_config(filename, required_namelists, & - configuration=modeldb%configuration, & + call init_config(filename, required_namelists, & config=modeldb%config) + call init_logger( modeldb%mpi%get_comm(), program_name ) + ! Before anything else, test that the mesh provided was a regional domain. ! This application is not intended for cubed-sphere meshes. geometry = modeldb%config%base_mesh%geometry() @@ -64,10 +58,12 @@ program lbc_demo call log_event( 'Cubed-Sphere mesh is not supported.', log_level_error) end if - call init_logger( modeldb%mpi%get_comm(), program_name ) + write(log_scratch_space, '(A)') & + 'Application built with ' // trim(precision_real) // '-bit real numbers' + call log_event( log_scratch_space, log_level_trace ) + call init_collections() call init_time(modeldb) - deallocate( filename ) ! Create the depository field collection and place it in modeldb diff --git a/applications/simple_diffusion/source/algorithm/simple_diffusion_constants_mod.x90 b/applications/simple_diffusion/source/algorithm/simple_diffusion_constants_mod.x90 index eba4754c6..77613851e 100644 --- a/applications/simple_diffusion/source/algorithm/simple_diffusion_constants_mod.x90 +++ b/applications/simple_diffusion/source/algorithm/simple_diffusion_constants_mod.x90 @@ -17,7 +17,6 @@ module simple_diffusion_constants_mod ! Infrastructure use constants_mod, only: i_def, r_def, l_def, & str_def, str_short - use driver_modeldb_mod, only: modeldb_type use field_collection_mod, only: field_collection_type use field_mod, only: field_type use fs_continuity_mod, only: W2 @@ -49,19 +48,16 @@ module simple_diffusion_constants_mod contains !> @brief Subroutine to create the finite element constants - !> @param[in] modeldb Application state object !> @param[in] mesh The prime model mesh !> @param[in] chi Coordinate fields !> @param[in] panel_id Panel_id field - subroutine create_simple_diffusion_constants( modeldb, & - mesh, & + subroutine create_simple_diffusion_constants( mesh, & chi, & panel_id ) implicit none ! Arguments - type(modeldb_type), intent(in) :: modeldb type(mesh_type), pointer, intent(in) :: mesh type(field_type), target, intent(in) :: chi(:) type(field_type), target, intent(in) :: panel_id diff --git a/applications/simple_diffusion/source/driver/init_simple_diffusion_mod.F90 b/applications/simple_diffusion/source/driver/init_simple_diffusion_mod.F90 index 1dc960087..44a047234 100644 --- a/applications/simple_diffusion/source/driver/init_simple_diffusion_mod.F90 +++ b/applications/simple_diffusion/source/driver/init_simple_diffusion_mod.F90 @@ -21,8 +21,7 @@ module init_simple_diffusion_mod use function_space_collection_mod, only : function_space_collection use function_space_mod, only : function_space_type use fs_continuity_mod, only : Wtheta - use log_mod, only : log_event, & - LOG_LEVEL_TRACE + use log_mod, only : log_event, log_level_trace use mesh_mod, only : mesh_type use lfric_xios_write_mod, only : write_field_generic use simple_diffusion_constants_mod, only : create_simple_diffusion_constants @@ -64,7 +63,8 @@ subroutine init_simple_diffusion(mesh, chi, panel_id, modeldb) fs => function_space_collection%get_fs(mesh, order_h, order_v, Wtheta) - call log_event( 'simple_diffusion: Initialising miniapp ...', LOG_LEVEL_TRACE ) + call log_event( 'simple_diffusion: Initialising miniapp ...', & + log_level_trace ) ! Create prognostic fields ! Creates a field in the Wtheta function space @@ -87,9 +87,9 @@ subroutine init_simple_diffusion(mesh, chi, panel_id, modeldb) ! Create simple_diffusion runtime constants. This creates various things ! needed by the fem algorithms such as mass matrix operators, mass ! matrix diagonal fields and the geopotential field - call create_simple_diffusion_constants(modeldb, mesh, chi, panel_id) + call create_simple_diffusion_constants(mesh, chi, panel_id) - call log_event( 'simple_diffusion: Miniapp initialised', LOG_LEVEL_TRACE ) + call log_event( 'simple_diffusion: Miniapp initialised', log_level_trace ) end subroutine init_simple_diffusion diff --git a/applications/simple_diffusion/source/driver/simple_diffusion_driver_mod.f90 b/applications/simple_diffusion/source/driver/simple_diffusion_driver_mod.f90 index 6907b7da9..e62497053 100644 --- a/applications/simple_diffusion/source/driver/simple_diffusion_driver_mod.f90 +++ b/applications/simple_diffusion/source/driver/simple_diffusion_driver_mod.f90 @@ -149,7 +149,7 @@ subroutine initialise( program_name, modeldb) ! --------------------------------------------------------- stencil_depth = 1 check_partitions = .false. - call init_mesh( modeldb%configuration, & + call init_mesh( modeldb%config, & modeldb%mpi%get_comm_rank(), & modeldb%mpi%get_comm_size(), & base_mesh_names, extrusion, & diff --git a/applications/simple_diffusion/source/simple_diffusion.f90 b/applications/simple_diffusion/source/simple_diffusion.f90 index e2b09fce6..b990fe6cf 100644 --- a/applications/simple_diffusion/source/simple_diffusion.f90 +++ b/applications/simple_diffusion/source/simple_diffusion.f90 @@ -36,25 +36,25 @@ program simple_diffusion call parse_command_line( filename ) call modeldb%values%initialise() - call modeldb%configuration%initialise( program_name, table_len=10 ) call modeldb%config%initialise( program_name ) - write(log_scratch_space,& - '("Application built with ", A, "-bit real numbers")') & - trim(precision_real) - call log_event( log_scratch_space, log_level_trace ) modeldb%mpi => global_mpi - call init_comm(program_name, modeldb) - call init_config( filename, simple_diffusion_required_namelists, & - configuration=modeldb%configuration, & + call init_comm(program_name, modeldb) + call init_config( filename, & + simple_diffusion_required_namelists, & config=modeldb%config ) - deallocate( filename ) - call init_logger( modeldb%mpi%get_comm(), program_name ) + + write(log_scratch_space,& + '("Application built with ", A, "-bit real numbers")') & + trim(precision_real) + call log_event( log_scratch_space, log_level_trace ) + call init_collections() call init_time( modeldb ) + deallocate( filename ) allocate(rng, source=random_number_generator_type(default_seed)) call modeldb%values%add_key_value("rng", rng) diff --git a/applications/skeleton/source/algorithm/skeleton_constants_mod.x90 b/applications/skeleton/source/algorithm/skeleton_constants_mod.x90 index 0cc5cada1..4717f9b7c 100644 --- a/applications/skeleton/source/algorithm/skeleton_constants_mod.x90 +++ b/applications/skeleton/source/algorithm/skeleton_constants_mod.x90 @@ -113,6 +113,7 @@ contains integer(tik) :: id if ( LPROF ) call start_timing( id, 'skeleton_constants_alg' ) + call log_event( "Skeleton: creating runtime constants", LOG_LEVEL_INFO ) order_h = modeldb%config%finite_element%element_order_h() diff --git a/applications/skeleton/source/driver/skeleton_driver_mod.f90 b/applications/skeleton/source/driver/skeleton_driver_mod.f90 index 0ea9629ac..c0a005fd5 100644 --- a/applications/skeleton/source/driver/skeleton_driver_mod.f90 +++ b/applications/skeleton/source/driver/skeleton_driver_mod.f90 @@ -141,7 +141,7 @@ subroutine initialise(program_name, modeldb) !----------------------------------------------------------------------- stencil_depth = 1 apply_partition_check = .false. - call init_mesh( modeldb%configuration, & + call init_mesh( modeldb%config, & modeldb%mpi%get_comm_rank(), & modeldb%mpi%get_comm_size(), & base_mesh_names, extrusion, & diff --git a/applications/skeleton/source/skeleton.f90 b/applications/skeleton/source/skeleton.f90 index 687fe9fc9..cd35a0ee8 100644 --- a/applications/skeleton/source/skeleton.f90 +++ b/applications/skeleton/source/skeleton.f90 @@ -37,22 +37,21 @@ program skeleton character(:), allocatable :: filename call parse_command_line( filename ) - call modeldb%configuration%initialise( program_name, table_len=10 ) call modeldb%config%initialise(program_name) - write(log_scratch_space,'(A)') & - 'Application built with '// trim(precision_real) // & - '-bit real numbers.' - call log_event( log_scratch_space, log_level_trace ) - modeldb%mpi => global_mpi call init_comm( "skeleton", modeldb ) call init_config( filename, skeleton_required_namelists, & - configuration=modeldb%configuration, & config=modeldb%config ) call init_logger( modeldb%mpi%get_comm(), program_name ) + + write(log_scratch_space,'(A)') & + 'Application built with '// trim(precision_real) // & + '-bit real numbers.' + call log_event( log_scratch_space, log_level_trace ) + call init_collections() call init_time( modeldb ) deallocate( filename ) diff --git a/components/driver/source/driver_fem_mod.f90 b/components/driver/source/driver_fem_mod.f90 index 715786011..a4ccd99ae 100644 --- a/components/driver/source/driver_fem_mod.f90 +++ b/components/driver/source/driver_fem_mod.f90 @@ -37,6 +37,8 @@ module driver_fem_mod use mesh_mod, only: mesh_type use mesh_collection_mod, only: mesh_collection_type + use base_mesh_config_mod, only: geometry, geometry_spherical + implicit none private diff --git a/components/driver/source/driver_io_mod.F90 b/components/driver/source/driver_io_mod.F90 index 294cac940..2beadda81 100644 --- a/components/driver/source/driver_io_mod.F90 +++ b/components/driver/source/driver_io_mod.F90 @@ -10,7 +10,7 @@ !> module driver_io_mod - use constants_mod, only: str_def, i_def + use constants_mod, only: str_def, i_def, l_def use driver_modeldb_mod, only: modeldb_type use driver_model_data_mod, only: model_data_type use empty_io_context_mod, only: empty_io_context_type @@ -32,7 +32,6 @@ module driver_io_mod use mesh_mod, only: mesh_type use mesh_collection_mod, only: mesh_collection use model_clock_mod, only: model_clock_type - use namelist_mod, only: namelist_type implicit none @@ -87,12 +86,9 @@ subroutine init_io( context_name, & procedure(callback_clock_arg), pointer :: before_close_ptr - type(namelist_type), pointer :: io_nml + logical(l_def) :: use_xios_io - logical :: use_xios_io - - io_nml => modeldb%configuration%get_namelist('io') - call io_nml%get_value( 'use_xios_io', use_xios_io ) + use_xios_io = modeldb%config%io%use_xios_io() ! Allocate IO context type based on model configuration if ( use_xios_io ) then @@ -201,10 +197,6 @@ subroutine init_xios_io_context( context_name, & integer(i_def) :: num_meshes, i, j - type(namelist_type), pointer :: io_nml - - io_nml => modeldb%configuration%get_namelist('io') - mesh => null() chi => null() panel_id => null() diff --git a/components/driver/source/driver_mesh_mod.f90 b/components/driver/source/driver_mesh_mod.f90 index 37452a28a..015cc492f 100644 --- a/components/driver/source/driver_mesh_mod.f90 +++ b/components/driver/source/driver_mesh_mod.f90 @@ -29,6 +29,7 @@ module driver_mesh_mod str_max_filename use check_global_mesh_mod, only: check_global_mesh use check_local_mesh_mod, only: check_local_mesh + use config_mod, only: config_type use create_mesh_mod, only: create_extrusion, create_mesh use extrusion_mod, only: extrusion_type use global_mesh_mod, only: global_mesh_type @@ -39,8 +40,6 @@ module driver_mesh_mod log_scratch_space, & log_level_debug, & log_level_error - use namelist_collection_mod, only: namelist_collection_type - use namelist_mod, only: namelist_type use panel_decomposition_mod, only: panel_decomposition_type use partition_mod, only: partitioner_interface @@ -70,7 +69,7 @@ module driver_mesh_mod !=============================================================================== !> @brief Generates mesh(es) from mesh input file(s) on a given extrusion. !> -!> @param[in] configuration Application configuration object. +!> @param[in] config Application configuration object. !> This configuration object should contain the !> following defined namelist objects: !> * base_mesh @@ -87,7 +86,7 @@ module driver_mesh_mod !> @param[in] alt_names (Optional), Alternative names for meshes in the !> application mesh collection object. !=============================================================================== -subroutine init_mesh( configuration, & +subroutine init_mesh( config, & local_rank, total_ranks, & mesh_names, extrusion, & stencil_depth, & @@ -97,8 +96,7 @@ subroutine init_mesh( configuration, & implicit none ! Arguments - type(namelist_collection_type) :: configuration - + type(config_type), intent(in) :: config integer(i_def), intent(in) :: local_rank integer(i_def), intent(in) :: total_ranks character(str_def), intent(in) :: mesh_names(:) @@ -113,16 +111,12 @@ subroutine init_mesh( configuration, & character(len=9), parameter :: routine_name = 'init_mesh' ! Namelist variables - type(namelist_type), pointer :: base_mesh_nml - type(namelist_type), pointer :: finite_element_nml - type(namelist_type), pointer :: partitioning_nml - character(str_max_filename) :: file_prefix integer(i_def) :: cellshape - logical :: prepartitioned - logical :: generate_inner_halos + logical(l_def) :: prepartitioned + logical(l_def) :: generate_inner_halos integer :: geometry integer :: topology @@ -141,24 +135,19 @@ subroutine init_mesh( configuration, & character(str_def) :: fmt_str, number_str !============================================================================ - ! 0.0 Extract configuration variables + ! Extract configuration variables !============================================================================ - base_mesh_nml => configuration%get_namelist('base_mesh') - call base_mesh_nml%get_value( 'prepartitioned', prepartitioned ) - call base_mesh_nml%get_value( 'file_prefix', file_prefix ) - - finite_element_nml => configuration%get_namelist('finite_element') - call finite_element_nml%get_value( 'cellshape', cellshape ) + prepartitioned = config%base_mesh%prepartitioned() + file_prefix = config%base_mesh%file_prefix() + cellshape = config%finite_element%cellshape() if ( .not. prepartitioned ) then - partitioning_nml => configuration%get_namelist('partitioning') - call partitioning_nml%get_value( 'generate_inner_halos', generate_inner_halos ) + generate_inner_halos = config%partitioning%generate_inner_halos() end if - !============================================================================ - ! 0.1 Some basic checks + ! Some basic checks !============================================================================ ! Set up stencil depth if (stencil_depth < 0_i_def) then @@ -175,7 +164,7 @@ subroutine init_mesh( configuration, & !============================================================================ - ! 1.0 Determine which names to apply to resultant meshes. + ! Determine which names to apply to resultant meshes. !============================================================================ if (present(alt_names)) then if (size(alt_names) == size(mesh_names)) then @@ -192,15 +181,15 @@ subroutine init_mesh( configuration, & !=========================================================================== - ! 2.0 Create local mesh objects: - ! Two code pathes presented, either: - ! 1. The input files have been pre-partitioned. - ! Meshes and are simply read from file and local mesh objects - ! are populated. - ! 2. The input files have not been partitioned. - ! Global meshes are loaded from file and partitioning is applied - ! at runtime. NOTE: This option is provided as legacy, and support - ! is on a best endeavours basis. + ! Create local mesh objects: + ! Two code pathes presented, either: + ! 1. The input files have been pre-partitioned. + ! Meshes and are simply read from file and local mesh objects + ! are populated. + ! 2. The input files have not been partitioned. + ! Global meshes are loaded from file and partitioning is applied + ! at runtime. NOTE: This option is provided as legacy, and support + ! is on a best endeavours basis. !=========================================================================== generate_inner_halos = .false. @@ -208,8 +197,8 @@ subroutine init_mesh( configuration, & if (prepartitioned) then !========================================================================== - ! 2.1 Read in local meshes / partition information / mesh maps - ! direct from file. + ! Read in local meshes / partition information / mesh maps + ! direct from file. !========================================================================== ! ! For this local rank, a mesh input file with a common base name @@ -229,22 +218,22 @@ subroutine init_mesh( configuration, & call log_event( "Loading local mesh(es)", log_level_debug ) - ! 2.1a Read in all local mesh data for this rank and - ! initialise local mesh objects from them. + ! Read in all local mesh data for this rank and + ! initialise local mesh objects from them. !=========================================================== ! Each partitioned mesh file will contain meshes of the ! same name as all other partitions. call load_local_mesh( input_mesh_file, mesh_names ) - ! 2.1b Apply configuration related checks to ensure that these - ! meshes are suitable for the supplied application - ! configuration. + ! Apply configuration related checks to ensure that these + ! meshes are suitable for the supplied application + ! configuration. !=========================================================== - call check_local_mesh( configuration, & + call check_local_mesh( config, & stencil_depth, & mesh_names ) - ! 2.1c Load and assign mesh maps. + ! Load and assign mesh maps. !=========================================================== ! Mesh map identifiers are determined by the source/target ! mesh IDs they relate to. As a result inter-grid mesh maps @@ -257,15 +246,12 @@ subroutine init_mesh( configuration, & else !========================================================================== - ! 2.2 Perform runtime partitioning of global meshes. + ! Perform runtime partitioning of global meshes. !========================================================================== - call base_mesh_nml%get_value( 'geometry', geometry ) - call base_mesh_nml%get_value( 'topology', topology ) - - partitioning_nml => configuration%get_namelist('partitioning') + geometry = config%base_mesh%geometry() + topology = config%base_mesh%topology() - call partitioning_nml%get_value( 'generate_inner_halos', & - generate_inner_halos ) + generate_inner_halos = config%partitioning%generate_inner_halos() if ( geometry == geometry_spherical .and. & topology == topology_fully_periodic ) then @@ -281,8 +267,8 @@ subroutine init_mesh( configuration, & ! 2.2a Set constants that will control partitioning. !=========================================================== - call get_partition_parameters( configuration, mesh_selection, & - total_ranks, decomposition, & + call get_partition_parameters( config%partitioning, mesh_selection, & + total_ranks, decomposition, & partitioner_ptr ) ! 2.2b Read in all global meshes from input file @@ -293,7 +279,7 @@ subroutine init_mesh( configuration, & ! meshes are suitable for the supplied application ! configuration. !=========================================================== - call check_global_mesh( configuration, mesh_names ) + call check_global_mesh( config, mesh_names ) ! 2.2e Partition the global meshes !=========================================================== diff --git a/components/driver/source/driver_time_mod.f90 b/components/driver/source/driver_time_mod.f90 index 71dfb926f..f553795c2 100644 --- a/components/driver/source/driver_time_mod.f90 +++ b/components/driver/source/driver_time_mod.f90 @@ -12,7 +12,6 @@ module driver_time_mod use driver_modeldb_mod, only: modeldb_type use log_mod, only: log_event, LOG_LEVEL_ERROR use model_clock_mod, only: model_clock_type - use namelist_mod, only: namelist_type use step_calendar_mod, only: step_calendar_type implicit none @@ -40,9 +39,6 @@ subroutine init_time( modeldb ) integer(i_timestep) :: first integer(i_timestep) :: last - type(namelist_type), pointer :: time_nml - type(namelist_type), pointer :: timestepping_nml - character(str_def) :: timestep_start character(str_def) :: timestep_end character(str_def) :: calendar_origin @@ -54,18 +50,13 @@ subroutine init_time( modeldb ) ! ------------------------------- ! Extract namelist variables ! ------------------------------- - time_nml => modeldb%configuration%get_namelist('time') - timestepping_nml => modeldb%configuration%get_namelist('timestepping') - - call time_nml%get_value( 'timestep_start', timestep_start ) - call time_nml%get_value( 'timestep_end', timestep_end ) - call time_nml%get_value( 'calendar_origin', calendar_origin ) - call time_nml%get_value( 'calendar_start', calendar_start ) - - call timestepping_nml%get_value( 'dt', timestep_length ) - call timestepping_nml%get_value( 'spinup_period', spinup_period ) + timestep_start = modeldb%config%time%timestep_start() + timestep_end = modeldb%config%time%timestep_end() + calendar_origin = modeldb%config%time%calendar_origin() + calendar_start = modeldb%config%time%calendar_start() - nullify( time_nml, timestepping_nml ) + timestep_length = modeldb%config%timestepping%dt() + spinup_period = modeldb%config%timestepping%spinup_period() ! Instantiate the calendar !--------------------------------- diff --git a/components/driver/source/mesh/check_global_mesh_mod.f90 b/components/driver/source/mesh/check_global_mesh_mod.f90 index 55efb274e..e7665fefa 100644 --- a/components/driver/source/mesh/check_global_mesh_mod.f90 +++ b/components/driver/source/mesh/check_global_mesh_mod.f90 @@ -5,14 +5,12 @@ !----------------------------------------------------------------------------- module check_global_mesh_mod - use constants_mod, only: i_def, str_def, & - str_max_filename - use global_mesh_mod, only: global_mesh_type - use log_mod, only: log_event, & - log_scratch_space, & - LOG_LEVEL_ERROR - use namelist_collection_mod, only: namelist_collection_type - use namelist_mod, only: namelist_type + use constants_mod, only: i_def, str_def, str_max_filename + use config_mod, only: config_type + use global_mesh_mod, only: global_mesh_type + use log_mod, only: log_event, & + log_scratch_space, & + LOG_LEVEL_ERROR use global_mesh_collection_mod, only: global_mesh_collection @@ -34,15 +32,15 @@ module check_global_mesh_mod !> @brief Basic validation that global meshes are suitable !! for the specified configuration. -!> @param[in] configuration Configuration object. -!> @param[in] mesh_names Global meshes held in application -!! global mesh collection object. -subroutine check_global_mesh( configuration, mesh_names ) +!> @param[in] config Configuration object. +!> @param[in] mesh_names Global meshes held in application +!! global mesh collection object. +subroutine check_global_mesh( config, mesh_names ) implicit none - type(namelist_collection_type), intent(in) :: configuration - character(str_def), intent(in) :: mesh_names(:) + type(config_type), intent(in) :: config + character(str_def), intent(in) :: mesh_names(:) integer(i_def) :: topology integer(i_def) :: geometry @@ -50,17 +48,12 @@ subroutine check_global_mesh( configuration, mesh_names ) logical :: valid_geometry logical :: valid_topology - type(global_mesh_type), pointer :: global_mesh => null() - type(namelist_type), pointer :: base_mesh_nml => null() + type(global_mesh_type), pointer :: global_mesh integer(i_def) :: i - base_mesh_nml => configuration%get_namelist('base_mesh') - - call base_mesh_nml%get_value( 'geometry', geometry ) - call base_mesh_nml%get_value( 'topology', topology ) - - base_mesh_nml => null() + geometry = config%base_mesh%geometry() + topology = config%base_mesh%topology() do i=1, size(mesh_names) diff --git a/components/driver/source/mesh/check_local_mesh_mod.f90 b/components/driver/source/mesh/check_local_mesh_mod.f90 index fc9bd8ed3..14759d787 100644 --- a/components/driver/source/mesh/check_local_mesh_mod.f90 +++ b/components/driver/source/mesh/check_local_mesh_mod.f90 @@ -7,13 +7,13 @@ module check_local_mesh_mod use constants_mod, only: i_def, str_def, & str_max_filename + use config_mod, only: config_type use local_mesh_collection_mod, only: local_mesh_collection use local_mesh_mod, only: local_mesh_type use log_mod, only: log_event, & log_scratch_space, & log_level_error - use namelist_collection_mod, only: namelist_collection_type - use namelist_mod, only: namelist_type + use sci_query_mod, only: is_lbc, check_lbc use base_mesh_config_mod, only: key_from_geometry, & @@ -31,20 +31,20 @@ module check_local_mesh_mod !> @brief Basic validation that local meshes are suitable !! for the specified configuration. -!> @param[in] configuration Configuration object. +!> @param[in] config Configuration object. !> @param[in] stencil_depth Stencil depth that local meshes !> need to support. !> @param[in] mesh_names Local meshes held in application !! local mesh collection object. -subroutine check_local_mesh( configuration, & +subroutine check_local_mesh( config, & stencil_depth, & mesh_names ) implicit none - type(namelist_collection_type), intent(in) :: configuration - integer(i_def), intent(in) :: stencil_depth - character(str_def), intent(in) :: mesh_names(:) + type(config_type), intent(in) :: config + integer(i_def), intent(in) :: stencil_depth + character(str_def), intent(in) :: mesh_names(:) integer(i_def) :: topology integer(i_def) :: geometry @@ -52,18 +52,13 @@ subroutine check_local_mesh( configuration, & logical :: valid_geometry logical :: valid_topology - type(local_mesh_type), pointer :: local_mesh => null() - type(namelist_type), pointer :: base_mesh_nml => null() - integer(i_def) :: i integer(i_def) :: max_stencil_depth - base_mesh_nml => configuration%get_namelist('base_mesh') - - call base_mesh_nml%get_value( 'geometry', geometry ) - call base_mesh_nml%get_value( 'topology', topology ) + type(local_mesh_type), pointer :: local_mesh - base_mesh_nml => null() + geometry = config%base_mesh%geometry() + topology = config%base_mesh%topology() do i=1, size(mesh_names) diff --git a/components/driver/source/mesh/runtime_partition_lfric_mod.f90 b/components/driver/source/mesh/runtime_partition_lfric_mod.f90 index 155662def..3916697b7 100644 --- a/components/driver/source/mesh/runtime_partition_lfric_mod.f90 +++ b/components/driver/source/mesh/runtime_partition_lfric_mod.f90 @@ -9,8 +9,8 @@ module runtime_partition_lfric_mod use constants_mod, only: i_def, l_def - use namelist_collection_mod, only: namelist_collection_type - use namelist_mod, only: namelist_type + use config_mod, only: config_type + use partitioning_nml_mod, only: partitioning_nml_type use partition_mod, only: partitioner_interface use runtime_partition_mod, only: get_partition_strategy use panel_decomposition_mod, only: panel_decomposition_type, & @@ -34,53 +34,19 @@ module runtime_partition_lfric_mod private public :: get_partition_parameters - interface get_partition_parameters - procedure get_partition_parameters_cfg - procedure get_partition_parameters_nml - end interface get_partition_parameters contains -subroutine get_partition_parameters_cfg( configuration, & - mesh_selection, & - total_ranks, & - decomposition, & - partitioner_ptr ) - - implicit none - - type(namelist_collection_type), intent(in) :: configuration - - integer, intent(in) :: mesh_selection - integer(i_def), intent(in) :: total_ranks - - class(panel_decomposition_type), intent(inout), allocatable :: decomposition - - type(namelist_type), pointer :: partitioning - - procedure(partitioner_interface), intent(out), pointer :: partitioner_ptr - - partitioning => configuration%get_namelist('partitioning') - - call get_partition_parameters_nml( partitioning, & +subroutine get_partition_parameters( partitioning_nml, & mesh_selection, & total_ranks, & decomposition, & partitioner_ptr ) - -end subroutine get_partition_parameters_cfg - -subroutine get_partition_parameters_nml( partitioning, & - mesh_selection, & - total_ranks, & - decomposition, & - partitioner_ptr ) - implicit none - type(namelist_type), intent(in), pointer :: partitioning + type(partitioning_nml_type), intent(in) :: partitioning_nml integer, intent(in) :: mesh_selection integer(i_def), intent(in) :: total_ranks @@ -91,9 +57,11 @@ subroutine get_partition_parameters_nml( partitioning, & integer(i_def) :: panel_xproc, panel_yproc - integer :: panel_decomposition + integer(i_def) :: panel_decomposition - call partitioning%get_value( 'panel_decomposition', panel_decomposition ) + panel_decomposition = partitioning_nml%panel_decomposition() + panel_xproc = partitioning_nml%panel_xproc() + panel_yproc = partitioning_nml%panel_yproc() select case (panel_decomposition) @@ -107,15 +75,12 @@ subroutine get_partition_parameters_nml( partitioning, & decomposition = column_decomposition_type() case ( panel_decomposition_custom ) - call partitioning%get_value( 'panel_xproc', panel_xproc ) - call partitioning%get_value( 'panel_yproc', panel_yproc ) decomposition = custom_decomposition_type( panel_xproc, panel_yproc ) case ( panel_decomposition_auto_nonuniform ) decomposition = auto_nonuniform_decomposition_type() case ( panel_decomposition_guided_nonuniform ) - call partitioning%get_value( 'panel_xproc', panel_xproc ) decomposition = guided_nonuniform_decomposition_type( panel_xproc ) case default @@ -127,7 +92,7 @@ subroutine get_partition_parameters_nml( partitioning, & call get_partition_strategy(mesh_selection, total_ranks, partitioner_ptr) -end subroutine get_partition_parameters_nml +end subroutine get_partition_parameters end module runtime_partition_lfric_mod diff --git a/infrastructure/build/tools/configurator/templates/config_loader.f90.jinja b/infrastructure/build/tools/configurator/templates/config_loader.f90.jinja index 8edad5bf7..ea542679b 100644 --- a/infrastructure/build/tools/configurator/templates/config_loader.f90.jinja +++ b/infrastructure/build/tools/configurator/templates/config_loader.f90.jinja @@ -11,7 +11,6 @@ module {{moduleName}} use constants_mod, only : i_def, l_def, str_def, str_max_filename use lfric_mpi_mod, only : global_mpi - use log_mod, only : log_scratch_space, log_event, LOG_LEVEL_ERROR use namelist_collection_mod, only: namelist_collection_type use namelist_mod, only: namelist_type @@ -65,10 +64,11 @@ contains integer(i_def) :: unit if (.not. present(configuration) .and. .not. present(config)) then - write(log_scratch_space,'(A)') & - 'At least one optional argument must be provided for ' //& - 'read_configuration.' - call log_event(log_scratch_space, log_level_error) + write(6,'(A)') & + 'At least one optional argument must ' //& + 'be provided for read_configuration.' + flush(6) + stop end if local_rank = global_mpi%get_comm_rank() @@ -175,17 +175,19 @@ contains logical(l_def), optional, intent(out) :: success_mask(:) logical(l_def) :: ensure_configuration - integer(i_def) :: i - logical :: configuration_found = .True. + integer(i_def) :: i + logical :: configuration_found = .true. if (present(success_mask) & .and. (size(success_mask, 1) /= size(names, 1))) then - call log_event( 'Arguments "names" and "success_mask" to function' & - // '"ensure_configuration" are different shapes', & - LOG_LEVEL_ERROR ) + write(6, '(A)') & + 'Arguments "names" and "success_mask" to function' //& + '"ensure_configuration" are different shapes.' + flush(6) + stop end if - ensure_configuration = .True. + ensure_configuration = .true. name_loop: do i = 1, size(names) select case(trim( names(i) )) @@ -195,10 +197,11 @@ contains {%- endfor %} case default - write( log_scratch_space, '(A)' ) & - 'Tried to ensure unrecognised namelist "'// & + write(6, '(A)') & + 'Tried to ensure unrecognised namelist "' //& trim(names(i))//'" was loaded.' - call log_event( log_scratch_space, LOG_LEVEL_ERROR ) + flush(6) + stop end select ensure_configuration = ensure_configuration .and. configuration_found @@ -269,18 +272,20 @@ contains end if else - write( log_scratch_space, '(A)' ) & - 'Namelist "'//trim(namelists(i))// & + write(6, '(A)') & + 'Namelist "'//trim(namelists(i)) //& '" can not be read. Too many instances?' - call log_event( log_scratch_space, LOG_LEVEL_ERROR ) + flush(6) + stop end if {%- endfor %} case default - write( log_scratch_space, '(A)' ) & - 'Unrecognised namelist "'//trim(namelists(i))// & + write(6, '(A)') & + 'Unrecognised namelist "'//trim(namelists(i)) //& '" found in file '//trim(filename)//'.' - call log_event( log_scratch_space, LOG_LEVEL_ERROR ) + flush(6) + stop end select end do ! Namelists diff --git a/infrastructure/build/tools/configurator/templates/config_type.f90.jinja b/infrastructure/build/tools/configurator/templates/config_type.f90.jinja index d79fc8a48..aa91770be 100644 --- a/infrastructure/build/tools/configurator/templates/config_type.f90.jinja +++ b/infrastructure/build/tools/configurator/templates/config_type.f90.jinja @@ -14,8 +14,6 @@ module {{moduleName}} use constants_mod, only: i_def, l_def, str_def, cmdi - use log_mod, only: log_event, log_scratch_space, & - log_level_error, log_level_warning use linked_list_mod, only: linked_list_type, linked_list_item_type use namelist_mod, only: namelist_type @@ -102,11 +100,12 @@ subroutine initialise(self, name) character(*), optional, intent(in) :: name if (self%isinitialised) then - write(log_scratch_space, '(A)') & - 'Application configuration: [' // & - trim(self%config_name) // & - '] has already been initiaised.' - call log_event(log_scratch_space, log_level_error) + write(6, '(A)') & + 'Application configuration: [' //& + trim(self%config_name) //& + '] has already been initialised.' + flush(6) + stop end if if (present(name)) then @@ -115,6 +114,13 @@ subroutine initialise(self, name) self%config_name = cmdi end if + ! Allocate linked lists +{%- for i in range(namelists|length) %} +{%- if duplicates[i] %} + allocate(self%{{namelists[i]}}) +{%- endif %} +{%- endfor %} + self%isinitialised = .true. end subroutine initialise @@ -149,9 +155,10 @@ subroutine add_namelist(self, namelist_obj) type is( {{namelists[i]}}_nml_type ) ! Multiple instances: NOT ALLOWED if (self%namelist_exists(trim(name))) then - write(log_scratch_space, '(A)') & + write(6, '(A)') & trim(name) // ' namelist already allocated.' - call log_event(log_scratch_space, log_level_error) + flush(6) + stop else allocate(self%{{namelists[i]}}, source=namelist_obj) call self%update_contents(trim(name)) @@ -164,27 +171,26 @@ subroutine add_namelist(self, namelist_obj) type is ( {{namelists[i]}}_nml_type ) ! Multiple instances: ALLOWED if (trim(profile_name) == cmdi) then - write(log_scratch_space, '(A)') 'Ignoring ' // trim(name) // & + write(6, '(A)') 'Ignoring ' // trim(name) // & ' namelist: missing profile name.' - call log_event(log_scratch_space, log_level_warning) + flush(6) else if (self%namelist_exists(trim(full_name))) then - write(log_scratch_space, '(A)') trim(name) // & + write(6, '(A)') trim(name) // & ' namelist (' // trim(profile_name) // '), already allocated.' - call log_event(log_scratch_space, log_level_error) + flush(6) + stop else - if (.not. allocated(self%{{namelists[i]}})) then - allocate(self%{{namelists[i]}}) - end if call self%{{namelists[i]}}%insert_item( namelist_obj ) call self%update_contents(namelist_obj%get_full_name()) end if {% endif %} {%- endfor %} class default - write(log_scratch_space, '(A)') & - ' Undefined namelist type(' // trim(name) // & - '), for this configuration.' - call log_event(log_scratch_space, log_level_error) + write(6, '(A)') & + ' Undefined namelist type(' // trim(name) //& + '), for this configuration.' + flush(6) + stop end select @@ -264,11 +270,12 @@ function {{namelists[i]}}_list(self, profile_name) result({{namelists[i]}}_nml_o ! reached without finding the namelist, fail with ! an error. if (.not. associated(loop)) then - write(log_scratch_space, '(A)') & + write(6, '(A)') & 'Instance ' // trim(profile_name) // ' of ' // & '{{namelists[i]}}_nml_type ' // & 'not found in configuration.' - call log_event(log_scratch_space, log_level_error) + flush(6) + stop end if ! Otherwise 'cast' to a {{namelists[i]}}_namelist_type diff --git a/infrastructure/build/tools/configurator/tests/app_config/bar_nml_iterator_mod.f90 b/infrastructure/build/tools/configurator/tests/app_config/bar_nml_iterator_mod.f90 index 81329a75b..0d9f5b225 100644 --- a/infrastructure/build/tools/configurator/tests/app_config/bar_nml_iterator_mod.f90 +++ b/infrastructure/build/tools/configurator/tests/app_config/bar_nml_iterator_mod.f90 @@ -10,7 +10,7 @@ !> @details Provides functionality for iteratively returning every member !> of the defined namelist (bar) collection. The order of !> the namelists returned is not defined and can change if the -!> implementation of the namelist collection is changed. +!> implementation of the namelist collection is changes. ! module bar_nml_iterator_mod diff --git a/infrastructure/build/tools/configurator/tests/app_config/content_mod.f90 b/infrastructure/build/tools/configurator/tests/app_config/content_mod.f90 index c84d6c534..58666a61f 100644 --- a/infrastructure/build/tools/configurator/tests/app_config/content_mod.f90 +++ b/infrastructure/build/tools/configurator/tests/app_config/content_mod.f90 @@ -14,8 +14,6 @@ module config_mod use constants_mod, only: i_def, l_def, str_def, cmdi - use log_mod, only: log_event, log_scratch_space, & - log_level_error, log_level_warning use linked_list_mod, only: linked_list_type, linked_list_item_type use namelist_mod, only: namelist_type @@ -91,11 +89,12 @@ subroutine initialise(self, name) character(*), optional, intent(in) :: name if (self%isinitialised) then - write(log_scratch_space, '(A)') & - 'Application configuration: [' // & - trim(self%config_name) // & - '] has already been initiaised.' - call log_event(log_scratch_space, log_level_error) + write(6, '(A)') & + 'Application configuration: [' //& + trim(self%config_name) //& + '] has already been initialised.' + flush(6) + stop end if if (present(name)) then @@ -104,6 +103,10 @@ subroutine initialise(self, name) self%config_name = cmdi end if + ! Allocate linked lists + allocate(self%bar) + allocate(self%pot) + self%isinitialised = .true. end subroutine initialise @@ -136,9 +139,10 @@ subroutine add_namelist(self, namelist_obj) type is( foo_nml_type ) ! Multiple instances: NOT ALLOWED if (self%namelist_exists(trim(name))) then - write(log_scratch_space, '(A)') & + write(6, '(A)') & trim(name) // ' namelist already allocated.' - call log_event(log_scratch_space, log_level_error) + flush(6) + stop else allocate(self%foo, source=namelist_obj) call self%update_contents(trim(name)) @@ -147,9 +151,10 @@ subroutine add_namelist(self, namelist_obj) type is( moo_nml_type ) ! Multiple instances: NOT ALLOWED if (self%namelist_exists(trim(name))) then - write(log_scratch_space, '(A)') & + write(6, '(A)') & trim(name) // ' namelist already allocated.' - call log_event(log_scratch_space, log_level_error) + flush(6) + stop else allocate(self%moo, source=namelist_obj) call self%update_contents(trim(name)) @@ -158,17 +163,15 @@ subroutine add_namelist(self, namelist_obj) type is ( bar_nml_type ) ! Multiple instances: ALLOWED if (trim(profile_name) == cmdi) then - write(log_scratch_space, '(A)') 'Ignoring ' // trim(name) // & + write(6, '(A)') 'Ignoring ' // trim(name) // & ' namelist: missing profile name.' - call log_event(log_scratch_space, log_level_warning) + flush(6) else if (self%namelist_exists(trim(full_name))) then - write(log_scratch_space, '(A)') trim(name) // & + write(6, '(A)') trim(name) // & ' namelist (' // trim(profile_name) // '), already allocated.' - call log_event(log_scratch_space, log_level_error) + flush(6) + stop else - if (.not. allocated(self%bar)) then - allocate(self%bar) - end if call self%bar%insert_item( namelist_obj ) call self%update_contents(namelist_obj%get_full_name()) end if @@ -176,26 +179,25 @@ subroutine add_namelist(self, namelist_obj) type is ( pot_nml_type ) ! Multiple instances: ALLOWED if (trim(profile_name) == cmdi) then - write(log_scratch_space, '(A)') 'Ignoring ' // trim(name) // & + write(6, '(A)') 'Ignoring ' // trim(name) // & ' namelist: missing profile name.' - call log_event(log_scratch_space, log_level_warning) + flush(6) else if (self%namelist_exists(trim(full_name))) then - write(log_scratch_space, '(A)') trim(name) // & + write(6, '(A)') trim(name) // & ' namelist (' // trim(profile_name) // '), already allocated.' - call log_event(log_scratch_space, log_level_error) + flush(6) + stop else - if (.not. allocated(self%pot)) then - allocate(self%pot) - end if call self%pot%insert_item( namelist_obj ) call self%update_contents(namelist_obj%get_full_name()) end if class default - write(log_scratch_space, '(A)') & - ' Undefined namelist type(' // trim(name) // & - '), for this configuration.' - call log_event(log_scratch_space, log_level_error) + write(6, '(A)') & + ' Undefined namelist type(' // trim(name) //& + '), for this configuration.' + flush(6) + stop end select @@ -272,11 +274,12 @@ function bar_list(self, profile_name) result(bar_nml_obj) ! reached without finding the namelist, fail with ! an error. if (.not. associated(loop)) then - write(log_scratch_space, '(A)') & + write(6, '(A)') & 'Instance ' // trim(profile_name) // ' of ' // & 'bar_nml_type ' // & 'not found in configuration.' - call log_event(log_scratch_space, log_level_error) + flush(6) + stop end if ! Otherwise 'cast' to a bar_namelist_type @@ -321,11 +324,12 @@ function pot_list(self, profile_name) result(pot_nml_obj) ! reached without finding the namelist, fail with ! an error. if (.not. associated(loop)) then - write(log_scratch_space, '(A)') & + write(6, '(A)') & 'Instance ' // trim(profile_name) // ' of ' // & 'pot_nml_type ' // & 'not found in configuration.' - call log_event(log_scratch_space, log_level_error) + flush(6) + stop end if ! Otherwise 'cast' to a pot_namelist_type diff --git a/infrastructure/build/tools/configurator/tests/configuration_loader/content_mod.f90 b/infrastructure/build/tools/configurator/tests/configuration_loader/content_mod.f90 index 2a4164c97..9f6588cad 100644 --- a/infrastructure/build/tools/configurator/tests/configuration_loader/content_mod.f90 +++ b/infrastructure/build/tools/configurator/tests/configuration_loader/content_mod.f90 @@ -9,7 +9,6 @@ module content_mod use constants_mod, only : i_def, l_def, str_def, str_max_filename use lfric_mpi_mod, only : global_mpi - use log_mod, only : log_scratch_space, log_event, LOG_LEVEL_ERROR use namelist_collection_mod, only: namelist_collection_type use namelist_mod, only: namelist_type @@ -57,10 +56,11 @@ subroutine read_configuration( filename, configuration, config ) integer(i_def) :: unit if (.not. present(configuration) .and. .not. present(config)) then - write(log_scratch_space,'(A)') & - 'At least one optional argument must be provided for ' //& - 'read_configuration.' - call log_event(log_scratch_space, log_level_error) + write(6,'(A)') & + 'At least one optional argument must ' //& + 'be provided for read_configuration.' + flush(6) + stop end if local_rank = global_mpi%get_comm_rank() @@ -167,17 +167,19 @@ function ensure_configuration( names, success_mask ) logical(l_def), optional, intent(out) :: success_mask(:) logical(l_def) :: ensure_configuration - integer(i_def) :: i - logical :: configuration_found = .True. + integer(i_def) :: i + logical :: configuration_found = .true. if (present(success_mask) & .and. (size(success_mask, 1) /= size(names, 1))) then - call log_event( 'Arguments "names" and "success_mask" to function' & - // '"ensure_configuration" are different shapes', & - LOG_LEVEL_ERROR ) + write(6, '(A)') & + 'Arguments "names" and "success_mask" to function' //& + '"ensure_configuration" are different shapes.' + flush(6) + stop end if - ensure_configuration = .True. + ensure_configuration = .true. name_loop: do i = 1, size(names) select case(trim( names(i) )) @@ -185,10 +187,11 @@ function ensure_configuration( names, success_mask ) configuration_found = foo_is_loaded() case default - write( log_scratch_space, '(A)' ) & - 'Tried to ensure unrecognised namelist "'// & + write(6, '(A)') & + 'Tried to ensure unrecognised namelist "' //& trim(names(i))//'" was loaded.' - call log_event( log_scratch_space, LOG_LEVEL_ERROR ) + flush(6) + stop end select ensure_configuration = ensure_configuration .and. configuration_found @@ -254,17 +257,19 @@ subroutine read_configuration_namelists( unit, local_rank, & end if else - write( log_scratch_space, '(A)' ) & - 'Namelist "'//trim(namelists(i))// & + write(6, '(A)') & + 'Namelist "'//trim(namelists(i)) //& '" can not be read. Too many instances?' - call log_event( log_scratch_space, LOG_LEVEL_ERROR ) + flush(6) + stop end if case default - write( log_scratch_space, '(A)' ) & - 'Unrecognised namelist "'//trim(namelists(i))// & + write(6, '(A)') & + 'Unrecognised namelist "'//trim(namelists(i)) //& '" found in file '//trim(filename)//'.' - call log_event( log_scratch_space, LOG_LEVEL_ERROR ) + flush(6) + stop end select end do ! Namelists diff --git a/mesh_tools/source/cubedsphere_mesh_generator.f90 b/mesh_tools/source/cubedsphere_mesh_generator.f90 index 6447f856b..7f6f70045 100644 --- a/mesh_tools/source/cubedsphere_mesh_generator.f90 +++ b/mesh_tools/source/cubedsphere_mesh_generator.f90 @@ -40,8 +40,6 @@ program cubedsphere_mesh_generator log_scratch_space, log_level_info, & log_level_error, log_level_warning - use namelist_collection_mod, only: namelist_collection_type - use ncdf_quad_mod, only: ncdf_quad_type use omp_lib, only: omp_get_thread_num use partition_mod, only: partition_type, & @@ -135,7 +133,6 @@ program cubedsphere_mesh_generator integer(i_def) :: i, j, k, l, n_voids type(config_type), save :: config - type(namelist_collection_type), save :: configuration ! Configuration variables to obtain from configuration. character(str_max_filename) :: mesh_file_prefix @@ -194,12 +191,9 @@ program cubedsphere_mesh_generator local_rank = global_mpi%get_comm_rank() call initialise_logging( communicator%get_comm_mpi_val(), 'CubeGen' ) - call configuration%initialise( 'CubeGen', table_len=10 ) call config%initialise( 'CubeGen' ) - call read_configuration( filename, & - configuration=configuration, & - config=config ) + call read_configuration( filename, config=config ) deallocate( filename ) diff --git a/mesh_tools/source/planar_mesh_generator.f90 b/mesh_tools/source/planar_mesh_generator.f90 index 6ac208821..80bd9f604 100644 --- a/mesh_tools/source/planar_mesh_generator.f90 +++ b/mesh_tools/source/planar_mesh_generator.f90 @@ -41,7 +41,6 @@ program planar_mesh_generator log_scratch_space, LOG_LEVEL_INFO, & LOG_LEVEL_ERROR - use namelist_collection_mod, only: namelist_collection_type use ncdf_quad_mod, only: ncdf_quad_type use omp_lib, only: omp_get_thread_num use partition_mod, only: partition_type, partitioner_interface @@ -138,7 +137,6 @@ program planar_mesh_generator ! Configuration variables type(config_type), save :: config - type(namelist_collection_type), save :: configuration character(str_max_filename) :: mesh_file_prefix @@ -211,12 +209,9 @@ program planar_mesh_generator local_rank = global_mpi%get_comm_rank() call initialise_logging( communicator%get_comm_mpi_val(), "PlanarGen" ) - call configuration%initialise( 'PlanarGen', table_len=10 ) call config%initialise( 'PlanarGen' ) - call read_configuration( filename, & - configuration=configuration, & - config=config ) + call read_configuration( filename, config=config ) deallocate( filename )