Skip to content

Commit

Permalink
#312 commit changes associated with the Reading branch and the new te…
Browse files Browse the repository at this point in the history
…st-harness set-up to the trunk

Merged into /main/trunk: /main/branches/pkg/adrianhill/r5986_vn1.0_part2@6199 cf. /main/trunk@5986


git-svn-id: https://code.metoffice.gov.uk/svn/monc/main/trunk@6205 0f676ef4-b20c-4647-9485-21614760d15f
  • Loading branch information
adrianhill committed Jan 18, 2019
1 parent d6d5eb0 commit d7d69b8
Show file tree
Hide file tree
Showing 170 changed files with 7,701 additions and 1,625 deletions.
35 changes: 30 additions & 5 deletions components/cfltest/src/cfltest.F90
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ module cfltest_mod
use monc_component_mod, only : component_descriptor_type
use state_mod, only : model_state_type, parallel_state_type
use collections_mod, only : map_type
use logging_mod, only : LOG_WARN, LOG_DEBUG, LOG_ERROR, log_log, log_get_logging_level
use logging_mod, only : LOG_WARN, LOG_DEBUG, LOG_ERROR, LOG_INFO, &
log_log, log_get_logging_level, log_newline
use conversions_mod, only : conv_to_string
use optionsdatabase_mod, only : options_get_integer, options_get_real
use optionsdatabase_mod, only : options_get_integer, options_get_real, options_get_logical
use grids_mod, only : Z_INDEX, Y_INDEX, X_INDEX
use mpi, only : MPI_MAX, MPI_MIN
implicit none
Expand All @@ -20,6 +21,8 @@ module cfltest_mod

!! Configuration options - all are optional and have default values
real(kind=DEFAULT_PRECISION) :: tollerance, cvismax, cvelmax, dtmmax, dtmmin, rincmax
logical l_monitor_cfl

public cfltest_get_descriptor
contains

Expand All @@ -45,6 +48,8 @@ subroutine initialisation_callback(current_state)
dtmmin=options_get_real(current_state%options_database, "cfl_dtmmin")
rincmax=options_get_real(current_state%options_database, "cfl_rincmax")

l_monitor_cfl = options_get_logical(current_state%options_database,"cfl_monitor")

allocate(current_state%abswmax(current_state%local_grid%local_domain_end_index(Z_INDEX)))
end subroutine initialisation_callback

Expand Down Expand Up @@ -79,21 +84,26 @@ subroutine timestep_callback(current_state)
end if
end if
end if
call update_dtm_based_on_absolute(current_state)
call update_dtm_based_on_absolute(current_state, cfl_number)
current_state%cvis=0.0_DEFAULT_PRECISION
end subroutine timestep_callback

!> Updates the (new) dtm value, which is actioned after time step completion, based upon the absolute value. This is incremented
!! towards the absolute if that is too large a step, and even if the absolute value has not been updated in this timestep,
!! this ratcheting will still occur if needed.
!! @param current_state The current model state
subroutine update_dtm_based_on_absolute(current_state)
subroutine update_dtm_based_on_absolute(current_state, cfl_number)
type(model_state_type), intent(inout), target :: current_state
real(kind=DEFAULT_PRECISION), intent(in) :: cfl_number

if (current_state%dtm .ne. current_state%absolute_new_dtm .and. &
(current_state%dtm .ne. dtmmax .or. current_state%absolute_new_dtm .lt. dtmmax)) then

current_state%update_dtm=.true.

current_state%dtm_new=min(current_state%dtm*(1.0_DEFAULT_PRECISION+rincmax), current_state%absolute_new_dtm, dtmmax)

