MONC
checkpointcommon.F90
Go to the documentation of this file.
1 
3 #ifndef TEST_MODE
4  use netcdf, only : nf90_ebaddim, nf90_enotatt, nf90_enotvar, nf90_noerr, nf90_strerror
5 #else
7 #endif
8  use logging_mod, only : log_error, log_log
9  implicit none
10 
11  character(len=*), parameter :: x_dim_key = "x", & !< X dimension/variable key
12  y_dim_key="y", &
13  z_dim_key="z", &
14  zn_dim_key="zn", &
15  q_dim_key="q", &
16  u_key = "u_nogal", &
17  v_key = "v_nogal", &
18  w_key = "w", &
19  q_key = "q", &
20  zu_key = "zu", &
21  zv_key = "zv", &
22  zw_key = "zw" , &
23  zq_key = "zq", &
24  x_key = "x", &
25  y_key = "y", &
26  z_key = "z", &
27  zn_key="zn", &
28  th_key = "th", &
29  zth_key = "zth", &
30  p_key = "p", &
31  timestep="timestep", &
32  time_key="time",&
33  dtm_key="dtm",&
34  dtm_new_key="dtm_new",&
35  absolute_new_dtm_key="absolute_new_dtm",&
36  ugal="ugal",&
37  vgal="vgal",&
38  empty_dim_key="empty_dim", &
39  key_value_pair_key="kvp", &
40  options_dim_key="number_options", &
41  options_key="options_database", &
42  string_dim_key="string",&
43  title_attribute_key="title",&
44  created_attribute_key="created",&
45  nqfields="nqfields", &
46  q_indices_dim_key="active_q_indicies", &
47  q_indices_key="q_indicies", &
48  x_resolution="x_resolution", &
49  y_resolution="y_resolution", &
50  x_top="x_top", &
51  y_top="y_top", &
52  x_bottom="x_bottom", &
53  y_bottom="y_bottom", &
54  q_field_anonymous_name="q_qfield", &
55  zq_field_anonymous_name="zq_qfield", &
56  thref="thref", &
57  olubar="olubar", &
58  olzubar="olzubar", &
59  olvbar="olvbar", &
60  olzvbar="olzvbar", &
61  olthbar="olthbar", &
62  olzthbar="olzthbar", &
63  olqbar="olqbar", &
64  olqbar_anonymous_name="olqbar_qfield", &
65  olzqbar="olzqbar", &
66  olzqbar_anonymous_name="olzqbar_qfield", &
67  rad_last_time_key="rad_last_time", &
68  sth_lw_key="sth_lw", &
69  sth_sw_key="sth_sw", &
70  wup='w_up', &
71  wdwn='w_dwn'
72 
73  integer, parameter :: max_string_length = 100
74 
75 contains
76 
81  subroutine check_status(status, found_flag)
82  integer, intent(in) :: status
83  logical, intent(out), optional :: found_flag
84 
85  if (present(found_flag)) then
86  found_flag = status /= nf90_ebaddim .and. status /= nf90_enotatt .and. status /= nf90_enotvar
87  if (.not. found_flag) return
88  end if
89 
90  if (status /= nf90_noerr) then
91  call log_log(log_error, "NetCDF returned error code of "//trim(nf90_strerror(status)))
92  end if
93  end subroutine check_status
94 
98  subroutine remove_null_terminator_from_string(net_cdf_string)
99  character(len=*), intent(inout) :: net_cdf_string
100  integer :: i
101  do i=1,len(net_cdf_string)
102  if (iachar(net_cdf_string(i:i)) == 0) then
103  net_cdf_string(i:len(net_cdf_string)) = ' '
104  exit
105  end if
106  end do
108 end module checkpointer_common_mod
logging_mod::log_error
integer, parameter, public log_error
Only log ERROR messages.
Definition: logging.F90:11
checkpointer_common_mod::olubar
character(len= *), parameter olubar
Definition: checkpointcommon.F90:11
checkpointer_common_mod::remove_null_terminator_from_string
subroutine remove_null_terminator_from_string(net_cdf_string)
Removes NetCDF C style null termination of string. This is placed right at the end,...
Definition: checkpointcommon.F90:99
checkpointer_common_mod::p_key
character(len= *), parameter p_key
Pressure variable NetCDF key.
Definition: checkpointcommon.F90:11
checkpointer_common_mod::q_key
character(len= *), parameter q_key
Q variable NetCDF key.
Definition: checkpointcommon.F90:11
checkpointer_common_mod::empty_dim_key
character(len= *), parameter empty_dim_key
Empty dimension key.
Definition: checkpointcommon.F90:11
checkpointer_common_mod::zn_key
character(len= *), parameter zn_key
Definition: checkpointcommon.F90:11
checkpointer_common_mod::y_dim_key
character(len= *), parameter y_dim_key
Y dimension/variable key.
Definition: checkpointcommon.F90:11
checkpointer_common_mod::u_key
character(len= *), parameter u_key
U variable NetCDF key.
Definition: checkpointcommon.F90:11
checkpointer_common_mod::thref
character(len= *), parameter thref
Definition: checkpointcommon.F90:11
checkpointer_common_mod::key_value_pair_key
character(len= *), parameter key_value_pair_key
Key-value pair dimension key.
Definition: checkpointcommon.F90:11
checkpointer_common_mod::rad_last_time_key
character(len= *), parameter rad_last_time_key
Definition: checkpointcommon.F90:11
checkpointer_common_mod::zv_key
character(len= *), parameter zv_key
Definition: checkpointcommon.F90:11
checkpointer_common_mod::y_top
character(len= *), parameter y_top
Definition: checkpointcommon.F90:11
checkpointer_common_mod::olzqbar_anonymous_name
character(len= *), parameter olzqbar_anonymous_name
Definition: checkpointcommon.F90:11
checkpointer_common_mod::zth_key
character(len= *), parameter zth_key
Definition: checkpointcommon.F90:11
checkpointer_common_mod::created_attribute_key
character(len= *), parameter created_attribute_key
Definition: checkpointcommon.F90:11
checkpointer_common_mod::max_string_length
integer, parameter max_string_length
Maximum string length (stored size)
Definition: checkpointcommon.F90:73
dummy_netcdf_mod::nf90_enotvar
integer, parameter nf90_enotvar
Definition: dummy_netcdf.F90:24
checkpointer_common_mod::x_key
character(len= *), parameter x_key
Definition: checkpointcommon.F90:11
logging_mod::log_log
subroutine, public log_log(level, message, str)
Logs a message at the specified level. If the level is above the current level then the message is ig...
Definition: logging.F90:75
checkpointer_common_mod::v_key
character(len= *), parameter v_key
V variable NetCDF key.
Definition: checkpointcommon.F90:11
checkpointer_common_mod::zq_field_anonymous_name
character(len= *), parameter zq_field_anonymous_name
Definition: checkpointcommon.F90:11
checkpointer_common_mod::time_key
character(len= *), parameter time_key
Definition: checkpointcommon.F90:11
checkpointer_common_mod::absolute_new_dtm_key
character(len= *), parameter absolute_new_dtm_key
Definition: checkpointcommon.F90:11
checkpointer_common_mod::timestep
character(len= *), parameter timestep
Timestep NetCDF key.
Definition: checkpointcommon.F90:11
checkpointer_common_mod::olzvbar
character(len= *), parameter olzvbar
Definition: checkpointcommon.F90:11
checkpointer_common_mod::zu_key
character(len= *), parameter zu_key
Definition: checkpointcommon.F90:11
checkpointer_common_mod::sth_lw_key
character(len= *), parameter sth_lw_key
Definition: checkpointcommon.F90:11
checkpointer_common_mod::z_dim_key
character(len= *), parameter z_dim_key
Z dimension/variable key.
Definition: checkpointcommon.F90:11
checkpointer_common_mod::options_dim_key
character(len= *), parameter options_dim_key
Options dimension key.
Definition: checkpointcommon.F90:11
dummy_netcdf_mod::nf90_ebaddim
integer, parameter nf90_ebaddim
Definition: dummy_netcdf.F90:24
dummy_netcdf_mod::nf90_strerror
character(len=10) function nf90_strerror(status)
Definition: dummy_netcdf.F90:360
checkpointer_common_mod::wup
character(len= *), parameter wup
Definition: checkpointcommon.F90:11
checkpointer_common_mod::x_bottom
character(len= *), parameter x_bottom
Definition: checkpointcommon.F90:11
checkpointer_common_mod::olvbar
character(len= *), parameter olvbar
Definition: checkpointcommon.F90:11
dummy_netcdf_mod
Definition: dummy_netcdf.F90:4
checkpointer_common_mod::q_indices_key
character(len= *), parameter q_indices_key
Definition: checkpointcommon.F90:11
checkpointer_common_mod::w_key
character(len= *), parameter w_key
W variable NetCDF key.
Definition: checkpointcommon.F90:11
checkpointer_common_mod::title_attribute_key
character(len= *), parameter title_attribute_key
Definition: checkpointcommon.F90:11
checkpointer_common_mod::dtm_key
character(len= *), parameter dtm_key
Definition: checkpointcommon.F90:11
checkpointer_common_mod::check_status
subroutine check_status(status, found_flag)
Will check a NetCDF status and write to log_log error any decoded statuses. Can be used to decode whe...
Definition: checkpointcommon.F90:82
checkpointer_common_mod::z_key
character(len= *), parameter z_key
Definition: checkpointcommon.F90:11
dummy_netcdf_mod::nf90_noerr
integer, parameter nf90_noerr
Definition: dummy_netcdf.F90:24
checkpointer_common_mod::y_bottom
character(len= *), parameter y_bottom
Definition: checkpointcommon.F90:11
checkpointer_common_mod::string_dim_key
character(len= *), parameter string_dim_key
String dimension key.
Definition: checkpointcommon.F90:11
checkpointer_common_mod::q_field_anonymous_name
character(len= *), parameter q_field_anonymous_name
Definition: checkpointcommon.F90:11
checkpointer_common_mod::olzubar
character(len= *), parameter olzubar
Definition: checkpointcommon.F90:11
checkpointer_common_mod
Common checkpoint functionality which is used by reader and writers to NetCDF checkpoints.
Definition: checkpointcommon.F90:2
checkpointer_common_mod::olzqbar
character(len= *), parameter olzqbar
Definition: checkpointcommon.F90:11
checkpointer_common_mod::q_dim_key
character(len= *), parameter q_dim_key
Definition: checkpointcommon.F90:11
checkpointer_common_mod::olthbar
character(len= *), parameter olthbar
Definition: checkpointcommon.F90:11
checkpointer_common_mod::dtm_new_key
character(len= *), parameter dtm_new_key
Definition: checkpointcommon.F90:11
checkpointer_common_mod::zn_dim_key
character(len= *), parameter zn_dim_key
Definition: checkpointcommon.F90:11
checkpointer_common_mod::sth_sw_key
character(len= *), parameter sth_sw_key
Definition: checkpointcommon.F90:11
checkpointer_common_mod::x_resolution
character(len= *), parameter x_resolution
Definition: checkpointcommon.F90:11
logging_mod
Logging utility.
Definition: logging.F90:2
checkpointer_common_mod::q_indices_dim_key
character(len= *), parameter q_indices_dim_key
Definition: checkpointcommon.F90:11
dummy_netcdf_mod::nf90_enotatt
integer, parameter nf90_enotatt
Definition: dummy_netcdf.F90:24
checkpointer_common_mod::olqbar_anonymous_name
character(len= *), parameter olqbar_anonymous_name
Definition: checkpointcommon.F90:11
checkpointer_common_mod::zq_key
character(len= *), parameter zq_key
Definition: checkpointcommon.F90:11
checkpointer_common_mod::th_key
character(len= *), parameter th_key
Theta variable NetCDF key.
Definition: checkpointcommon.F90:11
checkpointer_common_mod::x_dim_key
character(len= *), parameter x_dim_key
X dimension/variable key.
Definition: checkpointcommon.F90:11
checkpointer_common_mod::nqfields
character(len= *), parameter nqfields
Definition: checkpointcommon.F90:11
checkpointer_common_mod::y_resolution
character(len= *), parameter y_resolution
Definition: checkpointcommon.F90:11
checkpointer_common_mod::wdwn
character(len= *), parameter wdwn
Definition: checkpointcommon.F90:11
checkpointer_common_mod::zw_key
character(len= *), parameter zw_key
Definition: checkpointcommon.F90:11
checkpointer_common_mod::olqbar
character(len= *), parameter olqbar
Definition: checkpointcommon.F90:11
checkpointer_common_mod::vgal
character(len= *), parameter vgal
Definition: checkpointcommon.F90:11
checkpointer_common_mod::olzthbar
character(len= *), parameter olzthbar
Definition: checkpointcommon.F90:11
checkpointer_common_mod::ugal
character(len= *), parameter ugal
Definition: checkpointcommon.F90:11
checkpointer_common_mod::options_key
character(len= *), parameter options_key
Options variable key.
Definition: checkpointcommon.F90:11
checkpointer_common_mod::x_top
character(len= *), parameter x_top
Definition: checkpointcommon.F90:11
checkpointer_common_mod::y_key
character(len= *), parameter y_key
Definition: checkpointcommon.F90:11