SCALE-RM
Data Types | Functions/Subroutines | Variables
scale_file_history Module Reference

module file_history More...

Functions/Subroutines

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_tstats_op, default_datatype, myrank)
 Setup. More...
 
subroutine, public file_history_reg (name, desc, unit, itemid, standard_name, ndims, dim_type, cell_measures, fill_halo)
 Register/Append variable to history file. More...
 
subroutine file_history_in_0d (var, name, desc, unit, standard_name, dim_type)
 Wrapper routine of FILE_HISTORY_reg + FILE_HISTORY_put. More...
 
subroutine file_history_in_1d (var, name, desc, unit, standard_name, dim_type)
 Wrapper routine of FILE_HISTORY_reg + FILE_HISTORY_put. More...
 
subroutine file_history_in_2d (var, name, desc, unit, standard_name, dim_type, fill_halo)
 Wrapper routine of FILE_HISTORY_reg + FILE_HISTORY_put. More...
 
subroutine file_history_in_3d (var, name, desc, unit, standard_name, dim_type, fill_halo)
 Wrapper routine of FILE_HISTORY_reg + FILE_HISTORY_put. More...
 
subroutine file_history_in_4d (var, name, desc, unit, standard_name, dim_type, fill_halo)
 Wrapper routine of FILE_HISTORY_reg + FILE_HISTORY_put. More...
 
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 More...
 
subroutine, public file_history_set_axis (name, desc, units, dim, var, bounds, down, gsize, start)
 set axis information More...
 
subroutine, public file_history_write
 
subroutine, public file_history_set_nowdate (NOWDATE, NOWSUBSEC, NOWSTEP)
 set now step More...
 
subroutine, public file_history_set_disable (switch)
 set switch to turn on/off history More...
 
subroutine, public file_history_finalize
 finalization More...
 
subroutine file_history_set_associatedcoordinate_1d (name, desc, units, dims, var, datatype, start)
 
subroutine file_history_set_associatedcoordinate_2d (name, desc, units, dims, var, datatype, start)
 
subroutine file_history_set_associatedcoordinate_3d (name, desc, units, dims, var, datatype, start)
 
subroutine file_history_set_attribute_text (varname, key, val, add_variable)
 
subroutine file_history_set_attribute_logical (varname, key, val, add_variable)
 
subroutine file_history_set_attribute_int_ary (varname, key, val, add_variable)
 
subroutine file_history_set_attribute_int (varname, key, val, add_variable)
 
subroutine file_history_set_attribute_float (varname, key, val, add_variable)
 
subroutine file_history_set_attribute_double (varname, key, val, add_variable)
 

Variables

procedure(truncate_1d), pointer, public file_history_truncate_1d => NULL()
 
procedure(truncate_2d), pointer, public file_history_truncate_2d => NULL()
 
procedure(truncate_3d), pointer, public file_history_truncate_3d => NULL()
 
procedure(truncate_4d), pointer, public file_history_truncate_4d => NULL()
 
logical, public file_history_aggregate
 
logical, public switch
 
logical, public to
 
logical, public use
 
logical, public aggregate
 
logical, public file
 
logical, public i
 
logical, public o
 

Detailed Description

module file_history

Description
I/O handling for history output
Author
Team SCALE
NAMELIST
  • PARAM_FILE_HISTORY
    nametypedefault valuecomment
    FILE_HISTORY_TITLE character(len=H_MID) > Header information of the output file: title
    FILE_HISTORY_SOURCE character(len=H_MID) > Header information of the output file: model name
    FILE_HISTORY_INSTITUTION character(len=H_MID) > Header information of the output file: institution
    FILE_HISTORY_TIME_UNITS character(len=H_MID) > Unit for time axis
    FILE_HISTORY_DEFAULT_BASENAME character(len=H_LONG) > Base name of the file
    FILE_HISTORY_DEFAULT_POSTFIX_TIMELABEL logical > Add timelabel to the basename?
    FILE_HISTORY_DEFAULT_ZCOORD character(len=H_SHORT) > Default z-coordinate
    FILE_HISTORY_DEFAULT_TINTERVAL real(DP) > Time interval
    FILE_HISTORY_DEFAULT_TUNIT character(len=H_SHORT) > Time unit
    FILE_HISTORY_DEFAULT_TAVERAGE logical > Apply time average? (obsolete)
    FILE_HISTORY_DEFAULT_TSTATS_OP character(len=4) > Statistics operation: none, mean, min, max
    FILE_HISTORY_DEFAULT_DATATYPE character(len=5) > Data type: REAL4, REAL8
    FILE_HISTORY_OUTPUT_STEP0 logical .false. > Output value at step=0?
    FILE_HISTORY_OUTPUT_WAIT real(DP) > Time length to suppress output
    FILE_HISTORY_OUTPUT_WAIT_TUNIT character(len=H_SHORT) > Time unit
    FILE_HISTORY_OUTPUT_SWITCH_TINTERVAL real(DP) > Time interval to switch output file
    FILE_HISTORY_OUTPUT_SWITCH_TUNIT character(len=H_SHORT) > Time unit
    FILE_HISTORY_ERROR_PUTMISS logical .true. > Abort if the value is never stored after last output?
    FILE_HISTORY_AGGREGATE logical > Switch to use aggregate file I/O
    FILE_HISTORY_OPTIONS character(len=H_MID) '' !> option to give file. 'filetype1:key1=val1&filetype2:key2=val2&...'
    DEBUG logical .false.

  • HISTORY_ITEM
    nametypedefault valuecomment
    NAME character(len=*)
    OUTNAME character(len=H_SHORT) > name of variable (for output)
    BASENAME character(len=H_LONG) > base name of the file
    POSTFIX_TIMELABEL logical > Add timelabel to the basename?
    ZCOORD character(len=*)
    TINTERVAL real(DP) > time interval
    TUNIT character(len=H_SHORT) > time unit
    TAVERAGE logical > apply time average? (obsolete)
    TSTATS_OP character(len=4) > statistics operation: none, mean, min, max
    DATATYPE character(len=*)

History Output
No history output

Function/Subroutine Documentation

◆ file_history_setup()

subroutine, public scale_file_history::file_history_setup ( character(len=*), intent(in)  title,
character(len=*), intent(in)  source,
character(len=*), intent(in)  institution,
real(dp), intent(in)  time_start,
real(dp), intent(in)  time_interval,
character(len=*), intent(in), optional  time_units,
character(len=*), intent(in), optional  time_since,
character(len=*), intent(in), optional  calendar,
character(len=*), intent(in), optional  default_basename,
logical, intent(in), optional  default_postfix_timelabel,
character(len=*), intent(in), optional  default_zcoord,
real(dp), intent(in), optional  default_tinterval,
character(len=*), intent(in), optional  default_tunit,
logical, intent(in), optional  default_taverage,
character(len=*), intent(in), optional  default_tstats_op,
character(len=*), intent(in), optional  default_datatype,
integer, intent(in), optional  myrank 
)

Setup.

REAL4 : single precision REAL8 : double precision

Unit for time axis

Base name of the file

Add timelabel to the basename?

Default z-coordinate

Time interval

Time unit

Apply time average? (obsolete)

Statistics operation

Data type

Time length to suppress output

Time unit

Time interval to switch output file

Time unit

Definition at line 345 of file scale_file_history.F90.

