52 USE constants_mod,
ONLY: seconds_per_hour, seconds_per_minute
59 USE netcdf,
ONLY: nf_fill_real => nf90_fill_real
67 integer,
parameter :: diag_null = -999
68 character(len=1),
parameter :: diag_null_string =
" "
69 integer,
parameter :: diag_not_found = -1
70 integer,
parameter :: diag_not_registered = 0
71 integer,
parameter :: diag_registered_id = 10
74 integer,
parameter :: daily = 24
75 integer,
parameter :: diurnal = 2
76 integer,
parameter :: yearly = 12
77 integer,
parameter :: no_diag_averaging = 0
78 integer,
parameter :: instantaneous = 0
79 integer,
parameter :: three_hourly = 3
80 integer,
parameter :: six_hourly = 6
84 integer,
parameter ::
r8 = 8
85 integer,
parameter :: r4 = 4
86 integer,
parameter :: i8 = -8
87 integer,
parameter :: i4 = -4
89 integer,
parameter :: null_type_int = -999
91 INTEGER,
PARAMETER :: diag_other = 0
92 INTEGER,
PARAMETER :: diag_ocean = 1
93 INTEGER,
PARAMETER :: diag_all = 2
94 INTEGER,
PARAMETER :: very_large_file_freq = 100000
95 INTEGER,
PARAMETER :: very_large_axis_length = 10000
96 INTEGER,
PARAMETER :: every_time = 0
97 INTEGER,
PARAMETER :: end_of_run = -1
98 INTEGER,
PARAMETER :: diag_seconds = 1, diag_minutes = 2, diag_hours = 3
99 INTEGER,
PARAMETER :: diag_days = 4, diag_months = 5, diag_years = 6
100 INTEGER,
PARAMETER :: max_subaxes = 10
113 INTEGER,
PARAMETER :: latlon_gridtype = 1
114 INTEGER,
PARAMETER :: index_gridtype = 2
115 INTEGER,
PARAMETER :: null_gridtype = diag_null
137 REAL,
DIMENSION(3) :: start
138 REAL,
DIMENSION(3) :: end
139 INTEGER,
DIMENSION(3) :: l_start_indx
140 INTEGER,
DIMENSION(3) :: l_end_indx
141 INTEGER,
DIMENSION(3) :: subaxes
147 TYPE(domain2d) :: Domain
148 TYPE(domainUG) :: DomainU
149 REAL :: miss, miss_pack
150 LOGICAL :: miss_present, miss_pack_present
151 INTEGER :: tile_count
152 character(len=128) :: fieldname
161 CHARACTER(len=128) :: name
162 CHARACTER(len=1280) :: catt
163 REAL,
allocatable,
DIMENSION(:) :: fatt
164 INTEGER,
allocatable,
DIMENSION(:) :: iatt
183 CHARACTER(len=FMS_FILE_LEN) :: name
184 CHARACTER(len=128) :: long_name
185 INTEGER,
DIMENSION(max_fields_per_file) :: fields
186 INTEGER :: num_fields
187 INTEGER :: output_freq
188 INTEGER :: output_units
190 INTEGER :: time_units
192 INTEGER :: bytes_written
193 INTEGER :: time_axis_id, time_bounds_id
194 INTEGER :: new_file_freq
195 INTEGER :: new_file_freq_units
197 INTEGER :: duration_units
198 INTEGER :: tile_count
204 TYPE(
diag_fieldtype):: f_avg_start, f_avg_end, f_avg_nitems, f_bounds
206 INTEGER :: num_attributes
209 logical(I4_KIND) :: use_domainug = .false.
210 logical(I4_KIND) :: use_domain2d = .false.
213 logical,
allocatable :: is_time_axis_registered
215 real :: rtime_current
216 integer :: time_index
217 CHARACTER(len=10) :: filename_time_bounds
223 CHARACTER(len=128) :: module_name, field_name, long_name, units
224 CHARACTER(len=256) :: standard_name
225 CHARACTER(len=64) :: interp_method
226 INTEGER,
DIMENSION(3) :: axes
228 LOGICAL :: missing_value_present, range_present
229 REAL :: missing_value
230 REAL,
DIMENSION(2) :: range
231 INTEGER,
allocatable,
dimension(:) :: output_fields
232 INTEGER :: num_output_fields
233 INTEGER,
DIMENSION(3) :: size
234 LOGICAL :: static, register, mask_variant, local
235 INTEGER :: numthreads
236 INTEGER :: active_omp_level
237 INTEGER :: tile_count
240 LOGICAL :: issued_mask_ignore_warning
250 INTEGER :: input_field
251 INTEGER :: output_file
252 CHARACTER(len=128) :: output_name
262 CHARACTER(len=50) :: time_method
264 REAL,
allocatable,
DIMENSION(:,:,:,:) :: buffer
266 REAL,
allocatable,
DIMENSION(:,:,:,:) :: counter
273 REAL,
allocatable,
DIMENSION(:) :: count_0d
279 INTEGER,
allocatable,
dimension(:) :: num_elements
286 TYPE(
time_type) :: last_output, next_output, next_next_output
288 INTEGER,
DIMENSION(4) :: axes
289 INTEGER :: num_axes, total_elements, region_elements
290 INTEGER :: n_diurnal_samples
292 LOGICAL :: local_output, need_compute, phys_window, written_once
293 LOGICAL :: reduced_k_range
295 TYPE(
time_type) :: time_of_prev_field_data
296 TYPE(
diag_atttype),
allocatable,
dimension(:) :: attributes
297 INTEGER :: num_attributes
300 logical :: reduced_k_unstruct = .false.
307 CHARACTER(len=128) :: name
308 CHARACTER(len=256) :: units, long_name
309 CHARACTER(len=1) :: cart_name
310 REAL,
DIMENSION(:),
POINTER :: diag_type_data
311 INTEGER,
DIMENSION(MAX_SUBAXES) :: start
312 INTEGER,
DIMENSION(MAX_SUBAXES) :: end
313 CHARACTER(len=128),
DIMENSION(MAX_SUBAXES) :: subaxis_name
314 INTEGER :: length, direction, edges, set, shift
315 TYPE(domain1d) :: Domain
316 TYPE(domain2d) :: Domain2
317 TYPE(domain2d),
dimension(MAX_SUBAXES) :: subaxis_domain2
318 type(domainUG) :: DomainUG
319 CHARACTER(len=128) :: aux, req
320 INTEGER :: tile_count
322 INTEGER :: num_attributes
323 INTEGER :: domain_position
328 CHARACTER(len=128) :: grid_type=
'regular'
329 CHARACTER(len=128) :: tile_name=
'N/A'
335 class(*),
allocatable :: att_value(:)
336 character(len=:),
allocatable :: att_name
342 #include<file_version.h>
351 INTEGER :: null_axis_id
354 LOGICAL :: append_pelist_name = .false.
355 LOGICAL :: mix_snapshot_average_fields =.false.
362 LOGICAL :: do_diag_field_log = .false.
363 LOGICAL :: write_bytes_in_file = .false.
364 LOGICAL :: debug_diag_manager = .false.
371 INTEGER :: max_num_axis_sets = 25
413 REAL(r8_kind) :: empty = 0.0
414 REAL(r8_kind) :: max_value, min_value
422 INTEGER,
private :: base_year, base_month, base_day, base_hour, base_minute, base_second
423 CHARACTER(len = 256):: global_descriptor
426 TYPE(file_type),
SAVE,
ALLOCATABLE :: files(:)
430 type(fmsnetcdfunstructureddomainfile_t),
allocatable,
target :: fileobju(:)
431 type(fmsnetcdfdomainfile_t),
allocatable,
target :: fileobj(:)
432 type(fmsnetcdffile_t),
allocatable,
target :: fileobjnd(:)
438 LOGICAL :: first_send_data_call = .true.
440 INTEGER :: diag_log_unit
441 CHARACTER(len=10),
DIMENSION(6) :: time_unit_list = (/
'seconds ',
'minutes ',&
442 &
'hours ',
'days ',
'months ',
'years '/)
443 character(len=32) :: pelist_name
444 INTEGER :: oor_warning = warning
463 integer :: base_time_int(6)
465 CHARACTER(len=9) :: amonth
466 INTEGER :: stdlog_unit
471 base_year = base_time_int(1)
472 base_month = base_time_int(2)
473 base_day = base_time_int(3)
474 base_hour = base_time_int(4)
475 base_minute = base_time_int(5)
476 base_second = base_time_int(6)
480 IF ( base_year==0 .OR. base_month==0 .OR. base_day==0 )
THEN
481 call mpp_error(fatal,
'diag_data_mod::set_base_time'//&
482 &
'The base_year/month/day can not equal zero')
484 base_time =
set_date(base_year, base_month, base_day, base_hour, base_minute, base_second)
488 base_time =
set_time(nint(base_hour*seconds_per_hour)+nint(base_minute*seconds_per_minute)+base_second, &
498 IF (
mpp_pe() == mpp_root_pe() )
THEN
499 WRITE (stdlog_unit,
'("base date used = ",I4,1X,A,2I3,2(":",I2.2)," gmt")') base_year, trim(amonth), base_day, &
500 & base_hour, base_minute, base_second
566 character(len=*),
intent(in) :: att_name
567 class(*),
intent(in) :: att_value(:)
571 natt =
size(att_value)
572 this%att_name = att_name
573 select type (att_value)
574 type is (
integer(kind=i4_kind))
575 allocate(
integer(kind=i4_kind) :: this%att_value(natt))
576 this%att_value = att_value
577 type is (
integer(kind=i8_kind))
578 allocate(
integer(kind=i8_kind) :: this%att_value(natt))
579 this%att_value = att_value
580 type is (real(kind=r4_kind))
581 allocate(real(kind=r4_kind) :: this%att_value(natt))
582 this%att_value = att_value
583 type is (real(kind=r8_kind))
584 allocate(real(kind=r8_kind) :: this%att_value(natt))
585 this%att_value = att_value
586 type is (
character(len=*))
587 allocate(
character(len=len(att_value)) :: this%att_value(natt))
588 select type(aval => this%att_value)
589 type is (
character(len=*))
599 class(*),
intent(in) :: var
603 type is (real(r4_kind))
605 type is (real(r8_kind))
607 type is (
integer(i4_kind))
609 type is (
integer(i8_kind))
611 type is (
character(len=*))
614 call mpp_error(fatal,
"get_var_type:: The variable does not have a supported type. &
615 &The supported types are r4, r8, i4, i8 and string.")
622 class(fmsnetcdffile_t),
INTENT(INOUT) :: fileobj
623 character(len=*),
intent(in) :: var_name
624 character(len=*),
optional,
intent(inout) :: cell_methods
626 select type (att_value =>this%att_value)
627 type is (
character(len=*))
630 if (
present(cell_methods))
then
631 if (trim(this%att_name) .eq.
"cell_methods")
then
632 cell_methods = trim(cell_methods)//
" "//trim(att_value(1))
637 call register_variable_attribute(fileobj, var_name, this%att_name, trim(att_value(1)), &
638 str_len=len_trim(att_value(1)))
639 type is (real(kind=r8_kind))
640 call register_variable_attribute(fileobj, var_name, this%att_name, real(att_value, kind=r8_kind))
641 type is (real(kind=r4_kind))
642 call register_variable_attribute(fileobj, var_name, this%att_name, real(att_value, kind=r4_kind))
643 type is (
integer(kind=i4_kind))
644 call register_variable_attribute(fileobj, var_name, this%att_name, int(att_value, kind=i4_kind))
645 type is (
integer(kind=i8_kind))
646 call register_variable_attribute(fileobj, var_name, this%att_name, int(att_value, kind=i8_kind))
650 END MODULE diag_data_mod
character(len=8) no_units
String indicating that the variable has no units.
integer max_output_fields
Maximum number of output fields. Increase via diag_manager_nml.
real fill_value
Fill value used. Value will be NF90_FILL_REAL if using the netCDF module, otherwise will be 9....
integer, parameter direction_down
The axis points down if positive.
integer, parameter sub_regional
This is a file with a sub_region use the FmsNetcdfFile_t fileobj.
integer pack_size
1 for double and 2 for float
integer, parameter max_str_len
Max length for a string.
integer function get_base_minute()
gets the module variable base_minute
integer function get_base_year()
gets the module variable base_year
integer num_input_fields
Number of input fields in use.
integer function get_base_hour()
gets the module variable base_hour
logical use_cmor
Indicates if we should overwrite the MISSING_VALUE to use the CMOR missing value.
logical flush_nc_files
Control if diag_manager will force a flush of the netCDF file on each write. Note: changing this to ....
integer function get_var_type(var)
gets the type of a variable
integer, parameter no_domain
Use the FmsNetcdfFile_t fileobj.
character(len=7) avg_name
Name of the average fields.
integer, parameter end_time
Use the end of the time average bounds.
integer, parameter glo_reg_val_alt
Alternate value used in the region specification of the diag_table to indicate to use the full axis i...
integer max_axis_attributes
Maximum number of user definable attributes per axis.
integer, parameter monthly
Supported averaging intervals.
character(len=6) pack_size_str
Pack size as a string to be used in fms2_io register call set to "double" or "float".
logical use_modern_diag
Namelist flag to use the modernized diag_manager code.
type(time_type) function get_base_time()
gets the module variable base_time
integer max_axes
Maximum number of independent axes.
logical use_mpp_io
false is fms2_io (default); true is mpp_io
type(time_type), private base_time
The base_time read from diag_table.
integer, parameter is_x_axis
integer indicating that it is a x axis
integer, parameter diag_field_not_found
Return value for a diag_field that isn't found in the diag_table.
integer max_out_per_in_field
Maximum number of output_fields per input_field. Increase via diag_manager_nml.
integer max_input_fields
Maximum number of input fields. Increase via diag_manager_nml.
logical use_clock_average
.TRUE. if the averaging of variable is done based on the clock For example, if doing daily averages a...
integer, parameter string
s is the 19th letter of the alphabet
logical issue_oor_warnings
Issue warnings if the output field has values outside the given range for a variable.
logical region_out_use_alt_value
Will determine which value to use when checking a regional output if the region is the full axis or a...
integer num_output_fields
Number of output fields in use.
integer, parameter is_y_axis
integer indicating that it is a y axis
integer function get_base_day()
gets the module variable base_day
type(time_type) diag_init_time
Time diag_manager_init called. If init_time not included in diag_manager_init call,...
integer, parameter time_min
The reduction method is min value.
integer, parameter ug_domain
Use the FmsNetcdfUnstructuredDomainFile_t fileobj.
subroutine set_base_time(base_time_int)
Set the module variable base_time.
integer, parameter time_diurnal
The reduction method is diurnal.
integer, parameter time_power
The reduction method is average with exponents.
integer max_files
Maximum number of output files allowed. Increase via diag_manager_nml.
integer num_files
Number of output files currenly in use by the diag_manager.
integer max_file_attributes
Maximum number of user definable global attributes per file.
real(r8_kind), parameter cmor_missing_value
CMOR standard missing value.
subroutine write_metadata(this, fileobj, var_name, cell_methods)
Writes out the attributes from an fmsDiagAttribute_type.
logical prepend_date
Should the history file have the start date prepended to the file name. .TRUE. is only supported if t...
character(len=2), dimension(:), allocatable fnum_for_domain
If this file number in the array is for the "unstructured" or "2d" domain.
integer, parameter begin_time
Use the begining of the time average bounds.
subroutine diag_data_init()
Initialize and write the version number of this file to the log file.
integer, parameter time_average
The reduction method is average of values.
integer, parameter direction_up
The axis points up if positive.
integer function get_base_month()
gets the module variable base_month
integer, parameter time_sum
The reduction method is sum of values.
subroutine fms_add_attribute(this, att_name, att_value)
Adds an attribute to the attribute type.
integer, parameter time_rms
The reudction method is root mean square of values.
integer, parameter middle_time
Use the middle of the time average bounds.
logical module_is_initialized
Indicate if diag_manager has been initialized.
integer, parameter glo_reg_val
Value used in the region specification of the diag_table to indicate to use the full axis instead of ...
logical, private base_time_set
Flag indicating that the base_time is set This is to prevent users from calling set_base_time multipl...
integer, parameter time_none
There is no reduction method.
logical oor_warnings_fatal
Cause a fatal error if the output field has a value outside the given range for a variable.
integer function get_base_second()
gets the module variable base_second
integer, parameter time_max
The reduction method is max value.
integer, parameter max_fields_per_file
Maximum number of fields per file.
logical use_refactored_send
Namelist flag to use refactored send_data math funcitons.
integer, parameter r8
Supported type/kind of the variable.
integer max_field_attributes
Maximum number of user definable attributes per field. Liptak: Changed from 2 to 4 20170718.
integer, parameter two_d_domain
Use the FmsNetcdfDomainFile_t fileobj.
Define the region for field output.
Attribute type for diagnostic fields.
Type to hold the diagnostic axis description.
Contains the coordinates of the local domain to output.
Type to hold the attributes of the field/axis/file.
Type to hold the output field description.
subroutine, public write_version_number(version, tag, unit)
Prints to the log file (or a specified unit) the version id string and tag name.
One dimensional domain used to manage shared data access between pes.
The domain2D type contains all the necessary information to define the global, compute and data domai...
Domain information for managing data on unstructured grids.
integer function stdlog()
This function returns the current standard fortran unit numbers for log messages. Log messages,...
integer function mpp_pe()
Returns processor ID.
character(len=9) function, public month_name(n)
Returns a character string containing the name of the month corresponding to month number n.
integer function, public get_calendar_type()
Returns default calendar type for mapping from time to date.
Given an input date in year, month, days, etc., creates a time_type that represents this time interva...
Given some number of seconds and days, returns the corresponding time_type.
Type to represent amounts of time. Implemented as seconds and days to allow for larger intervals.
Data structure holding a 3D bounding box. It is commonlyused to represent the interval bounds or limi...