MESH, PROBLEMS: Move procedure pointer to MESH.

This inverts the dependencies allowing for initiating module MESH
from PROBLEMS.

Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
Grzegorz Kowal 2021-11-16 14:02:25 -03:00
parent 384e1ab3d6
commit 40f3e24631
2 changed files with 20 additions and 38 deletions

View File

@ -28,18 +28,12 @@
module mesh
#ifdef PROFILE
! import external subroutines
!
use timers, only : set_timer, start_timer, stop_timer
#endif /* PROFILE */
! module variables are not implicit by default
!
implicit none
#ifdef PROFILE
! timer indices
!
integer , save :: imi, ims, img, imu, ima, imp, imr
#endif /* PROFILE */
@ -51,10 +45,23 @@ module mesh
end subroutine
end interface
! interfaces for the problem setup
!
abstract interface
subroutine setup_problem_iface(pdata)
use blocks, only : block_data
type(block_data), pointer, intent(inout) :: pdata
end subroutine
end interface
! pointer to the problem domain setup subroutine
!
procedure(setup_domain_iface) , pointer, save :: setup_domain => null()
! pointer to the problem initial setup subroutine
!
procedure(setup_problem_iface), pointer, save :: setup_problem => null()
! the handler of the mesh statistics file
!
integer, save :: funit = 11
@ -72,6 +79,7 @@ module mesh
public :: initialize_mesh, finalize_mesh, print_mesh
public :: generate_mesh, update_mesh
public :: redistribute_blocks, store_mesh_stats
public :: setup_problem
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!
@ -230,6 +238,8 @@ module mesh
status = 0
nullify(setup_problem)
if (master) close(funit)
call finalize_refinement(status)
@ -301,7 +311,6 @@ module mesh
use helpers , only : print_section
use iso_fortran_env, only : error_unit
use mpitools , only : master, nproc, nprocs, npmax, nodes, lprocs
use problems , only : setup_problem
use refinement , only : check_refinement_criterion
implicit none

View File

@ -32,46 +32,20 @@
module problems
#ifdef PROFILE
! include external procedures
!
use timers, only : set_timer, start_timer, stop_timer
#endif /* PROFILE */
! module variables are not implicit by default
!
implicit none
#ifdef PROFILE
! timer indices
!
integer, save :: imi, imu
#endif /* PROFILE */
! problem name
!
character(len=64), save :: problem_name = "none"
! interfaces for procedure pointers
!
abstract interface
subroutine setup_problem_iface(pdata)
use blocks, only : block_data
type(block_data), pointer, intent(inout) :: pdata
end subroutine
end interface
! pointer to the problem setup subroutine
!
procedure(setup_problem_iface), pointer, save :: setup_problem => null()
! by default everything is private
!
private
! declare public subroutines
!
public :: initialize_problems, finalize_problems
public :: setup_problem
public :: problem_name
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -102,6 +76,7 @@ module problems
!
subroutine initialize_problems(problem, rcount, verbose, status)
use mesh , only : setup_problem
use parameters , only : get_parameter
use user_problem, only : initialize_user_problem, setup_user_problem
@ -111,7 +86,7 @@ module problems
integer , intent(in) :: rcount
logical , intent(in) :: verbose
integer , intent(out) :: status
!
!-------------------------------------------------------------------------------
!
#ifdef PROFILE
@ -186,7 +161,7 @@ module problems
implicit none
integer, intent(out) :: status
!
!-------------------------------------------------------------------------------
!
#ifdef PROFILE
@ -195,8 +170,6 @@ module problems
status = 0
nullify(setup_problem)
call finalize_user_problem(status)
#ifdef PROFILE