345  use scale_file_h, only: &
346  file_real4, &
347  file_real8
348  use scale_file, only: &
350  use scale_calendar, only: &
352  implicit none
353 
354  character(len=*), intent(in) :: title
355  character(len=*), intent(in) :: source
356  character(len=*), intent(in) :: institution
357  real(DP), intent(in) :: time_start
358  real(DP), intent(in) :: time_interval
359 
360  character(len=*), intent(in), optional :: time_units
361  character(len=*), intent(in), optional :: time_since
362  character(len=*), intent(in), optional :: calendar
363  character(len=*), intent(in), optional :: default_basename
364  logical, intent(in), optional :: default_postfix_timelabel
365  character(len=*), intent(in), optional :: default_zcoord
366  real(DP), intent(in), optional :: default_tinterval
367  character(len=*), intent(in), optional :: default_tunit
368  logical, intent(in), optional :: default_taverage
369  character(len=*), intent(in), optional :: default_tstats_op
370  character(len=*), intent(in), optional :: default_datatype
371  integer, intent(in), optional :: myrank
372 
373  character(len=H_LONG) :: FILE_HISTORY_DEFAULT_BASENAME
374  logical :: FILE_HISTORY_DEFAULT_POSTFIX_TIMELABEL
375  character(len=H_SHORT) :: FILE_HISTORY_DEFAULT_ZCOORD
376  real(DP) :: FILE_HISTORY_DEFAULT_TINTERVAL
377  character(len=H_SHORT) :: FILE_HISTORY_DEFAULT_TUNIT
378  logical :: FILE_HISTORY_DEFAULT_TAVERAGE
379  character(len=4) :: FILE_HISTORY_DEFAULT_TSTATS_OP
380  character(len=5) :: FILE_HISTORY_DEFAULT_DATATYPE
383  real(DP) :: FILE_HISTORY_OUTPUT_WAIT
384  character(len=H_SHORT) :: FILE_HISTORY_OUTPUT_WAIT_TUNIT
385  real(DP) :: FILE_HISTORY_OUTPUT_SWITCH_TINTERVAL
386  character(len=H_SHORT) :: FILE_HISTORY_OUTPUT_SWITCH_TUNIT
387 
388  namelist / param_file_history / &
389  file_history_title, &
390  file_history_source, &
391  file_history_institution, &
392  file_history_time_units, &
393  file_history_default_basename, &
394  file_history_default_postfix_timelabel, &
395  file_history_default_zcoord, &
396  file_history_default_tinterval, &
397  file_history_default_tunit, &
398  file_history_default_taverage, &
399  file_history_default_tstats_op, &
400  file_history_default_datatype, &
401  file_history_output_step0, &
402  file_history_output_wait, &
403  file_history_output_wait_tunit, &
404  file_history_output_switch_tinterval, &
405  file_history_output_switch_tunit, &
406  file_history_error_putmiss, &
407  file_history_aggregate, &
408  file_history_options, &
409  debug
410 
411  character(len=H_SHORT) :: NAME
412  character(len=H_SHORT) :: OUTNAME
413  character(len=H_LONG) :: BASENAME
414  logical :: POSTFIX_TIMELABEL
415  character(len=H_SHORT) :: ZCOORD
416  real(DP) :: TINTERVAL
417  character(len=H_SHORT) :: TUNIT
418  logical :: TAVERAGE
419  character(len=4) :: TSTATS_OP
420  character(len=5) :: DATATYPE
421 
422  namelist / history_item / &
423  name, &
424  outname, &
425  basename, &
426  postfix_timelabel, &
427  zcoord, &
428  tinterval, &
429  tunit, &
430  taverage, &
431  tstats_op, &
432  datatype
433 
434 
435  integer :: reqid
436  real(DP) :: dtsec
437  integer :: dstep
438 
439  integer :: ierr
440  integer :: n, id
441 
442  intrinsic size
443  !---------------------------------------------------------------------------
444 
445  log_newline
446  log_info("FILE_HISTORY_Setup",*) 'Setup'
447 
448  ! setup
449  if ( present(myrank) ) then
450  file_history_myrank = myrank
451  else
452  file_history_myrank = 0
453  end if
454 
455  file_history_startdaysec = time_start
456  file_history_dtsec = time_interval
457  if ( present(time_since) ) then
458  file_history_time_since = time_since
459  else
460  file_history_time_since = ''
461  endif
462 
463  if ( present(calendar) ) then
464  file_history_calendar = calendar
465  else
466  file_history_calendar = ""
467  end if
468 
469  file_history_time_units = 'seconds'
470  file_history_default_basename = ''
471  file_history_default_postfix_timelabel = .false.
472  file_history_default_zcoord = ''
473  file_history_default_tinterval = -1.0_dp
474  file_history_default_tunit = 'SEC'
475  file_history_default_taverage = .false.
476  file_history_default_tstats_op = "none"
477  file_history_default_datatype = 'REAL4'
478  file_history_output_wait = 0.0_dp
479  file_history_output_wait_tunit = 'SEC'
480  file_history_output_switch_tinterval = -1.0_dp
481  file_history_output_switch_tunit = 'SEC'
482 
483  file_history_aggregate = file_aggregate
484 
485  !--- read namelist
486  file_history_title = title
487  file_history_source = source
488  file_history_institution = institution
489  if( present(time_units) ) file_history_time_units = time_units
490  if( present(default_basename) ) file_history_default_basename = default_basename
491  if( present(default_postfix_timelabel) ) file_history_default_postfix_timelabel = default_postfix_timelabel
492  if( present(default_zcoord) ) file_history_default_zcoord = default_zcoord
493  if( present(default_tinterval) ) file_history_default_tinterval = default_tinterval
494  if( present(default_tunit) ) file_history_default_tunit = default_tunit
495  if( present(default_taverage) ) file_history_default_taverage = default_taverage
496  if( present(default_tstats_op) ) file_history_default_tstats_op = default_tstats_op
497  if( present(default_datatype) ) file_history_default_datatype = default_datatype
498 
499  !--- read namelist
500  rewind(io_fid_conf)
501  read(io_fid_conf,nml=param_file_history,iostat=ierr)
502  if( ierr < 0 ) then !--- missing
503  log_info("FILE_HISTORY_Setup",*) 'Not found namelist. Default used.'
504  elseif( ierr > 0 ) then !--- fatal error
505  log_error("FILE_HISTORY_Setup",*) 'Not appropriate names in namelist PARAM_FILE_HISTORY. Check!'
506  call prc_abort
507  endif
508  log_nml(param_file_history)
509 
510 
511 
512  if ( file_history_output_wait >= 0.0_dp ) then
513  call calendar_unit2sec( dtsec, file_history_output_wait, file_history_output_wait_tunit )
514  file_history_output_wait_step = int( dtsec / file_history_dtsec )
515  else
516  log_error("FILE_HISTORY_Setup",*) 'FILE_HISTORY_OUTPUT_WAIT must be positive. STOP'
517  call prc_abort
518  endif
519 
520  if ( file_history_output_switch_tinterval >= 0.0_dp ) then
521  call calendar_unit2sec( dtsec, file_history_output_switch_tinterval, file_history_output_switch_tunit )
522  file_history_output_switch_step = int( dtsec / file_history_dtsec )
523  else
524  file_history_output_switch_step = -1
525  endif
526  file_history_output_switch_laststep = 0
527 
528 
529  ! count history request
530  file_history_nreqs = 0
531  if ( io_fid_conf > 0 ) rewind(io_fid_conf)
532  do n = 1, file_history_req_max
533  name = ''
534  outname = 'undefined'
535  basename = file_history_default_basename
536 
537  read(io_fid_conf,nml=history_item,iostat=ierr)
538  if( ierr /= 0 ) exit
539  if( basename == '' .OR. name == '' .OR. outname == '' ) cycle ! invalid HISTORY_ITEM
540 
541  file_history_nreqs = file_history_nreqs + 1
542  enddo
543 
544  if ( file_history_nreqs > file_history_req_max ) then
545  log_error("FILE_HISTORY_Setup",*) 'request of history file is exceed! n >', file_history_req_max
546  call prc_abort
547  elseif( file_history_nreqs == 0 ) then
548  log_info("FILE_HISTORY_Setup",*) 'No history file specified.'
549  return
550  endif
551 
552  allocate( file_history_req(file_history_nreqs) )
553 
554  ! read history request
555  reqid = 0
556  if ( io_fid_conf > 0 ) rewind(io_fid_conf)
557  do n = 1, file_history_req_max
558  ! set default
559  name = ''
560  outname = 'undefined'
561  basename = file_history_default_basename
562  postfix_timelabel = file_history_default_postfix_timelabel
563  zcoord = file_history_default_zcoord
564  tinterval = file_history_default_tinterval
565  tunit = file_history_default_tunit
566  taverage = file_history_default_taverage
567  tstats_op = file_history_default_tstats_op
568  datatype = file_history_default_datatype
569 
570  read(io_fid_conf,nml=history_item,iostat=ierr)
571  if ( ierr < 0 ) then
572  exit ! no more items
573  elseif( ierr > 0 ) then
574  log_error("FILE_HISTORY_Setup",*) 'Not appropriate names in namelist HISTORY_ITEM. Check!'
575  call prc_abort
576  endif
577  if( basename == '' .OR. name == '' .OR. outname == '' ) cycle ! invalid HISTORY_ITEM
578 
579  log_nml(history_item)
580 
581  ! check duplicated request
582  if ( outname == 'undefined' ) outname = name ! set default name
583  do id = 1, reqid
584  if ( file_history_req(id)%outname == outname ) then
585  log_error("FILE_HISTORY_Setup",*) 'Same name of history output is already registered. Check!', trim(outname)
586  call prc_abort
587  endif
588  enddo
589 
590  reqid = reqid + 1
591 
592  file_history_req(reqid)%name = name
593  file_history_req(reqid)%outname = outname
594  file_history_req(reqid)%basename = basename
595  file_history_req(reqid)%postfix_timelabel = postfix_timelabel
596  if( file_history_output_switch_step >= 0 ) file_history_req(reqid)%postfix_timelabel = .true. ! force true
597  file_history_req(reqid)%zcoord = zcoord
598  select case ( tstats_op )
599  case ( "none", "NONE", "" )
600  file_history_req(reqid)%tstats_op = i_none
601  case ( "mean", "MEAN", "average", "AVERAGE" )
602  file_history_req(reqid)%tstats_op = i_mean
603  case ( "min", "MIN" )
604  file_history_req(reqid)%tstats_op = i_min
605  case ( "max", "MAX" )
606  file_history_req(reqid)%tstats_op = i_max
607  case default
608  log_error("FILE_HISTORY_Setup",*) 'TSTATS_OP is invalid (none, mean, min, or max) ,', trim(tstats_op)
609  call prc_abort
610  end select
611  if ( taverage ) then
612  log_warn("FILE_HISTORY_Setup",*) 'TAVERAGE is obsolete. Use TSTATS_OP instead'
613  if ( file_history_req(reqid)%tstats_op > 1 ) then
614  log_error("FILE_HISTORY_Setup",*) 'TSTATS_OP and TAVERAGE are conflicted'
615  call prc_abort
616  end if
617  file_history_req(reqid)%tstats_op = i_mean
618  end if
619 
620  call calendar_unit2sec( dtsec, tinterval, tunit )
621  dstep = int( dtsec / file_history_dtsec )
622 
623  if ( dtsec <= 0.d0 ) then
624  log_error("FILE_HISTORY_Setup",*) 'Not appropriate time interval. Check!', trim(name), tinterval, trim(tunit)
625  call prc_abort
626  endif
627 
628  if ( abs(dtsec-real(dstep,kind=dp)*file_history_dtsec) > dtsec*1.e-3_dp ) then
629  log_error("FILE_HISTORY_Setup",*) 'time interval must be a multiple of delta t. (interval,dt)=', dtsec, file_history_dtsec
630  call prc_abort
631  endif
632 
633  file_history_req(reqid)%dstep = dstep
634 
635  if ( datatype == 'REAL4' ) then
636  file_history_req(reqid)%dtype = file_real4
637  elseif( datatype == 'REAL8' ) then
638  file_history_req(reqid)%dtype = file_real8
639  else
640  log_error("FILE_HISTORY_Setup",*) 'Not appropriate DATATYPE. Check!', datatype
641  call prc_abort
642  endif
643 
644  file_history_req(reqid)%registered = .false.
645  enddo
646 
647  log_newline
648  log_info("FILE_HISTORY_Setup",*) 'Number of requested history item : ', file_history_nreqs
649  log_info("FILE_HISTORY_Setup",*) 'Output default data type : ', trim(file_history_default_datatype)
650  log_info("FILE_HISTORY_Setup",*) 'Output value at the initial step? : ', file_history_output_step0
651  if ( file_history_output_wait_step > 0 ) then
652  log_info("FILE_HISTORY_Setup",*) 'Time when the output is suppressed [step] : ', file_history_output_wait_step
653  end if
654  if ( file_history_output_switch_step >= 0 ) then
655  log_info("FILE_HISTORY_Setup",*) 'Interval for switching the file [step] : ', file_history_output_switch_step
656  end if
657  log_info("FILE_HISTORY_Setup",*) 'Check if requested item is not registered? : ', file_history_error_putmiss
658 
659  file_history_nitems = 0
660  allocate( file_history_vars(file_history_nreqs) )
661 
662  file_history_nvar_inputs = 0
663  allocate( file_history_var_inputs(file_history_nreqs) )
664 
665  file_history_truncate_1d => file_history_truncate_1d_default
666  file_history_truncate_2d => file_history_truncate_2d_default
667  file_history_truncate_3d => file_history_truncate_3d_default
668  file_history_truncate_4d => file_history_truncate_4d_default
669 
670  file_history_disabled = .false.
671 
672  return

