63 INTERFACE ASSIGNMENT(=)
65 END INTERFACE ASSIGNMENT(=)
72 CHARACTER(len=128) :: output_name
73 CHARACTER(len=128) :: module_name
74 CHARACTER(len=128) :: input_name
75 CHARACTER(len=50) :: time_method
107 INTEGER,
INTENT(in) :: file
109 INTEGER :: file_unit, ios
110 INTEGER :: num_static, num_temporal
111 INTEGER :: year, month, day, hour, minute, second
114 CHARACTER(len=128) :: manifilename
115 CHARACTER(len=32) :: filename_appendix
116 CHARACTER(len=24) :: start_date
125 manifilename = trim(
files(file)%name)//
".mfst" 127 IF ( prepend_date )
THEN 128 call get_date(diag_init_time, year, month, day, hour, minute, second)
129 write (start_date,
'(1I20.4, 2I2.2)') year, month, day
131 manifilename = trim(adjustl(start_date))//
'.'//trim(manifilename)
140 num_static = static_fields%num_1d + static_fields%num_2d + static_fields%num_3d + static_fields%num_4d
141 num_temporal = temporal_fields%num_1d + temporal_fields%num_2d + temporal_fields%num_3d + temporal_fields%num_4d
148 IF ( mpp_pe() .EQ. mpp_root_pe() .AND.&
149 & (index(filename_appendix,
'ens_').EQ.0 .OR. index(filename_appendix,
'ens_01').GT.0) )
THEN 151 IF ( num_static + num_temporal .GT. 0 )
THEN 153 file_unit = get_unit()
156 OPEN(unit=file_unit, file=trim(manifilename), access=
'SEQUENTIAL', form=
'FORMATTED',&
157 & action=
'WRITE', position=
'REWIND', iostat=ios)
158 IF ( ios .NE. 0 )
THEN 159 CALL error_mesg(
'diag_manifest_mod::write_diag_manifest',&
160 &
'Unable to open file "'//trim(manifilename)//
'". No manifest file will be created.',&
164 write(file_unit,
'(A1)')
'{' 169 write(file_unit,
'(A1)')
'}' 186 TYPE(manifest_fields_type),
INTENT(inout) :: manifest_fields
189 manifest_fields%num_1d = 0
190 manifest_fields%num_2d = 0
191 manifest_fields%num_3d = 0
192 manifest_fields%num_4d = 0
194 IF (
ALLOCATED(manifest_fields%fields_1d) )
DEALLOCATE(manifest_fields%fields_1d)
195 IF (
ALLOCATED(manifest_fields%fields_2d) )
DEALLOCATE(manifest_fields%fields_2d)
196 IF (
ALLOCATED(manifest_fields%fields_3d) )
DEALLOCATE(manifest_fields%fields_3d)
197 IF (
ALLOCATED(manifest_fields%fields_4d) )
DEALLOCATE(manifest_fields%fields_4d)
204 TYPE(manifest_field_type),
INTENT(out) :: lhs
205 TYPE(manifest_field_type),
INTENT(in) :: rhs
207 lhs%output_name = rhs%output_name
208 lhs%module_name = rhs%module_name
209 lhs%input_name = rhs%input_name
210 lhs%time_method = rhs%time_method
211 lhs%packing = rhs%packing
217 INTEGER,
INTENT(in) :: unit
218 TYPE(manifest_field_type),
DIMENSION(:),
INTENT(in) :: fields
221 CHARACTER(LEN=*),
PARAMETER :: FMT_FLD =
"(12X,'""',A,'""',': {')" 222 CHARACTER(LEN=*),
PARAMETER :: FMT_MOF =
"(16X,'""model_field"":','""',A,'"",')" 223 CHARACTER(LEN=*),
PARAMETER :: FMT_MOD =
"(16X,'""module"":','""',A,'"",')" 224 CHARACTER(LEN=*),
PARAMETER :: FMT_PAK =
"(16X,'""packing"":',I1,',')" 225 CHARACTER(LEN=*),
PARAMETER :: FMT_TAV =
"(16X,'""time_averaging"":','""',A,'""')" 228 WRITE (unit,fmt_fld) trim(fields(i)%output_name)
229 WRITE (unit,fmt_mof) trim(fields(i)%input_name)
230 WRITE (unit,fmt_mod) trim(fields(i)%module_name)
231 WRITE (unit,fmt_pak) fields(i)%packing
232 WRITE (unit,fmt_tav) trim(fields(i)%time_method)
233 IF ( i.EQ.
SIZE(fields) )
THEN 234 WRITE (unit,
'(12X,A1)')
'}' 236 WRITE (unit,
'(12X,A2)')
'},' 243 INTEGER,
INTENT(in) :: unit
244 TYPE(manifest_fields_type),
INTENT(in) :: fields
245 LOGICAL,
INTENT(in) :: static
248 CHARACTER(len=*),
PARAMETER :: FMT_DIM =
"(8X,'""',A2,'""',': {')" 249 CHARACTER(len=*),
PARAMETER :: FMT_STA =
"(4X,'""',A6,'""',': {')" 250 CHARACTER(len=*),
PARAMETER :: FMT_TEM =
"(4X,'""',A8,'""',': {')" 254 WRITE (unit,fmt_sta)
'Static' 256 WRITE (unit,fmt_tem)
'Temporal' 260 WRITE (unit,fmt_dim)
'1D' 261 CALL write_fields(unit, fields%fields_1d(1:fields%num_1d))
262 WRITE (unit,
'(8X,A2)')
'},' 265 WRITE (unit,fmt_dim)
'2D' 266 CALL write_fields(unit, fields%fields_2d(1:fields%num_2d))
267 WRITE (unit,
'(8X,A2)')
'},' 270 WRITE (unit,fmt_dim)
'3D' 271 CALL write_fields(unit, fields%fields_3d(1:fields%num_3d))
272 WRITE (unit,
'(8X,A2)')
'},' 275 WRITE (unit,fmt_dim)
'4D' 276 CALL write_fields(unit, fields%fields_4d(1:fields%num_4d))
277 WRITE (unit,
'(8X,A1)')
'}' 281 WRITE (unit,
'(4X,A2)')
'},' 283 WRITE (unit,
'(4X,A1)')
'}' 289 TYPE(manifest_fields_type) FUNCTION get_diagnostic_fields(file, static)
290 INTEGER,
INTENT(in) :: file
291 LOGICAL,
INTENT(in) :: static
299 CHARACTER(len=128) :: manifilename
300 LOGICAL,
DIMENSION(:),
ALLOCATABLE :: data_written
304 manifilename = trim(
files(file)%name)//
".mfst" 306 ALLOCATE(data_written(mpp_npes()), stat=istat)
307 IF ( istat.NE.0 )
THEN 308 CALL error_mesg(
'diag_manifest_mod::get_diagnostic_fields',&
309 &
'Unable to allocate array to determine if field written to file. No manifest file will be created.',&
312 get_diagnostic_fields%num_1d = 0
313 get_diagnostic_fields%num_2d = 0
314 get_diagnostic_fields%num_3d = 0
315 get_diagnostic_fields%num_4d = 0
317 DO j=1,
files(file)%num_fields
318 o =
files(file)%fields(j)
323 IF ( output_fields(o)%local_output )
THEN 327 CALL mpp_gather((/output_fields(o)%written_once/), data_written)
330 data_written = output_fields(o)%written_once
333 IF ( any(data_written) .AND. (static.EQV.output_fields(o)%static) )
THEN 336 i = output_fields(o)%input_field
339 manifield%output_name = output_fields(o)%output_name
340 manifield%module_name = input_fields(i)%module_name
341 manifield%input_name = input_fields(i)%field_name
342 IF ( output_fields(o)%static )
THEN 344 manifield%time_method =
".false." 346 manifield%time_method = output_fields(o)%time_method
348 manifield%packing = output_fields(o)%pack
349 manifield%nDim = output_fields(o)%num_axes
352 SELECT CASE (manifield%nDim)
354 get_diagnostic_fields%num_1d = get_diagnostic_fields%num_1d + 1
355 IF ( .NOT.
ALLOCATED(get_diagnostic_fields%fields_1d) )
THEN 357 ALLOCATE(get_diagnostic_fields%fields_1d(
files(file)%num_fields), stat=istat)
358 IF ( istat.NE.0 )
THEN 359 CALL error_mesg(
'diag_manifest_mod::get_diagnostic_fields',&
360 &
'Unable to allocate 1d array for manifest file "'//trim(manifilename)//
'". Manifest incomplete.',&
363 get_diagnostic_fields%num_1d = 0
367 IF (
ALLOCATED(get_diagnostic_fields%fields_1d) )
THEN 368 get_diagnostic_fields%fields_1d(get_diagnostic_fields%num_1d) = manifield
371 get_diagnostic_fields%num_2d = get_diagnostic_fields%num_2d + 1
372 IF ( .NOT.
ALLOCATED(get_diagnostic_fields%fields_2d) )
THEN 374 ALLOCATE(get_diagnostic_fields%fields_2d(
files(file)%num_fields), stat=istat)
375 IF ( istat.NE.0 )
THEN 376 CALL error_mesg(
'diag_manifest_mod::get_diagnostic_fields',&
377 &
'Unable to allocate 2d array for manifest file "'//trim(manifilename)//
'". Manifest incomplete.',&
380 get_diagnostic_fields%num_2d = 0
384 IF (
ALLOCATED(get_diagnostic_fields%fields_2d) )
THEN 385 get_diagnostic_fields%fields_2d(get_diagnostic_fields%num_2d) = manifield
388 get_diagnostic_fields%num_3d = get_diagnostic_fields%num_3d + 1
389 IF ( .NOT.
ALLOCATED(get_diagnostic_fields%fields_3d) )
THEN 391 ALLOCATE(get_diagnostic_fields%fields_3d(
files(file)%num_fields), stat=istat)
392 IF ( istat.NE.0 )
THEN 393 CALL error_mesg(
'diag_manifest_mod::get_diagnostic_fields',&
394 &
'Unable to allocate 3d array for manifest file "'//trim(manifilename)//
'". Manifest incomplete.',&
397 get_diagnostic_fields%num_3d = 0
401 IF (
ALLOCATED(get_diagnostic_fields%fields_3d) )
THEN 402 get_diagnostic_fields%fields_3d(get_diagnostic_fields%num_3d) = manifield
405 get_diagnostic_fields%num_4d = get_diagnostic_fields%num_4d + 1
406 IF ( .NOT.
ALLOCATED(get_diagnostic_fields%fields_4d) )
THEN 408 ALLOCATE(get_diagnostic_fields%fields_4d(
files(file)%num_fields), stat=istat)
409 IF ( istat.NE.0 )
THEN 410 CALL error_mesg(
'diag_manifest_mod::get_diagnostic_fields',&
411 &
'Unable to allocate 4d array for manifest file "'//trim(manifilename)//
'". Manifest incomplete.',&
414 get_diagnostic_fields%num_4d = 0
418 IF (
ALLOCATED(get_diagnostic_fields%fields_4d) )
THEN 419 get_diagnostic_fields%fields_4d(get_diagnostic_fields%num_4d) = manifield
426 IF (
ALLOCATED(data_written))
DEALLOCATE(data_written)
subroutine, public get_date(time, year, month, day, hour, minute, second, tick, err_msg)
subroutine destroy_manifest_fields_type(manifest_fields)
De-allocate arrays used in the manifest_fields_type.
subroutine write_manifest(unit, fields, static)
Write the JSON format of the static/temporal object.
subroutine manifest_field_type_assign(lhs, rhs)
Allow ASSIGNMENT(=) operator to work on TYPE(manifest_field_type)
type(manifest_fields_type) function get_diagnostic_fields(file, static)
Extract the diagnostic fields, and collect the information about the fields.
A type to hold all the fields by dimension size.
subroutine write_fields(unit, fields)
Write the JSON format of the field object.
type(file_type), dimension(:), allocatable, save files
subroutine, public write_diag_manifest(file)
Public routine that will start the writing of the manifest file.
A type to hold the data required for the manifest file.
subroutine, public get_filename_appendix(string_out)
subroutine, public error_mesg(routine, message, level)
diag_manifest_mod writes out a manifest file for each diagnostic output file defined in the diag_tabl...