Skip to content

Commit

Permalink
Introduced marbl%init subroutine
Browse files Browse the repository at this point in the history
If you are initializing via namelist and don't want to use marbl%put() or
marbl%get(), this routine runs all three stages of initialization in a single
call.

The init_from_namelist test uses it (so interface is different in the "no
namelist" test), and I also updated the stand-alone test suites so the MARBL
log ontains the subroutine names updated in the last commit rather than the old
subroutine names.
  • Loading branch information
mnlevy1981 committed Jul 13, 2017
1 parent 1a0b842 commit 6afefd0
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 33 deletions.
58 changes: 58 additions & 0 deletions src/marbl_interface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ module marbl_interface

contains

procedure, public :: init
procedure, public :: init_configuration
procedure, public :: init_parameters_and_tracers
procedure, public :: init_complete
Expand All @@ -134,6 +135,7 @@ module marbl_interface

end type marbl_interface_class

private :: init
private :: init_configuration
private :: init_parameters_and_tracers
private :: init_complete
Expand All @@ -150,6 +152,62 @@ module marbl_interface

!***********************************************************************

subroutine init(this, &
gcm_nl_buffer, &
gcm_num_levels, &
gcm_num_PAR_subcols, &
gcm_num_elements_surface_forcing, &
gcm_delta_z, &
gcm_zw, &
gcm_zt, &
marbl_tracer_cnt, &
lgcm_has_global_ops)


class(marbl_interface_class), intent(inout) :: this
character(len=*), intent(in) :: gcm_nl_buffer(:)
integer(int_kind), intent(in) :: gcm_num_levels
integer(int_kind), intent(in) :: gcm_num_PAR_subcols
integer(int_kind), intent(in) :: gcm_num_elements_surface_forcing
real(r8), intent(in) :: gcm_delta_z(gcm_num_levels) ! thickness of layer k
real(r8), intent(in) :: gcm_zw(gcm_num_levels) ! thickness of layer k
real(r8), intent(in) :: gcm_zt(gcm_num_levels) ! thickness of layer k
integer(int_kind), optional, intent(out) :: marbl_tracer_cnt
logical, optional, intent(in) :: lgcm_has_global_ops

character(len=*), parameter :: subname = 'marbl_interface:init'


call this%init_configuration(lgcm_has_global_ops=lgcm_has_global_ops, &
gcm_nl_buffer=gcm_nl_buffer)
if (this%StatusLog%labort_marbl) then
call this%StatusLog%log_error_trace('init_configuration', subname)
return
end if

call this%init_parameters_and_tracers(gcm_num_levels, &
gcm_num_PAR_subcols, &
gcm_num_elements_surface_forcing, &
gcm_delta_z, &
gcm_zw, &
gcm_zt, &
gcm_nl_buffer=gcm_nl_buffer, &
marbl_tracer_cnt=marbl_tracer_cnt)
if (this%StatusLog%labort_marbl) then
call this%StatusLog%log_error_trace('init_parameters_and_tracers', subname)
return
end if

call this%init_complete()
if (this%StatusLog%labort_marbl) then
call this%StatusLog%log_error_trace('init_complete', subname)
return
end if

end subroutine init

!***********************************************************************

subroutine init_configuration(this, &
lgcm_has_global_ops, &
gcm_nl_buffer)
Expand Down
7 changes: 3 additions & 4 deletions tests/driver_src/marbl_get_put_drv.F90
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ subroutine test(marbl_instance, marbl_status_log)
! Call marbl%config
call marbl_instance%init_configuration(lgcm_has_global_ops = .true.)
if (marbl_instance%StatusLog%labort_marbl) then
call marbl_instance%StatusLog%log_error_trace('marbl%config', subname)
call marbl_instance%StatusLog%log_error_trace('marbl%init_configuration', subname)
return
end if

Expand Down Expand Up @@ -75,7 +75,7 @@ subroutine test(marbl_instance, marbl_status_log)
gcm_zw = zw, &
gcm_zt = zt)
if (marbl_instance%StatusLog%labort_marbl) then
call marbl_instance%StatusLog%log_error_trace('marbl%init', subname)
call marbl_instance%StatusLog%log_error_trace('marbl%init_parameters_and_tracers', subname)
return
end if