!! --- Diagnostic Writing -----------------
if (current_state%parallel%my_rank==0) then
if (log_get_logging_level() .eq. LOG_DEBUG) then
call log_log(LOG_DEBUG, "dtm changed from "//trim(conv_to_string(current_state%dtm, 5))//" to "//&
Expand All @@ -103,7 +113,22 @@ subroutine update_dtm_based_on_absolute(current_state)
call log_log(LOG_ERROR, "Timestep too small, dtmnew="//trim(conv_to_string(current_state%dtm_new, 5))//&
" dtmmin="//trim(conv_to_string(dtmmin, 5)))
end if
end if
if (l_monitor_cfl) then
call log_log(LOG_INFO, " --- CFL Monitoring Information --- ")
call log_log(LOG_INFO, "dtm changed from "//trim(conv_to_string(current_state%dtm, 5))//" to "//&
trim(conv_to_string(current_state%dtm_new, 5)))
if (cfl_number .gt. 0.0) then
call log_log(LOG_INFO, "cfl_number : "//trim(conv_to_string(cfl_number))//" (change divisor)")
call log_log(LOG_INFO, "cvis : "//trim(conv_to_string(current_state%cvis)) )
call log_log(LOG_INFO, "cvel : "//trim(conv_to_string(current_state%cvel)) )
else
call log_log(LOG_INFO, "dtm change due to ratcheting only. Target dtm unchanged.")
end if
call log_log(LOG_INFO, "target dtm : "//trim(conv_to_string(current_state%absolute_new_dtm)) )
call log_newline()

end if ! l_monitor_cfl
end if ! Diagnostic Writing
end if
end subroutine update_dtm_based_on_absolute

Expand Down
4 changes: 3 additions & 1 deletion components/checkpointer/src/checkpointcommon.F90
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ module checkpointer_common_mod
OLZQBAR_ANONYMOUS_NAME="olzqbar_qfield", &
RAD_LAST_TIME_KEY="rad_last_time", &
STH_LW_KEY="sth_lw", &
STH_SW_KEY="sth_sw"
STH_SW_KEY="sth_sw", &
WUP='w_up', &
WDWN='w_dwn'

integer, parameter :: MAX_STRING_LENGTH = 100 !< Maximum string length (stored size)

Expand Down
23 changes: 22 additions & 1 deletion components/checkpointer/src/readcheckpoint.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ module checkpointer_read_checkpoint_mod
Z_KEY, ZN_KEY, NQFIELDS, UGAL, VGAL, TIME_KEY, TIMESTEP, CREATED_ATTRIBUTE_KEY, TITLE_ATTRIBUTE_KEY, ABSOLUTE_NEW_DTM_KEY, &
DTM_KEY, DTM_NEW_KEY, Q_INDICES_DIM_KEY, Q_INDICES_KEY, Q_FIELD_ANONYMOUS_NAME, ZQ_FIELD_ANONYMOUS_NAME, &
MAX_STRING_LENGTH, THREF, OLUBAR, OLZUBAR, OLVBAR, OLZVBAR, OLTHBAR, OLZTHBAR, OLQBAR, OLZQBAR, OLQBAR_ANONYMOUS_NAME, &
OLZQBAR_ANONYMOUS_NAME, RAD_LAST_TIME_KEY, STH_LW_KEY, STH_SW_KEY, check_status, remove_null_terminator_from_string
OLZQBAR_ANONYMOUS_NAME, RAD_LAST_TIME_KEY, STH_LW_KEY, STH_SW_KEY, check_status, remove_null_terminator_from_string, &
WUP, WDWN
use datadefn_mod, only : DEFAULT_PRECISION
use q_indices_mod, only : q_metadata_type, set_q_index, get_q_index, get_indices_descriptor, standard_q_names
implicit none
Expand Down Expand Up @@ -56,6 +57,7 @@ subroutine read_checkpoint_file(current_state, filename)
call load_all_fields(current_state, ncid)
call initalise_source_and_sav_fields(current_state)
call load_mean_profiles(current_state, ncid, z_dim)
call load_pdf_profiles(current_state, ncid, z_dim)
call check_status(nf90_close(ncid))

if (current_state%number_q_fields .gt. 0) then
Expand Down Expand Up @@ -482,6 +484,25 @@ subroutine load_mean_profiles(current_state, ncid, z_dim_id)
end if
end subroutine load_mean_profiles


subroutine load_pdf_profiles(current_state, ncid, z_dim_id)
type(model_state_type), intent(inout) :: current_state
integer, intent(in) :: ncid, z_dim_id

integer :: z_size, i

call check_status(nf90_inquire_dimension(ncid, z_dim_id, len=z_size))
if (does_field_exist(ncid, WUP)) then
allocate(current_state%global_grid%configuration%vertical%w_up(z_size))
call read_single_variable(ncid, WUP, real_data_1d_double=current_state%global_grid%configuration%vertical%w_up)
end if
if (does_field_exist(ncid, WDWN)) then
allocate(current_state%global_grid%configuration%vertical%w_dwn(z_size))
call read_single_variable(ncid, WDWN, real_data_1d_double=current_state%global_grid%configuration%vertical%w_dwn)
end if
end subroutine load_pdf_profiles


!> Defines the vertical levels of the grid. This is both the grid points and corresponding height
!! for each point in metres
!! @param current_state The current model state_mod
Expand Down
39 changes: 38 additions & 1 deletion components/checkpointer/src/writecheckpoint.F90
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module checkpointer_write_checkpoint_mod
ZU_KEY, ZV_KEY, ZW_KEY, X_KEY, Y_KEY, Z_KEY, ZN_KEY, NQFIELDS, UGAL, VGAL, TIME_KEY, TIMESTEP, MAX_STRING_LENGTH, &
CREATED_ATTRIBUTE_KEY, TITLE_ATTRIBUTE_KEY, ABSOLUTE_NEW_DTM_KEY, DTM_KEY, DTM_NEW_KEY, Q_INDICES_KEY, &
Q_INDICES_DIM_KEY, X_RESOLUTION, Y_RESOLUTION,X_TOP, Y_TOP, X_BOTTOM, Y_BOTTOM, THREF, OLUBAR, OLZUBAR, OLVBAR, &
OLZVBAR, OLTHBAR, OLZTHBAR, OLQBAR, OLZQBAR, check_status
OLZVBAR, OLTHBAR, OLZTHBAR, OLQBAR, OLZQBAR, check_status, WUP, WDWN
use datadefn_mod, only : DEFAULT_PRECISION, SINGLE_PRECISION, DOUBLE_PRECISION, STRING_LENGTH
use q_indices_mod, only : q_metadata_type, get_max_number_q_indices, get_indices_descriptor, get_number_active_q_indices
use mpi, only : MPI_INFO_NULL
Expand Down Expand Up @@ -85,6 +85,10 @@ subroutine write_checkpoint_file(current_state, filename)
ugal_id, vgal_id, number_q_fields_id, dtm_id, dtm_new_id, absolute_new_dtm_id)
end if

!> writeout pdf fields in checkpoint file
call define_pdf_fields(current_state, ncid)
if (current_state%parallel%my_rank==0) call write_out_pdf_fields(ncid, current_state%global_grid)

call check_status(nf90_close(ncid))
end subroutine write_checkpoint_file

Expand Down Expand Up @@ -650,4 +654,37 @@ subroutine define_velocity_variable(ncid, multi_process, dimone, dimtwo, dimthre
end if
call check_status(nf90_put_att(ncid, field_id, "units", "m/s"))
end subroutine define_velocity_variable

subroutine define_pdf_fields(current_state, ncid)
type(model_state_type), intent(inout) :: current_state
integer, intent(in) :: ncid

integer :: var_id, z_dim_id

call check_status(nf90_inq_dimid(ncid, Z_DIM_KEY, z_dim_id))

if (allocated(current_state%global_grid%configuration%vertical%w_up)) then
call check_status(nf90_def_var(ncid, WUP, NF90_DOUBLE, z_dim_id, var_id))
end if
if (allocated(current_state%global_grid%configuration%vertical%w_dwn)) then
call check_status(nf90_def_var(ncid, WDWN, NF90_DOUBLE, z_dim_id, var_id))
end if
end subroutine define_pdf_fields

subroutine write_out_pdf_fields(ncid, grid)
integer, intent(in) :: ncid
type(global_grid_type), intent(in) :: grid

integer :: var_id

if (allocated(grid%configuration%vertical%w_up)) then
call check_status(nf90_inq_varid(ncid, WUP, var_id))
call check_status(nf90_put_var(ncid, var_id, grid%configuration%vertical%w_up))
end if
if (allocated(grid%configuration%vertical%w_dwn)) then
call check_status(nf90_inq_varid(ncid, WDWN, var_id))
call check_status(nf90_put_var(ncid, var_id, grid%configuration%vertical%w_dwn))
end if
end subroutine write_out_pdf_fields

end module checkpointer_write_checkpoint_mod
3 changes: 3 additions & 0 deletions components/componentheaders.static
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ use lateral_bcs_mod, only : lateral_bcs_get_descriptor
use casim_mod, only : casim_get_descriptor
use casim_profile_dgs_mod, only: casim_profile_dgs_get_descriptor
use socrates_couple_mod, only : socrates_couple_get_descriptor
use conditional_diagnostics_column_mod, only : conditional_diagnostics_column_get_descriptor
use conditional_diagnostics_whole_mod, only : conditional_diagnostics_whole_get_descriptor
use pdf_analysis_mod, only : pdf_analysis_get_descriptor
3 changes: 3 additions & 0 deletions components/componentregistrations.static
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ call add_component(component_descriptions, lateral_bcs_get_descriptor())
call add_component(component_descriptions, casim_get_descriptor())
call add_component(component_descriptions, casim_profile_dgs_get_descriptor())
call add_component(component_descriptions, socrates_couple_get_descriptor())
call add_component(component_descriptions, conditional_diagnostics_column_get_descriptor())
call add_component(component_descriptions, conditional_diagnostics_whole_get_descriptor())
call add_component(component_descriptions, pdf_analysis_get_descriptor())
14 changes: 14 additions & 0 deletions components/conditional_diagnostics_column/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
SRCSF = src/conditional_diagnostics_column.F90

BUILDDIR=build
COREDIR=../../model_core/build
FFLAGS=-I $(BUILDDIR) -I $(COREDIR) $(COMPILERFFLAGS)
OBJS = $(patsubst %.F90,$(BUILDDIR)/%.o,$(SRCSF))

all: create-build-dirs $(OBJS)

create-build-dirs:
mkdir -p $(BUILDDIR)

$(OBJS) : $(BUILDDIR)/%.o : %.F90
$(FTN) $(OPT) $(FFLAGS) $< -o $(BUILDDIR)/$(notdir $@)
Loading

0 comments on commit d7d69b8

Please sign in to comment.