References scale_calendar::calendar_unit2sec(), scale_precision::dp, scale_file::file_aggregate, file_history_aggregate, file_history_truncate_1d, file_history_truncate_2d, file_history_truncate_3d, file_history_truncate_4d, scale_file_h::file_real4, scale_file_h::file_real8, scale_io::io_fid_conf, and scale_prc::prc_abort().

Referenced by scale_file_history_cartesc::file_history_cartesc_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_history_reg()

subroutine, public scale_file_history::file_history_reg ( character(len=*), intent(in)  name,
character(len=*), intent(in)  desc,
character(len=*), intent(in)  unit,
integer, intent(out)  itemid,
character(len=*), intent(in), optional  standard_name,
integer, intent(in), optional  ndims,
character(len=*), intent(in), optional  dim_type,
character(len=*), intent(in), optional  cell_measures,
logical, intent(in), optional  fill_halo 
)

Register/Append variable to history file.

Parameters
[in]namename of the item
[in]descdescription of the item
[in]unitunit of the item
[out]itemidindex number of the item
[in]ndimsif ndims is set and dim_type is not set, the dim_type that set firstry by FILE_HISTORY_set_dim of ndims is used

Definition at line 685 of file scale_file_history.F90.

685  implicit none
686 
687  character(len=*), intent(in) :: name
688  character(len=*), intent(in) :: desc
689  character(len=*), intent(in) :: unit
690 
691  integer, intent(out) :: itemid
692 
693  character(len=*), intent(in), optional :: standard_name
694  integer, intent(in), optional :: ndims
695  character(len=*), intent(in), optional :: dim_type
696  character(len=*), intent(in), optional :: cell_measures
697  logical, intent(in), optional :: fill_halo
698 
699  character(len=H_SHORT) :: standard_name_
700  character(len=H_SHORT) :: cell_measures_
701  integer :: dimid, iid
702  integer :: n
703  !---------------------------------------------------------------------------
704 
705  itemid = -1
706  if ( file_history_nreqs == 0 ) return
707 
708  itemid = file_history_find_id( name )
709  if ( itemid > 0 ) return ! already registered
710 
711  call prof_rapstart('FILE_HISTORY_OUT', 2)
712 
713  if ( len_trim(name) >= h_short ) then
714  log_error("FILE_HISTORY_reg",'(1x,A,I2,A,A)') 'Length of history name should be <= ', h_short-1 ,' chars. name=', trim(name)
715  call prc_abort
716  endif
717 
718  ! standard_name
719  if ( present(standard_name) ) then
720  standard_name_ = standard_name
721  else
722  standard_name_ = ""
723  end if
724 
725  ! get dimension id
726  if ( file_history_ndims < 1 ) then
727  log_error("FILE_HISTORY_reg",*) 'at least one dim_type must be registerd with FILE_HISTORY_set_dim. name=', trim(name)
728  call prc_abort
729  end if
730  dimid = -1
731  if ( present(dim_type) ) then
732  do n = 1, file_history_ndims
733  if ( file_history_dims(n)%name == dim_type ) then
734  dimid = n
735  exit
736  end if
737  end do
738  if ( dimid == -1 ) then
739  log_error("FILE_HISTORY_reg",*) 'dim_type must be registerd with FILE_HISTORY_set_dim: ', trim(dim_type) ,' name=', trim(name)
740  call prc_abort
741  end if
742  else if ( present(ndims) ) then
743  do n = 1, file_history_ndims
744  if ( file_history_dims(n)%ndims == ndims ) then
745  dimid = n
746  exit
747  end if
748  end do
749  if ( dimid == -1 ) then
750  log_error("FILE_HISTORY_reg",'(a,i1,a)') 'dim_type of ', ndims, 'D must be registerd with FILE_HISTORY_set_dim. name=', trim(name)
751  call prc_abort
752  end if
753  else
754  ! ndims = 3 is assumed as default
755  do n = 1, file_history_ndims
756  if ( file_history_dims(n)%ndims == 3 ) then
757  dimid = n
758  exit
759  end if
760  end do
761  if ( dimid == -1 ) then
762  log_error("FILE_HISTORY_reg",'(a,i1,a)') 'dim_type or ndims must be specified. name=', trim(name)
763  call prc_abort
764  end if
765  end if
766 
767  if ( present(cell_measures) ) then
768  select case ( cell_measures )
769  case ( "area" )
770  if ( file_history_dims(dimid)%area == "" ) then
771  log_error("FILE_HISTORY_reg",*) 'area is not supported for cell_measures. name=', trim(name)
772  call prc_abort
773  end if
774  case ( "area_z" )
775  if ( file_history_dims(dimid)%area == "" ) then
776  log_error("FILE_HISTORY_reg",*) 'area_z is not supported for cell_measures. name=', trim(name)
777  call prc_abort
778  end if
779  case ( "area_x" )
780  if ( file_history_dims(dimid)%area_x == "" ) then
781  log_error("FILE_HISTORY_reg",*) 'area_x is not supported for cell_measures. name=', trim(name)
782  call prc_abort
783  end if
784  case ( "area_y" )
785  if ( file_history_dims(dimid)%area_y == "" ) then
786  log_error("FILE_HISTORY_reg",*) 'area_y is not supported for cell_measures. name=', trim(name)
787  call prc_abort
788  end if
789  case ( "volume" )
790  if ( file_history_dims(dimid)%volume == "" ) then
791  log_error("FILE_HISTORY_reg",*) 'volume is not supported for cell_measures. name=', trim(name)
792  call prc_abort
793  end if
794  case default
795  log_error("FILE_HISTORY_reg",*) 'cell_measures must be "area" or "volume". name=', trim(name)
796  call prc_abort
797  end select
798  cell_measures_ = cell_measures
799  else if ( file_history_dims(dimid)%ndims == 2 ) then
800  cell_measures_ = "area"
801  else if ( file_history_dims(dimid)%ndims == 3 ) then
802  cell_measures_ = "volume"
803  else
804  cell_measures_ = ""
805  end if
806 
807  if ( file_history_dims(dimid)%nzcoords > 1 ) then
808 
809  itemid = -1
810  do n = 1, file_history_dims(dimid)%nzcoords
811  if ( file_history_dims(dimid)%zcoords(n) == "model" ) then
812  call file_history_add_variable( name, desc, unit, standard_name_, & ! (in)
813  dimid, & ! (in)
814  file_history_dims(dimid)%zcoords(n), & ! (in)
815  iid, & ! (out)
816  cell_measures = cell_measures_, & ! (in)
817  fill_halo = fill_halo ) ! (in)
818  else
819  call file_history_add_variable( name, desc, unit, standard_name_, & ! (in)
820  dimid, & ! (in)
821  file_history_dims(dimid)%zcoords(n), & ! (in)
822  iid, & ! (out)
823  fill_halo = fill_halo ) ! (in)
824  end if
825  if ( iid > 0 ) itemid = iid
826  end do
827 
828  else
829 
830  call file_history_add_variable( name, desc, unit, standard_name_, & ! (in)
831  dimid, & ! (in)
832  "model", & ! (in)
833  itemid, & ! (out)
834  cell_measures = cell_measures_, & ! (in)
835  fill_halo = fill_halo ) ! (in)
836 
837  end if
838 
839  call prof_rapend('FILE_HISTORY_OUT', 2)
840 
841  return