Expand All @@ -98,8 +98,7 @@ subroutine test(marbl_instance, marbl_status_log)

call marbl_instance%init_complete()
if (marbl_instance%StatusLog%labort_marbl) then
call marbl_instance%StatusLog%log_error_trace( &
'marbl%complete_config_and_init', subname)
call marbl_instance%StatusLog%log_error_trace('marbl%init_complete', subname)
return
end if

Expand Down
32 changes: 7 additions & 25 deletions tests/driver_src/marbl_init_namelist_drv.F90
Original file line number Diff line number Diff line change
Expand Up @@ -33,38 +33,20 @@ subroutine test(marbl_instance, gcm_namelist, nt)
zt(k) = p5*(zw(k-1)+zw(k))
end do

! Call marbl%config
call marbl_instance%init_configuration(gcm_nl_buffer = gcm_namelist)
if (marbl_instance%StatusLog%labort_marbl) then
call marbl_instance%StatusLog%log_error_trace('marbl%config', subname)
return
end if

! Optional: call marbl_instance%configuration%put()

! Call marbl%init
call marbl_instance%init_parameters_and_tracers(gcm_num_levels = km, &
gcm_num_PAR_subcols = 1, &
gcm_num_elements_surface_forcing = 1, &
gcm_delta_z = delta_z, &
gcm_zw = zw, &
gcm_zt = zt, &
gcm_nl_buffer = gcm_namelist, &
call marbl_instance%init(gcm_nl_buffer = gcm_namelist, &
gcm_num_levels = km, &
gcm_num_PAR_subcols = 1, &
gcm_num_elements_surface_forcing = 1, &
gcm_delta_z = delta_z, &
gcm_zw = zw, &
gcm_zt = zt, &
marbl_tracer_cnt = nt)
if (marbl_instance%StatusLog%labort_marbl) then
call marbl_instance%StatusLog%log_error_trace('marbl%init', subname)
return
end if

! Optional: call marbl_instance%parameters%put()

call marbl_instance%init_complete()
if (marbl_instance%StatusLog%labort_marbl) then
call marbl_instance%StatusLog%log_error_trace( &
'marbl%complete_config_and_init', subname)
return
end if

! Shutdown
call marbl_instance%shutdown()
if (marbl_instance%StatusLog%labort_marbl) then
Expand Down
7 changes: 3 additions & 4 deletions tests/driver_src/marbl_init_no_namelist_drv.F90
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ subroutine test(marbl_instance)
! Call marbl%config
call marbl_instance%init_configuration()
if (marbl_instance%StatusLog%labort_marbl) then
call marbl_instance%StatusLog%log_error_trace('marbl%config', subname)
call marbl_instance%StatusLog%log_error_trace('marbl%init_configuration', subname)
return
end if

Expand All @@ -53,16 +53,15 @@ subroutine test(marbl_instance)
gcm_zw = zw, &
gcm_zt = zt)
if (marbl_instance%StatusLog%labort_marbl) then
call marbl_instance%StatusLog%log_error_trace('marbl%init', subname)
call marbl_instance%StatusLog%log_error_trace('marbl%init_parameters_and_tracers', subname)
return
end if

! Optional: call marbl_instance%parameters%put()

call marbl_instance%init_complete()
if (marbl_instance%StatusLog%labort_marbl) then
call marbl_instance%StatusLog%log_error_trace( &
'marbl%complete_config_and_init', subname)
call marbl_instance%StatusLog%log_error_trace('marbl%init_complete', subname)
return
end if

Expand Down

0 comments on commit 6afefd0

Please sign in to comment.