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
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 end interface file_history_set_attribute
145 private :: file_history_create
146 private :: file_history_close
147 private :: file_history_add_variable
148 private :: file_history_write_axes
149 private :: file_history_write_onevar
150 private :: file_history_output_list
151 private :: file_history_check
159 character(len=H_SHORT) :: name
160 character(len=H_SHORT) :: outname
161 character(len=H_LONG) :: basename
162 logical :: postfix_timelabel
163 character(len=H_SHORT) :: zcoord
167 character(len=H_SHORT) :: cell_measures
168 logical :: registered
172 character(len=H_SHORT) :: name
173 character(len=H_SHORT) :: outname
174 character(len=H_LONG) :: basename
175 logical :: postfix_timelabel
176 character(len=H_SHORT) :: zcoord
184 character(len=H_LONG) :: desc
185 character(len=H_SHORT) :: units
186 character(len=H_SHORT) :: standard_name
188 character(len=H_SHORT) :: cell_measures
190 integer :: laststep_write
191 integer :: laststep_put
192 logical :: flag_clear
195 real(DP),
pointer :: varsum(:)
199 integer,
parameter :: file_history_variant_max = 10
201 character(len=H_SHORT) :: name
203 integer :: variants(file_history_variant_max)
207 character(len=H_SHORT) :: name
210 character(len=H_SHORT),
pointer :: dims(:,:)
211 integer ,
pointer :: start(:,:)
212 integer ,
pointer :: count(:,:)
213 integer ,
pointer :: size(:)
214 character(len=H_SHORT),
pointer :: zcoords(:)
215 character(len=H_SHORT) :: mapping
216 character(len=H_SHORT) :: area
217 character(len=H_SHORT) :: area_x
218 character(len=H_SHORT) :: area_y
219 character(len=H_SHORT) :: volume
220 character(len=H_SHORT) :: location
221 character(len=H_SHORT) :: grid
225 character(len=H_SHORT) :: name
226 character(len=H_LONG) :: desc
227 character(len=H_SHORT) :: units
228 character(len=H_SHORT) :: dim
230 real(DP),
pointer :: var(:)
231 real(DP),
pointer :: bounds(:,:)
238 character(len=H_SHORT) :: name
239 character(len=H_LONG) :: desc
240 character(len=H_SHORT) :: units
242 character(len=H_SHORT) :: dims(4)
244 real(DP),
pointer :: var(:)
249 integer,
parameter :: i_text = 1, i_int = 2, i_float = 3, i_double = 4
251 character(len=H_SHORT) :: varname
252 character(len=H_MID) :: key
254 character(len=H_LONG) :: text
255 integer,
pointer :: int(:)
256 real(SP),
pointer ::
float(:)
257 real(DP),
pointer ::
double(:)
258 logical :: add_variable
262 integer :: file_history_myrank
265 real(DP) :: file_history_startdaysec
266 real(DP) :: file_history_dtsec
267 character(len=H_MID) :: file_history_time_since
270 character(len=H_MID) :: file_history_title
271 character(len=H_MID) :: file_history_source
272 character(len=H_MID) :: file_history_institution
274 character(len=H_MID) :: file_history_time_units
275 character(len=H_SHORT) :: file_history_calendar
276 logical :: file_history_output_step0 = .false.
277 integer :: file_history_output_wait_step
278 integer :: file_history_output_switch_step
279 integer :: file_history_output_switch_laststep
280 logical :: file_history_error_putmiss = .true.
283 integer,
parameter :: file_history_req_max = 1000
284 integer :: file_history_nreqs = 0
285 type(request),
allocatable :: file_history_req(:)
287 integer :: file_history_nitems = 0
288 type(var_out),
allocatable :: file_history_vars(:)
290 integer :: file_history_nvar_inputs
291 type(var_in),
allocatable :: file_history_var_inputs(:)
293 integer,
parameter :: file_history_dim_max = 30
294 integer :: file_history_ndims = 0
295 type(dim) :: file_history_dims(file_history_dim_max)
297 integer,
parameter :: file_history_axis_max = 100
298 integer :: file_history_naxes = 0
299 type(axis) :: file_history_axes(file_history_axis_max)
301 integer,
parameter :: file_history_assoc_max = 40
302 integer :: file_history_nassocs = 0
303 type(assoc) :: file_history_assocs(file_history_assoc_max)
305 integer,
parameter :: file_history_attr_max = 200
306 integer :: file_history_nattrs = 0
307 type(attr) :: file_history_attrs(file_history_attr_max)
309 integer :: file_history_nowdate(6)
310 real(DP) :: file_history_nowms
311 integer :: file_history_nowstep
313 integer(8) :: file_history_io_buffer_size = 0
315 character(len=H_MID) :: file_history_options =
'' 318 logical :: file_history_disabled = .true.
320 integer :: laststep_write = -1
321 logical :: firsttime = .true.
322 logical :: debug = .false.
330 title, source, institution, &
331 time_start, time_interval, &
332 time_units, time_since, calendar, &
334 default_postfix_timelabel, &
350 character(len=*),
intent(in) :: title
351 character(len=*),
intent(in) :: source
352 character(len=*),
intent(in) :: institution
353 real(DP),
intent(in) :: time_start
354 real(DP),
intent(in) :: time_interval
356 character(len=*),
intent(in),
optional :: time_units
357 character(len=*),
intent(in),
optional :: time_since
358 character(len=*),
intent(in),
optional :: calendar
359 character(len=*),
intent(in),
optional :: default_basename
360 logical,
intent(in),
optional :: default_postfix_timelabel
361 character(len=*),
intent(in),
optional :: default_zcoord
362 real(DP),
intent(in),
optional :: default_tinterval
363 character(len=*),
intent(in),
optional :: default_tunit
364 logical,
intent(in),
optional :: default_taverage
365 character(len=*),
intent(in),
optional :: default_datatype
366 integer,
intent(in),
optional :: myrank
368 character(len=H_LONG) :: FILE_HISTORY_DEFAULT_BASENAME
369 logical :: FILE_HISTORY_DEFAULT_POSTFIX_TIMELABEL
370 character(len=H_SHORT) :: FILE_HISTORY_DEFAULT_ZCOORD
371 real(DP) :: FILE_HISTORY_DEFAULT_TINTERVAL
372 character(len=H_SHORT) :: FILE_HISTORY_DEFAULT_TUNIT
373 logical :: FILE_HISTORY_DEFAULT_TAVERAGE
374 character(len=H_SHORT) :: FILE_HISTORY_DEFAULT_DATATYPE
377 real(DP) :: FILE_HISTORY_OUTPUT_WAIT
378 character(len=H_SHORT) :: FILE_HISTORY_OUTPUT_WAIT_TUNIT
379 real(DP) :: FILE_HISTORY_OUTPUT_SWITCH_TINTERVAL
380 character(len=H_SHORT) :: FILE_HISTORY_OUTPUT_SWITCH_TUNIT
382 namelist / param_file_history / &
383 file_history_title, &
384 file_history_source, &
385 file_history_institution, &
386 file_history_time_units, &
387 file_history_default_basename, &
388 file_history_default_postfix_timelabel, &
389 file_history_default_zcoord, &
390 file_history_default_tinterval, &
391 file_history_default_tunit, &
392 file_history_default_taverage, &
393 file_history_default_datatype, &
394 file_history_output_step0, &
395 file_history_output_wait, &
396 file_history_output_wait_tunit, &
397 file_history_output_switch_tinterval, &
398 file_history_output_switch_tunit, &
399 file_history_error_putmiss, &
401 file_history_options, &
404 character(len=H_SHORT) :: NAME
405 character(len=H_SHORT) :: OUTNAME
406 character(len=H_LONG) :: BASENAME
407 logical :: POSTFIX_TIMELABEL
408 character(len=H_SHORT) :: ZCOORD
409 real(DP) :: TINTERVAL
410 character(len=H_SHORT) :: TUNIT
412 character(len=H_SHORT) :: DATATYPE
414 namelist / history_item / &
437 log_info(
"FILE_HISTORY_Setup",*)
'Setup' 440 file_history_myrank = myrank
442 file_history_startdaysec = time_start
443 file_history_dtsec = time_interval
444 if (
present(time_since) )
then 445 file_history_time_since = time_since
447 file_history_time_since =
'' 450 if (
present(calendar) )
then 451 file_history_calendar = calendar
453 file_history_calendar =
"" 456 file_history_time_units =
'seconds' 457 file_history_default_basename =
'' 458 file_history_default_postfix_timelabel = .false.
459 file_history_default_zcoord =
'' 460 file_history_default_tinterval = -1.0_dp
461 file_history_default_tunit =
'SEC' 462 file_history_default_taverage = .false.
463 file_history_default_datatype =
'REAL4' 464 file_history_output_wait = 0.0_dp
465 file_history_output_wait_tunit =
'SEC' 466 file_history_output_switch_tinterval = -1.0_dp
467 file_history_output_switch_tunit =
'SEC' 472 file_history_title = title
473 file_history_source = source
474 file_history_institution = institution
475 if(
present(time_units) ) file_history_time_units = time_units
476 if(
present(default_basename) ) file_history_default_basename = default_basename
477 if(
present(default_postfix_timelabel) ) file_history_default_postfix_timelabel = default_postfix_timelabel
478 if(
present(default_zcoord) ) file_history_default_zcoord = default_zcoord
479 if(
present(default_tinterval) ) file_history_default_tinterval = default_tinterval
480 if(
present(default_tunit) ) file_history_default_tunit = default_tunit
481 if(
present(default_taverage) ) file_history_default_taverage = default_taverage
482 if(
present(default_datatype) ) file_history_default_datatype = default_datatype
486 read(
io_fid_conf,nml=param_file_history,iostat=ierr)
488 log_info(
"FILE_HISTORY_Setup",*)
'Not found namelist. Default used.' 489 elseif( ierr > 0 )
then 490 log_error(
"FILE_HISTORY_Setup",*)
'Not appropriate names in namelist PARAM_FILE_HISTORY. Check!' 493 log_nml(param_file_history)
497 if ( file_history_output_wait >= 0.0_dp )
then 498 call calendar_unit2sec( dtsec, file_history_output_wait, file_history_output_wait_tunit )
499 file_history_output_wait_step = int( dtsec / file_history_dtsec )
501 log_error(
"FILE_HISTORY_Setup",*)
'FILE_HISTORY_OUTPUT_WAIT must be positive. STOP' 505 if ( file_history_output_switch_tinterval >= 0.0_dp )
then 506 call calendar_unit2sec( dtsec, file_history_output_switch_tinterval, file_history_output_switch_tunit )
507 file_history_output_switch_step = int( dtsec / file_history_dtsec )
509 file_history_output_switch_step = -1
511 file_history_output_switch_laststep = 0
515 file_history_nreqs = 0
517 do n = 1, file_history_req_max
519 outname =
'undefined' 520 basename = file_history_default_basename
524 if( basename ==
'' .OR. name ==
'' .OR. outname ==
'' ) cycle
526 file_history_nreqs = file_history_nreqs + 1
529 if ( file_history_nreqs > file_history_req_max )
then 530 log_error(
"FILE_HISTORY_Setup",*)
'request of history file is exceed! n >', file_history_req_max
532 elseif( file_history_nreqs == 0 )
then 533 log_info(
"FILE_HISTORY_Setup",*)
'No history file specified.' 537 allocate( file_history_req(file_history_nreqs) )
542 do n = 1, file_history_req_max
545 outname =
'undefined' 546 basename = file_history_default_basename
547 postfix_timelabel = file_history_default_postfix_timelabel
548 zcoord = file_history_default_zcoord
549 tinterval = file_history_default_tinterval
550 tunit = file_history_default_tunit
551 taverage = file_history_default_taverage
552 datatype = file_history_default_datatype
557 elseif( ierr > 0 )
then 558 log_error(
"FILE_HISTORY_Setup",*)
'Not appropriate names in namelist HISTORY_ITEM. Check!' 561 if( basename ==
'' .OR. name ==
'' .OR. outname ==
'' ) cycle
563 log_nml(history_item)
566 if ( outname ==
'undefined' ) outname = name
568 if ( file_history_req(id)%outname == outname )
then 569 log_error(
"FILE_HISTORY_Setup",*)
'Same name of history output is already registered. Check!', trim(outname)
576 file_history_req(reqid)%name = name
577 file_history_req(reqid)%outname = outname
578 file_history_req(reqid)%basename = basename
579 file_history_req(reqid)%postfix_timelabel = postfix_timelabel
580 if( file_history_output_switch_step >= 0 ) file_history_req(reqid)%postfix_timelabel = .true.
581 file_history_req(reqid)%zcoord = zcoord
582 file_history_req(reqid)%taverage = taverage
585 dstep = int( dtsec / file_history_dtsec )
587 if ( dtsec <= 0.d0 )
then 588 log_error(
"FILE_HISTORY_Setup",*)
'Not appropriate time interval. Check!', trim(name), tinterval, trim(tunit)
592 if ( abs(dtsec-
real(dstep,kind=
dp)*file_history_dtsec) > dtsec*1.e-3_dp )
then 593 log_error(
"FILE_HISTORY_Setup",*)
'time interval must be a multiple of delta t. (interval,dt)=', dtsec, file_history_dtsec
597 file_history_req(reqid)%dstep = dstep
599 if ( datatype ==
'REAL4' )
then 601 elseif( datatype ==
'REAL8' )
then 604 log_error(
"FILE_HISTORY_Setup",*)
'Not appropriate DATATYPE. Check!', datatype
608 file_history_req(reqid)%registered = .false.
612 log_info(
"FILE_HISTORY_Setup",*)
'Number of requested history item : ', file_history_nreqs
613 log_info(
"FILE_HISTORY_Setup",*)
'Output default data type : ', trim(file_history_default_datatype)
614 log_info(
"FILE_HISTORY_Setup",*)
'Output value at the initial step? : ', file_history_output_step0
615 if ( file_history_output_wait_step > 0 )
then 616 log_info(
"FILE_HISTORY_Setup",*)
'Time when the output is suppressed [step] : ', file_history_output_wait_step
618 if ( file_history_output_switch_step >= 0 )
then 619 log_info(
"FILE_HISTORY_Setup",*)
'Interval for switching the file [step] : ', file_history_output_switch_step
621 log_info(
"FILE_HISTORY_Setup",*)
'Check if requested item is not registered? : ', file_history_error_putmiss
623 file_history_nitems = 0
624 allocate( file_history_vars(file_history_nreqs) )
626 file_history_nvar_inputs = 0
627 allocate( file_history_var_inputs(file_history_nreqs) )
634 file_history_disabled = .false.
651 character(len=*),
intent(in) :: name
652 character(len=*),
intent(in) :: desc
653 character(len=*),
intent(in) :: unit
655 integer,
intent(out) :: itemid
657 character(len=*),
intent(in),
optional :: standard_name
658 integer,
intent(in),
optional :: ndims
659 character(len=*),
intent(in),
optional :: dim_type
660 character(len=*),
intent(in),
optional :: cell_measures
661 logical,
intent(in),
optional :: fill_halo
663 character(len=H_SHORT) :: standard_name_
664 character(len=H_SHORT) :: cell_measures_
665 integer :: dimid, iid
670 if ( file_history_nreqs == 0 )
return 672 itemid = file_history_find_id( name )
673 if ( itemid > 0 )
return 677 if ( len_trim(name) >=
h_short )
then 678 log_error(
"FILE_HISTORY_reg",
'(1x,A,I2,A,A)')
'Length of history name should be <= ',
h_short-1 ,
' chars. name=', trim(name)
683 if (
present(standard_name) )
then 684 standard_name_ = standard_name
690 if ( file_history_ndims < 1 )
then 691 log_error(
"FILE_HISTORY_reg",*)
'at least one dim_type must be registerd with FILE_HISTORY_set_dim. name=', trim(name)
694 if (
present(dim_type) )
then 696 do n = 1, file_history_ndims
697 if ( file_history_dims(n)%name == dim_type )
then 702 if ( dimid == -1 )
then 703 log_error(
"FILE_HISTORY_reg",*)
'dim_type must be registerd with FILE_HISTORY_set_dim: ', trim(dim_type) ,
' name=', trim(name)
706 else if (
present(ndims) )
then 707 do n = 1, file_history_ndims
708 if ( file_history_dims(n)%ndims == ndims )
then 713 if ( dimid == -1 )
then 714 log_error(
"FILE_HISTORY_reg",
'(a,i1,a)')
'dim_type of ', ndims,
'D must be registerd with FILE_HISTORY_set_dim. name=', trim(name)
719 do n = 1, file_history_ndims
720 if ( file_history_dims(n)%ndims == 3 )
then 725 if ( dimid == -1 )
then 726 log_error(
"FILE_HISTORY_reg",
'(a,i1,a)')
'dim_type or ndims must be specified. name=', trim(name)
731 if (
present(cell_measures) )
then 732 select case ( cell_measures )
734 if ( file_history_dims(dimid)%area ==
"" )
then 735 log_error(
"FILE_HISTORY_reg",*)
'area is not supported for cell_measures. name=', trim(name)
739 if ( file_history_dims(dimid)%area ==
"" )
then 740 log_error(
"FILE_HISTORY_reg",*)
'area_z is not supported for cell_measures. name=', trim(name)
744 if ( file_history_dims(dimid)%area_x ==
"" )
then 745 log_error(
"FILE_HISTORY_reg",*)
'area_x is not supported for cell_measures. name=', trim(name)
749 if ( file_history_dims(dimid)%area_y ==
"" )
then 750 log_error(
"FILE_HISTORY_reg",*)
'area_y is not supported for cell_measures. name=', trim(name)
754 if ( file_history_dims(dimid)%volume ==
"" )
then 755 log_error(
"FILE_HISTORY_reg",*)
'volume is not supported for cell_measures. name=', trim(name)
759 log_error(
"FILE_HISTORY_reg",*)
'cell_measures must be "area" or "volume". name=', trim(name)
762 cell_measures_ = cell_measures
763 else if ( file_history_dims(dimid)%ndims == 2 )
then 764 cell_measures_ =
"area" 765 else if ( file_history_dims(dimid)%ndims == 3 )
then 766 cell_measures_ =
"volume" 771 if ( file_history_dims(dimid)%nzcoords > 1 )
then 774 do n = 1, file_history_dims(dimid)%nzcoords
775 if ( file_history_dims(dimid)%zcoords(n) ==
"model" )
then 776 call file_history_add_variable( name, desc, unit, standard_name_, &
778 file_history_dims(dimid)%zcoords(n), &
780 cell_measures = cell_measures_, &
781 fill_halo = fill_halo )
783 call file_history_add_variable( name, desc, unit, standard_name_, &
785 file_history_dims(dimid)%zcoords(n), &
787 fill_halo = fill_halo )
789 if ( iid > 0 ) itemid = iid
794 call file_history_add_variable( name, desc, unit, standard_name_, &
798 cell_measures = cell_measures_, &
799 fill_halo = fill_halo )
810 subroutine file_history_put_0d( &
820 integer,
intent(in) :: itemid
821 real(RP),
intent(in) :: var
824 real(DP),
allocatable :: buffer(:)
834 if ( file_history_disabled )
return 835 if ( itemid < 0 )
return 837 call file_history_query( itemid, do_put )
838 if ( .not. do_put )
return 842 do i = 1, file_history_var_inputs(itemid)%nvariants
843 id = file_history_var_inputs(itemid)%variants(i)
845 dt = ( file_history_nowstep - file_history_vars(id)%laststep_put ) * file_history_dtsec
847 if ( dt < eps .AND. ( .NOT. file_history_vars(id)%taverage ) )
then 848 log_error(
"FILE_HISTORY_Put_0D",*)
'variable was put two times before output!: ', &
849 trim(file_history_vars(id)%name), file_history_nowstep, file_history_vars(id)%laststep_put
853 if ( file_history_vars(id)%flag_clear )
then 854 file_history_vars(id)%timesum = 0.0_dp
855 if ( file_history_vars(id)%taverage ) file_history_vars(id)%varsum(:) = 0.0_dp
858 dimid = file_history_vars(id)%dimid
859 if ( file_history_vars(id)%taverage )
then 860 if ( file_history_vars(id)%varsum(1) /= rmiss )
then 861 if ( var /= undef )
then 862 file_history_vars(id)%varsum(1) = file_history_vars(id)%varsum(1) + var * dt
864 file_history_vars(id)%varsum(1) = rmiss
867 file_history_vars(id)%timesum = file_history_vars(id)%timesum + dt
869 file_history_vars(id)%varsum(1) = var
870 file_history_vars(id)%timesum = 0.0_dp
873 file_history_vars(id)%laststep_put = file_history_nowstep
874 file_history_vars(id)%flag_clear = .false.
881 end subroutine file_history_put_0d
893 real(RP),
intent(in) :: var
894 character(len=*),
intent(in) :: name
895 character(len=*),
intent(in) :: desc
896 character(len=*),
intent(in) :: unit
898 character(len=*),
intent(in),
optional :: standard_name
899 character(len=*),
intent(in),
optional :: dim_type
901 logical,
parameter :: fill_halo = .false.
903 integer,
parameter :: ndim = 0
908 if ( file_history_disabled )
return 913 standard_name=standard_name, &
916 fill_halo=fill_halo )
918 if ( itemid < 0 )
return 921 call file_history_query( itemid, do_put )
923 if ( do_put )
call file_history_put( itemid, var )
929 subroutine file_history_put_1d( &
939 integer,
intent(in) :: itemid
940 real(RP),
intent(in) :: var(:)
943 real(DP),
allocatable :: buffer(:)
953 if ( file_history_disabled )
return 954 if ( itemid < 0 )
return 956 call file_history_query( itemid, do_put )
957 if ( .not. do_put )
return 961 do i = 1, file_history_var_inputs(itemid)%nvariants
962 id = file_history_var_inputs(itemid)%variants(i)
964 dt = ( file_history_nowstep - file_history_vars(id)%laststep_put ) * file_history_dtsec
966 if ( dt < eps .AND. ( .NOT. file_history_vars(id)%taverage ) )
then 967 log_error(
"FILE_HISTORY_Put_1D",*)
'variable was put two times before output!: ', &
968 trim(file_history_vars(id)%name), file_history_nowstep, file_history_vars(id)%laststep_put
972 if ( file_history_vars(id)%flag_clear )
then 973 file_history_vars(id)%timesum = 0.0_dp
974 if ( file_history_vars(id)%taverage ) file_history_vars(id)%varsum(:) = 0.0_dp
977 dimid = file_history_vars(id)%dimid
978 if ( file_history_vars(id)%taverage )
then 979 allocate( buffer( file_history_vars(id)%size ) )
981 file_history_dims(dimid)%name, &
982 file_history_vars(id)%zcoord, &
983 file_history_vars(id)%fill_halo, &
985 do idx = 1, file_history_vars(id)%size
986 if ( file_history_vars(id)%varsum(idx) /= rmiss )
then 987 if ( buffer(idx) /= undef )
then 988 file_history_vars(id)%varsum(idx) = file_history_vars(id)%varsum(idx) + buffer(idx) * dt
990 file_history_vars(id)%varsum(idx) = rmiss
995 file_history_vars(id)%timesum = file_history_vars(id)%timesum + dt
998 file_history_dims(dimid)%name, &
999 file_history_vars(id)%zcoord, &
1000 file_history_vars(id)%fill_halo, &
1001 file_history_vars(id)%varsum(:) )
1002 file_history_vars(id)%timesum = 0.0_dp
1005 file_history_vars(id)%laststep_put = file_history_nowstep
1006 file_history_vars(id)%flag_clear = .false.
1013 end subroutine file_history_put_1d
1025 real(RP),
intent(in) :: var(:)
1026 character(len=*),
intent(in) :: name
1027 character(len=*),
intent(in) :: desc
1028 character(len=*),
intent(in) :: unit
1030 character(len=*),
intent(in),
optional :: standard_name
1031 character(len=*),
intent(in),
optional :: dim_type
1033 logical,
parameter :: fill_halo = .false.
1035 integer,
parameter :: ndim = 1
1040 if ( file_history_disabled )
return 1045 standard_name=standard_name, &
1047 dim_type=dim_type, &
1048 fill_halo=fill_halo )
1050 if ( itemid < 0 )
return 1053 call file_history_query( itemid, do_put )
1055 if ( do_put )
call file_history_put( itemid, var(:) )
1061 subroutine file_history_put_2d( &
1071 integer,
intent(in) :: itemid
1072 real(RP),
intent(in) :: var(:,:)
1075 real(DP),
allocatable :: buffer(:)
1085 if ( file_history_disabled )
return 1086 if ( itemid < 0 )
return 1088 call file_history_query( itemid, do_put )
1089 if ( .not. do_put )
return 1093 do i = 1, file_history_var_inputs(itemid)%nvariants
1094 id = file_history_var_inputs(itemid)%variants(i)
1096 dt = ( file_history_nowstep - file_history_vars(id)%laststep_put ) * file_history_dtsec
1098 if ( dt < eps .AND. ( .NOT. file_history_vars(id)%taverage ) )
then 1099 log_error(
"FILE_HISTORY_Put_2D",*)
'variable was put two times before output!: ', &
1100 trim(file_history_vars(id)%name), file_history_nowstep, file_history_vars(id)%laststep_put
1104 if ( file_history_vars(id)%flag_clear )
then 1105 file_history_vars(id)%timesum = 0.0_dp
1106 if ( file_history_vars(id)%taverage ) file_history_vars(id)%varsum(:) = 0.0_dp
1109 dimid = file_history_vars(id)%dimid
1110 if ( file_history_vars(id)%taverage )
then 1111 allocate( buffer( file_history_vars(id)%size ) )
1113 file_history_dims(dimid)%name, &
1114 file_history_vars(id)%zcoord, &
1115 file_history_vars(id)%fill_halo, &
1117 do idx = 1, file_history_vars(id)%size
1118 if ( file_history_vars(id)%varsum(idx) /= rmiss )
then 1119 if ( buffer(idx) /= undef )
then 1120 file_history_vars(id)%varsum(idx) = file_history_vars(id)%varsum(idx) + buffer(idx) * dt
1122 file_history_vars(id)%varsum(idx) = rmiss
1126 deallocate( buffer )
1127 file_history_vars(id)%timesum = file_history_vars(id)%timesum + dt
1130 file_history_dims(dimid)%name, &
1131 file_history_vars(id)%zcoord, &
1132 file_history_vars(id)%fill_halo, &
1133 file_history_vars(id)%varsum(:) )
1134 file_history_vars(id)%timesum = 0.0_dp
1137 file_history_vars(id)%laststep_put = file_history_nowstep
1138 file_history_vars(id)%flag_clear = .false.
1145 end subroutine file_history_put_2d
1158 real(RP),
intent(in) :: var(:,:)
1159 character(len=*),
intent(in) :: name
1160 character(len=*),
intent(in) :: desc
1161 character(len=*),
intent(in) :: unit
1163 character(len=*),
intent(in),
optional :: standard_name
1164 character(len=*),
intent(in),
optional :: dim_type
1165 logical,
intent(in),
optional :: fill_halo
1167 integer,
parameter :: ndim = 2
1172 if ( file_history_disabled )
return 1177 standard_name=standard_name, &
1179 dim_type=dim_type, &
1180 fill_halo=fill_halo )
1182 if ( itemid < 0 )
return 1185 call file_history_query( itemid, do_put )
1187 if ( do_put )
call file_history_put( itemid, var(:,:) )
1193 subroutine file_history_put_3d( &
1203 integer,
intent(in) :: itemid
1204 real(RP),
intent(in) :: var(:,:,:)
1207 real(DP),
allocatable :: buffer(:)
1217 if ( file_history_disabled )
return 1218 if ( itemid < 0 )
return 1220 call file_history_query( itemid, do_put )
1221 if ( .not. do_put )
return 1225 do i = 1, file_history_var_inputs(itemid)%nvariants
1226 id = file_history_var_inputs(itemid)%variants(i)
1228 dt = ( file_history_nowstep - file_history_vars(id)%laststep_put ) * file_history_dtsec
1230 if ( dt < eps .AND. ( .NOT. file_history_vars(id)%taverage ) )
then 1231 log_error(
"FILE_HISTORY_Put_3D",*)
'variable was put two times before output!: ', &
1232 trim(file_history_vars(id)%name), file_history_nowstep, file_history_vars(id)%laststep_put
1236 if ( file_history_vars(id)%flag_clear )
then 1237 file_history_vars(id)%timesum = 0.0_dp
1238 if ( file_history_vars(id)%taverage ) file_history_vars(id)%varsum(:) = 0.0_dp
1241 dimid = file_history_vars(id)%dimid
1242 if ( file_history_vars(id)%taverage )
then 1243 allocate( buffer( file_history_vars(id)%size ) )
1245 file_history_dims(dimid)%name, &
1246 file_history_vars(id)%zcoord, &
1247 file_history_vars(id)%fill_halo, &
1249 do idx = 1, file_history_vars(id)%size
1250 if ( file_history_vars(id)%varsum(idx) /= rmiss )
then 1251 if ( buffer(idx) /= undef )
then 1252 file_history_vars(id)%varsum(idx) = file_history_vars(id)%varsum(idx) + buffer(idx) * dt
1254 file_history_vars(id)%varsum(idx) = rmiss
1258 deallocate( buffer )
1259 file_history_vars(id)%timesum = file_history_vars(id)%timesum + dt
1262 file_history_dims(dimid)%name, &
1263 file_history_vars(id)%zcoord, &
1264 file_history_vars(id)%fill_halo, &
1265 file_history_vars(id)%varsum(:) )
1266 file_history_vars(id)%timesum = 0.0_dp
1269 file_history_vars(id)%laststep_put = file_history_nowstep
1270 file_history_vars(id)%flag_clear = .false.
1277 end subroutine file_history_put_3d
1290 real(RP),
intent(in) :: var(:,:,:)
1291 character(len=*),
intent(in) :: name
1292 character(len=*),
intent(in) :: desc
1293 character(len=*),
intent(in) :: unit
1295 character(len=*),
intent(in),
optional :: standard_name
1296 character(len=*),
intent(in),
optional :: dim_type
1297 logical,
intent(in),
optional :: fill_halo
1299 integer,
parameter :: ndim = 3
1304 if ( file_history_disabled )
return 1309 standard_name=standard_name, &
1311 dim_type=dim_type, &
1312 fill_halo=fill_halo )
1314 if ( itemid < 0 )
return 1317 call file_history_query( itemid, do_put )
1319 if ( do_put )
call file_history_put( itemid, var(:,:,:) )
1325 subroutine file_history_put_4d( &
1335 integer,
intent(in) :: itemid
1336 real(RP),
intent(in) :: var(:,:,:,:)
1339 real(DP),
allocatable :: buffer(:)
1349 if ( file_history_disabled )
return 1350 if ( itemid < 0 )
return 1352 call file_history_query( itemid, do_put )
1353 if ( .not. do_put )
return 1357 do i = 1, file_history_var_inputs(itemid)%nvariants
1358 id = file_history_var_inputs(itemid)%variants(i)
1360 dt = ( file_history_nowstep - file_history_vars(id)%laststep_put ) * file_history_dtsec
1362 if ( dt < eps .AND. ( .NOT. file_history_vars(id)%taverage ) )
then 1363 log_error(
"FILE_HISTORY_Put_4D",*)
'variable was put two times before output!: ', &
1364 trim(file_history_vars(id)%name), file_history_nowstep, file_history_vars(id)%laststep_put
1368 if ( file_history_vars(id)%flag_clear )
then 1369 file_history_vars(id)%timesum = 0.0_dp
1370 if ( file_history_vars(id)%taverage ) file_history_vars(id)%varsum(:) = 0.0_dp
1373 dimid = file_history_vars(id)%dimid
1374 if ( file_history_vars(id)%taverage )
then 1375 allocate( buffer( file_history_vars(id)%size ) )
1377 file_history_dims(dimid)%name, &
1378 file_history_vars(id)%zcoord, &
1379 file_history_vars(id)%fill_halo, &
1381 do idx = 1, file_history_vars(id)%size
1382 if ( file_history_vars(id)%varsum(idx) /= rmiss )
then 1383 if ( buffer(idx) /= undef )
then 1384 file_history_vars(id)%varsum(idx) = file_history_vars(id)%varsum(idx) + buffer(idx) * dt
1386 file_history_vars(id)%varsum(idx) = rmiss
1390 deallocate( buffer )
1391 file_history_vars(id)%timesum = file_history_vars(id)%timesum + dt
1394 file_history_dims(dimid)%name, &
1395 file_history_vars(id)%zcoord, &
1396 file_history_vars(id)%fill_halo, &
1397 file_history_vars(id)%varsum(:) )
1398 file_history_vars(id)%timesum = 0.0_dp
1401 file_history_vars(id)%laststep_put = file_history_nowstep
1402 file_history_vars(id)%flag_clear = .false.
1409 end subroutine file_history_put_4d
1422 real(RP),
intent(in) :: var(:,:,:,:)
1423 character(len=*),
intent(in) :: name
1424 character(len=*),
intent(in) :: desc
1425 character(len=*),
intent(in) :: unit
1427 character(len=*),
intent(in),
optional :: standard_name
1428 character(len=*),
intent(in),
optional :: dim_type
1429 logical,
intent(in),
optional :: fill_halo
1431 integer,
parameter :: ndim = 4
1436 if ( file_history_disabled )
return 1441 standard_name=standard_name, &
1443 dim_type=dim_type, &
1444 fill_halo=fill_halo )
1446 if ( itemid < 0 )
return 1449 call file_history_query( itemid, do_put )
1451 if ( do_put )
call file_history_put( itemid, var(:,:,:,:) )
1466 area, area_x, area_y, &
1471 character(len=*),
intent(in) :: name
1472 integer,
intent(in) :: ndims
1473 integer,
intent(in) :: nzcoords
1474 character(len=*),
intent(in) :: dims(ndims,nzcoords)
1475 character(len=*),
intent(in) :: zcoords(nzcoords)
1476 integer,
intent(in) :: start(ndims,nzcoords)
1477 integer,
intent(in) :: count(ndims,nzcoords)
1479 character(len=*),
intent(in),
optional :: mapping
1480 character(len=*),
intent(in),
optional :: area
1481 character(len=*),
intent(in),
optional :: area_x
1482 character(len=*),
intent(in),
optional :: area_y
1483 character(len=*),
intent(in),
optional :: volume
1484 character(len=*),
intent(in),
optional :: location
1485 character(len=*),
intent(in),
optional :: grid
1488 integer :: size, n, m
1490 if ( file_history_ndims >= file_history_dim_max )
then 1491 log_error(
"FILE_HISTORY_Set_Dim",*)
'number of dimension exceed max limit: ', file_history_dim_max
1494 file_history_ndims = file_history_ndims + 1
1495 id = file_history_ndims
1497 allocate( file_history_dims(id)%dims(ndims,nzcoords) )
1498 allocate( file_history_dims(id)%start(ndims,nzcoords) )
1499 allocate( file_history_dims(id)%count(ndims,nzcoords) )
1500 allocate( file_history_dims(id)%zcoords(nzcoords) )
1501 allocate( file_history_dims(id)%size(nzcoords) )
1503 file_history_dims(id)%name = name
1504 file_history_dims(id)%ndims = ndims
1505 file_history_dims(id)%dims(:,:) = dims(:,:)
1506 file_history_dims(id)%nzcoords = nzcoords
1507 file_history_dims(id)%zcoords(:) = zcoords(:)
1508 file_history_dims(id)%start(:,:) = start(:,:)
1509 file_history_dims(id)%count(:,:) = count(:,:)
1514 size =
size * count(n,m)
1516 file_history_dims(id)%size(m) =
size 1519 if (
present(mapping) )
then 1520 file_history_dims(id)%mapping = mapping
1522 file_history_dims(id)%mapping =
"" 1525 if (
present(area) )
then 1526 file_history_dims(id)%area = area
1528 file_history_dims(id)%area =
"" 1530 if (
present(area_x) )
then 1531 file_history_dims(id)%area_x = area_x
1533 file_history_dims(id)%area_x =
"" 1535 if (
present(area_y) )
then 1536 file_history_dims(id)%area_y = area_y
1538 file_history_dims(id)%area_y =
"" 1540 if (
present(volume) )
then 1541 file_history_dims(id)%volume = volume
1543 file_history_dims(id)%volume =
"" 1546 if (
present(location) )
then 1547 file_history_dims(id)%location = location
1548 if (
present(grid) )
then 1549 file_history_dims(id)%grid =
"grid_"//trim(grid)
1551 file_history_dims(id)%grid =
"grid" 1554 file_history_dims(id)%location =
"" 1555 file_history_dims(id)%grid =
"" 1565 name, desc, units, &
1574 character(len=*),
intent(in) :: name
1575 character(len=*),
intent(in) :: desc
1576 character(len=*),
intent(in) :: units
1577 character(len=*),
intent(in) :: dim
1578 real(RP),
intent(in) :: var(:)
1580 real(RP),
intent(in),
optional :: bounds(:,:)
1581 logical,
intent(in),
optional :: down
1582 integer,
intent(in),
optional :: gsize
1583 integer,
intent(in),
optional :: start
1591 dim_size =
size(var)
1593 if ( file_history_naxes >= file_history_axis_max )
then 1594 log_error(
"FILE_HISTORY_Set_Axis",*)
'Number of axis exceeds the limit.' 1598 file_history_naxes = file_history_naxes + 1
1599 id = file_history_naxes
1601 allocate( file_history_axes(id)%var(dim_size) )
1603 file_history_axes(id)%name = name
1604 file_history_axes(id)%desc = desc
1605 file_history_axes(id)%units = units
1606 file_history_axes(id)%dim = dim
1607 file_history_axes(id)%dim_size = dim_size
1608 file_history_axes(id)%var(:) = var(:)
1610 if (
present(down) )
then 1611 file_history_axes(id)%down = down
1613 file_history_axes(id)%down = .false.
1615 if (
present(gsize) )
then 1616 file_history_axes(id)%gdim_size = gsize
1618 file_history_axes(id)%gdim_size = -1
1620 if (
present(start) )
then 1621 file_history_axes(id)%start = start
1623 file_history_axes(id)%start = 1
1626 if (
present(bounds) )
then 1627 allocate( file_history_axes(id)%bounds(2,dim_size) )
1628 file_history_axes(id)%bounds(:,:) = bounds(:,:)
1641 integer :: fid, prev_fid
1645 if ( file_history_disabled )
return 1650 do id = 1, file_history_nitems
1651 call file_history_write_onevar( id, file_history_nowstep )
1657 do id = 1, file_history_nitems
1658 fid = file_history_vars(id)%fid
1659 if ( fid > 0 .AND. fid /= prev_fid )
then 1666 if ( file_history_output_switch_step >= 0 &
1667 .AND. file_history_nowstep-file_history_output_switch_laststep > file_history_output_switch_step )
then 1669 call file_history_close
1671 log_info(
"FILE_HISTORY_Write",*)
'FILE_HISTORY file is switched.' 1673 do id = 1, file_history_nitems
1674 file_history_vars(id)%fid = -1
1675 file_history_vars(id)%vid = -1
1678 file_history_output_switch_laststep = file_history_nowstep - 1
1690 integer,
intent(in) :: NOWDATE(:)
1691 real(DP),
intent(in) :: NOWMS
1692 integer,
intent(in) :: NOWSTEP
1694 file_history_nowdate(:) = nowdate(:)
1695 file_history_nowms = nowms
1696 file_history_nowstep = nowstep
1707 logical,
intent(in) :: switch
1710 file_history_disabled = switch
1720 call file_history_close
1729 subroutine file_history_check( &
1734 character(len=*),
intent(in) :: name
1735 character(len=*),
intent(in) :: zcoord
1736 integer,
intent(out) :: itemid
1742 do itemid = 1, file_history_nvar_inputs
1743 if ( name == file_history_var_inputs(itemid)%name )
then 1744 do i = 1, file_history_var_inputs(itemid)%nvariants
1745 id = file_history_var_inputs(itemid)%variants(i)
1747 if ( file_history_vars(id)%zcoord == zcoord )
return 1754 end subroutine file_history_check
1757 subroutine file_history_add_variable( &
1758 name, desc, units, &
1768 character(len=*),
intent(in) :: name
1769 character(len=*),
intent(in) :: desc
1770 character(len=*),
intent(in) :: units
1771 character(len=*),
intent(in) :: standard_name
1772 integer,
intent(in) :: dimid
1773 character(len=*),
intent(in) :: zcoord
1774 integer,
intent(out) :: itemid
1775 character(len=*),
intent(in),
optional :: cell_measures
1776 logical,
intent(in),
optional :: fill_halo
1778 integer :: reqid, zid, id
1785 call file_history_check( name, zcoord, &
1788 if ( itemid > 0 )
return 1790 do reqid = 1, file_history_nreqs
1792 if ( file_history_req(reqid)%registered ) cycle
1793 if ( name /= file_history_req(reqid)%name ) cycle
1795 if ( file_history_dims(dimid)%nzcoords == 1 .or. &
1796 zcoord == file_history_req(reqid)%zcoord )
then 1798 file_history_req(reqid)%registered = .true.
1800 file_history_nitems = file_history_nitems + 1
1801 id = file_history_nitems
1803 file_history_vars(id)%name = file_history_req(reqid)%name
1804 file_history_vars(id)%outname = file_history_req(reqid)%outname
1805 file_history_vars(id)%basename = file_history_req(reqid)%basename
1806 file_history_vars(id)%postfix_timelabel = file_history_req(reqid)%postfix_timelabel
1807 file_history_vars(id)%zcoord = zcoord
1808 file_history_vars(id)%dstep = file_history_req(reqid)%dstep
1809 file_history_vars(id)%taverage = file_history_req(reqid)%taverage
1810 file_history_vars(id)%dtype = file_history_req(reqid)%dtype
1812 file_history_vars(id)%zid = -1
1813 do zid = 1, file_history_dims(dimid)%nzcoords
1814 if ( file_history_dims(dimid)%zcoords(zid) == file_history_vars(id)%zcoord )
then 1815 file_history_vars(id)%zid = zid
1820 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)
1824 file_history_vars(id)%fid = -1
1825 file_history_vars(id)%vid = -1
1826 file_history_vars(id)%desc = desc
1827 file_history_vars(id)%units = units
1828 file_history_vars(id)%standard_name = standard_name
1829 file_history_vars(id)%dimid = dimid
1830 if (
present(cell_measures) )
then 1831 file_history_vars(id)%cell_measures = cell_measures
1833 file_history_vars(id)%cell_measures =
"" 1835 if (
present(fill_halo) )
then 1836 file_history_vars(id)%fill_halo = fill_halo
1838 file_history_vars(id)%fill_halo = .false.
1841 file_history_vars(id)%waitstep = file_history_output_wait_step
1842 if ( file_history_output_step0 .AND. file_history_nowstep == 1 )
then 1843 file_history_vars(id)%laststep_write = 1 - file_history_vars(id)%dstep
1845 file_history_vars(id)%laststep_write = 1
1847 file_history_vars(id)%laststep_put = file_history_vars(id)%laststep_write
1848 file_history_vars(id)%flag_clear = .true.
1849 file_history_vars(id)%size = file_history_dims(dimid)%size(zid)
1850 allocate( file_history_vars(id)%varsum( file_history_vars(id)%size ) )
1852 file_history_vars(id)%timesum = 0.0_dp
1855 log_info(
"FILE_HISTORY_Add_Variable",*)
'[HISTORY] Item registration No.= ', id
1856 log_info_cont(*)
'Item name : ', trim(file_history_vars(id)%name)
1857 log_info_cont(*)
'Output name : ', trim(file_history_vars(id)%outname)
1858 log_info_cont(*)
'Description : ', trim(file_history_vars(id)%desc)
1859 log_info_cont(*)
'Unit : ', trim(file_history_vars(id)%units)
1860 log_info_cont(*)
'Basename of output file : ', trim(file_history_vars(id)%basename)
1861 log_info_cont(*)
'Add timelabel to the filename? : ', file_history_vars(id)%postfix_timelabel
1862 log_info_cont(*)
'Zcoord : ', trim(file_history_vars(id)%zcoord)
1863 log_info_cont(*)
'Interval [step] : ', file_history_vars(id)%dstep
1864 log_info_cont(*)
'Time Average? : ', file_history_vars(id)%taverage
1865 log_info_cont(*)
'Datatype : ', trim(
file_dtypelist(file_history_vars(id)%dtype))
1866 log_info_cont(*)
'axis name : ', ( trim(file_history_dims(dimid)%dims(n,zid))//
" ", n=1, file_history_dims(dimid)%ndims )
1870 do m = 1, file_history_nvar_inputs
1871 if ( file_history_var_inputs(m)%name == name )
then 1872 file_history_var_inputs(m)%nvariants = file_history_var_inputs(m)%nvariants + 1
1873 if ( file_history_var_inputs(m)%nvariants > file_history_variant_max )
then 1874 log_error(
"FILE_HISTORY_Add_Variable",*)
'Number of variant for ', trim(name),
' excees limit!' 1877 file_history_var_inputs(m)%variants(file_history_var_inputs(m)%nvariants) = id
1883 if ( .not. existed )
then 1884 file_history_nvar_inputs = file_history_nvar_inputs + 1
1885 itemid = file_history_nvar_inputs
1886 file_history_var_inputs(itemid)%name = name
1887 file_history_var_inputs(itemid)%nvariants = 1
1888 file_history_var_inputs(itemid)%variants(1) = id
1896 end subroutine file_history_add_variable
1899 subroutine file_history_create( &
1912 file_add_variable, &
1918 integer,
intent(in) :: id
1920 character(len=*),
intent(in) :: options
1923 character(len=H_MID) :: tunits
1924 character(len=H_LONG) :: basename_mod
1925 logical :: fileexisted
1926 integer(8) :: array_size
1929 integer :: dimid, zid
1931 character(len=H_SHORT) :: dims(3)
1934 character(len=H_MID) :: timelabel
1936 integer :: ic, ie, is, lo
1940 fid = file_history_vars(id)%fid
1942 if ( fid >= 0 )
return 1944 if ( file_history_time_since ==
'' )
then 1945 tunits = trim(file_history_time_units)
1947 tunits = trim(file_history_time_units)//
' since '//trim(file_history_time_since)
1950 if ( file_history_vars(id)%postfix_timelabel )
then 1953 basename_mod = trim(file_history_vars(id)%basename)//
'_'//trim(timelabel)
1955 basename_mod = trim(file_history_vars(id)%basename)
1959 file_history_title, &
1960 file_history_source, &
1961 file_history_institution, &
1963 rankid = file_history_myrank, &
1965 time_units = tunits, &
1966 calendar = file_history_calendar )
1968 file_history_vars(id)%fid = fid
1974 lo = len_trim(options)
1977 if ( m == lo+1 .OR. options(m:m) ==
'&' )
then 1978 if ( ic == -1 .OR. ie == -1 )
then 1979 log_error(
"FILE_HISTORY_Create",*)
'option is invalid: ', trim(options)
1982 call file_set_option( fid, options(is:ic-1), options(ic+1:ie-1), options(ie+1:m -1) )
1986 elseif( options(m:m) ==
':' )
then 1988 elseif( options(m:m) ==
'=' )
then 1994 if (
rp ==
dp )
then 2002 do m = 1, file_history_naxes
2004 dim_size = file_history_axes(m)%gdim_size
2005 if ( dim_size < 1 )
then 2006 log_error(
"FILE_HISTORY_Create",*)
'gsize is not set by FILE_HISTORY_Set_Axis' 2007 log_error_cont(*)
'It is necessary for aggregate file' 2011 dim_size = file_history_axes(m)%dim_size
2014 file_history_axes(m)%name, &
2015 file_history_axes(m)%desc, &
2016 file_history_axes(m)%units, &
2017 file_history_axes(m)%dim, &
2019 bounds=
associated(file_history_axes(m)%bounds) )
2020 if ( file_history_axes(m)%down )
then 2021 call file_set_attribute( fid, file_history_axes(m)%name,
'positive',
'down' )
2027 do m = 1, file_history_nassocs
2028 ndims = file_history_assocs(m)%ndims
2030 file_history_assocs(m)%name, &
2031 file_history_assocs(m)%desc, &
2032 file_history_assocs(m)%units, &
2033 file_history_assocs(m)%dims(1:ndims), &
2034 file_history_assocs(m)%dtype )
2038 do m = 1, file_history_nattrs
2040 if ( file_history_attrs(m)%add_variable )
then 2045 select case ( file_history_attrs(m)%type )
2047 call file_set_attribute( fid, &
2048 file_history_attrs(m)%varname, &
2049 file_history_attrs(m)%key, &
2050 file_history_attrs(m)%text )
2052 call file_set_attribute( fid, &
2053 file_history_attrs(m)%varname, &
2054 file_history_attrs(m)%key, &
2055 file_history_attrs(m)%int(:) )
2057 call file_set_attribute( fid, &
2058 file_history_attrs(m)%varname, &
2059 file_history_attrs(m)%key, &
2060 file_history_attrs(m)%float(:) )
2062 call file_set_attribute( fid, &
2063 file_history_attrs(m)%varname, &
2064 file_history_attrs(m)%key, &
2065 file_history_attrs(m)%double(:) )
2072 if ( file_history_io_buffer_size == 0 )
then 2074 do m = 1, file_history_nitems
2075 array_size = array_size + file_history_vars(m)%size
2077 file_history_io_buffer_size = array_size *
dp 2082 do m = 1, file_history_nitems
2083 if ( file_history_vars(id)%basename == file_history_vars(m)%basename )
then 2085 file_history_vars(m)%fid = fid
2086 dtsec =
real(FILE_HISTORY_vars(m)%dstep,kind=DP) * FILE_HISTORY_DTSEC
2087 dimid = file_history_vars(m)%dimid
2088 zid = file_history_vars(m)%zid
2089 ndims = file_history_dims(dimid)%ndims
2090 dims(1:ndims) = file_history_dims(dimid)%dims(1:ndims,zid)
2091 call file_add_variable( file_history_vars(m)%fid, &
2092 file_history_vars(m)%outname, &
2093 file_history_vars(m)%desc, &
2094 file_history_vars(m)%units, &
2095 file_history_vars(m)%standard_name, &
2097 file_history_vars(m)%dtype, &
2099 file_history_vars(m)%vid, &
2100 time_avg=file_history_vars(m)%taverage )
2101 if ( file_history_dims(dimid)%mapping /=
"" )
then 2102 call file_set_attribute( file_history_vars(m)%fid, file_history_vars(m)%outname, &
2103 'grid_mapping', file_history_dims(dimid)%mapping )
2106 select case( file_history_vars(m)%cell_measures )
2107 case (
"area",
"area_z" )
2108 if ( file_history_dims(dimid)%area /=
"" )
then 2109 call file_set_attribute( file_history_vars(m)%fid, file_history_vars(m)%outname, &
2110 'cell_measures',
"area: "//trim(file_history_dims(dimid)%area) )
2113 if ( file_history_dims(dimid)%area_x /=
"" )
then 2114 call file_set_attribute( file_history_vars(m)%fid, file_history_vars(m)%outname, &
2115 'cell_measures',
"area: "//trim(file_history_dims(dimid)%area_x) )
2118 if ( file_history_dims(dimid)%area_x /=
"" )
then 2119 call file_set_attribute( file_history_vars(m)%fid, file_history_vars(m)%outname, &
2120 'cell_measures',
"area: "//trim(file_history_dims(dimid)%area_y) )
2123 if ( file_history_dims(dimid)%area_x /=
"" )
then 2124 call file_set_attribute( file_history_vars(m)%fid, file_history_vars(m)%outname, &
2125 'cell_measures',
"volume: "//trim(file_history_dims(dimid)%volume) )
2129 if ( file_history_dims(dimid)%location /=
"" )
then 2130 if ( file_history_vars(m)%zcoord ==
"model" )
then 2131 call file_set_attribute( file_history_vars(m)%fid, file_history_vars(m)%outname, &
2132 'grid', file_history_dims(dimid)%grid )
2134 call file_set_attribute( file_history_vars(m)%fid, file_history_vars(m)%outname, &
2135 'grid', trim(file_history_dims(dimid)%grid)//
'_'//trim(file_history_vars(id)%zcoord) )
2137 call file_set_attribute( file_history_vars(m)%fid, file_history_vars(m)%outname, &
2138 'location', file_history_dims(dimid)%location )
2143 call file_history_write_axes(id)
2146 end subroutine file_history_create
2148 subroutine file_history_close
2154 integer :: fid, prev_fid
2159 do id = 1, file_history_nitems
2160 fid = file_history_vars(id)%fid
2161 file_history_vars(id)%fid = -1
2162 if ( fid > 0 .AND. fid /= prev_fid )
then 2170 end subroutine file_history_close
2188 character(len=*),
intent(in) :: name
2189 character(len=*),
intent(in) :: desc
2190 character(len=*),
intent(in) :: units
2191 character(len=*),
intent(in) :: dims(:)
2192 real(RP),
intent(in) :: var(:)
2193 character(len=*),
intent(in),
optional :: datatype
2194 integer,
intent(in),
optional :: start(:)
2200 intrinsic size, shape, reshape
2203 if (
present(datatype) )
then 2204 if ( datatype ==
'REAL4' )
then 2206 elseif( datatype ==
'REAL8' )
then 2209 log_error(
"FILE_HISTORY_Set_AssociatedCoordinate_1D",*)
'Not appropriate datatype. Check!', datatype
2212 else if (
rp ==
sp )
then 2218 dim_size =
size(var)
2220 if ( file_history_nassocs < file_history_assoc_max )
then 2221 file_history_nassocs = file_history_nassocs + 1
2222 id = file_history_nassocs
2224 allocate( file_history_assocs(id)%var(dim_size) )
2226 file_history_assocs(id)%name = name
2227 file_history_assocs(id)%desc = desc
2228 file_history_assocs(id)%units = units
2229 file_history_assocs(id)%ndims = 1
2230 file_history_assocs(id)%dims(:) =
'' 2231 file_history_assocs(id)%dims(1:1) = dims(1:1)
2232 file_history_assocs(id)%dtype = dtype
2233 file_history_assocs(id)%var(:) =
real(reshape( var, (/ dim_size /) ),kind=
dp)
2237 file_history_assocs(id)%count(1:1) = shape(var)
2238 if (
present(start) )
then 2239 file_history_assocs(id)%start(1:1) = start(1:1)
2241 file_history_assocs(id)%start = (/ 1, 1, 1, 1 /)
2244 log_error(
"FILE_HISTORY_Set_AssociatedCoordinate_1D",*)
'Number of associate coordinates exceeds the limit.' 2265 character(len=*),
intent(in) :: name
2266 character(len=*),
intent(in) :: desc
2267 character(len=*),
intent(in) :: units
2268 character(len=*),
intent(in) :: dims(:)
2269 real(RP),
intent(in) :: var(:,:)
2270 character(len=*),
intent(in),
optional :: datatype
2271 integer,
intent(in),
optional :: start(:)
2277 intrinsic size, shape, reshape
2280 if (
present(datatype) )
then 2281 if ( datatype ==
'REAL4' )
then 2283 elseif( datatype ==
'REAL8' )
then 2286 log_error(
"FILE_HISTORY_Set_AssociatedCoordinate_2D",*)
'Not appropriate datatype. Check!', datatype
2289 else if (
rp ==
sp )
then 2295 dim_size =
size(var)
2297 if ( file_history_nassocs < file_history_assoc_max )
then 2298 file_history_nassocs = file_history_nassocs + 1
2299 id = file_history_nassocs
2301 allocate( file_history_assocs(id)%var(dim_size) )
2303 file_history_assocs(id)%name = name
2304 file_history_assocs(id)%desc = desc
2305 file_history_assocs(id)%units = units
2306 file_history_assocs(id)%ndims = 2
2307 file_history_assocs(id)%dims(:) =
'' 2308 file_history_assocs(id)%dims(1:2) = dims(1:2)
2309 file_history_assocs(id)%dtype = dtype
2310 file_history_assocs(id)%var(:) =
real(reshape( var, (/ dim_size /) ),kind=
dp)
2314 file_history_assocs(id)%count(1:2) = shape(var)
2315 if (
present(start) )
then 2316 file_history_assocs(id)%start(1:2) = start(1:2)
2318 file_history_assocs(id)%start = (/ 1, 1, 1, 1 /)
2321 log_error(
"FILE_HISTORY_Set_AssociatedCoordinate_2D",*)
'Number of associate coordinates exceeds the limit.' 2342 character(len=*),
intent(in) :: name
2343 character(len=*),
intent(in) :: desc
2344 character(len=*),
intent(in) :: units
2345 character(len=*),
intent(in) :: dims(:)
2346 real(RP),
intent(in) :: var(:,:,:)
2347 character(len=*),
intent(in),
optional :: datatype
2348 integer,
intent(in),
optional :: start(:)
2354 intrinsic size, shape, reshape
2357 if (
present(datatype) )
then 2358 if ( datatype ==
'REAL4' )
then 2360 elseif( datatype ==
'REAL8' )
then 2363 log_error(
"FILE_HISTORY_Set_AssociatedCoordinate_3D",*)
'Not appropriate datatype. Check!', datatype
2366 else if (
rp ==
sp )
then 2372 dim_size =
size(var)
2374 if ( file_history_nassocs < file_history_assoc_max )
then 2375 file_history_nassocs = file_history_nassocs + 1
2376 id = file_history_nassocs
2378 allocate( file_history_assocs(id)%var(dim_size) )
2380 file_history_assocs(id)%name = name
2381 file_history_assocs(id)%desc = desc
2382 file_history_assocs(id)%units = units
2383 file_history_assocs(id)%ndims = 3
2384 file_history_assocs(id)%dims(:) =
'' 2385 file_history_assocs(id)%dims(1:3) = dims(1:3)
2386 file_history_assocs(id)%dtype = dtype
2387 file_history_assocs(id)%var(:) =
real(reshape( var, (/ dim_size /) ),kind=
dp)
2391 file_history_assocs(id)%count(1:3) = shape(var)
2392 if (
present(start) )
then 2393 file_history_assocs(id)%start(1:3) = start(1:3)
2395 file_history_assocs(id)%start = (/ 1, 1, 1, 1 /)
2398 log_error(
"FILE_HISTORY_Set_AssociatedCoordinate_3D",*)
'Number of associate coordinates exceeds the limit.' 2417 character(len=*),
intent(in) :: varname
2418 character(len=*),
intent(in) :: key
2419 character(len=*),
intent(in) :: val
2420 logical,
intent(in),
optional :: add_variable
2425 file_history_nattrs = file_history_nattrs + 1
2426 if ( file_history_nattrs > file_history_attr_max )
then 2427 log_error(
"FILE_HISTORY_Set_Attribute_Text",*)
'number of attributes exceeds the limit' 2431 id = file_history_nattrs
2433 file_history_attrs(id)%varname = varname
2434 file_history_attrs(id)%key = key
2435 file_history_attrs(id)%text = val
2436 file_history_attrs(id)%type = i_text
2438 if (
present(add_variable) )
then 2439 file_history_attrs(id)%add_variable = add_variable
2441 file_history_attrs(id)%add_variable = .false.
2454 character(len=*),
intent(in) :: varname
2455 character(len=*),
intent(in) :: key
2456 logical,
intent(in) :: val
2457 logical,
intent(in),
optional :: add_variable
2459 character(len=5) :: buf
2483 character(len=*),
intent(in) :: varname
2484 character(len=*),
intent(in) :: key
2485 integer,
intent(in) :: val(:)
2486 logical,
intent(in),
optional :: add_variable
2493 file_history_nattrs = file_history_nattrs + 1
2494 if ( file_history_nattrs > file_history_attr_max )
then 2495 log_error(
"FILE_HISTORY_Set_Attribute_Int",*)
'number of attributes exceeds the limit' 2499 id = file_history_nattrs
2501 allocate( file_history_attrs(id)%int(
size(val) ) )
2503 file_history_attrs(id)%varname = varname
2504 file_history_attrs(id)%key = key
2505 file_history_attrs(id)%int(:) = val(:)
2506 file_history_attrs(id)%type = i_int
2508 if (
present(add_variable) )
then 2509 file_history_attrs(id)%add_variable = add_variable
2511 file_history_attrs(id)%add_variable = .false.
2527 character(len=*),
intent(in) :: varname
2528 character(len=*),
intent(in) :: key
2529 real(SP),
intent(in) :: val(:)
2530 logical,
intent(in),
optional :: add_variable
2537 file_history_nattrs = file_history_nattrs + 1
2538 if ( file_history_nattrs > file_history_attr_max )
then 2539 log_error(
"FILE_HISTORY_Set_Attribute_Float",*)
'number of attributes exceeds the limit' 2543 id = file_history_nattrs
2545 allocate( file_history_attrs(id)%float(
size(val) ) )
2547 file_history_attrs(id)%varname = varname
2548 file_history_attrs(id)%key = key
2549 file_history_attrs(id)%float(:) = val(:)
2550 file_history_attrs(id)%type = i_float
2552 if (
present(add_variable) )
then 2553 file_history_attrs(id)%add_variable = add_variable
2555 file_history_attrs(id)%add_variable = .false.
2571 character(len=*),
intent(in) :: varname
2572 character(len=*),
intent(in) :: key
2573 real(DP),
intent(in) :: val(:)
2574 logical,
intent(in),
optional :: add_variable
2581 file_history_nattrs = file_history_nattrs + 1
2582 if ( file_history_nattrs > file_history_attr_max )
then 2583 log_error(
"FILE_HISTORY_Set_Attribute_Double",*)
'number of attributes exceeds the limit' 2587 id = file_history_nattrs
2589 allocate( file_history_attrs(id)%double(
size(val) ) )
2591 file_history_attrs(id)%varname = varname
2592 file_history_attrs(id)%key = key
2593 file_history_attrs(id)%double(:) = val(:)
2594 file_history_attrs(id)%type = i_double
2596 if (
present(add_variable) )
then 2597 file_history_attrs(id)%add_variable = add_variable
2599 file_history_attrs(id)%add_variable = .false.
2612 integer,
intent(in) :: itemid
2613 logical,
intent(out) :: answer
2618 if ( file_history_disabled )
return 2619 if ( itemid < 0 )
return 2621 do i = 1, file_history_var_inputs(itemid)%nvariants
2622 id = file_history_var_inputs(itemid)%variants(i)
2623 if ( file_history_vars(id)%taverage )
then 2626 else if ( file_history_nowstep >= file_history_vars(id)%laststep_write + file_history_vars(id)%dstep )
then 2635 subroutine file_history_query_name( &
2640 character(len=*),
intent(in) :: name
2642 logical,
intent(out) :: answer
2648 if ( file_history_disabled )
return 2650 do itemid = 1, file_history_nvar_inputs
2651 if ( file_history_var_inputs(itemid)%name == name )
then 2658 end subroutine file_history_query_name
2661 subroutine file_history_write_axes(id)
2666 file_write_associatedcoordinate
2670 integer,
intent(in) :: id
2676 if ( id < 0 )
return 2678 fid = file_history_vars(id)%fid
2682 do m = 1, file_history_naxes
2683 if ( file_history_axes(m)%start > 0 )
then 2684 start(1) = file_history_axes(m)%start
2686 call file_write_axis( fid, &
2687 file_history_axes(m)%name, &
2688 file_history_axes(m)%var, &
2691 if (
associated(file_history_axes(m)%bounds) )
then 2692 call file_write_associatedcoordinate( fid, &
2693 trim(file_history_axes(m)%name)//
'_bnds', &
2694 file_history_axes(m)%bounds(:,:), &
2701 do m = 1, file_history_nassocs
2702 call file_write_associatedcoordinate( fid, &
2703 file_history_assocs(m)%name, &
2704 file_history_assocs(m)%var, &
2705 file_history_assocs(m)%start, &
2706 file_history_assocs(m)%count, &
2707 file_history_assocs(m)%ndims )
2714 end subroutine file_history_write_axes
2717 subroutine file_history_write_onevar( &
2728 integer,
intent(in) :: id
2729 integer,
intent(in) :: step_now
2731 integer :: dimid, zid
2732 real(DP) :: time_str, time_end
2733 real(DP) :: sec_str, sec_end
2737 if( file_history_nreqs == 0 )
return 2739 if ( step_now < file_history_vars(id)%laststep_write + file_history_vars(id)%dstep )
then 2743 if ( file_history_vars(id)%flag_clear )
then 2744 if ( file_history_error_putmiss )
then 2745 log_error(
"FILE_HISTORY_Write_OneVar",*)
'The time interval of history output ', trim(file_history_vars(id)%name), &
2746 ' and the time interval of its related scheme are inconsistent.' 2747 log_error_cont(*)
'Please check the namelist PARAM_TIME, PARAM_FILE_HISTORY, and HISTORY_ITEM.' 2748 log_error_cont(*)
'Please set FILE_HISTORY_ERROR_PUTMISS in the namelist PARAM_FILE_HISTORY to .false.', &
2749 ' when you want to disable this check.' 2750 log_error_cont(*)
'The time interval of history output ', trim(file_history_vars(id)%name), &
2751 ' and the time interval of its related scheme are inconsistent.', &
2752 ' Please see detail in log file.' 2755 log_warn(
"FILE_HISTORY_Write_OneVar",*)
'Output value is not updated in this step.', &
2756 ' NAME = ', trim(file_history_vars(id)%name), &
2757 ', OUTNAME = ', trim(file_history_vars(id)%outname)
2761 if ( .NOT. file_history_vars(id)%flag_clear .AND. file_history_vars(id)%taverage )
then 2762 do i = 1, file_history_vars(id)%size
2763 if ( file_history_vars(id)%varsum(i) /= rmiss )
then 2764 file_history_vars(id)%varsum(i) = file_history_vars(id)%varsum(i) / file_history_vars(id)%timesum
2769 if ( firsttime )
then 2771 call file_history_output_list
2774 if ( step_now > file_history_vars(id)%waitstep )
then 2775 if ( laststep_write < step_now )
then 2776 log_progress(*)
'output history' 2781 call file_history_create( id, options = file_history_options )
2783 sec_str = file_history_startdaysec +
real(FILE_HISTORY_vars(id)%laststep_write-1,kind=DP) * FILE_HISTORY_DTSEC
2784 sec_end = file_history_startdaysec +
real(step_now -1,kind=DP) * FILE_HISTORY_DTSEC
2790 dimid = file_history_vars(id)%dimid
2791 zid = file_history_vars(id)%zid
2792 if ( file_history_dims(dimid)%count(1,zid) > 0 )
then 2799 call file_write( file_history_vars(id)%vid, &
2800 file_history_vars(id)%varsum(:), &
2803 ndims=file_history_dims(dimid)%ndims, &
2804 count=file_history_dims(dimid)%count(:,zid), &
2805 start=file_history_dims(dimid)%start(:,zid) )
2808 if ( laststep_write < step_now )
then 2809 log_progress(*)
'history output is suppressed' 2813 file_history_vars(id)%laststep_write = step_now
2814 file_history_vars(id)%flag_clear = .true.
2816 laststep_write = step_now
2819 end subroutine file_history_write_onevar
2822 subroutine file_history_output_list
2829 if ( file_history_nitems /= file_history_nreqs )
then 2831 log_info(
"FILE_HISTORY_Output_List",*)
'[HISTORY] All of requested variable by the namelist HISTORY_ITEM did not find.' 2832 do id = 1, file_history_nreqs
2833 log_info(
"FILE_HISTORY_Output_List",
'(A,A24,A,L1)')
'NAME : ', file_history_req(id)%name, &
2834 ', registered? : ', file_history_req(id)%registered
2836 log_info(
"FILE_HISTORY_Output_List",*)
'Please set FILE_HISTORY_ERROR_PUTMISS in the namelist PARAM_FILE_HISTORY to .false.', &
2837 ' when you want to disable this check.' 2839 if ( file_history_error_putmiss )
then 2840 log_error(
"FILE_HISTORY_Output_List",*)
'Requested variables by the namelist HISTORY_ITEM did not find. Please see detail in log file.' 2845 log_info(
"FILE_HISTORY_Output_List",*)
'[HISTORY] Output item list ' 2846 log_info_cont(
'(1x,A,I4)')
'Number of history item :', file_history_nreqs
2847 log_info_cont(*)
'ITEM :OUTNAME ', &
2848 ': size:interval[sec]: step:timeavg?:zcoord' 2849 log_info_cont(*)
'=================================================', &
2850 '=================================================' 2853 do id = 1, file_history_nitems
2854 dtsec =
real(FILE_HISTORY_vars(id)%dstep,kind=DP) * FILE_HISTORY_DTSEC
2856 log_info_cont(
'(1x,A24,1x,A24,1x,I8,1x,F13.3,1x,I8,1x,L8,1x,A8)') &
2857 file_history_vars(id)%name, &
2858 file_history_vars(id)%outname, &
2859 file_history_vars(id)%size, &
2861 file_history_vars(id)%dstep, &
2862 file_history_vars(id)%taverage, &
2863 file_history_vars(id)%zcoord
2866 log_info_cont(*)
'=================================================', &
2867 '=================================================' 2870 end subroutine file_history_output_list
2872 function file_history_find_id( name )
2873 character(len=*),
intent(in) :: name
2874 integer :: FILE_HISTORY_find_id
2878 do itemid = 1, file_history_nvar_inputs
2879 if ( file_history_var_inputs(itemid)%name == name )
then 2880 file_history_find_id = itemid
2885 file_history_find_id = -1
2888 end function file_history_find_id
2890 function file_history_get_size( &
2892 character(len=*),
intent(in) :: dims(:)
2893 integer,
intent(in) :: ndims
2894 integer :: FILE_HISTORY_get_size
2899 file_history_get_size = 1
2902 do i = 1, file_history_naxes
2903 if ( file_history_axes(i)%name == dims(n) )
then 2904 len = file_history_axes(i)%dim_size
2909 log_error(
"FILE_HISTORY_get_size",*)
'dimension name is not found: ', dims(n)
2912 file_history_get_size = file_history_get_size * len
2916 end function file_history_get_size
2918 subroutine file_history_truncate_1d_default( &
2920 dim_type, zcoord, fill_halo, &
2922 real(RP),
intent(in) :: src(:)
2923 character(len=*),
intent(in) :: dim_type
2924 character(len=*),
intent(in) :: zcoord
2925 logical,
intent(in) :: fill_halo
2926 real(DP),
intent(out) :: dsc(:)
2931 end subroutine file_history_truncate_1d_default
2932 subroutine file_history_truncate_2d_default( &
2934 dim_type, zcoord, fill_halo, &
2936 real(RP),
intent(in) :: src(:,:)
2937 character(len=*),
intent(in) :: dim_type
2938 character(len=*),
intent(in) :: zcoord
2939 logical,
intent(in) :: fill_halo
2940 real(DP),
intent(out) :: dsc(:)
2948 do j = 1,
size(src,2)
2949 do i = 1,
size(src,1)
2950 dsc(idx) = src(i, j)
2956 end subroutine file_history_truncate_2d_default
2957 subroutine file_history_truncate_3d_default( &
2959 dim_type, zcoord, fill_halo, &
2961 real(RP),
intent(in) :: src(:,:,:)
2962 character(len=*),
intent(in) :: dim_type
2963 character(len=*),
intent(in) :: zcoord
2964 logical,
intent(in) :: fill_halo
2965 real(DP),
intent(out) :: dsc(:)
2973 do j = 1,
size(src,3)
2974 do i = 1,
size(src,2)
2975 do k = 1,
size(src,1)
2976 dsc(idx) = src(k, i, j)
2983 end subroutine file_history_truncate_3d_default
2984 subroutine file_history_truncate_4d_default( &
2986 dim_type, zcoord, fill_halo, &
2988 real(RP),
intent(in) :: src(:,:,:,:)
2989 character(len=*),
intent(in) :: dim_type
2990 character(len=*),
intent(in) :: zcoord
2991 logical,
intent(in) :: fill_halo
2992 real(DP),
intent(out) :: dsc(:)
2994 integer :: l, k, i, j
3000 do j = 1,
size(src,4)
3001 do i = 1,
size(src,3)
3002 do k = 1,
size(src,2)
3003 do l = 1,
size(src,1)
3004 dsc(idx) = src(l, k, i, j)
3012 end subroutine file_history_truncate_4d_default
subroutine file_history_in_0d(var, name, desc, unit, standard_name, dim_type)
Wrapper routine of FILE_HISTORY_reg + FILE_HISTORY_put.
subroutine, public file_history_setup(title, source, institution, time_start, time_interval, time_units, time_since, calendar, default_basename, default_postfix_timelabel, default_zcoord, default_tinterval, default_tunit, default_taverage, default_datatype, myrank)
Setup.
subroutine, public calendar_unit2sec(second, value, unit)
Convert several units to second.
subroutine, public file_close(fid, skip_abort)
subroutine file_history_set_attribute_int(varname, key, val, add_variable)
subroutine, public file_history_set_dim(name, ndims, nzcoords, dims, zcoords, start, count, mapping, area, area_x, area_y, volume, location, grid)
set dimension information
integer, parameter, public file_real4
subroutine file_history_in_4d(var, name, desc, unit, standard_name, dim_type, fill_halo)
Wrapper routine of FILE_HISTORY_reg + FILE_HISTORY_put.
subroutine, public time_time2label(date, ms, timelabel)
generate time label
logical, public file_aggregate
subroutine, public file_def_axis(fid, name, desc, units, dim_name, dtype, dim_size, bounds)
logical, public aggregate
subroutine, public file_set_option(fid, filetype, key, val)
integer, public io_fid_conf
Config file ID.
subroutine, public file_history_reg(name, desc, unit, itemid, standard_name, ndims, dim_type, cell_measures, fill_halo)
Register/Append variable to history file.
subroutine, public file_detach_buffer(fid)
integer, parameter, public file_real8
subroutine, public file_history_set_axis(name, desc, units, dim, var, bounds, down, gsize, start)
set axis information
real(rp), public const_undef
subroutine, public file_attach_buffer(fid, buf_amount)
subroutine, public file_flush(fid)
subroutine file_history_set_attribute_float(varname, key, val, add_variable)
subroutine file_history_set_associatedcoordinate_1d(name, desc, units, dims, var, datatype, start)
character(len=file_hshort), dimension(0:4), public file_dtypelist
subroutine, public file_history_set_disable(switch)
set switch to turn on/off history
subroutine file_history_set_attribute_double(varname, key, val, add_variable)
subroutine file_history_query_id(itemid, answer)
subroutine, public calendar_sec2unit(value, second, unit)
Convert several second to specified unit.
subroutine file_history_in_3d(var, name, desc, unit, standard_name, dim_type, fill_halo)
Wrapper routine of FILE_HISTORY_reg + FILE_HISTORY_put.
logical, public file_history_aggregate
subroutine file_history_set_attribute_text(varname, key, val, add_variable)
subroutine, public file_history_write
subroutine, public file_history_finalize
finalization
subroutine, public prc_abort
Abort Process.
subroutine file_history_in_1d(var, name, desc, unit, standard_name, dim_type)
Wrapper routine of FILE_HISTORY_reg + FILE_HISTORY_put.
procedure(truncate_2d), pointer, public file_history_truncate_2d
real(dp), parameter, public file_rmiss
subroutine, public file_create(basename, title, source, institution, fid, existed, rankid, single, aggregate, time_units, calendar, append)
create file fid is >= 1
integer, parameter, public h_short
Character length (short=16)
subroutine, public prof_rapstart(rapname_base, level)
Start raptime.
subroutine, public file_def_associatedcoordinate(fid, name, desc, units, dim_names, dtype)
subroutine file_history_set_associatedcoordinate_3d(name, desc, units, dims, var, datatype, start)
procedure(truncate_4d), pointer, public file_history_truncate_4d
subroutine file_history_in_2d(var, name, desc, unit, standard_name, dim_type, fill_halo)
Wrapper routine of FILE_HISTORY_reg + FILE_HISTORY_put.
subroutine file_history_set_attribute_logical(varname, key, val, add_variable)
real(rp), public const_eps
small number
procedure(truncate_1d), pointer, public file_history_truncate_1d
integer, parameter, public sp
subroutine, public file_add_associatedvariable(fid, vname, existed)
subroutine file_history_set_associatedcoordinate_2d(name, desc, units, dims, var, datatype, start)
subroutine, public prof_rapend(rapname_base, level)
Save raptime.
integer, parameter, public rp
integer, parameter, public dp
subroutine, public file_enddef(fid)
procedure(truncate_3d), pointer, public file_history_truncate_3d
subroutine, public file_history_set_nowdate(NOWDATE, NOWMS, NOWSTEP)
set now step