References scale_const::const_eps, scale_const::const_huge, scale_const::const_undef, scale_file_h::file_rmiss, scale_io::h_short, i, scale_prc::prc_abort(), scale_prof::prof_rapend(), and scale_prof::prof_rapstart().

Referenced by scale_atmos_dyn_tstep_large_fvm_heve::atmos_dyn_tstep_large_fvm_heve_setup(), mod_atmos_phy_ae_vars::atmos_phy_ae_vars_setup(), scale_atmos_phy_bl_mynn::atmos_phy_bl_mynn_setup(), scale_atmos_phy_cp_kf::atmos_phy_cp_kf_setup(), mod_atmos_phy_lt_driver::atmos_phy_lt_driver_setup(), scale_atmos_phy_lt_sato2019::atmos_phy_lt_sato2019_setup(), mod_atmos_phy_mp_driver::atmos_phy_mp_driver_setup(), scale_atmos_phy_mp_sn14::atmos_phy_mp_sn14_setup(), scale_atmos_phy_mp_tomita08::atmos_phy_mp_tomita08_setup(), mod_atmos_phy_mp_vars::atmos_phy_mp_vars_setup(), mod_atmos_phy_sf_driver::atmos_phy_sf_driver_setup(), mod_atmos_vars::atmos_vars_setup(), file_history_in_0d(), file_history_in_1d(), file_history_in_2d(), file_history_in_3d(), file_history_in_4d(), and scale_urban_dyn_kusaka01::urban_dyn_kusaka01_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_history_in_0d()

subroutine scale_file_history::file_history_in_0d ( real(rp), intent(in)  var,
character(len=*), intent(in)  name,
character(len=*), intent(in)  desc,
character(len=*), intent(in)  unit,
character(len=*), intent(in), optional  standard_name,
character(len=*), intent(in), optional  dim_type 
)

Wrapper routine of FILE_HISTORY_reg + FILE_HISTORY_put.

Parameters
[in]varvalue
[in]namename of the item
[in]descdescription of the item
[in]unitunit of the item

Definition at line 960 of file scale_file_history.F90.

960  implicit none
961 
962  real(RP), intent(in) :: var
963  character(len=*), intent(in) :: name
964  character(len=*), intent(in) :: desc
965  character(len=*), intent(in) :: unit
966 
967  character(len=*), intent(in), optional :: standard_name
968  character(len=*), intent(in), optional :: dim_type
969 
970  logical, parameter :: fill_halo = .false.
971 
972  integer, parameter :: ndim = 0
973  integer :: itemid
974  logical :: do_put
975  !---------------------------------------------------------------------------
976 
977  if ( file_history_disabled ) return
978 
979  ! Check whether the item has been already registered
980  call file_history_reg( name, desc, unit, & ! [IN]
981  itemid, & ! [OUT]
982  standard_name=standard_name, & ! [IN]
983  ndims=ndim, & ! [IN]
984  dim_type=dim_type, & ! [IN]
985  fill_halo=fill_halo ) ! [IN]
986 
987  if ( itemid < 0 ) return
988 
989  ! Check whether it is time to input the item
990  call file_history_query( itemid, do_put ) ! [IN], [OUT]
991 
992  if ( do_put ) call file_history_put( itemid, var )
993 
994  return

References scale_const::const_eps, scale_const::const_huge, scale_const::const_undef, file_history_reg(), file_history_truncate_1d, scale_file_h::file_rmiss, scale_prc::prc_abort(), scale_prof::prof_rapend(), and scale_prof::prof_rapstart().

Here is the call graph for this function:

◆ file_history_in_1d()

subroutine scale_file_history::file_history_in_1d ( real(rp), dimension(:), intent(in)  var,
character(len=*), intent(in)  name,
character(len=*), intent(in)  desc,
character(len=*), intent(in)  unit,
character(len=*), intent(in), optional  standard_name,
character(len=*), intent(in), optional  dim_type 
)

Wrapper routine of FILE_HISTORY_reg + FILE_HISTORY_put.

Parameters
[in]varvalue
[in]namename of the item
[in]descdescription of the item
[in]unitunit of the item

Definition at line 1142 of file scale_file_history.F90.

1142  implicit none
1143 
1144  real(RP), intent(in) :: var(:)
1145  character(len=*), intent(in) :: name
1146  character(len=*), intent(in) :: desc
1147  character(len=*), intent(in) :: unit
1148 
1149  character(len=*), intent(in), optional :: standard_name
1150  character(len=*), intent(in), optional :: dim_type
1151 
1152  logical, parameter :: fill_halo = .false.
1153 
1154  integer, parameter :: ndim = 1
1155  integer :: itemid
1156  logical :: do_put
1157  !---------------------------------------------------------------------------
1158 
1159  if ( file_history_disabled ) return
1160 
1161  ! Check whether the item has been already registered
1162  call file_history_reg( name, desc, unit, & ! [IN]
1163  itemid, & ! [OUT]
1164  standard_name=standard_name, & ! [IN]
1165  ndims=ndim, & ! [IN]
1166  dim_type=dim_type, & ! [IN]
1167  fill_halo=fill_halo ) ! [IN]
1168 
1169  if ( itemid < 0 ) return
1170 
1171  ! Check whether it is time to input the item
1172  call file_history_query( itemid, do_put ) ! [IN], [OUT]
1173 
1174  if ( do_put ) call file_history_put( itemid, var(:) )
1175 
1176  return

References scale_const::const_eps, scale_const::const_huge, scale_const::const_undef, file_history_reg(), file_history_truncate_2d, scale_file_h::file_rmiss, scale_prc::prc_abort(), scale_prof::prof_rapend(), and scale_prof::prof_rapstart().

Here is the call graph for this function:

◆ file_history_in_2d()

subroutine scale_file_history::file_history_in_2d ( real(rp), dimension(:,:), intent(in)  var,
character(len=*), intent(in)  name,
character(len=*), intent(in)  desc,
character(len=*), intent(in)  unit,
character(len=*), intent(in), optional  standard_name,
character(len=*), intent(in), optional  dim_type,
logical, intent(in), optional  fill_halo 
)

Wrapper routine of FILE_HISTORY_reg + FILE_HISTORY_put.

Parameters
[in]varvalue
[in]namename of the item
[in]descdescription of the item
[in]unitunit of the item

Definition at line 1325 of file scale_file_history.F90.

1325  implicit none
1326 
1327  real(RP), intent(in) :: var(:,:)
1328  character(len=*), intent(in) :: name
1329  character(len=*), intent(in) :: desc
1330  character(len=*), intent(in) :: unit
1331 
1332  character(len=*), intent(in), optional :: standard_name
1333  character(len=*), intent(in), optional :: dim_type
1334  logical, intent(in), optional :: fill_halo
1335 
1336  integer, parameter :: ndim = 2
1337  integer :: itemid
1338  logical :: do_put
1339  !---------------------------------------------------------------------------
1340 
1341  if ( file_history_disabled ) return
1342 
1343  ! Check whether the item has been already registered
1344  call file_history_reg( name, desc, unit, & ! [IN]
1345  itemid, & ! [OUT]
1346  standard_name=standard_name, & ! [IN]
1347  ndims=ndim, & ! [IN]
1348  dim_type=dim_type, & ! [IN]
1349  fill_halo=fill_halo ) ! [IN]
1350 
1351  if ( itemid < 0 ) return
1352 
1353  ! Check whether it is time to input the item
1354  call file_history_query( itemid, do_put ) ! [IN], [OUT]
1355 
1356  if ( do_put ) call file_history_put( itemid, var(:,:) )
1357 
1358  return

References scale_const::const_eps, scale_const::const_huge, scale_const::const_undef, file_history_reg(), file_history_truncate_3d, scale_file_h::file_rmiss, scale_prc::prc_abort(), scale_prof::prof_rapend(), and scale_prof::prof_rapstart().

Here is the call graph for this function:

◆ file_history_in_3d()

subroutine scale_file_history::file_history_in_3d ( real(rp), dimension(:,:,:), intent(in)  var,
character(len=*), intent(in)  name,
character(len=*), intent(in)  desc,
character(len=*), intent(in)  unit,
character(len=*), intent(in), optional  standard_name,
character(len=*), intent(in), optional  dim_type,
logical, intent(in), optional  fill_halo 
)

Wrapper routine of FILE_HISTORY_reg + FILE_HISTORY_put.

Parameters
[in]varvalue
[in]namename of the item
[in]descdescription of the item
[in]unitunit of the item

Definition at line 1507 of file scale_file_history.F90.

