33 public :: file_history_query
35 public :: file_history_put
37 public :: file_history_in
40 public :: file_history_set_associatedcoordinate
41 public :: file_history_set_attribute
46 interface file_history_query
47 module procedure file_history_query_name
48 module procedure file_history_query_id
49 end interface file_history_query
51 interface file_history_put
52 module procedure file_history_put_0d
53 module procedure file_history_put_1d
54 module procedure file_history_put_2d
55 module procedure file_history_put_3d
56 module procedure file_history_put_4d
57 end interface file_history_put
59 interface file_history_in
65 end interface file_history_in
68 subroutine truncate_1d( src, dim_type, zcoord, fill_halo, dsc )
70 real(RP),
intent(in) :: src(:)
71 character(len=*),
intent(in) :: dim_type
72 character(len=*),
intent(in) :: zcoord
73 logical,
intent(in) :: fill_halo
74 real(DP),
intent(out) :: dsc(:)
75 end subroutine truncate_1d
80 subroutine truncate_2d( src, dim_type, zcoord, fill_halo, dsc )
82 real(
rp),
intent(in) :: src(:,:)
83 character(len=*),
intent(in) :: dim_type
84 character(len=*),
intent(in) :: zcoord
85 logical,
intent(in) :: fill_halo
86 real(
dp),
intent(out) :: dsc(:)
87 end subroutine truncate_2d
92 subroutine truncate_3d( src, dim_type, zcoord, fill_halo, dsc )
94 real(
rp),
intent(in) :: src(:,:,:)
95 character(len=*),
intent(in) :: dim_type
96 character(len=*),
intent(in) :: zcoord
97 logical,
intent(in) :: fill_halo
98 real(
dp),
intent(out) :: dsc(:)
99 end subroutine truncate_3d
104 subroutine truncate_4d( src, dim_type, zcoord, fill_halo, dsc )
106 real(
rp),
intent(in) :: src(:,:,:,:)
107 character(len=*),
intent(in) :: dim_type
108 character(len=*),
intent(in) :: zcoord
109 logical,
intent(in) :: fill_halo
110 real(
dp),
intent(out) :: dsc(:)
111 end subroutine truncate_4d
117 interface file_history_set_associatedcoordinate
121 end interface file_history_set_associatedcoordinate
123 interface file_history_set_attribute
129 module procedure file_history_set_attribute_float_ary
131 module procedure file_history_set_attribute_double_ary
132 end interface file_history_set_attribute
148 private :: file_history_create
149 private :: file_history_close
150 private :: file_history_add_variable
151 private :: file_history_write_axes
152 private :: file_history_write_onevar
153 private :: file_history_output_list
154 private :: file_history_check
162 character(len=H_SHORT) :: name
163 character(len=H_SHORT) :: outname
164 character(len=H_LONG) :: basename
165 logical :: postfix_timelabel
166 character(len=H_SHORT) :: zcoord
170 character(len=H_SHORT) :: cell_measures
171 logical :: registered
175 character(len=H_SHORT) :: name
176 character(len=H_SHORT) :: outname
177 character(len=H_LONG) :: basename
178 logical :: postfix_timelabel
179 character(len=H_SHORT) :: zcoord
187 character(len=H_LONG) :: desc
188 character(len=H_SHORT) :: units
189 character(len=H_SHORT) :: standard_name
191 character(len=H_SHORT) :: cell_measures
193 integer :: laststep_write
194 integer :: laststep_put
195 logical :: flag_clear
198 real(
dp),
pointer :: varsum(:)
202 integer,
parameter :: file_history_variant_max = 10
204 character(len=H_SHORT) :: name
206 integer :: variants(file_history_variant_max)
210 character(len=H_SHORT) :: name
213 character(len=H_SHORT),
pointer :: dims(:,:)
214 integer ,
pointer :: start(:,:)
215 integer ,
pointer :: count(:,:)
216 integer ,
pointer :: size(:)
217 character(len=H_SHORT),
pointer :: zcoords(:)
218 character(len=H_SHORT) :: mapping
219 character(len=H_SHORT) :: area
220 character(len=H_SHORT) :: area_x
221 character(len=H_SHORT) :: area_y
222 character(len=H_SHORT) :: volume
223 character(len=H_SHORT) :: location
224 character(len=H_SHORT) :: grid
228 character(len=H_SHORT) :: name
229 character(len=H_LONG) :: desc
230 character(len=H_SHORT) :: units
231 character(len=H_SHORT) :: dim
233 real(
dp),
pointer :: var(:)
234 real(
dp),
pointer :: bounds(:,:)
241 character(len=H_SHORT) :: name
242 character(len=H_LONG) :: desc
243 character(len=H_SHORT) :: units
245 character(len=H_SHORT) :: dims(4)
247 real(
dp),
pointer :: var(:)
252 integer,
parameter :: i_text = 1, i_int = 2, i_float = 3, i_double = 4
254 character(len=H_SHORT) :: varname
255 character(len=H_MID) :: key
257 character(len=H_LONG) :: text
258 integer,
pointer :: int(:)
261 logical :: add_variable
265 integer :: file_history_myrank
268 real(
dp) :: file_history_startdaysec
269 real(
dp) :: file_history_dtsec
270 character(len=H_MID) :: file_history_time_since
273 character(len=H_MID) :: file_history_title
274 character(len=H_MID) :: file_history_source
275 character(len=H_MID) :: file_history_institution
277 character(len=H_MID) :: file_history_time_units
278 character(len=H_SHORT) :: file_history_calendar
279 logical :: file_history_output_step0 = .false.
280 integer :: file_history_output_wait_step
281 integer :: file_history_output_switch_step
282 integer :: file_history_output_switch_laststep
283 logical :: file_history_error_putmiss = .true.
286 integer,
parameter :: file_history_req_max = 1000
287 integer :: file_history_nreqs = 0
288 type(request),
allocatable :: file_history_req(:)
290 integer :: file_history_nitems = 0
291 type(var_out),
allocatable :: file_history_vars(:)
293 integer :: file_history_nvar_inputs
294 type(var_in),
allocatable :: file_history_var_inputs(:)
296 integer,
parameter :: file_history_dim_max = 30
297 integer :: file_history_ndims = 0
298 type(dim) :: file_history_dims(file_history_dim_max)
300 integer,
parameter :: file_history_axis_max = 100
301 integer :: file_history_naxes = 0
302 type(axis) :: file_history_axes(file_history_axis_max)
304 integer,
parameter :: file_history_assoc_max = 40
305 integer :: file_history_nassocs = 0
306 type(assoc) :: file_history_assocs(file_history_assoc_max)
308 integer,
parameter :: file_history_attr_max = 200
309 integer :: file_history_nattrs = 0
310 type(attr) :: file_history_attrs(file_history_attr_max)
312 integer :: file_history_nowdate(6)
313 real(
dp) :: file_history_nowsubsec
314 integer :: file_history_nowstep
316 character(len=H_MID) :: file_history_options =
''
319 logical :: file_history_disabled = .true.
321 integer :: laststep_write = -1
322 logical :: list_outputed = .false.
323 logical :: debug = .false.
331 title, source, institution, &
332 time_start, time_interval, &
333 time_units, time_since, calendar, &
335 default_postfix_timelabel, &
351 character(len=*),
intent(in) :: title
352 character(len=*),
intent(in) :: source
353 character(len=*),
intent(in) :: institution
354 real(
dp),
intent(in) :: time_start
355 real(
dp),
intent(in) :: time_interval
357 character(len=*),
intent(in),
optional :: time_units
358 character(len=*),
intent(in),
optional :: time_since
359 character(len=*),
intent(in),
optional :: calendar
360 character(len=*),
intent(in),
optional :: default_basename
361 logical,
intent(in),
optional :: default_postfix_timelabel
362 character(len=*),
intent(in),
optional :: default_zcoord
363 real(
dp),
intent(in),
optional :: default_tinterval
364 character(len=*),
intent(in),
optional :: default_tunit
365 logical,
intent(in),
optional :: default_taverage
366 character(len=*),
intent(in),
optional :: default_datatype
367 integer,
intent(in),
optional :: myrank
369 character(len=H_LONG) :: file_history_default_basename
370 logical :: file_history_default_postfix_timelabel
371 character(len=H_SHORT) :: file_history_default_zcoord
372 real(
dp) :: file_history_default_tinterval
373 character(len=H_SHORT) :: file_history_default_tunit
374 logical :: file_history_default_taverage
375 character(len=H_SHORT) :: file_history_default_datatype
378 real(
dp) :: file_history_output_wait
379 character(len=H_SHORT) :: file_history_output_wait_tunit
380 real(
dp) :: file_history_output_switch_tinterval
381 character(len=H_SHORT) :: file_history_output_switch_tunit
383 namelist / param_file_history / &
384 file_history_title, &
385 file_history_source, &
386 file_history_institution, &
387 file_history_time_units, &
388 file_history_default_basename, &
389 file_history_default_postfix_timelabel, &
390 file_history_default_zcoord, &
391 file_history_default_tinterval, &
392 file_history_default_tunit, &
393 file_history_default_taverage, &
394 file_history_default_datatype, &
395 file_history_output_step0, &
396 file_history_output_wait, &
397 file_history_output_wait_tunit, &
398 file_history_output_switch_tinterval, &
399 file_history_output_switch_tunit, &
400 file_history_error_putmiss, &
402 file_history_options, &
405 character(len=H_SHORT) :: name
406 character(len=H_SHORT) :: outname
407 character(len=H_LONG) :: basename
408 logical :: postfix_timelabel
409 character(len=H_SHORT) :: zcoord
410 real(
dp) :: tinterval
411 character(len=H_SHORT) :: tunit
413 character(len=H_SHORT) :: datatype
415 namelist / history_item / &
438 log_info(
"FILE_HISTORY_Setup",*)
'Setup'
441 file_history_myrank = myrank
443 file_history_startdaysec = time_start
444 file_history_dtsec = time_interval
445 if (
present(time_since) )
then
446 file_history_time_since = time_since
448 file_history_time_since =
''
451 if (
present(calendar) )
then
452 file_history_calendar = calendar
454 file_history_calendar =
""
457 file_history_time_units =
'seconds'
458 file_history_default_basename =
''
459 file_history_default_postfix_timelabel = .false.
460 file_history_default_zcoord =
''
461 file_history_default_tinterval = -1.0_dp
462 file_history_default_tunit =
'SEC'
463 file_history_default_taverage = .false.
464 file_history_default_datatype =
'REAL4'
465 file_history_output_wait = 0.0_dp
466 file_history_output_wait_tunit =
'SEC'
467 file_history_output_switch_tinterval = -1.0_dp
468 file_history_output_switch_tunit =
'SEC'
473 file_history_title = title
474 file_history_source = source
475 file_history_institution = institution
476 if(
present(time_units) ) file_history_time_units = time_units
477 if(
present(default_basename) ) file_history_default_basename = default_basename
478 if(
present(default_postfix_timelabel) ) file_history_default_postfix_timelabel = default_postfix_timelabel
479 if(
present(default_zcoord) ) file_history_default_zcoord = default_zcoord
480 if(
present(default_tinterval) ) file_history_default_tinterval = default_tinterval
481 if(
present(default_tunit) ) file_history_default_tunit = default_tunit
482 if(
present(default_taverage) ) file_history_default_taverage = default_taverage
483 if(
present(default_datatype) ) file_history_default_datatype = default_datatype
487 read(
io_fid_conf,nml=param_file_history,iostat=ierr)
489 log_info(
"FILE_HISTORY_Setup",*)
'Not found namelist. Default used.'
490 elseif( ierr > 0 )
then
491 log_error(
"FILE_HISTORY_Setup",*)
'Not appropriate names in namelist PARAM_FILE_HISTORY. Check!'
494 log_nml(param_file_history)
498 if ( file_history_output_wait >= 0.0_dp )
then
499 call calendar_unit2sec( dtsec, file_history_output_wait, file_history_output_wait_tunit )
500 file_history_output_wait_step = int( dtsec / file_history_dtsec )
502 log_error(
"FILE_HISTORY_Setup",*)
'FILE_HISTORY_OUTPUT_WAIT must be positive. STOP'
506 if ( file_history_output_switch_tinterval >= 0.0_dp )
then
507 call calendar_unit2sec( dtsec, file_history_output_switch_tinterval, file_history_output_switch_tunit )
508 file_history_output_switch_step = int( dtsec / file_history_dtsec )
510 file_history_output_switch_step = -1
512 file_history_output_switch_laststep = 0
516 file_history_nreqs = 0
518 do n = 1, file_history_req_max
520 outname =
'undefined'
521 basename = file_history_default_basename
525 if( basename ==
'' .OR. name ==
'' .OR. outname ==
'' ) cycle
527 file_history_nreqs = file_history_nreqs + 1
530 if ( file_history_nreqs > file_history_req_max )
then
531 log_error(
"FILE_HISTORY_Setup",*)
'request of history file is exceed! n >', file_history_req_max
533 elseif( file_history_nreqs == 0 )
then
534 log_info(
"FILE_HISTORY_Setup",*)
'No history file specified.'
538 allocate( file_history_req(file_history_nreqs) )
543 do n = 1, file_history_req_max
546 outname =
'undefined'
547 basename = file_history_default_basename
548 postfix_timelabel = file_history_default_postfix_timelabel
549 zcoord = file_history_default_zcoord
550 tinterval = file_history_default_tinterval
551 tunit = file_history_default_tunit
552 taverage = file_history_default_taverage
553 datatype = file_history_default_datatype
558 elseif( ierr > 0 )
then
559 log_error(
"FILE_HISTORY_Setup",*)
'Not appropriate names in namelist HISTORY_ITEM. Check!'
562 if( basename ==
'' .OR. name ==
'' .OR. outname ==
'' ) cycle
564 log_nml(history_item)
567 if ( outname ==
'undefined' ) outname = name
569 if ( file_history_req(id)%outname == outname )
then
570 log_error(
"FILE_HISTORY_Setup",*)
'Same name of history output is already registered. Check!', trim(outname)
577 file_history_req(reqid)%name = name
578 file_history_req(reqid)%outname = outname
579 file_history_req(reqid)%basename = basename
580 file_history_req(reqid)%postfix_timelabel = postfix_timelabel
581 if( file_history_output_switch_step >= 0 ) file_history_req(reqid)%postfix_timelabel = .true.
582 file_history_req(reqid)%zcoord = zcoord
583 file_history_req(reqid)%taverage = taverage
586 dstep = int( dtsec / file_history_dtsec )
588 if ( dtsec <= 0.d0 )
then
589 log_error(
"FILE_HISTORY_Setup",*)
'Not appropriate time interval. Check!', trim(name), tinterval, trim(tunit)
593 if ( abs(dtsec-real(dstep,kind=
dp)*file_history_dtsec) > dtsec*1.e-3_dp )
then
594 log_error(
"FILE_HISTORY_Setup",*)
'time interval must be a multiple of delta t. (interval,dt)=', dtsec, file_history_dtsec
598 file_history_req(reqid)%dstep = dstep
600 if ( datatype ==
'REAL4' )
then
602 elseif( datatype ==
'REAL8' )
then
605 log_error(
"FILE_HISTORY_Setup",*)
'Not appropriate DATATYPE. Check!', datatype
609 file_history_req(reqid)%registered = .false.
613 log_info(
"FILE_HISTORY_Setup",*)
'Number of requested history item : ', file_history_nreqs
614 log_info(
"FILE_HISTORY_Setup",*)
'Output default data type : ', trim(file_history_default_datatype)
615 log_info(
"FILE_HISTORY_Setup",*)
'Output value at the initial step? : ', file_history_output_step0
616 if ( file_history_output_wait_step > 0 )
then
617 log_info(
"FILE_HISTORY_Setup",*)
'Time when the output is suppressed [step] : ', file_history_output_wait_step
619 if ( file_history_output_switch_step >= 0 )
then
620 log_info(
"FILE_HISTORY_Setup",*)
'Interval for switching the file [step] : ', file_history_output_switch_step
622 log_info(
"FILE_HISTORY_Setup",*)
'Check if requested item is not registered? : ', file_history_error_putmiss
624 file_history_nitems = 0
625 allocate( file_history_vars(file_history_nreqs) )
627 file_history_nvar_inputs = 0
628 allocate( file_history_var_inputs(file_history_nreqs) )
635 file_history_disabled = .false.
652 character(len=*),
intent(in) :: name
653 character(len=*),
intent(in) :: desc
654 character(len=*),
intent(in) :: unit
656 integer,
intent(out) :: itemid
658 character(len=*),
intent(in),
optional :: standard_name
659 integer,
intent(in),
optional :: ndims
660 character(len=*),
intent(in),
optional :: dim_type
661 character(len=*),
intent(in),
optional :: cell_measures
662 logical,
intent(in),
optional :: fill_halo
664 character(len=H_SHORT) :: standard_name_
665 character(len=H_SHORT) :: cell_measures_
666 integer :: dimid, iid
671 if ( file_history_nreqs == 0 )
return
673 itemid = file_history_find_id( name )
674 if ( itemid > 0 )
return
678 if ( len_trim(name) >=
h_short )
then
679 log_error(
"FILE_HISTORY_reg",
'(1x,A,I2,A,A)')
'Length of history name should be <= ',
h_short-1 ,
' chars. name=', trim(name)
684 if (
present(standard_name) )
then
685 standard_name_ = standard_name
691 if ( file_history_ndims < 1 )
then
692 log_error(
"FILE_HISTORY_reg",*)
'at least one dim_type must be registerd with FILE_HISTORY_set_dim. name=', trim(name)
696 if (
present(dim_type) )
then
697 do n = 1, file_history_ndims
698 if ( file_history_dims(n)%name == dim_type )
then
703 if ( dimid == -1 )
then
704 log_error(
"FILE_HISTORY_reg",*)
'dim_type must be registerd with FILE_HISTORY_set_dim: ', trim(dim_type) ,
' name=', trim(name)
707 else if (
present(ndims) )
then
708 do n = 1, file_history_ndims
709 if ( file_history_dims(n)%ndims == ndims )
then
714 if ( dimid == -1 )
then
715 log_error(
"FILE_HISTORY_reg",
'(a,i1,a)')
'dim_type of ', ndims,
'D must be registerd with FILE_HISTORY_set_dim. name=', trim(name)
720 do n = 1, file_history_ndims
721 if ( file_history_dims(n)%ndims == 3 )
then
726 if ( dimid == -1 )
then
727 log_error(
"FILE_HISTORY_reg",
'(a,i1,a)')
'dim_type or ndims must be specified. name=', trim(name)
732 if (
present(cell_measures) )
then
733 select case ( cell_measures )
735 if ( file_history_dims(dimid)%area ==
"" )
then
736 log_error(
"FILE_HISTORY_reg",*)
'area is not supported for cell_measures. name=', trim(name)
740 if ( file_history_dims(dimid)%area ==
"" )
then
741 log_error(
"FILE_HISTORY_reg",*)
'area_z is not supported for cell_measures. name=', trim(name)
745 if ( file_history_dims(dimid)%area_x ==
"" )
then
746 log_error(
"FILE_HISTORY_reg",*)
'area_x is not supported for cell_measures. name=', trim(name)
750 if ( file_history_dims(dimid)%area_y ==
"" )
then
751 log_error(
"FILE_HISTORY_reg",*)
'area_y is not supported for cell_measures. name=', trim(name)
755 if ( file_history_dims(dimid)%volume ==
"" )
then
756 log_error(
"FILE_HISTORY_reg",*)
'volume is not supported for cell_measures. name=', trim(name)
760 log_error(
"FILE_HISTORY_reg",*)
'cell_measures must be "area" or "volume". name=', trim(name)
763 cell_measures_ = cell_measures
764 else if ( file_history_dims(dimid)%ndims == 2 )
then
765 cell_measures_ =
"area"
766 else if ( file_history_dims(dimid)%ndims == 3 )
then
767 cell_measures_ =
"volume"
772 if ( file_history_dims(dimid)%nzcoords > 1 )
then
775 do n = 1, file_history_dims(dimid)%nzcoords
776 if ( file_history_dims(dimid)%zcoords(n) ==
"model" )
then
777 call file_history_add_variable( name, desc, unit, standard_name_, &
779 file_history_dims(dimid)%zcoords(n), &
781 cell_measures = cell_measures_, &
782 fill_halo = fill_halo )
784 call file_history_add_variable( name, desc, unit, standard_name_, &
786 file_history_dims(dimid)%zcoords(n), &
788 fill_halo = fill_halo )
790 if ( iid > 0 ) itemid = iid
795 call file_history_add_variable( name, desc, unit, standard_name_, &
799 cell_measures = cell_measures_, &
800 fill_halo = fill_halo )
811 subroutine file_history_put_0d( &
821 integer,
intent(in) :: itemid
822 real(
rp),
intent(in) :: var
825 real(
dp),
allocatable :: buffer(:)
835 if ( file_history_disabled )
return
836 if ( itemid < 0 )
return
838 call file_history_query( itemid, do_put )
839 if ( .not. do_put )
return
843 do i = 1, file_history_var_inputs(itemid)%nvariants
844 id = file_history_var_inputs(itemid)%variants(
i)
846 dt = ( file_history_nowstep - file_history_vars(id)%laststep_put ) * file_history_dtsec
848 if ( dt < eps .AND. ( .NOT. file_history_vars(id)%taverage ) )
then
849 log_error(
"FILE_HISTORY_Put_0D",*)
'variable was put two times before output!: ', &
850 trim(file_history_vars(id)%name), file_history_nowstep, file_history_vars(id)%laststep_put
854 if ( file_history_vars(id)%flag_clear )
then
855 file_history_vars(id)%timesum = 0.0_dp
856 if ( file_history_vars(id)%taverage ) file_history_vars(id)%varsum(:) = 0.0_dp
859 dimid = file_history_vars(id)%dimid
860 if ( file_history_vars(id)%taverage )
then
861 if ( file_history_vars(id)%varsum(1) /= rmiss )
then
862 if ( var /= undef )
then
863 file_history_vars(id)%varsum(1) = file_history_vars(id)%varsum(1) + var * dt
865 file_history_vars(id)%varsum(1) = rmiss
868 file_history_vars(id)%timesum = file_history_vars(id)%timesum + dt
870 file_history_vars(id)%varsum(1) = var
871 file_history_vars(id)%timesum = 0.0_dp
874 file_history_vars(id)%laststep_put = file_history_nowstep
875 file_history_vars(id)%flag_clear = .false.
882 end subroutine file_history_put_0d
894 real(RP),
intent(in) :: var
895 character(len=*),
intent(in) :: name
896 character(len=*),
intent(in) :: desc
897 character(len=*),
intent(in) :: unit
899 character(len=*),
intent(in),
optional :: standard_name
900 character(len=*),
intent(in),
optional :: dim_type
902 logical,
parameter :: fill_halo = .false.
904 integer,
parameter :: ndim = 0
909 if ( file_history_disabled )
return
914 standard_name=standard_name, &
917 fill_halo=fill_halo )
919 if ( itemid < 0 )
return
922 call file_history_query( itemid, do_put )
924 if ( do_put )
call file_history_put( itemid, var )
930 subroutine file_history_put_1d( &
940 integer,
intent(in) :: itemid
941 real(RP),
intent(in) :: var(:)
944 real(DP),
allocatable :: buffer(:)
954 if ( file_history_disabled )
return
955 if ( itemid < 0 )
return
957 call file_history_query( itemid, do_put )
958 if ( .not. do_put )
return
962 do i = 1, file_history_var_inputs(itemid)%nvariants
963 id = file_history_var_inputs(itemid)%variants(i)
965 dt = ( file_history_nowstep - file_history_vars(id)%laststep_put ) * file_history_dtsec
967 if ( dt < eps .AND. ( .NOT. file_history_vars(id)%taverage ) )
then
968 log_error(
"FILE_HISTORY_Put_1D",*)
'variable was put two times before output!: ', &
969 trim(file_history_vars(id)%name), file_history_nowstep, file_history_vars(id)%laststep_put
973 if ( file_history_vars(id)%flag_clear )
then
974 file_history_vars(id)%timesum = 0.0_dp
975 if ( file_history_vars(id)%taverage ) file_history_vars(id)%varsum(:) = 0.0_dp
978 dimid = file_history_vars(id)%dimid
979 if ( file_history_vars(id)%taverage )
then
980 allocate( buffer( file_history_vars(id)%size ) )
982 file_history_dims(dimid)%name, &
983 file_history_vars(id)%zcoord, &
984 file_history_vars(id)%fill_halo, &
986 do idx = 1, file_history_vars(id)%size
987 if ( file_history_vars(id)%varsum(idx) /= rmiss )
then
988 if ( buffer(idx) /= undef )
then
989 file_history_vars(id)%varsum(idx) = file_history_vars(id)%varsum(idx) + buffer(idx) * dt
991 file_history_vars(id)%varsum(idx) = rmiss
996 file_history_vars(id)%timesum = file_history_vars(id)%timesum + dt
999 file_history_dims(dimid)%name, &
1000 file_history_vars(id)%zcoord, &
1001 file_history_vars(id)%fill_halo, &
1002 file_history_vars(id)%varsum(:) )
1003 file_history_vars(id)%timesum = 0.0_dp
1006 file_history_vars(id)%laststep_put = file_history_nowstep
1007 file_history_vars(id)%flag_clear = .false.
1014 end subroutine file_history_put_1d
1026 real(RP),
intent(in) :: var(:)
1027 character(len=*),
intent(in) :: name
1028 character(len=*),
intent(in) :: desc
1029 character(len=*),
intent(in) :: unit
1031 character(len=*),
intent(in),
optional :: standard_name
1032 character(len=*),
intent(in),
optional :: dim_type
1034 logical,
parameter :: fill_halo = .false.
1036 integer,
parameter :: ndim = 1
1041 if ( file_history_disabled )
return
1046 standard_name=standard_name, &
1048 dim_type=dim_type, &
1049 fill_halo=fill_halo )
1051 if ( itemid < 0 )
return
1054 call file_history_query( itemid, do_put )
1056 if ( do_put )
call file_history_put( itemid, var(:) )
1062 subroutine file_history_put_2d( &
1072 integer,
intent(in) :: itemid
1073 real(RP),
intent(in) :: var(:,:)
1076 real(DP),
allocatable :: buffer(:)
1086 if ( file_history_disabled )
return
1087 if ( itemid < 0 )
return
1089 call file_history_query( itemid, do_put )
1090 if ( .not. do_put )
return
1094 do i = 1, file_history_var_inputs(itemid)%nvariants
1095 id = file_history_var_inputs(itemid)%variants(i)
1097 dt = ( file_history_nowstep - file_history_vars(id)%laststep_put ) * file_history_dtsec
1099 if ( dt < eps .AND. ( .NOT. file_history_vars(id)%taverage ) )
then
1100 log_error(
"FILE_HISTORY_Put_2D",*)
'variable was put two times before output!: ', &
1101 trim(file_history_vars(id)%name), file_history_nowstep, file_history_vars(id)%laststep_put
1105 if ( file_history_vars(id)%flag_clear )
then
1106 file_history_vars(id)%timesum = 0.0_dp
1107 if ( file_history_vars(id)%taverage ) file_history_vars(id)%varsum(:) = 0.0_dp
1110 dimid = file_history_vars(id)%dimid
1111 if ( file_history_vars(id)%taverage )
then
1112 allocate( buffer( file_history_vars(id)%size ) )
1114 file_history_dims(dimid)%name, &
1115 file_history_vars(id)%zcoord, &
1116 file_history_vars(id)%fill_halo, &
1118 do idx = 1, file_history_vars(id)%size
1119 if ( file_history_vars(id)%varsum(idx) /= rmiss )
then
1120 if ( buffer(idx) /= undef )
then
1121 file_history_vars(id)%varsum(idx) = file_history_vars(id)%varsum(idx) + buffer(idx) * dt
1123 file_history_vars(id)%varsum(idx) = rmiss
1127 deallocate( buffer )
1128 file_history_vars(id)%timesum = file_history_vars(id)%timesum + dt
1131 file_history_dims(dimid)%name, &
1132 file_history_vars(id)%zcoord, &
1133 file_history_vars(id)%fill_halo, &
1134 file_history_vars(id)%varsum(:) )
1135 file_history_vars(id)%timesum = 0.0_dp
1138 file_history_vars(id)%laststep_put = file_history_nowstep
1139 file_history_vars(id)%flag_clear = .false.
1146 end subroutine file_history_put_2d
1159 real(RP),
intent(in) :: var(:,:)
1160 character(len=*),
intent(in) :: name
1161 character(len=*),
intent(in) :: desc
1162 character(len=*),
intent(in) :: unit
1164 character(len=*),
intent(in),
optional :: standard_name
1165 character(len=*),
intent(in),
optional :: dim_type
1166 logical,
intent(in),
optional :: fill_halo
1168 integer,
parameter :: ndim = 2
1173 if ( file_history_disabled )
return
1178 standard_name=standard_name, &
1180 dim_type=dim_type, &
1181 fill_halo=fill_halo )
1183 if ( itemid < 0 )
return
1186 call file_history_query( itemid, do_put )
1188 if ( do_put )
call file_history_put( itemid, var(:,:) )
1194 subroutine file_history_put_3d( &
1204 integer,
intent(in) :: itemid
1205 real(RP),
intent(in) :: var(:,:,:)
1208 real(DP),
allocatable :: buffer(:)
1218 if ( file_history_disabled )
return
1219 if ( itemid < 0 )
return
1221 call file_history_query( itemid, do_put )
1222 if ( .not. do_put )
return
1226 do i = 1, file_history_var_inputs(itemid)%nvariants
1227 id = file_history_var_inputs(itemid)%variants(i)
1229 dt = ( file_history_nowstep - file_history_vars(id)%laststep_put ) * file_history_dtsec
1231 if ( dt < eps .AND. ( .NOT. file_history_vars(id)%taverage ) )
then
1232 log_error(
"FILE_HISTORY_Put_3D",*)
'variable was put two times before output!: ', &
1233 trim(file_history_vars(id)%name), file_history_nowstep, file_history_vars(id)%laststep_put
1237 if ( file_history_vars(id)%flag_clear )
then
1238 file_history_vars(id)%timesum = 0.0_dp
1239 if ( file_history_vars(id)%taverage ) file_history_vars(id)%varsum(:) = 0.0_dp
1242 dimid = file_history_vars(id)%dimid
1243 if ( file_history_vars(id)%taverage )
then
1244 allocate( buffer( file_history_vars(id)%size ) )
1246 file_history_dims(dimid)%name, &
1247 file_history_vars(id)%zcoord, &
1248 file_history_vars(id)%fill_halo, &
1250 do idx = 1, file_history_vars(id)%size
1251 if ( file_history_vars(id)%varsum(idx) /= rmiss )
then
1252 if ( buffer(idx) /= undef )
then
1253 file_history_vars(id)%varsum(idx) = file_history_vars(id)%varsum(idx) + buffer(idx) * dt
1255 file_history_vars(id)%varsum(idx) = rmiss
1259 deallocate( buffer )
1260 file_history_vars(id)%timesum = file_history_vars(id)%timesum + dt
1263 file_history_dims(dimid)%name, &
1264 file_history_vars(id)%zcoord, &
1265 file_history_vars(id)%fill_halo, &
1266 file_history_vars(id)%varsum(:) )
1267 file_history_vars(id)%timesum = 0.0_dp
1270 file_history_vars(id)%laststep_put = file_history_nowstep
1271 file_history_vars(id)%flag_clear = .false.
1278 end subroutine file_history_put_3d
1291 real(RP),
intent(in) :: var(:,:,:)
1292 character(len=*),
intent(in) :: name
1293 character(len=*),
intent(in) :: desc
1294 character(len=*),
intent(in) :: unit
1296 character(len=*),
intent(in),
optional :: standard_name
1297 character(len=*),
intent(in),
optional :: dim_type
1298 logical,
intent(in),
optional :: fill_halo
1300 integer,
parameter :: ndim = 3
1305 if ( file_history_disabled )
return
1310 standard_name=standard_name, &
1312 dim_type=dim_type, &
1313 fill_halo=fill_halo )
1315 if ( itemid < 0 )
return
1318 call file_history_query( itemid, do_put )
1320 if ( do_put )
call file_history_put( itemid, var(:,:,:) )
1326 subroutine file_history_put_4d( &
1336 integer,
intent(in) :: itemid
1337 real(RP),
intent(in) :: var(:,:,:,:)
1340 real(DP),
allocatable :: buffer(:)
1350 if ( file_history_disabled )
return
1351 if ( itemid < 0 )
return
1353 call file_history_query( itemid, do_put )
1354 if ( .not. do_put )
return
1358 do i = 1, file_history_var_inputs(itemid)%nvariants
1359 id = file_history_var_inputs(itemid)%variants(i)
1361 dt = ( file_history_nowstep - file_history_vars(id)%laststep_put ) * file_history_dtsec
1363 if ( dt < eps .AND. ( .NOT. file_history_vars(id)%taverage ) )
then
1364 log_error(
"FILE_HISTORY_Put_4D",*)
'variable was put two times before output!: ', &
1365 trim(file_history_vars(id)%name), file_history_nowstep, file_history_vars(id)%laststep_put
1369 if ( file_history_vars(id)%flag_clear )
then
1370 file_history_vars(id)%timesum = 0.0_dp
1371 if ( file_history_vars(id)%taverage ) file_history_vars(id)%varsum(:) = 0.0_dp
1374 dimid = file_history_vars(id)%dimid
1375 if ( file_history_vars(id)%taverage )
then
1376 allocate( buffer( file_history_vars(id)%size ) )
1378 file_history_dims(dimid)%name, &
1379 file_history_vars(id)%zcoord, &
1380 file_history_vars(id)%fill_halo, &
1382 do idx = 1, file_history_vars(id)%size
1383 if ( file_history_vars(id)%varsum(idx) /= rmiss )
then
1384 if ( buffer(idx) /= undef )
then
1385 file_history_vars(id)%varsum(idx) = file_history_vars(id)%varsum(idx) + buffer(idx) * dt
1387 file_history_vars(id)%varsum(idx) = rmiss
1391 deallocate( buffer )
1392 file_history_vars(id)%timesum = file_history_vars(id)%timesum + dt
1395 file_history_dims(dimid)%name, &
1396 file_history_vars(id)%zcoord, &
1397 file_history_vars(id)%fill_halo, &
1398 file_history_vars(id)%varsum(:) )
1399 file_history_vars(id)%timesum = 0.0_dp
1402 file_history_vars(id)%laststep_put = file_history_nowstep
1403 file_history_vars(id)%flag_clear = .false.
1410 end subroutine file_history_put_4d
1423 real(RP),
intent(in) :: var(:,:,:,:)
1424 character(len=*),
intent(in) :: name
1425 character(len=*),
intent(in) :: desc
1426 character(len=*),
intent(in) :: unit
1428 character(len=*),
intent(in),
optional :: standard_name
1429 character(len=*),
intent(in),
optional :: dim_type
1430 logical,
intent(in),
optional :: fill_halo
1432 integer,
parameter :: ndim = 4
1437 if ( file_history_disabled )
return
1442 standard_name=standard_name, &
1444 dim_type=dim_type, &
1445 fill_halo=fill_halo )
1447 if ( itemid < 0 )
return
1450 call file_history_query( itemid, do_put )
1452 if ( do_put )
call file_history_put( itemid, var(:,:,:,:) )
1467 area, area_x, area_y, &
1472 character(len=*),
intent(in) :: name
1473 integer,
intent(in) :: ndims
1474 integer,
intent(in) :: nzcoords
1475 character(len=*),
intent(in) :: dims(ndims,nzcoords)
1476 character(len=*),
intent(in) :: zcoords(nzcoords)
1477 integer,
intent(in) :: start(ndims,nzcoords)
1478 integer,
intent(in) :: count(ndims,nzcoords)
1480 character(len=*),
intent(in),
optional :: mapping
1481 character(len=*),
intent(in),
optional :: area
1482 character(len=*),
intent(in),
optional :: area_x
1483 character(len=*),
intent(in),
optional :: area_y
1484 character(len=*),
intent(in),
optional :: volume
1485 character(len=*),
intent(in),
optional :: location
1486 character(len=*),
intent(in),
optional :: grid
1489 integer :: size, n, m
1491 if ( file_history_ndims >= file_history_dim_max )
then
1492 log_error(
"FILE_HISTORY_Set_Dim",*)
'number of dimension exceed max limit: ', file_history_dim_max
1495 file_history_ndims = file_history_ndims + 1
1496 id = file_history_ndims
1498 allocate( file_history_dims(id)%dims (max(ndims,1),nzcoords) )
1499 allocate( file_history_dims(id)%start(max(ndims,1),nzcoords) )
1500 allocate( file_history_dims(id)%count(max(ndims,1),nzcoords) )
1501 allocate( file_history_dims(id)%zcoords(nzcoords) )
1502 allocate( file_history_dims(id)%size(nzcoords) )
1504 file_history_dims(id)%name = name
1505 file_history_dims(id)%ndims = ndims
1506 file_history_dims(id)%nzcoords = nzcoords
1507 file_history_dims(id)%zcoords(:) = zcoords(:)
1508 if ( ndims > 0 )
then
1509 file_history_dims(id)%dims(:,:) = dims(:,:)
1510 file_history_dims(id)%start(:,:) = start(:,:)
1511 file_history_dims(id)%count(:,:) = count(:,:)
1513 file_history_dims(id)%dims(1,1) =
""
1514 file_history_dims(id)%start(1,1) = 1
1515 file_history_dims(id)%count(1,1) = 1
1521 size =
size * count(n,m)
1523 file_history_dims(id)%size(m) =
size
1526 if (
present(mapping) )
then
1527 file_history_dims(id)%mapping = mapping
1529 file_history_dims(id)%mapping =
""
1532 if (
present(area) )
then
1533 file_history_dims(id)%area = area
1535 file_history_dims(id)%area =
""
1537 if (
present(area_x) )
then
1538 file_history_dims(id)%area_x = area_x
1540 file_history_dims(id)%area_x =
""
1542 if (
present(area_y) )
then
1543 file_history_dims(id)%area_y = area_y
1545 file_history_dims(id)%area_y =
""
1547 if (
present(volume) )
then
1548 file_history_dims(id)%volume = volume
1550 file_history_dims(id)%volume =
""
1553 if (
present(location) )
then
1554 file_history_dims(id)%location = location
1555 if (
present(grid) )
then
1556 file_history_dims(id)%grid =
"grid_"//trim(grid)
1558 file_history_dims(id)%grid =
"grid"
1561 file_history_dims(id)%location =
""
1562 file_history_dims(id)%grid =
""
1572 name, desc, units, &
1581 character(len=*),
intent(in) :: name
1582 character(len=*),
intent(in) :: desc
1583 character(len=*),
intent(in) :: units
1584 character(len=*),
intent(in) :: dim
1585 real(
rp),
intent(in) :: var(:)
1587 real(
rp),
intent(in),
optional :: bounds(:,:)
1588 logical,
intent(in),
optional :: down
1589 integer,
intent(in),
optional :: gsize
1590 integer,
intent(in),
optional :: start
1598 dim_size =
size(var)
1600 if ( file_history_naxes >= file_history_axis_max )
then
1601 log_error(
"FILE_HISTORY_Set_Axis",*)
'Number of axis exceeds the limit.'
1605 file_history_naxes = file_history_naxes + 1
1606 id = file_history_naxes
1608 allocate( file_history_axes(id)%var(dim_size) )
1610 file_history_axes(id)%name = name
1611 file_history_axes(id)%desc = desc
1612 file_history_axes(id)%units = units
1613 file_history_axes(id)%dim = dim
1614 file_history_axes(id)%dim_size = dim_size
1615 file_history_axes(id)%var(:) = var(:)
1617 if (
present(down) )
then
1618 file_history_axes(id)%down = down
1620 file_history_axes(id)%down = .false.
1622 if (
present(gsize) )
then
1623 file_history_axes(id)%gdim_size = gsize
1625 file_history_axes(id)%gdim_size = -1
1627 if (
present(start) )
then
1628 file_history_axes(id)%start = start
1630 file_history_axes(id)%start = 1
1633 if (
present(bounds) )
then
1634 allocate( file_history_axes(id)%bounds(2,dim_size) )
1635 file_history_axes(id)%bounds(:,:) = bounds(:,:)
1648 integer :: fid, prev_fid
1652 if ( file_history_disabled )
return
1657 do id = 1, file_history_nitems
1658 call file_history_write_onevar( id, file_history_nowstep )
1664 do id = 1, file_history_nitems
1665 fid = file_history_vars(id)%fid
1666 if ( fid > 0 .AND. fid /= prev_fid )
then
1673 if ( file_history_output_switch_step >= 0 &
1674 .AND. file_history_nowstep-file_history_output_switch_laststep > file_history_output_switch_step )
then
1676 call file_history_close
1678 log_info(
"FILE_HISTORY_Write",*)
'FILE_HISTORY file is switched.'
1680 do id = 1, file_history_nitems
1681 file_history_vars(id)%fid = -1
1682 file_history_vars(id)%vid = -1
1685 file_history_output_switch_laststep = file_history_nowstep - 1
1697 integer,
intent(in) :: nowdate(:)
1698 real(
dp),
intent(in) :: nowsubsec
1699 integer,
intent(in) :: nowstep
1701 file_history_nowdate(:) = nowdate(:)
1702 file_history_nowsubsec = nowsubsec
1703 file_history_nowstep = nowstep
1714 logical,
intent(in) ::
switch
1717 file_history_disabled =
switch
1727 call file_history_close
1736 subroutine file_history_check( &
1741 character(len=*),
intent(in) :: name
1742 character(len=*),
intent(in) :: zcoord
1743 integer,
intent(out) :: itemid
1749 do itemid = 1, file_history_nvar_inputs
1750 if ( name == file_history_var_inputs(itemid)%name )
then
1751 do i = 1, file_history_var_inputs(itemid)%nvariants
1752 id = file_history_var_inputs(itemid)%variants(
i)
1754 if ( file_history_vars(id)%zcoord == zcoord )
return
1761 end subroutine file_history_check
1764 subroutine file_history_add_variable( &
1765 name, desc, units, &
1775 character(len=*),
intent(in) :: name
1776 character(len=*),
intent(in) :: desc
1777 character(len=*),
intent(in) :: units
1778 character(len=*),
intent(in) :: standard_name
1779 integer,
intent(in) :: dimid
1780 character(len=*),
intent(in) :: zcoord
1781 integer,
intent(out) :: itemid
1782 character(len=*),
intent(in),
optional :: cell_measures
1783 logical,
intent(in),
optional :: fill_halo
1785 integer :: reqid, zid, id
1792 call file_history_check( name, zcoord, &
1795 if ( itemid > 0 )
return
1797 do reqid = 1, file_history_nreqs
1799 if ( file_history_req(reqid)%registered ) cycle
1800 if ( name /= file_history_req(reqid)%name ) cycle
1802 if ( file_history_dims(dimid)%nzcoords == 1 .or. &
1803 zcoord == file_history_req(reqid)%zcoord )
then
1805 file_history_req(reqid)%registered = .true.
1807 file_history_nitems = file_history_nitems + 1
1808 id = file_history_nitems
1810 file_history_vars(id)%name = file_history_req(reqid)%name
1811 file_history_vars(id)%outname = file_history_req(reqid)%outname
1812 file_history_vars(id)%basename = file_history_req(reqid)%basename
1813 file_history_vars(id)%postfix_timelabel = file_history_req(reqid)%postfix_timelabel
1814 file_history_vars(id)%zcoord = zcoord
1815 file_history_vars(id)%dstep = file_history_req(reqid)%dstep
1816 file_history_vars(id)%taverage = file_history_req(reqid)%taverage
1817 file_history_vars(id)%dtype = file_history_req(reqid)%dtype
1819 file_history_vars(id)%zid = -1
1820 do zid = 1, file_history_dims(dimid)%nzcoords
1821 if ( file_history_dims(dimid)%zcoords(zid) == file_history_vars(id)%zcoord )
then
1822 file_history_vars(id)%zid = zid
1827 log_error(
"FILE_HISTORY_Add_Variable",*)
'z-coordinate ', trim(file_history_vars(id)%zcoord),
' is not found for dimension ', trim(file_history_dims(dimid)%name)
1831 file_history_vars(id)%fid = -1
1832 file_history_vars(id)%vid = -1
1833 file_history_vars(id)%desc = desc
1834 file_history_vars(id)%units = units
1835 file_history_vars(id)%standard_name = standard_name
1836 file_history_vars(id)%dimid = dimid
1837 if (
present(cell_measures) )
then
1838 file_history_vars(id)%cell_measures = cell_measures
1840 file_history_vars(id)%cell_measures =
""
1842 if (
present(fill_halo) )
then
1843 file_history_vars(id)%fill_halo = fill_halo
1845 file_history_vars(id)%fill_halo = .false.
1848 file_history_vars(id)%waitstep = file_history_output_wait_step
1849 if ( file_history_output_step0 .AND. file_history_nowstep == 1 )
then
1850 file_history_vars(id)%laststep_write = 1 - file_history_vars(id)%dstep
1852 file_history_vars(id)%laststep_write = 1
1854 file_history_vars(id)%laststep_put = file_history_vars(id)%laststep_write
1855 file_history_vars(id)%flag_clear = .true.
1856 file_history_vars(id)%size = file_history_dims(dimid)%size(zid)
1857 allocate( file_history_vars(id)%varsum( file_history_vars(id)%size ) )
1859 file_history_vars(id)%timesum = 0.0_dp
1862 log_info(
"FILE_HISTORY_Add_Variable",*)
'[HISTORY] Item registration No.= ', id
1863 log_info_cont(*)
'Item name : ', trim(file_history_vars(id)%name)
1864 log_info_cont(*)
'Output name : ', trim(file_history_vars(id)%outname)
1865 log_info_cont(*)
'Description : ', trim(file_history_vars(id)%desc)
1866 log_info_cont(*)
'Unit : ', trim(file_history_vars(id)%units)
1867 log_info_cont(*)
'Basename of output file : ', trim(file_history_vars(id)%basename)
1868 log_info_cont(*)
'Add timelabel to the filename? : ', file_history_vars(id)%postfix_timelabel
1869 log_info_cont(*)
'Zcoord : ', trim(file_history_vars(id)%zcoord)
1870 log_info_cont(*)
'Interval [step] : ', file_history_vars(id)%dstep
1871 log_info_cont(*)
'Time Average? : ', file_history_vars(id)%taverage
1872 log_info_cont(*)
'Datatype : ', trim(
file_dtypelist(file_history_vars(id)%dtype))
1873 log_info_cont(*)
'axis name : ', ( trim(file_history_dims(dimid)%dims(n,zid))//
" ", n=1, file_history_dims(dimid)%ndims )
1877 do m = 1, file_history_nvar_inputs
1878 if ( file_history_var_inputs(m)%name == name )
then
1879 file_history_var_inputs(m)%nvariants = file_history_var_inputs(m)%nvariants + 1
1880 if ( file_history_var_inputs(m)%nvariants > file_history_variant_max )
then
1881 log_error(
"FILE_HISTORY_Add_Variable",*)
'Number of variant for ', trim(name),
' excees limit!'
1884 file_history_var_inputs(m)%variants(file_history_var_inputs(m)%nvariants) = id
1890 if ( .not. existed )
then
1891 file_history_nvar_inputs = file_history_nvar_inputs + 1
1892 itemid = file_history_nvar_inputs
1893 file_history_var_inputs(itemid)%name = name
1894 file_history_var_inputs(itemid)%nvariants = 1
1895 file_history_var_inputs(itemid)%variants(1) = id
1903 end subroutine file_history_add_variable
1906 subroutine file_history_create( &
1921 file_add_variable, &
1927 integer,
intent(in) :: id
1929 character(len=*),
intent(in) :: options
1932 character(len=H_MID) :: tunits
1933 character(len=H_LONG) :: basename_mod
1934 logical :: fileexisted
1935 integer(8) :: array_size
1938 integer :: dimid, zid
1940 character(len=H_SHORT) :: dims(3)
1943 character(len=H_MID) :: timelabel
1945 integer :: ic, ie, is, lo
1949 fid = file_history_vars(id)%fid
1951 if ( fid >= 0 )
return
1953 if ( file_history_time_since ==
'' )
then
1954 tunits = trim(file_history_time_units)
1956 tunits = trim(file_history_time_units)//
' since '//trim(file_history_time_since)
1959 if ( file_history_vars(id)%postfix_timelabel )
then
1962 basename_mod = trim(file_history_vars(id)%basename)//
'_'//trim(timelabel)
1964 basename_mod = trim(file_history_vars(id)%basename)
1968 file_history_title, &
1969 file_history_source, &
1970 file_history_institution, &
1972 rankid = file_history_myrank, &
1974 time_units = tunits, &
1975 calendar = file_history_calendar )
1977 if ( .not. fileexisted )
then
1983 lo = len_trim(options)
1986 if ( m == lo+1 .OR. options(m:m) ==
'&' )
then
1987 if ( ic == -1 .OR. ie == -1 )
then
1988 log_error(
"FILE_HISTORY_Create",*)
'option is invalid: ', trim(options)
1991 call file_set_option( fid, options(is:ic-1), options(ic+1:ie-1), options(ie+1:m -1) )
1995 elseif( options(m:m) ==
':' )
then
1997 elseif( options(m:m) ==
'=' )
then
2003 if (
rp ==
dp )
then
2011 do m = 1, file_history_naxes
2013 dim_size = file_history_axes(m)%gdim_size
2014 if ( dim_size < 1 )
then
2015 log_error(
"FILE_HISTORY_Create",*)
'gsize is not set by FILE_HISTORY_Set_Axis'
2016 log_error_cont(*)
'It is necessary for aggregate file'
2020 dim_size = file_history_axes(m)%dim_size
2023 file_history_axes(m)%name, &
2024 file_history_axes(m)%desc, &
2025 file_history_axes(m)%units, &
2026 file_history_axes(m)%dim, &
2028 bounds=
associated(file_history_axes(m)%bounds) )
2029 if ( file_history_axes(m)%down )
then
2030 call file_set_attribute( fid, file_history_axes(m)%name,
'positive',
'down' )
2036 do m = 1, file_history_nassocs
2037 ndims = file_history_assocs(m)%ndims
2039 file_history_assocs(m)%name, &
2040 file_history_assocs(m)%desc, &
2041 file_history_assocs(m)%units, &
2042 file_history_assocs(m)%dims(1:ndims), &
2043 file_history_assocs(m)%dtype )
2047 do m = 1, file_history_nattrs
2049 if ( file_history_attrs(m)%add_variable )
then
2054 select case ( file_history_attrs(m)%type )
2056 call file_set_attribute( fid, &
2057 file_history_attrs(m)%varname, &
2058 file_history_attrs(m)%key, &
2059 file_history_attrs(m)%text )
2061 call file_set_attribute( fid, &
2062 file_history_attrs(m)%varname, &
2063 file_history_attrs(m)%key, &
2064 file_history_attrs(m)%int(:) )
2066 call file_set_attribute( fid, &
2067 file_history_attrs(m)%varname, &
2068 file_history_attrs(m)%key, &
2069 file_history_attrs(m)%float(:) )
2071 call file_set_attribute( fid, &
2072 file_history_attrs(m)%varname, &
2073 file_history_attrs(m)%key, &
2074 file_history_attrs(m)%double(:) )
2084 do m = 1, file_history_nitems
2085 if ( file_history_vars(id)%basename == file_history_vars(m)%basename .and. &
2086 file_history_vars(m)%fid < 0 )
then
2088 file_history_vars(m)%fid = fid
2089 dtsec = real(file_history_vars(m)%dstep,kind=
dp) * file_history_dtsec
2090 dimid = file_history_vars(m)%dimid
2091 zid = file_history_vars(m)%zid
2092 ndims = file_history_dims(dimid)%ndims
2093 dims(1:ndims) = file_history_dims(dimid)%dims(1:ndims,zid)
2094 call file_add_variable( file_history_vars(m)%fid, &
2095 file_history_vars(m)%outname, &
2096 file_history_vars(m)%desc, &
2097 file_history_vars(m)%units, &
2098 file_history_vars(m)%standard_name, &
2100 file_history_vars(m)%dtype, &
2102 file_history_vars(m)%vid, &
2103 time_avg=file_history_vars(m)%taverage )
2104 if ( file_history_dims(dimid)%mapping /=
"" )
then
2105 call file_set_attribute( file_history_vars(m)%fid, file_history_vars(m)%outname, &
2106 'grid_mapping', file_history_dims(dimid)%mapping )
2109 select case( file_history_vars(m)%cell_measures )
2110 case (
"area",
"area_z" )
2111 if ( file_history_dims(dimid)%area /=
"" )
then
2112 call file_set_attribute( file_history_vars(m)%fid, file_history_vars(m)%outname, &
2113 'cell_measures',
"area: "//trim(file_history_dims(dimid)%area) )
2116 if ( file_history_dims(dimid)%area_x /=
"" )
then
2117 call file_set_attribute( file_history_vars(m)%fid, file_history_vars(m)%outname, &
2118 'cell_measures',
"area: "//trim(file_history_dims(dimid)%area_x) )
2121 if ( file_history_dims(dimid)%area_x /=
"" )
then
2122 call file_set_attribute( file_history_vars(m)%fid, file_history_vars(m)%outname, &
2123 'cell_measures',
"area: "//trim(file_history_dims(dimid)%area_y) )
2126 if ( file_history_dims(dimid)%area_x /=
"" )
then
2127 call file_set_attribute( file_history_vars(m)%fid, file_history_vars(m)%outname, &
2128 'cell_measures',
"volume: "//trim(file_history_dims(dimid)%volume) )
2132 if ( file_history_dims(dimid)%location /=
"" )
then
2133 if ( file_history_vars(m)%zcoord ==
"model" )
then
2134 call file_set_attribute( file_history_vars(m)%fid, file_history_vars(m)%outname, &
2135 'grid', file_history_dims(dimid)%grid )
2137 call file_set_attribute( file_history_vars(m)%fid, file_history_vars(m)%outname, &
2138 'grid', trim(file_history_dims(dimid)%grid)//
'_'//trim(file_history_vars(id)%zcoord) )
2140 call file_set_attribute( file_history_vars(m)%fid, file_history_vars(m)%outname, &
2141 'location', file_history_dims(dimid)%location )
2150 do m = 1, file_history_nitems
2151 if ( file_history_vars(m)%fid == file_history_vars(id)%fid )
then
2152 array_size = array_size + file_history_vars(m)%size
2158 if ( .not. fileexisted )
call file_history_write_axes(id)
2161 end subroutine file_history_create
2163 subroutine file_history_close
2169 integer :: fid, prev_fid
2174 do id = 1, file_history_nitems
2175 fid = file_history_vars(id)%fid
2176 file_history_vars(id)%fid = -1
2177 if ( fid > 0 .AND. fid /= prev_fid )
then
2185 end subroutine file_history_close
2203 character(len=*),
intent(in) :: name
2204 character(len=*),
intent(in) :: desc
2205 character(len=*),
intent(in) :: units
2206 character(len=*),
intent(in) :: dims(:)
2207 real(RP),
intent(in) :: var(:)
2208 character(len=*),
intent(in),
optional :: datatype
2209 integer,
intent(in),
optional :: start(:)
2215 intrinsic size, shape, reshape
2218 if (
present(datatype) )
then
2219 if ( datatype ==
'REAL4' )
then
2221 elseif( datatype ==
'REAL8' )
then
2224 log_error(
"FILE_HISTORY_Set_AssociatedCoordinate_1D",*)
'Not appropriate datatype. Check!', datatype
2227 else if ( rp ==
sp )
then
2233 dim_size =
size(var)
2235 if ( file_history_nassocs < file_history_assoc_max )
then
2236 file_history_nassocs = file_history_nassocs + 1
2237 id = file_history_nassocs
2239 allocate( file_history_assocs(id)%var(dim_size) )
2241 file_history_assocs(id)%name = name
2242 file_history_assocs(id)%desc = desc
2243 file_history_assocs(id)%units = units
2244 file_history_assocs(id)%ndims = 1
2245 file_history_assocs(id)%dims(:) =
''
2246 file_history_assocs(id)%dims(1:1) = dims(1:1)
2247 file_history_assocs(id)%dtype = dtype
2248 file_history_assocs(id)%var(:) = real(reshape( var, (/ dim_size /) ),kind=
dp)
2252 file_history_assocs(id)%count(1:1) = shape(var)
2253 if (
present(start) )
then
2254 file_history_assocs(id)%start(1:1) = start(1:1)
2256 file_history_assocs(id)%start = (/ 1, 1, 1, 1 /)
2259 log_error(
"FILE_HISTORY_Set_AssociatedCoordinate_1D",*)
'Number of associate coordinates exceeds the limit.'
2280 character(len=*),
intent(in) :: name
2281 character(len=*),
intent(in) :: desc
2282 character(len=*),
intent(in) :: units
2283 character(len=*),
intent(in) :: dims(:)
2284 real(RP),
intent(in) :: var(:,:)
2285 character(len=*),
intent(in),
optional :: datatype
2286 integer,
intent(in),
optional :: start(:)
2292 intrinsic size, shape, reshape
2295 if (
present(datatype) )
then
2296 if ( datatype ==
'REAL4' )
then
2298 elseif( datatype ==
'REAL8' )
then
2301 log_error(
"FILE_HISTORY_Set_AssociatedCoordinate_2D",*)
'Not appropriate datatype. Check!', datatype
2304 else if ( rp ==
sp )
then
2310 dim_size =
size(var)
2312 if ( file_history_nassocs < file_history_assoc_max )
then
2313 file_history_nassocs = file_history_nassocs + 1
2314 id = file_history_nassocs
2316 allocate( file_history_assocs(id)%var(dim_size) )
2318 file_history_assocs(id)%name = name
2319 file_history_assocs(id)%desc = desc
2320 file_history_assocs(id)%units = units
2321 file_history_assocs(id)%ndims = 2
2322 file_history_assocs(id)%dims(:) =
''
2323 file_history_assocs(id)%dims(1:2) = dims(1:2)
2324 file_history_assocs(id)%dtype = dtype
2325 file_history_assocs(id)%var(:) = real(reshape( var, (/ dim_size /) ),kind=
dp)
2329 file_history_assocs(id)%count(1:2) = shape(var)
2330 if (
present(start) )
then
2331 file_history_assocs(id)%start(1:2) = start(1:2)
2333 file_history_assocs(id)%start = (/ 1, 1, 1, 1 /)
2336 log_error(
"FILE_HISTORY_Set_AssociatedCoordinate_2D",*)
'Number of associate coordinates exceeds the limit.'
2357 character(len=*),
intent(in) :: name
2358 character(len=*),
intent(in) :: desc
2359 character(len=*),
intent(in) :: units
2360 character(len=*),
intent(in) :: dims(:)
2361 real(RP),
intent(in) :: var(:,:,:)
2362 character(len=*),
intent(in),
optional :: datatype
2363 integer,
intent(in),
optional :: start(:)
2369 intrinsic size, shape, reshape
2372 if (
present(datatype) )
then
2373 if ( datatype ==
'REAL4' )
then
2375 elseif( datatype ==
'REAL8' )
then
2378 log_error(
"FILE_HISTORY_Set_AssociatedCoordinate_3D",*)
'Not appropriate datatype. Check!', datatype
2381 else if ( rp ==
sp )
then
2387 dim_size =
size(var)
2389 if ( file_history_nassocs < file_history_assoc_max )
then
2390 file_history_nassocs = file_history_nassocs + 1
2391 id = file_history_nassocs
2393 allocate( file_history_assocs(id)%var(dim_size) )
2395 file_history_assocs(id)%name = name
2396 file_history_assocs(id)%desc = desc
2397 file_history_assocs(id)%units = units
2398 file_history_assocs(id)%ndims = 3
2399 file_history_assocs(id)%dims(:) =
''
2400 file_history_assocs(id)%dims(1:3) = dims(1:3)
2401 file_history_assocs(id)%dtype = dtype
2402 file_history_assocs(id)%var(:) = real(reshape( var, (/ dim_size /) ),kind=
dp)
2406 file_history_assocs(id)%count(1:3) = shape(var)
2407 if (
present(start) )
then
2408 file_history_assocs(id)%start(1:3) = start(1:3)
2410 file_history_assocs(id)%start = (/ 1, 1, 1, 1 /)
2413 log_error(
"FILE_HISTORY_Set_AssociatedCoordinate_3D",*)
'Number of associate coordinates exceeds the limit.'
2432 character(len=*),
intent(in) :: varname
2433 character(len=*),
intent(in) :: key
2434 character(len=*),
intent(in) :: val
2435 logical,
intent(in),
optional :: add_variable
2440 file_history_nattrs = file_history_nattrs + 1
2441 if ( file_history_nattrs > file_history_attr_max )
then
2442 log_error(
"FILE_HISTORY_Set_Attribute_Text",*)
'number of attributes exceeds the limit'
2446 id = file_history_nattrs
2448 file_history_attrs(id)%varname = varname
2449 file_history_attrs(id)%key = key
2450 file_history_attrs(id)%text = val
2451 file_history_attrs(id)%type = i_text
2453 if (
present(add_variable) )
then
2454 file_history_attrs(id)%add_variable = add_variable
2456 file_history_attrs(id)%add_variable = .false.
2469 character(len=*),
intent(in) :: varname
2470 character(len=*),
intent(in) :: key
2471 logical,
intent(in) :: val
2472 logical,
intent(in),
optional :: add_variable
2474 character(len=5) :: buf
2498 character(len=*),
intent(in) :: varname
2499 character(len=*),
intent(in) :: key
2500 integer,
intent(in) :: val(:)
2501 logical,
intent(in),
optional :: add_variable
2508 file_history_nattrs = file_history_nattrs + 1
2509 if ( file_history_nattrs > file_history_attr_max )
then
2510 log_error(
"FILE_HISTORY_Set_Attribute_Int",*)
'number of attributes exceeds the limit'
2514 id = file_history_nattrs
2516 allocate( file_history_attrs(id)%int(
size(val) ) )
2518 file_history_attrs(id)%varname = varname
2519 file_history_attrs(id)%key = key
2520 file_history_attrs(id)%int(:) = val(:)
2521 file_history_attrs(id)%type = i_int
2523 if (
present(add_variable) )
then
2524 file_history_attrs(id)%add_variable = add_variable
2526 file_history_attrs(id)%add_variable = .false.
2538 character(len=*),
intent(in) :: varname
2539 character(len=*),
intent(in) :: key
2540 integer,
intent(in) :: val
2541 logical,
intent(in),
optional :: add_variable
2549 add_variable=add_variable )
2555 subroutine file_history_set_attribute_float_ary( &
2564 character(len=*),
intent(in) :: varname
2565 character(len=*),
intent(in) :: key
2566 real(SP),
intent(in) :: val(:)
2567 logical,
intent(in),
optional :: add_variable
2574 file_history_nattrs = file_history_nattrs + 1
2575 if ( file_history_nattrs > file_history_attr_max )
then
2576 log_error(
"FILE_HISTORY_Set_Attribute_Float",*)
'number of attributes exceeds the limit'
2580 id = file_history_nattrs
2582 allocate( file_history_attrs(id)%float(
size(val) ) )
2584 file_history_attrs(id)%varname = varname
2585 file_history_attrs(id)%key = key
2586 file_history_attrs(id)%float(:) = val(:)
2587 file_history_attrs(id)%type = i_float
2589 if (
present(add_variable) )
then
2590 file_history_attrs(id)%add_variable = add_variable
2592 file_history_attrs(id)%add_variable = .false.
2596 end subroutine file_history_set_attribute_float_ary
2603 character(len=*),
intent(in) :: varname
2604 character(len=*),
intent(in) :: key
2605 real(SP),
intent(in) :: val
2606 logical,
intent(in),
optional :: add_variable
2611 call file_history_set_attribute_float_ary( varname, &
2618 subroutine file_history_set_attribute_double_ary( &
2627 character(len=*),
intent(in) :: varname
2628 character(len=*),
intent(in) :: key
2629 real(DP),
intent(in) :: val(:)
2630 logical,
intent(in),
optional :: add_variable
2637 file_history_nattrs = file_history_nattrs + 1
2638 if ( file_history_nattrs > file_history_attr_max )
then
2639 log_error(
"FILE_HISTORY_Set_Attribute_Double",*)
'number of attributes exceeds the limit'
2643 id = file_history_nattrs
2645 allocate( file_history_attrs(id)%double(
size(val) ) )
2647 file_history_attrs(id)%varname = varname
2648 file_history_attrs(id)%key = key
2649 file_history_attrs(id)%double(:) = val(:)
2650 file_history_attrs(id)%type = i_double
2652 if (
present(add_variable) )
then
2653 file_history_attrs(id)%add_variable = add_variable
2655 file_history_attrs(id)%add_variable = .false.
2659 end subroutine file_history_set_attribute_double_ary
2666 character(len=*),
intent(in) :: varname
2667 character(len=*),
intent(in) :: key
2668 real(DP),
intent(in) :: val
2669 logical,
intent(in),
optional :: add_variable
2674 call file_history_set_attribute_double_ary( varname, &
2684 subroutine file_history_query_id( &
2687 integer,
intent(in) :: itemid
2688 logical,
intent(out) :: answer
2693 if ( file_history_disabled )
return
2694 if ( itemid < 0 )
return
2696 do i = 1, file_history_var_inputs(itemid)%nvariants
2697 id = file_history_var_inputs(itemid)%variants(i)
2698 if ( file_history_vars(id)%taverage )
then
2701 else if ( file_history_nowstep >= file_history_vars(id)%laststep_write + file_history_vars(id)%dstep )
then
2708 end subroutine file_history_query_id
2710 subroutine file_history_query_name( &
2715 character(len=*),
intent(in) :: name
2717 logical,
intent(out) :: answer
2723 if ( file_history_disabled )
return
2725 do itemid = 1, file_history_nvar_inputs
2726 if ( file_history_var_inputs(itemid)%name == name )
then
2727 call file_history_query_id( itemid, answer )
2733 end subroutine file_history_query_name
2736 subroutine file_history_write_axes(id)
2741 file_write_associatedcoordinate
2745 integer,
intent(in) :: id
2751 if ( id < 0 )
return
2753 fid = file_history_vars(id)%fid
2757 do m = 1, file_history_naxes
2758 if ( file_history_axes(m)%start > 0 )
then
2759 start(1) = file_history_axes(m)%start
2761 call file_write_axis( fid, &
2762 file_history_axes(m)%name, &
2763 file_history_axes(m)%var, &
2766 if (
associated(file_history_axes(m)%bounds) )
then
2767 call file_write_associatedcoordinate( fid, &
2768 trim(file_history_axes(m)%name)//
'_bnds', &
2769 file_history_axes(m)%bounds(:,:), &
2776 do m = 1, file_history_nassocs
2777 call file_write_associatedcoordinate( fid, &
2778 file_history_assocs(m)%name, &
2779 file_history_assocs(m)%var, &
2780 file_history_assocs(m)%start, &
2781 file_history_assocs(m)%count, &
2782 file_history_assocs(m)%ndims )
2789 end subroutine file_history_write_axes
2792 subroutine file_history_write_onevar( &
2803 integer,
intent(in) :: id
2804 integer,
intent(in) :: step_now
2806 integer :: dimid, zid
2807 real(DP) :: time_str, time_end
2808 real(DP) :: sec_str, sec_end
2812 if( file_history_nreqs == 0 )
return
2814 if ( step_now < file_history_vars(id)%laststep_write + file_history_vars(id)%dstep )
then
2818 if ( file_history_vars(id)%flag_clear )
then
2819 if ( file_history_output_step0 .AND. file_history_nowstep == 1 )
then
2820 do i = 1, file_history_vars(id)%size
2821 file_history_vars(id)%varsum(i) = rmiss
2823 else if ( file_history_error_putmiss )
then
2824 log_error(
"FILE_HISTORY_Write_OneVar",*)
'The time interval of history output ', trim(file_history_vars(id)%name), &
2825 ' and the time interval of its related scheme are inconsistent.'
2826 log_error_cont(*)
'Please check the namelist PARAM_TIME, PARAM_FILE_HISTORY, and HISTORY_ITEM.'
2827 log_error_cont(*)
'Please set FILE_HISTORY_ERROR_PUTMISS in the namelist PARAM_FILE_HISTORY to .false.', &
2828 ' when you want to disable this check.'
2829 log_error_cont(*)
'The time interval of history output ', trim(file_history_vars(id)%name), &
2830 ' and the time interval of its related scheme are inconsistent.', &
2831 ' Please see detail in log file.'
2834 log_warn(
"FILE_HISTORY_Write_OneVar",*)
'Output value is not updated in this step.', &
2835 ' NAME = ', trim(file_history_vars(id)%name), &
2836 ', OUTNAME = ', trim(file_history_vars(id)%outname)
2840 if ( .NOT. file_history_vars(id)%flag_clear .AND. file_history_vars(id)%taverage )
then
2841 do i = 1, file_history_vars(id)%size
2842 if ( file_history_vars(id)%varsum(i) /= rmiss )
then
2843 file_history_vars(id)%varsum(i) = file_history_vars(id)%varsum(i) / file_history_vars(id)%timesum
2848 call file_history_output_list
2850 if ( step_now > file_history_vars(id)%waitstep )
then
2851 if ( laststep_write < step_now )
then
2852 log_progress(*)
'output history'
2857 call file_history_create( id, options = file_history_options )
2859 sec_str = file_history_startdaysec + real(file_history_vars(id)%laststep_write-1,kind=dp) * file_history_dtsec
2860 sec_end = file_history_startdaysec + real(step_now -1,kind=dp) * file_history_dtsec
2866 dimid = file_history_vars(id)%dimid
2867 zid = file_history_vars(id)%zid
2868 if ( file_history_dims(dimid)%count(1,zid) > 0 )
then
2875 call file_write( file_history_vars(id)%vid, &
2876 file_history_vars(id)%varsum(:), &
2879 ndims=file_history_dims(dimid)%ndims, &
2880 count=file_history_dims(dimid)%count(:,zid), &
2881 start=file_history_dims(dimid)%start(:,zid) )
2884 if ( laststep_write < step_now )
then
2885 log_progress(*)
'history output is suppressed'
2889 file_history_vars(id)%laststep_write = step_now
2890 file_history_vars(id)%flag_clear = .true.
2892 laststep_write = step_now
2895 end subroutine file_history_write_onevar
2898 subroutine file_history_output_list
2905 if ( list_outputed )
then
2909 if ( file_history_nitems /= file_history_nreqs )
then
2911 if ( .not. ( file_history_output_step0 .and. file_history_nowstep == 1 ) )
then
2913 log_info(
"FILE_HISTORY_Output_List",*)
'[HISTORY] All of requested variable by the namelist HISTORY_ITEM did not find.'
2914 do id = 1, file_history_nreqs
2915 log_info(
"FILE_HISTORY_Output_List",
'(A,A24,A,L1)')
'NAME : ', file_history_req(id)%name, &
2916 ', registered? : ', file_history_req(id)%registered
2918 log_info(
"FILE_HISTORY_Output_List",*)
'Please set FILE_HISTORY_ERROR_PUTMISS in the namelist PARAM_FILE_HISTORY to .false.', &
2919 ' when you want to disable this check.'
2921 if ( file_history_error_putmiss )
then
2922 log_error(
"FILE_HISTORY_Output_List",*)
'Requested variables by the namelist HISTORY_ITEM did not find. Please see detail in log file.'
2930 log_info(
"FILE_HISTORY_Output_List",*)
'[HISTORY] Output item list '
2931 log_info_cont(
'(1x,A,I4)')
'Number of history item :', file_history_nreqs
2932 log_info_cont(*)
'ITEM :OUTNAME ', &
2933 ': size:interval[sec]: step:timeavg?:zcoord'
2934 log_info_cont(*)
'=================================================', &
2935 '================================================='
2938 do id = 1, file_history_nitems
2939 dtsec = real(file_history_vars(id)%dstep,kind=dp) * file_history_dtsec
2941 log_info_cont(
'(1x,A24,1x,A24,1x,I8,1x,F13.3,1x,I8,1x,L8,1x,A8)') &
2942 file_history_vars(id)%name, &
2943 file_history_vars(id)%outname, &
2944 file_history_vars(id)%size, &
2946 file_history_vars(id)%dstep, &
2947 file_history_vars(id)%taverage, &
2948 file_history_vars(id)%zcoord
2951 log_info_cont(*)
'=================================================', &
2952 '================================================='
2954 list_outputed = .true.
2957 end subroutine file_history_output_list
2959 function file_history_find_id( name )
2960 character(len=*),
intent(in) :: name
2961 integer :: FILE_HISTORY_find_id
2965 do itemid = 1, file_history_nvar_inputs
2966 if ( file_history_var_inputs(itemid)%name == name )
then
2967 file_history_find_id = itemid
2972 file_history_find_id = -1
2975 end function file_history_find_id
2977 function file_history_get_size( &
2979 character(len=*),
intent(in) :: dims(:)
2980 integer,
intent(in) :: ndims
2981 integer :: FILE_HISTORY_get_size
2986 file_history_get_size = 1
2989 do i = 1, file_history_naxes
2990 if ( file_history_axes(i)%name == dims(n) )
then
2991 len = file_history_axes(i)%dim_size
2996 log_error(
"FILE_HISTORY_get_size",*)
'dimension name is not found: ', dims(n)
2999 file_history_get_size = file_history_get_size * len
3003 end function file_history_get_size
3005 subroutine file_history_truncate_1d_default( &
3007 dim_type, zcoord, fill_halo, &
3009 real(RP),
intent(in) :: src(:)
3010 character(len=*),
intent(in) :: dim_type
3011 character(len=*),
intent(in) :: zcoord
3012 logical,
intent(in) :: fill_halo
3013 real(DP),
intent(out) :: dsc(:)
3018 end subroutine file_history_truncate_1d_default
3019 subroutine file_history_truncate_2d_default( &
3021 dim_type, zcoord, fill_halo, &
3023 real(RP),
intent(in) :: src(:,:)
3024 character(len=*),
intent(in) :: dim_type
3025 character(len=*),
intent(in) :: zcoord
3026 logical,
intent(in) :: fill_halo
3027 real(DP),
intent(out) :: dsc(:)
3035 do j = 1,
size(src,2)
3036 do i = 1,
size(src,1)
3037 dsc(idx) = src(i, j)
3043 end subroutine file_history_truncate_2d_default
3044 subroutine file_history_truncate_3d_default( &
3046 dim_type, zcoord, fill_halo, &
3048 real(RP),
intent(in) :: src(:,:,:)
3049 character(len=*),
intent(in) :: dim_type
3050 character(len=*),
intent(in) :: zcoord
3051 logical,
intent(in) :: fill_halo
3052 real(DP),
intent(out) :: dsc(:)
3060 do j = 1,
size(src,3)
3061 do i = 1,
size(src,2)
3062 do k = 1,
size(src,1)
3063 dsc(idx) = src(k, i, j)
3070 end subroutine file_history_truncate_3d_default
3071 subroutine file_history_truncate_4d_default( &
3073 dim_type, zcoord, fill_halo, &
3075 real(RP),
intent(in) :: src(:,:,:,:)
3076 character(len=*),
intent(in) :: dim_type
3077 character(len=*),
intent(in) :: zcoord
3078 logical,
intent(in) :: fill_halo
3079 real(DP),
intent(out) :: dsc(:)
3081 integer :: l, k, i, j
3087 do j = 1,
size(src,4)
3088 do i = 1,
size(src,3)
3089 do k = 1,
size(src,2)
3090 do l = 1,
size(src,1)
3091 dsc(idx) = src(l, k, i, j)
3099 end subroutine file_history_truncate_4d_default