1507  implicit none
1508 
1509  real(RP), intent(in) :: var(:,:,:)
1510  character(len=*), intent(in) :: name
1511  character(len=*), intent(in) :: desc
1512  character(len=*), intent(in) :: unit
1513 
1514  character(len=*), intent(in), optional :: standard_name
1515  character(len=*), intent(in), optional :: dim_type
1516  logical, intent(in), optional :: fill_halo
1517 
1518  integer, parameter :: ndim = 3
1519  integer :: itemid
1520  logical :: do_put
1521  !---------------------------------------------------------------------------
1522 
1523  if ( file_history_disabled ) return
1524 
1525  ! Check whether the item has been already registered
1526  call file_history_reg( name, desc, unit, & ! [IN]
1527  itemid, & ! [OUT]
1528  standard_name=standard_name, & ! [IN]
1529  ndims=ndim, & ! [IN]
1530  dim_type=dim_type, & ! [IN]
1531  fill_halo=fill_halo ) ! [IN]
1532 
1533  if ( itemid < 0 ) return
1534 
1535  ! Check whether it is time to input the item
1536  call file_history_query( itemid, do_put ) ! [IN], [OUT]
1537 
1538  if ( do_put ) call file_history_put( itemid, var(:,:,:) )
1539 
1540  return

References scale_const::const_eps, scale_const::const_huge, scale_const::const_undef, file_history_reg(), file_history_truncate_4d, scale_file_h::file_rmiss, scale_prc::prc_abort(), scale_prof::prof_rapend(), and scale_prof::prof_rapstart().

Here is the call graph for this function:

◆ file_history_in_4d()

subroutine scale_file_history::file_history_in_4d ( real(rp), dimension(:,:,:,:), intent(in)  var,
character(len=*), intent(in)  name,
character(len=*), intent(in)  desc,
character(len=*), intent(in)  unit,
character(len=*), intent(in), optional  standard_name,
character(len=*), intent(in), optional  dim_type,
logical, intent(in), optional  fill_halo 
)

Wrapper routine of FILE_HISTORY_reg + FILE_HISTORY_put.

Parameters
[in]varvalue
[in]namename of the item
[in]descdescription of the item
[in]unitunit of the item

Definition at line 1689 of file scale_file_history.F90.

1689  implicit none
1690 
1691  real(RP), intent(in) :: var(:,:,:,:)
1692  character(len=*), intent(in) :: name
1693  character(len=*), intent(in) :: desc
1694  character(len=*), intent(in) :: unit
1695 
1696  character(len=*), intent(in), optional :: standard_name
1697  character(len=*), intent(in), optional :: dim_type
1698  logical, intent(in), optional :: fill_halo
1699 
1700  integer, parameter :: ndim = 4
1701  integer :: itemid
1702  logical :: do_put
1703  !---------------------------------------------------------------------------
1704 
1705  if ( file_history_disabled ) return
1706 
1707  ! Check whether the item has been already registered
1708  call file_history_reg( name, desc, unit, & ! [IN]
1709  itemid, & ! [OUT]
1710  standard_name=standard_name, & ! [IN]
1711  ndims=ndim, & ! [IN]
1712  dim_type=dim_type, & ! [IN]
1713  fill_halo=fill_halo ) ! [IN]
1714 
1715  if ( itemid < 0 ) return
1716 
1717  ! Check whether it is time to input the item
1718  call file_history_query( itemid, do_put ) ! [IN], [OUT]
1719 
1720  if ( do_put ) call file_history_put( itemid, var(:,:,:,:) )
1721 
1722  return

References file_history_reg().

Here is the call graph for this function:

◆ file_history_set_dim()

subroutine, public scale_file_history::file_history_set_dim ( character(len=*), intent(in)  name,
integer, intent(in)  ndims,
integer, intent(in)  nzcoords,
character(len=*), dimension(ndims,nzcoords), intent(in)  dims,
character(len=*), dimension(nzcoords), intent(in)  zcoords,
integer, dimension(ndims,nzcoords), intent(in)  start,
integer, dimension(ndims,nzcoords), intent(in)  count,
character(len=*), intent(in), optional  mapping,
character(len=*), intent(in), optional  area,
character(len=*), intent(in), optional  area_x,
character(len=*), intent(in), optional  area_y,
character(len=*), intent(in), optional  volume,
character(len=*), intent(in), optional  location,
character(len=*), intent(in), optional  grid 
)

set dimension information

Definition at line 1738 of file scale_file_history.F90.

1738  implicit none
1739 
1740  character(len=*), intent(in) :: name
1741  integer, intent(in) :: ndims
1742  integer, intent(in) :: nzcoords
1743  character(len=*), intent(in) :: dims(ndims,nzcoords)
1744  character(len=*), intent(in) :: zcoords(nzcoords)
1745  integer, intent(in) :: start(ndims,nzcoords)
1746  integer, intent(in) :: count(ndims,nzcoords)
1747 
1748  character(len=*), intent(in), optional :: mapping
1749  character(len=*), intent(in), optional :: area
1750  character(len=*), intent(in), optional :: area_x
1751  character(len=*), intent(in), optional :: area_y
1752  character(len=*), intent(in), optional :: volume
1753  character(len=*), intent(in), optional :: location
1754  character(len=*), intent(in), optional :: grid
1755 
1756  integer :: id
1757  integer :: size, n, m
1758 
1759  if ( file_history_ndims >= file_history_dim_max ) then
1760  log_error("FILE_HISTORY_Set_Dim",*) 'number of dimension exceed max limit: ', file_history_dim_max
1761  call prc_abort
1762  end if
1763  file_history_ndims = file_history_ndims + 1
1764  id = file_history_ndims
1765 
1766  allocate( file_history_dims(id)%dims (max(ndims,1),nzcoords) )
1767  allocate( file_history_dims(id)%start(max(ndims,1),nzcoords) )
1768  allocate( file_history_dims(id)%count(max(ndims,1),nzcoords) )
1769  allocate( file_history_dims(id)%zcoords(nzcoords) )
1770  allocate( file_history_dims(id)%size(nzcoords) )
1771 
1772  file_history_dims(id)%name = name
1773  file_history_dims(id)%ndims = ndims
1774  file_history_dims(id)%nzcoords = nzcoords
1775  file_history_dims(id)%zcoords(:) = zcoords(:)
1776  if ( ndims > 0 ) then
1777  file_history_dims(id)%dims(:,:) = dims(:,:)
1778  file_history_dims(id)%start(:,:) = start(:,:)
1779  file_history_dims(id)%count(:,:) = count(:,:)
1780  else ! 0D
1781  file_history_dims(id)%dims(1,1) = ""
1782  file_history_dims(id)%start(1,1) = 1
1783  file_history_dims(id)%count(1,1) = 1
1784  end if
1785 
1786  do m = 1, nzcoords
1787  size = 1
1788  do n = 1, ndims
1789  size = size * count(n,m)
1790  end do
1791  file_history_dims(id)%size(m) = size
1792  end do
1793 
1794  if ( present(mapping) ) then
1795  file_history_dims(id)%mapping = mapping
1796  else
1797  file_history_dims(id)%mapping = ""
1798  end if
1799 
1800  if ( present(area) ) then
1801  file_history_dims(id)%area = area
1802  else
1803  file_history_dims(id)%area = ""
1804  end if
1805  if ( present(area_x) ) then
1806  file_history_dims(id)%area_x = area_x
1807  else
1808  file_history_dims(id)%area_x = ""
1809  end if
1810  if ( present(area_y) ) then
1811  file_history_dims(id)%area_y = area_y
1812  else
1813  file_history_dims(id)%area_y = ""
1814  end if
1815  if ( present(volume) ) then
1816  file_history_dims(id)%volume = volume
1817  else
1818  file_history_dims(id)%volume = ""
1819  end if
1820 
1821  if ( present(location) ) then
1822  file_history_dims(id)%location = location
1823  if ( present(grid) ) then
1824  file_history_dims(id)%grid = "grid_"//trim(grid)
1825  else
1826  file_history_dims(id)%grid = "grid"
1827  end if
1828  else
1829  file_history_dims(id)%location = ""
1830  file_history_dims(id)%grid = ""
1831  end if
1832 
1833  return

References scale_prc::prc_abort().

Referenced by scale_file_history_cartesc::file_history_cartesc_set_pres().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_history_set_axis()

subroutine, public scale_file_history::file_history_set_axis ( character(len=*), intent(in)  name,
character(len=*), intent(in)  desc,
character(len=*), intent(in)  units,
character(len=*), intent(in)  dim,
real(rp), dimension(:), intent(in)  var,
real(rp), dimension(:,:), intent(in), optional  bounds,
logical, intent(in), optional  down,
integer, intent(in), optional  gsize,
integer, intent(in), optional  start 
)

set axis information

Definition at line 1847 of file scale_file_history.F90.

1847  implicit none
1848 
1849  character(len=*), intent(in) :: name
1850  character(len=*), intent(in) :: desc
1851  character(len=*), intent(in) :: units
1852  character(len=*), intent(in) :: dim
1853  real(RP), intent(in) :: var(:)
1854 
1855  real(RP), intent(in), optional :: bounds(:,:)
1856  logical, intent(in), optional :: down
1857  integer, intent(in), optional :: gsize ! global dim size
1858  integer, intent(in), optional :: start ! global subarray start indices
1859 
1860  integer :: dim_size
1861  integer :: id
1862 
1863  intrinsic size
1864  !---------------------------------------------------------------------------
1865 
1866  dim_size = size(var)
1867 
1868  if ( file_history_naxes >= file_history_axis_max ) then
1869  log_error("FILE_HISTORY_Set_Axis",*) 'Number of axis exceeds the limit.'
1870  call prc_abort
1871  endif
1872 
1873  file_history_naxes = file_history_naxes + 1
1874  id = file_history_naxes
1875 
1876  allocate( file_history_axes(id)%var(dim_size) )
1877 
1878  file_history_axes(id)%name = name
1879  file_history_axes(id)%desc = desc
1880  file_history_axes(id)%units = units
1881  file_history_axes(id)%dim = dim
1882  file_history_axes(id)%dim_size = dim_size
1883  file_history_axes(id)%var(:) = var(:)
1884 
1885  if ( present(down) ) then
1886  file_history_axes(id)%down = down
1887  else
1888  file_history_axes(id)%down = .false.
1889  endif
1890  if ( present(gsize) ) then ! global dimension size
1891  file_history_axes(id)%gdim_size = gsize
1892  else
1893  file_history_axes(id)%gdim_size = -1
1894  end if
1895  if ( present(start) ) then ! global subarray starting indices
1896  file_history_axes(id)%start = start
1897  else
1898  file_history_axes(id)%start = 1
1899  end if
1900 
1901  if ( present(bounds) ) then
1902  allocate( file_history_axes(id)%bounds(2,dim_size) )
1903  file_history_axes(id)%bounds(:,:) = bounds(:,:)
1904  end if
1905 
1906  return

References scale_prc::prc_abort().

Referenced by scale_file_history_cartesc::file_history_cartesc_truncate_3d().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_history_write()

subroutine, public scale_file_history::file_history_write

Definition at line 1911 of file scale_file_history.F90.

1911  use scale_file, only: &
1912  file_enddef, &
1913  file_flush
1914  implicit none
1915 
1916  integer :: fid, prev_fid
1917  integer :: id
1918  !---------------------------------------------------------------------------
1919 
1920  if ( file_history_disabled ) return
1921 
1922  call prof_rapstart('FILE_HISTORY_OUT', 2)
1923 
1924  ! Write registered history variables to history file
1925  do id = 1, file_history_nitems
1926  call file_history_write_onevar( id, file_history_nowstep ) ! [IN]
1927  enddo
1928 
1929  ! when using PnetCDF, the above FILE_HISTORY_Write() only posts write requests
1930  ! Now we need to commit the requests to the file
1931  prev_fid = -1
1932  do id = 1, file_history_nitems
1933  fid = file_history_vars(id)%fid
1934  if ( fid > 0 .AND. fid /= prev_fid ) then
1935  call file_flush( fid )
1936  prev_fid = fid
1937  endif
1938  enddo
1939 
1940  ! check time to switching output file
1941  if ( file_history_output_switch_step >= 0 &
1942  .AND. file_history_nowstep-file_history_output_switch_laststep > file_history_output_switch_step ) then
1943 
1944  call file_history_close
1945 
1946  log_info("FILE_HISTORY_Write",*) 'FILE_HISTORY file is switched.'
1947 
1948  do id = 1, file_history_nitems
1949  file_history_vars(id)%fid = -1 ! reset
1950  file_history_vars(id)%vid = -1 ! reset
1951  enddo
1952 
1953  file_history_output_switch_laststep = file_history_nowstep - 1
1954  endif
1955 
1956  call prof_rapend('FILE_HISTORY_OUT', 2)
1957 
1958  return

References scale_file::file_enddef(), scale_file::file_flush(), scale_prof::prof_rapend(), and scale_prof::prof_rapstart().

Referenced by mod_rm_driver::rm_driver().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_history_set_nowdate()

subroutine, public scale_file_history::file_history_set_nowdate ( integer, dimension(:), intent(in)  NOWDATE,
real(dp), intent(in)  NOWSUBSEC,
integer, intent(in)  NOWSTEP 
)

set now step

Definition at line 1965 of file scale_file_history.F90.

1965  integer, intent(in) :: NOWDATE(:)
1966  real(DP), intent(in) :: NOWSUBSEC
1967  integer, intent(in) :: NOWSTEP
1968 
1969  file_history_nowdate(:) = nowdate(:)
1970  file_history_nowsubsec = nowsubsec
1971  file_history_nowstep = nowstep
1972 
1973  return

Referenced by scale_file_history_cartesc::file_history_cartesc_setup(), and mod_rm_driver::rm_driver().

Here is the caller graph for this function:

◆ file_history_set_disable()

subroutine, public scale_file_history::file_history_set_disable ( logical, intent(in)  switch)

set switch to turn on/off history

Definition at line 1980 of file scale_file_history.F90.

1980  implicit none
1981 
1982  logical, intent(in) :: switch
1983  !---------------------------------------------------------------------------
1984 
1985  file_history_disabled = switch
1986 
1987  return

References switch.

Referenced by scale_atmos_dyn_tstep_large_fvm_heve::atmos_dyn_tstep_large_fvm_heve().

Here is the caller graph for this function:

◆ file_history_finalize()

subroutine, public scale_file_history::file_history_finalize

finalization

Definition at line 1994 of file scale_file_history.F90.

1994  implicit none
1995  integer :: id
1996 
1997  call file_history_close
1998 
1999  laststep_write = -1
2000  list_outputed = .false.
2001 
2002  do id = 1, file_history_nitems
2003  deallocate( file_history_vars(id)%varsum )
2004  end do
2005  file_history_nitems = 0
2006 
2007  do id = 1, file_history_ndims
2008  deallocate( file_history_dims(id)%dims )
2009  deallocate( file_history_dims(id)%start )
2010  deallocate( file_history_dims(id)%count )
2011  deallocate( file_history_dims(id)%zcoords )
2012  deallocate( file_history_dims(id)%size )
2013  end do
2014  file_history_ndims = 0
2015 
2016  do id = 1, file_history_naxes
2017  deallocate( file_history_axes(id)%var )
2018  if ( allocated( file_history_axes(id)%bounds ) ) &
2019  deallocate( file_history_axes(id)%bounds )
2020  end do
2021  file_history_naxes = 0
2022 
2023  do id = 1, file_history_nassocs
2024  deallocate( file_history_assocs(id)%var )
2025  end do
2026  file_history_nassocs = 0
2027 
2028  do id = 1, file_history_nattrs
2029  if ( allocated(file_history_attrs(id)%int ) ) &
2030  deallocate( file_history_attrs(id)%int )
2031  if ( allocated(file_history_attrs(id)%float ) ) &
2032  deallocate( file_history_attrs(id)%float )
2033  if ( allocated(file_history_attrs(id)%double ) ) &
2034  deallocate( file_history_attrs(id)%double )
2035  end do
2036  file_history_nattrs = 0
2037 
2038 
2039  if ( file_history_nreqs > 0 ) then
2040  deallocate( file_history_req )
2041  deallocate( file_history_vars )
2042  deallocate( file_history_var_inputs )
2043  end if
2044  file_history_nreqs = 0
2045 
2046  return

References aggregate, scale_precision::dp, scale_file::file_add_associatedvariable(), scale_file::file_attach_buffer(), scale_file::file_close(), scale_file::file_create(), scale_file::file_def_associatedcoordinate(), scale_file::file_def_axis(), scale_file::file_detach_buffer(), scale_file_h::file_dtypelist, scale_file::file_flush(), file_history_aggregate, scale_file_h::file_real4, scale_file_h::file_real8, scale_file::file_redef(), scale_file::file_set_option(), i, scale_prc::prc_abort(), scale_precision::rp, and scale_time::time_time2label().

Referenced by mod_rm_driver::rm_driver().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_history_set_associatedcoordinate_1d()

subroutine scale_file_history::file_history_set_associatedcoordinate_1d ( character(len=*), intent(in)  name,
character(len=*), intent(in)  desc,
character(len=*), intent(in)  units,
character(len=*), dimension(:), intent(in)  dims,
real(rp), dimension(:), intent(in)  var,
character(len=*), intent(in), optional  datatype,
integer, dimension(:), intent(in), optional  start 
)

Definition at line 2515 of file scale_file_history.F90.

2515  use scale_file_h, only: &
2516  file_real4, &
2517  file_real8
2518  implicit none
2519 
2520  character(len=*), intent(in) :: name
2521  character(len=*), intent(in) :: desc
2522  character(len=*), intent(in) :: units
2523  character(len=*), intent(in) :: dims(:)
2524  real(RP), intent(in) :: var(:)
2525  character(len=*), intent(in), optional :: datatype
2526  integer, intent(in), optional :: start(:)
2527 
2528  integer :: dtype
2529  integer :: dim_size
2530  integer :: id
2531 
2532  intrinsic size, shape, reshape
2533  !---------------------------------------------------------------------------
2534 
2535  if ( present(datatype) ) then
2536  if ( datatype == 'REAL4' ) then
2537  dtype = file_real4
2538  elseif( datatype == 'REAL8' ) then
2539  dtype = file_real8
2540  else
2541  log_error("FILE_HISTORY_Set_AssociatedCoordinate_1D",*) 'Not appropriate datatype. Check!', datatype
2542  call prc_abort
2543  endif
2544  else if ( rp == sp ) then
2545  dtype = file_real4
2546  else
2547  dtype = file_real8
2548  endif
2549 
2550  dim_size = size(var)
2551 
2552  if ( file_history_nassocs < file_history_assoc_max ) then
2553  file_history_nassocs = file_history_nassocs + 1
2554  id = file_history_nassocs
2555 
2556  allocate( file_history_assocs(id)%var(dim_size) )
2557 
2558  file_history_assocs(id)%name = name
2559  file_history_assocs(id)%desc = desc
2560  file_history_assocs(id)%units = units
2561  file_history_assocs(id)%ndims = 1
2562  file_history_assocs(id)%dims(:) = ''
2563  file_history_assocs(id)%dims(1:1) = dims(1:1)
2564  file_history_assocs(id)%dtype = dtype
2565  file_history_assocs(id)%var(:) = real(reshape( var, (/ dim_size /) ),kind=dp)
2566 
2567  ! start and count are used for parallel I/O to a single shared file
2568  ! since var is reshaped into 1D array, we need to preserve its original shape in count
2569  file_history_assocs(id)%count(1:1) = shape(var)
2570  if ( present(start) ) then
2571  file_history_assocs(id)%start(1:1) = start(1:1)
2572  else
2573  file_history_assocs(id)%start = (/ 1, 1, 1, 1 /)
2574  end if
2575  else
2576  log_error("FILE_HISTORY_Set_AssociatedCoordinate_1D",*) 'Number of associate coordinates exceeds the limit.'
2577  call prc_abort
2578  endif
2579 
2580  return

References scale_precision::dp, scale_file_h::file_real4, scale_file_h::file_real8, scale_prc::prc_abort(), and scale_precision::sp.

Here is the call graph for this function:

◆ file_history_set_associatedcoordinate_2d()

subroutine scale_file_history::file_history_set_associatedcoordinate_2d ( character(len=*), intent(in)  name,
character(len=*), intent(in)  desc,
character(len=*), intent(in)  units,
character(len=*), dimension(:), intent(in)  dims,
real(rp), dimension(:,:), intent(in)  var,
character(len=*), intent(in), optional  datatype,
integer, dimension(:), intent(in), optional  start 
)

Definition at line 2592 of file scale_file_history.F90.

2592  use scale_file_h, only: &
2593  file_real4, &
2594  file_real8
2595  implicit none
2596 
2597  character(len=*), intent(in) :: name
2598  character(len=*), intent(in) :: desc
2599  character(len=*), intent(in) :: units
2600  character(len=*), intent(in) :: dims(:)
2601  real(RP), intent(in) :: var(:,:)
2602  character(len=*), intent(in), optional :: datatype
2603  integer, intent(in), optional :: start(:)
2604 
2605  integer :: dtype
2606  integer :: dim_size
2607  integer :: id
2608 
2609  intrinsic size, shape, reshape
2610  !---------------------------------------------------------------------------
2611 
2612  if ( present(datatype) ) then
2613  if ( datatype == 'REAL4' ) then
2614  dtype = file_real4
2615  elseif( datatype == 'REAL8' ) then
2616  dtype = file_real8
2617  else
2618  log_error("FILE_HISTORY_Set_AssociatedCoordinate_2D",*) 'Not appropriate datatype. Check!', datatype
2619  call prc_abort
2620  endif
2621  else if ( rp == sp ) then
2622  dtype = file_real4
2623  else
2624  dtype = file_real8
2625  endif
2626 
2627  dim_size = size(var)
2628 
2629  if ( file_history_nassocs < file_history_assoc_max ) then
2630  file_history_nassocs = file_history_nassocs + 1
2631  id = file_history_nassocs
2632 
2633  allocate( file_history_assocs(id)%var(dim_size) )
2634 
2635  file_history_assocs(id)%name = name
2636  file_history_assocs(id)%desc = desc
2637  file_history_assocs(id)%units = units
2638  file_history_assocs(id)%ndims = 2
2639  file_history_assocs(id)%dims(:) = ''
2640  file_history_assocs(id)%dims(1:2) = dims(1:2)
2641  file_history_assocs(id)%dtype = dtype
2642  file_history_assocs(id)%var(:) = real(reshape( var, (/ dim_size /) ),kind=dp)
2643 
2644  ! start and count are used for parallel I/O to a single shared file
2645  ! since var is reshaped into 1D array, we need to preserve its original shape in count
2646  file_history_assocs(id)%count(1:2) = shape(var)
2647  if ( present(start) ) then
2648  file_history_assocs(id)%start(1:2) = start(1:2)
2649  else
2650  file_history_assocs(id)%start = (/ 1, 1, 1, 1 /)
2651  end if
2652  else
2653  log_error("FILE_HISTORY_Set_AssociatedCoordinate_2D",*) 'Number of associate coordinates exceeds the limit.'
2654  call prc_abort
2655  endif
2656 
2657  return

References scale_precision::dp, scale_file_h::file_real4, scale_file_h::file_real8, scale_prc::prc_abort(), and scale_precision::sp.

Here is the call graph for this function:

◆ file_history_set_associatedcoordinate_3d()

subroutine scale_file_history::file_history_set_associatedcoordinate_3d ( character(len=*), intent(in)  name,
character(len=*), intent(in)  desc,
character(len=*), intent(in)  units,
character(len=*), dimension(:), intent(in)  dims,
real(rp), dimension(:,:,:), intent(in)  var,
character(len=*), intent(in), optional  datatype,
integer, dimension(:), intent(in), optional  start 
)

Definition at line 2669 of file scale_file_history.F90.

2669  use scale_file_h, only: &
2670  file_real4, &
2671  file_real8
2672  implicit none
2673 
2674  character(len=*), intent(in) :: name
2675  character(len=*), intent(in) :: desc
2676  character(len=*), intent(in) :: units
2677  character(len=*), intent(in) :: dims(:)
2678  real(RP), intent(in) :: var(:,:,:)
2679  character(len=*), intent(in), optional :: datatype
2680  integer, intent(in), optional :: start(:)
2681 
2682  integer :: dtype
2683  integer :: dim_size
2684  integer :: id
2685 
2686  intrinsic size, shape, reshape
2687  !---------------------------------------------------------------------------
2688 
2689  if ( present(datatype) ) then
2690  if ( datatype == 'REAL4' ) then
2691  dtype = file_real4
2692  elseif( datatype == 'REAL8' ) then
2693  dtype = file_real8
2694  else
2695  log_error("FILE_HISTORY_Set_AssociatedCoordinate_3D",*) 'Not appropriate datatype. Check!', datatype
2696  call prc_abort
2697  endif
2698  else if ( rp == sp ) then
2699  dtype = file_real4
2700  else
2701  dtype = file_real8
2702  endif
2703 
2704  dim_size = size(var)
2705 
2706  if ( file_history_nassocs < file_history_assoc_max ) then
2707  file_history_nassocs = file_history_nassocs + 1
2708  id = file_history_nassocs
2709 
2710  allocate( file_history_assocs(id)%var(dim_size) )
2711 
2712  file_history_assocs(id)%name = name
2713  file_history_assocs(id)%desc = desc
2714  file_history_assocs(id)%units = units
2715  file_history_assocs(id)%ndims = 3
2716  file_history_assocs(id)%dims(:) = ''
2717  file_history_assocs(id)%dims(1:3) = dims(1:3)
2718  file_history_assocs(id)%dtype = dtype
2719  file_history_assocs(id)%var(:) = real(reshape( var, (/ dim_size /) ),kind=dp)
2720 
2721  ! start and count are used for parallel I/O to a single shared file
2722  ! since var is reshaped into 1D array, we need to preserve its original shape in count
2723  file_history_assocs(id)%count(1:3) = shape(var)
2724  if ( present(start) ) then
2725  file_history_assocs(id)%start(1:3) = start(1:3)
2726  else
2727  file_history_assocs(id)%start = (/ 1, 1, 1, 1 /)
2728  end if
2729  else
2730  log_error("FILE_HISTORY_Set_AssociatedCoordinate_3D",*) 'Number of associate coordinates exceeds the limit.'
2731  call prc_abort
2732  endif
2733 
2734  return

References scale_precision::dp, scale_file_h::file_real4, scale_file_h::file_real8, scale_prc::prc_abort(), and scale_precision::sp.

Here is the call graph for this function:

◆ file_history_set_attribute_text()

subroutine scale_file_history::file_history_set_attribute_text ( character(len=*), intent(in)  varname,
character(len=*), intent(in)  key,
character(len=*), intent(in)  val,
logical, intent(in), optional  add_variable 
)

Definition at line 2744 of file scale_file_history.F90.

2744  use scale_prc, only: &
2745  prc_abort
2746  use scale_file, only: &
2747  file_set_attribute
2748  implicit none
2749  character(len=*), intent(in) :: varname
2750  character(len=*), intent(in) :: key
2751  character(len=*), intent(in) :: val
2752  logical, intent(in), optional :: add_variable
2753 
2754  integer :: id
2755  !---------------------------------------------------------------------------
2756 
2757  file_history_nattrs = file_history_nattrs + 1
2758  if ( file_history_nattrs > file_history_attr_max ) then
2759  log_error("FILE_HISTORY_Set_Attribute_Text",*) 'number of attributes exceeds the limit'
2760  call prc_abort
2761  end if
2762 
2763  id = file_history_nattrs
2764 
2765  file_history_attrs(id)%varname = varname
2766  file_history_attrs(id)%key = key
2767  file_history_attrs(id)%text = val
2768  file_history_attrs(id)%type = i_text
2769 
2770  if ( present(add_variable) ) then
2771  file_history_attrs(id)%add_variable = add_variable
2772  else
2773  file_history_attrs(id)%add_variable = .false.
2774  end if
2775 
2776  return

References scale_prc::prc_abort().

Referenced by file_history_set_attribute_logical().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_history_set_attribute_logical()

subroutine scale_file_history::file_history_set_attribute_logical ( character(len=*), intent(in)  varname,
character(len=*), intent(in)  key,
logical, intent(in)  val,
logical, intent(in), optional  add_variable 
)

Definition at line 2783 of file scale_file_history.F90.

2783  use scale_file, only: &
2784  file_set_attribute
2785  implicit none
2786  character(len=*), intent(in) :: varname
2787  character(len=*), intent(in) :: key
2788  logical, intent(in) :: val
2789  logical, intent(in), optional :: add_variable
2790 
2791  character(len=5) :: buf
2792  !---------------------------------------------------------------------------
2793 
2794  if ( val ) then
2795  buf = "true"
2796  else
2797  buf = "false"
2798  end if
2799 
2800  call file_history_set_attribute_text( varname, key, buf, add_variable=add_variable )
2801 
2802  return

References file_history_set_attribute_text().

Here is the call graph for this function:

◆ file_history_set_attribute_int_ary()

subroutine scale_file_history::file_history_set_attribute_int_ary ( character(len=*), intent(in)  varname,
character(len=*), intent(in)  key,
integer, dimension(:), intent(in)  val,
logical, intent(in), optional  add_variable 
)

Definition at line 2810 of file scale_file_history.F90.

2810  use scale_prc, only: &
2811  prc_abort
2812  use scale_file, only: &
2813  file_set_attribute
2814  implicit none
2815  character(len=*), intent(in) :: varname
2816  character(len=*), intent(in) :: key
2817  integer, intent(in) :: val(:)
2818  logical, intent(in), optional :: add_variable
2819 
2820  integer :: id
2821 
2822  intrinsic size
2823  !---------------------------------------------------------------------------
2824 
2825  file_history_nattrs = file_history_nattrs + 1
2826  if ( file_history_nattrs > file_history_attr_max ) then
2827  log_error("FILE_HISTORY_Set_Attribute_Int",*) 'number of attributes exceeds the limit'
2828  call prc_abort
2829  end if
2830 
2831  id = file_history_nattrs
2832 
2833  allocate( file_history_attrs(id)%int( size(val) ) )
2834 
2835  file_history_attrs(id)%varname = varname
2836  file_history_attrs(id)%key = key
2837  file_history_attrs(id)%int(:) = val(:)
2838  file_history_attrs(id)%type = i_int
2839 
2840  if ( present(add_variable) ) then
2841  file_history_attrs(id)%add_variable = add_variable
2842  else
2843  file_history_attrs(id)%add_variable = .false.
2844  end if
2845 
2846  return

References scale_prc::prc_abort().

Referenced by file_history_set_attribute_int().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_history_set_attribute_int()

subroutine scale_file_history::file_history_set_attribute_int ( character(len=*), intent(in)  varname,
character(len=*), intent(in)  key,
integer, intent(in)  val,
logical, intent(in), optional  add_variable 
)

Definition at line 2854 of file scale_file_history.F90.

2854  implicit none
2855  character(len=*), intent(in) :: varname
2856  character(len=*), intent(in) :: key
2857  integer, intent(in) :: val
2858  logical, intent(in), optional :: add_variable
2859 
2860  integer :: ary(1)
2861  !---------------------------------------------------------------------------
2862 
2863  ary(1) = val
2864  call file_history_set_attribute_int_ary( varname, & ! (in)
2865  key, ary(:), & ! (in)
2866  add_variable=add_variable ) ! (in)
2867 
2868  return

References file_history_set_attribute_int_ary(), and scale_prc::prc_abort().

Here is the call graph for this function:

◆ file_history_set_attribute_float()

subroutine scale_file_history::file_history_set_attribute_float ( character(len=*), intent(in)  varname,
character(len=*), intent(in)  key,
real(sp), intent(in)  val,
logical, intent(in), optional  add_variable 
)

Definition at line 2919 of file scale_file_history.F90.

2919  implicit none
2920  character(len=*), intent(in) :: varname
2921  character(len=*), intent(in) :: key
2922  real(SP), intent(in) :: val
2923  logical, intent(in), optional :: add_variable
2924 
2925  real(SP) :: ary(1)
2926 
2927  ary(1) = val
2928  call file_history_set_attribute_float_ary( varname, & ! (in)
2929  key, ary(:), & ! (in)
2930  add_variable ) ! (in)
2931 
2932  return

References scale_prc::prc_abort().

Here is the call graph for this function:

◆ file_history_set_attribute_double()

subroutine scale_file_history::file_history_set_attribute_double ( character(len=*), intent(in)  varname,
character(len=*), intent(in)  key,
real(dp), intent(in)  val,
logical, intent(in), optional  add_variable 
)

Definition at line 2982 of file scale_file_history.F90.

2982  implicit none
2983  character(len=*), intent(in) :: varname
2984  character(len=*), intent(in) :: key
2985  real(DP), intent(in) :: val
2986  logical, intent(in), optional :: add_variable
2987 
2988  real(DP) :: ary(1)
2989 
2990  ary(1) = val
2991  call file_history_set_attribute_double_ary( varname, & ! (in)
2992  key, ary(:), & ! (in)
2993  add_variable ) ! (in)
2994 
2995  return

References scale_calendar::calendar_sec2unit(), scale_file::file_enddef(), scale_file::file_flush(), scale_file_h::file_rmiss, and scale_prc::prc_abort().

Here is the call graph for this function:

Variable Documentation

◆ file_history_truncate_1d

procedure(truncate_1d), pointer, public scale_file_history::file_history_truncate_1d => NULL()

Definition at line 77 of file scale_file_history.F90.

77  procedure(truncate_1D), pointer :: FILE_HISTORY_truncate_1D => null()

Referenced by scale_file_history_cartesc::file_history_cartesc_setup(), file_history_in_0d(), and file_history_setup().

◆ file_history_truncate_2d

procedure(truncate_2d), pointer, public scale_file_history::file_history_truncate_2d => NULL()

Definition at line 89 of file scale_file_history.F90.

89  procedure(truncate_2D), pointer :: FILE_HISTORY_truncate_2D => null()

Referenced by scale_file_history_cartesc::file_history_cartesc_setup(), file_history_in_1d(), and file_history_setup().

◆ file_history_truncate_3d

procedure(truncate_3d), pointer, public scale_file_history::file_history_truncate_3d => NULL()

Definition at line 101 of file scale_file_history.F90.

101  procedure(truncate_3D), pointer :: FILE_HISTORY_truncate_3D => null()

Referenced by scale_file_history_cartesc::file_history_cartesc_setup(), file_history_in_2d(), and file_history_setup().

◆ file_history_truncate_4d

procedure(truncate_4d), pointer, public scale_file_history::file_history_truncate_4d => NULL()

Definition at line 113 of file scale_file_history.F90.

113  procedure(truncate_4D), pointer :: FILE_HISTORY_truncate_4D => null()

Referenced by file_history_in_3d(), and file_history_setup().

◆ file_history_aggregate

logical, public scale_file_history::file_history_aggregate

Definition at line 143 of file scale_file_history.F90.

143  logical, public :: FILE_HISTORY_AGGREGATE

Referenced by scale_file_history_cartesc::file_history_cartesc_truncate_3d(), file_history_finalize(), and file_history_setup().

◆ switch

integer public scale_file_history::switch

Definition at line 143 of file scale_file_history.F90.

Referenced by file_history_set_disable().

◆ to

integer public scale_file_history::to

Definition at line 143 of file scale_file_history.F90.

◆ use

logical, public scale_file_history::use

Definition at line 143 of file scale_file_history.F90.

◆ aggregate

logical, public scale_file_history::aggregate

Definition at line 143 of file scale_file_history.F90.

Referenced by file_history_finalize().

◆ file

integer public scale_file_history::file

Definition at line 143 of file scale_file_history.F90.

◆ i

logical, public scale_file_history::i

Definition at line 143 of file scale_file_history.F90.

Referenced by file_history_finalize(), and file_history_reg().

◆ o

logical, public scale_file_history::o

Definition at line 143 of file scale_file_history.F90.

scale_precision::sp
integer, parameter, public sp
Definition: scale_precision.F90:31
scale_prc::prc_abort
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:350
scale_file_h::file_real4
integer, parameter, public file_real4
Definition: scale_file_h.F90:26
scale_file::file_enddef
subroutine, public file_enddef(fid)
Definition: scale_file.F90:6061
scale_file::file_flush
subroutine, public file_flush(fid)
Definition: scale_file.F90:6201
scale_calendar
module CALENDAR
Definition: scale_calendar.F90:13
scale_file
module file
Definition: scale_file.F90:15
scale_prc
module PROCESS
Definition: scale_prc.F90:11
scale_precision::rp
integer, parameter, public rp
Definition: scale_precision.F90:41
scale_precision::dp
integer, parameter, public dp
Definition: scale_precision.F90:32
scale_file_h
module file_h
Definition: scale_file_h.F90:11
scale_file::file_aggregate
logical, public file_aggregate
Definition: scale_file.F90:196
scale_file_h::file_real8
integer, parameter, public file_real8
Definition: scale_file_h.F90:27
scale_calendar::calendar_unit2sec
subroutine, public calendar_unit2sec(second, value, unit)
Convert several units to second.
Definition: scale_calendar.F90:486