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

module file More...

Functions/Subroutines

subroutine, public file_setup (myrank)
 setup More...
 
subroutine, public file_create (basename, title, source, institution, fid, existed, rankid, single, aggregate, time_units, calendar, append)
 create file fid is >= 1 More...
 
subroutine, public file_add_associatedvariable (fid, vname, existed)
 
subroutine, public file_set_option (fid, filetype, key, val)
 
subroutine, public file_open (basename, fid, mode, single, aggregate, rankid, postfix)
 
logical function, public file_opened (fid)
 check if the file is opened? More...
 
subroutine, public file_get_dimlength (fid, dimname, len, error)
 get length of dimension More...
 
subroutine, public file_def_axis (fid, name, desc, units, dim_name, dtype, dim_size, bounds)
 
subroutine, public file_def_associatedcoordinate (fid, name, desc, units, dim_names, dtype)
 
subroutine, public file_def_variable (fid, varname, desc, units, standard_name, ndims, dims, dtype, vid, time_int, time_avg, existed)
 
subroutine, public file_get_stepsize (fid, varname, len, error)
 get number of steps More...
 
subroutine, public file_enddef (fid)
 
subroutine, public file_attach_buffer (fid, buf_amount)
 
subroutine, public file_detach_buffer (fid)
 
subroutine, public file_flush (fid)
 
subroutine, public file_close (fid, skip_abort)
 
subroutine, public file_close_all (skip_abort)
 
subroutine, public file_make_fname (basename, prefix, rankid, len, fname)
 
subroutine, public file_get_cftunits (date, tunits)
 get unit of time More...
 
logical function, public file_get_aggregate (fid)
 

Variables

logical, public file_aggregate = .false.
 
logical, public do
 
logical, public parallel
 
logical, public i
 
logical, public o
 
logical, public through
 
logical, dimension(default setting), public pnetcdf
 

Detailed Description

module file

Description
file I/O hundring
Author
Team SCALE
NAMELIST
  • PARAM_FILE
    nametypedefault valuecomment
    FILE_AGGREGATE logical .false. > do parallel I/O through PnetCDF (default setting)

History Output
No history output

Function/Subroutine Documentation

◆ file_setup()

subroutine, public scale_file::file_setup ( integer, intent(in)  myrank)

setup

Definition at line 208 of file scale_file.F90.

References file_aggregate, file_close_all(), scale_io::io_fid_conf, and scale_prc::prc_set_file_closer().

Referenced by scale_file_cartesc::file_cartesc_setup().

208  use scale_prc, only: &
210  implicit none
211 
212  integer, intent(in) :: myrank
213 
214  namelist / param_file / &
215  file_aggregate
216 
217  integer :: ierr
218 
219  !--- read namelist
220  rewind(io_fid_conf)
221  read(io_fid_conf,nml=param_file,iostat=ierr)
222  if( ierr < 0 ) then !--- missing
223  log_info("FILE_setup",*) 'Not found namelist. Default used.'
224  elseif( ierr > 0 ) then !--- fatal error
225  log_error("FILE_setup",*) 'Not appropriate names in namelist PARAM_FILE. Check!'
226  call prc_abort
227  endif
228  log_nml(param_file)
229 
230  mpi_myrank = myrank
231 
232  call prc_set_file_closer( file_close_all )
233 
234  return
subroutine, public prc_set_file_closer(routine)
Definition: scale_prc.F90:972
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:55
module PROCESS
Definition: scale_prc.F90:11
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_create()

subroutine, public scale_file::file_create ( character(len=*), intent(in)  basename,
character(len=*), intent(in)  title,
character(len=*), intent(in)  source,
character(len=*), intent(in)  institution,
integer, intent(out)  fid,
logical, intent(out)  existed,
integer, intent(in), optional  rankid,
logical, intent(in), optional  single,
logical, intent(in), optional  aggregate,
character(len=*), intent(in), optional  time_units,
character(len=*), intent(in), optional  calendar,
logical, intent(in), optional  append 
)

create file fid is >= 1

Definition at line 248 of file scale_file.F90.

References scale_file_h::file_fappend, scale_file_h::file_fwrite, file_get_nvars_c(), file_get_varname_c(), file_opened(), file_set_tunits_c(), scale_file_h::file_success_code, and scale_prc::prc_abort().

Referenced by scale_file_cartesc::file_cartesc_create(), and scale_file_history::file_history_finalize().

248  implicit none
249 
250  character(len=*), intent(in) :: basename
251  character(len=*), intent(in) :: title
252  character(len=*), intent(in) :: source
253  character(len=*), intent(in) :: institution
254 
255  integer, intent(out) :: fid
256  logical, intent(out) :: existed
257 
258  integer, intent(in), optional :: rankid
259  logical, intent(in), optional :: single
260  logical, intent(in), optional :: aggregate
261  character(len=*), intent(in), optional :: time_units
262  character(len=*), intent(in), optional :: calendar
263  logical, intent(in), optional :: append
264 
265  character(len=FILE_HMID) :: time_units_
266  character(len=FILE_HSHORT) :: calendar_
267  integer :: rankid_
268  logical :: single_
269  integer :: mode
270 
271  integer :: error
272  !---------------------------------------------------------------------------
273 
274 
275  if ( present(rankid) ) then
276  rankid_ = rankid
277  else
278  rankid_ = mpi_myrank
279  end if
280 
281  single_ = .false.
282  if ( present(single) ) then
283  single_ = single
284  endif
285 
286  if ( present(time_units) ) then
287  time_units_ = time_units
288  else
289  time_units_ = 'seconds'
290  endif
291 
292  if ( present(calendar) ) then
293  calendar_ = calendar
294  else
295  calendar_ = ""
296  end if
297 
298  mode = file_fwrite
299  if ( present(append) ) then
300  if( append ) mode = file_fappend
301  endif
302 
303  if ( single_ .and. rankid_ /= 0 ) return
304 
305  call file_get_fid( basename, mode, & ! [IN]
306  rankid_, single_, & ! [IN]
307  fid, existed, & ! [OUT]
308  aggregate=aggregate ) ! [IN]
309 
310  if( existed ) return
311 
312  !--- append package header to the file
313  call file_set_attribute( fid, "global", "title" , title ) ! [IN]
314  call file_set_attribute( fid, "global", "source" , source ) ! [IN]
315  call file_set_attribute( fid, "global", "institution", institution ) ! [IN]
316 
317  if ( ( .not. present(aggregate) ) .or. .not. aggregate ) then
318  ! for shared-file parallel I/O, skip attributes related to MPI processes
319  call file_set_attribute( fid, "global", "rankid" , (/rankid/) ) ! [IN]
320  endif
321 
322  call file_set_tunits_c( file_files(fid)%fid, & ! [IN]
323  time_units_, calendar_, & ! [IN]
324  error ) ! [OUT]
325 
326  if ( error /= file_success_code ) then
327  log_error("FILE_create",*) 'failed to set time units'
328  call prc_abort
329  endif
330 
331  return
int32_t file_set_tunits_c(const int32_t fid, const char *time_units, const char *calendar)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_add_associatedvariable()

subroutine, public scale_file::file_add_associatedvariable ( integer, intent(in)  fid,
character(len=*), intent(in)  vname,
logical, intent(out), optional  existed 
)

Definition at line 399 of file scale_file.F90.

References file_add_associatedvariable_c(), scale_file_h::file_already_existed_code, file_opened(), scale_file_h::file_success_code, and scale_prc::prc_abort().

Referenced by scale_file_cartesc::file_cartesc_def_axes(), and scale_file_history::file_history_finalize().

399  integer, intent(in) :: fid
400  character(len=*), intent(in) :: vname
401  logical, optional, intent(out) :: existed
402 
403  integer :: error
404 
405  if ( .not. file_opened(fid) ) then
406  log_error("FILE_add_associatedVariable",*) 'File is not opened. fid = ', fid
407  call prc_abort
408  end if
409 
410  call file_add_associatedvariable_c( file_files(fid)%fid, vname , & ! (in)
411  error ) ! (out)
412 
413  if ( present(existed) ) then
414  if ( error == file_already_existed_code ) then
415  existed = .true.
416  return
417  end if
418  existed = .false.
419  end if
420 
421  if ( error /= file_success_code ) then
422  log_error("FILE_add_associatedvariable",*) 'failed to add associated variable: '//trim(vname)
423  call prc_abort
424  end if
425 
426  return
int32_t file_add_associatedvariable_c(const int32_t fid, const char *vname)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_set_option()

subroutine, public scale_file::file_set_option ( integer, intent(in)  fid,
character(len=*), intent(in)  filetype,
character(len=*), intent(in)  key,
character(len=*), intent(in)  val 
)

Definition at line 433 of file scale_file.F90.

References file_opened(), file_set_option_c(), scale_file_h::file_success_code, and scale_prc::prc_abort().

Referenced by scale_file_history::file_history_finalize().

433  integer, intent(in) :: fid
434  character(len=*), intent(in) :: filetype
435  character(len=*), intent(in) :: key
436  character(len=*), intent(in) :: val
437 
438  integer :: error
439 
440  if ( .not. file_opened(fid) ) then
441  log_error("FILE_set_option",*) 'File is not opened. fid = ', fid
442  call prc_abort
443  end if
444 
445  call file_set_option_c( file_files(fid)%fid, filetype, key, val, & ! (in)
446  error ) ! (out)
447  if ( error /= file_success_code ) then
448  log_error("FILE_set_option",*) 'failed to set option'
449  call prc_abort
450  end if
451 
452  return
int32_t file_set_option_c(const int32_t fid, const char *filetype, const char *key, const char *val)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_open()

subroutine, public scale_file::file_open ( character(len=*), intent(in)  basename,
integer, intent(out)  fid,
integer, intent(in), optional  mode,
logical, intent(in), optional  single,
logical, intent(in), optional  aggregate,
integer, intent(in), optional  rankid,
character(len=*), intent(in), optional  postfix 
)

Definition at line 464 of file scale_file.F90.

References scale_file_h::file_fread.

Referenced by scale_atmos_grid_cartesc::atmos_grid_cartesc_allocate(), scale_atmos_phy_rd_profile::atmos_phy_rd_profile_setup(), scale_comm_cartesc_nest::comm_cartesc_nest_setup(), mod_copytopo::copytopo(), scale_file_cartesc::file_cartesc_cleanup(), scale_file_cartesc::file_cartesc_open(), file_def_variable(), scale_file_external_input::file_external_input_regist(), scale_file_external_input::file_external_input_update_3d(), file_get_stepsize(), scale_land_grid_cartesc::land_grid_cartesc_setup(), scale_land_grid_icoa::land_grid_icoa_setup(), scale_ocean_grid_cartesc::ocean_grid_cartesc_setup(), scale_ocean_grid_icoa::ocean_grid_icoa_setup(), mod_realinput_scale::parentatmosinputscale(), mod_realinput_wrfarw::parentatmosinputwrfarw(), mod_realinput_nicam::parentatmosopennicam(), mod_realinput_scale::parentatmosopenscale(), mod_realinput_wrfarw::parentatmossetupwrfarw(), mod_realinput_scale::parentlandinputscale(), mod_realinput_wrfarw::parentlandinputwrfarw(), mod_realinput_wrfarw::parentlandsetupwrfarw(), mod_realinput_scale::parentoceaninputscale(), mod_realinput_wrfarw::parentoceaninputwrfarw(), mod_realinput_scale::parentoceanopenscale(), mod_realinput_wrfarw::parentoceansetupwrfarw(), scale_urban_grid_cartesc::urban_grid_cartesc_setup(), scale_urban_grid_icoa::urban_grid_icoa_setup(), and mod_realinput_wrfarw::wrf_arwpost_calc_uvmet().

464  implicit none
465 
466  character(len=*), intent( in) :: basename
467  integer, intent(out) :: fid
468  integer, intent( in), optional :: mode
469  logical, intent( in), optional :: single
470  logical, intent( in), optional :: aggregate
471  integer, intent( in), optional :: rankid
472  character(len=*), intent( in), optional :: postfix
473 
474  integer :: mode_
475  integer :: rankid_
476  logical :: existed
477  logical :: single_
478 
479  single_ = .false.
480 
481  if ( present(mode) ) then
482  mode_ = mode
483  else
484  mode_ = file_fread
485  end if
486 
487  if ( present(single) ) single_ = single
488  if ( present(rankid) ) then
489  rankid_ = rankid
490  else
491  rankid_ = mpi_myrank
492  end if
493 
494  call file_get_fid( basename, mode_, rankid_, single_, & ! (in)
495  fid, existed, & ! (out)
496  aggregate=aggregate, postfix=postfix ) ! (in)
497 
498  return
Here is the caller graph for this function:

◆ file_opened()

logical function, public scale_file::file_opened ( integer, intent(in)  fid)

check if the file is opened?

Definition at line 504 of file scale_file.F90.

Referenced by file_add_associatedvariable(), file_attach_buffer(), scale_file_cartesc::file_cartesc_close(), scale_file_cartesc::file_cartesc_def_axes(), scale_file_cartesc::file_cartesc_def_var(), scale_file_cartesc::file_cartesc_enddef(), scale_file_cartesc::file_cartesc_flush(), scale_file_cartesc::file_cartesc_put_globalattributes(), scale_file_cartesc::file_cartesc_read_1d(), scale_file_cartesc::file_cartesc_read_auto_2d(), scale_file_cartesc::file_cartesc_read_auto_3d(), scale_file_cartesc::file_cartesc_read_var_2d(), scale_file_cartesc::file_cartesc_read_var_3d(), scale_file_cartesc::file_cartesc_read_var_4d(), scale_file_cartesc::file_cartesc_write_axes(), scale_file_cartesc::file_cartesc_write_var_1d(), scale_file_cartesc::file_cartesc_write_var_2d(), scale_file_cartesc::file_cartesc_write_var_3d(), scale_file_cartesc::file_cartesc_write_var_3d_t(), scale_file_cartesc::file_cartesc_write_var_4d(), file_close(), file_create(), file_def_associatedcoordinate(), file_def_axis(), file_def_variable(), file_detach_buffer(), file_enddef(), file_flush(), file_get_aggregate(), file_get_dimlength(), file_get_stepsize(), and file_set_option().

504  implicit none
505 
506  integer, intent( in) :: fid
507  logical :: file_opened
508 
509  if ( fid < 1 ) then
510  file_opened = .false.
511  else
512  file_opened = file_files(fid)%fid >= 0
513  end if
514 
515  return
Here is the caller graph for this function:

◆ file_get_dimlength()

subroutine, public scale_file::file_get_dimlength ( integer, intent(in)  fid,
character(len=*), intent(in)  dimname,
integer, intent(out)  len,
logical, intent(out), optional  error 
)

get length of dimension

Definition at line 525 of file scale_file.F90.

References scale_precision::dp, scale_file_h::file_already_existed_code, file_get_dim_length_c(), file_opened(), file_put_axis_c(), scale_file_h::file_success_code, scale_prc::prc_abort(), and scale_precision::sp.

Referenced by mod_realinput_wrfarw::parentatmossetupwrfarw(), mod_realinput_wrfarw::parentlandsetupwrfarw(), and mod_realinput_wrfarw::parentoceansetupwrfarw().

525  integer, intent(in) :: fid
526  character(len=*), intent(in) :: dimname
527 
528  integer, intent(out) :: len
529 
530  logical, intent(out), optional :: error
531 
532  integer :: ierror
533 
534 
535  if ( .not. file_opened(fid) ) then
536  log_error("FILE_get_dimLength",*) 'File is not opened. fid = ', fid
537  call prc_abort
538  end if
539 
540  call file_get_dim_length_c( file_files(fid)%fid, dimname, & ! (in)
541  len, ierror ) ! (out)
542  if ( ierror /= file_success_code .and. ierror /= file_already_existed_code ) then
543  if ( present(error) ) then
544  error = .true.
545  else
546  log_error("FILE_get_dimLength",*) 'failed to get dimension length'
547  call prc_abort
548  end if
549  else
550  if ( present(error) ) error = .false.
551  end if
552 
553  return
int32_t file_get_dim_length_c(const int32_t fid, const char *dimname, int32_t *len)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_def_axis()

subroutine, public scale_file::file_def_axis ( integer, intent(in)  fid,
character(len=*), intent(in)  name,
character(len=*), intent(in)  desc,
character(len=*), intent(in)  units,
character(len=*), intent(in)  dim_name,
integer, intent(in)  dtype,
integer, intent(in)  dim_size,
logical, intent(in), optional  bounds 
)

Definition at line 627 of file scale_file.F90.

References scale_precision::dp, scale_file_h::file_already_existed_code, file_def_axis_c(), file_opened(), file_put_associatedcoordinate_c(), scale_file_h::file_success_code, file_write_axis_c(), scale_prc::prc_abort(), and scale_precision::sp.

Referenced by scale_file_cartesc::file_cartesc_def_axes(), and scale_file_history::file_history_finalize().

627  integer, intent(in) :: fid
628  character(len=*), intent(in) :: name
629  character(len=*), intent(in) :: desc
630  character(len=*), intent(in) :: units
631  character(len=*), intent(in) :: dim_name
632  integer, intent(in) :: dtype
633  integer, intent(in) :: dim_size
634 
635  logical, intent(in), optional :: bounds
636 
637  integer :: error
638  integer :: bounds_
639 
640  bounds_ = 0 ! .false.
641  if ( present(bounds) ) then
642  if ( bounds ) bounds_ = 1 ! .true.
643  end if
644 
645  if ( .not. file_opened(fid) ) then
646  log_error("FILE_def_axis",*) 'File is not opened. fid = ', fid
647  call prc_abort
648  end if
649 
650  call file_def_axis_c( file_files(fid)%fid, &
651  name, desc, units, dim_name, dtype, dim_size, bounds_, & ! (in)
652  error ) ! (out)
653  if ( error /= file_success_code .and. error /= file_already_existed_code ) then
654  log_error("FILE_def_axis",*) 'failed to define axis'
655  call prc_abort
656  end if
657 
658  return
int32_t file_def_axis_c(const int32_t fid, const char *name, const char *desc, const char *units, const char *dim_name, const int32_t dtype, const int32_t dim_size, const int32_t bounds)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_def_associatedcoordinate()

subroutine, public scale_file::file_def_associatedcoordinate ( integer, intent(in)  fid,
character(len=*), intent(in)  name,
character(len=*), intent(in)  desc,
character(len=*), intent(in)  units,
character(len=*), dimension(:), intent(in)  dim_names,
integer, intent(in)  dtype 
)

Definition at line 997 of file scale_file.F90.

References scale_precision::dp, file_add_variable_c(), scale_file_h::file_already_existed_code, file_def_associatedcoordinate_c(), file_opened(), scale_file_h::file_success_code, file_write_associatedcoordinate_c(), scale_prc::prc_abort(), and scale_precision::sp.

Referenced by scale_file_cartesc::file_cartesc_def_axes(), and scale_file_history::file_history_finalize().

997  integer, intent(in) :: fid
998  character(len=*), intent(in) :: name
999  character(len=*), intent(in) :: desc
1000  character(len=*), intent(in) :: units
1001  character(len=*), intent(in) :: dim_names(:)
1002  integer, intent(in) :: dtype
1003 
1004  integer :: error
1005  intrinsic size
1006 
1007  if ( .not. file_opened(fid) ) then
1008  log_error("FILE_def_associatedCoordinate",*) 'File is not opened. fid = ', fid
1009  call prc_abort
1010  end if
1011 
1012  call file_def_associatedcoordinate_c( file_files(fid)%fid, & ! (in)
1013  name, desc, units, dim_names, size(dim_names), dtype, & ! (in)
1014  error ) ! (out)
1015  if ( error /= file_success_code .and. error /= file_already_existed_code ) then
1016  log_error("FILE_def_associatedCoordinate",*) 'failed to put associated coordinate: '//trim(name)
1017  call prc_abort
1018  end if
1019 
1020  return
int32_t file_def_associatedcoordinate_c(const int32_t fid, const char *name, const char *desc, const char *units, const char **dim_names, const int32_t ndims, const int32_t dtype)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_def_variable()

subroutine, public scale_file::file_def_variable ( integer, intent(in)  fid,
character(len=*), intent(in)  varname,
character(len=*), intent(in)  desc,
character(len=*), intent(in)  units,
character(len=*), intent(in)  standard_name,
integer, intent(in)  ndims,
character(len=*), dimension(:), intent(in)  dims,
integer, intent(in)  dtype,
integer, intent(out)  vid,
real(dp), intent(in), optional  time_int,
logical, intent(in), optional  time_avg,
logical, intent(out), optional  existed 
)

Definition at line 1531 of file scale_file.F90.

References file_add_variable_c(), scale_file_h::file_already_existed_code, file_get_attribute_double_c(), file_get_attribute_float_c(), file_get_attribute_int_c(), file_get_attribute_text_c(), file_get_datainfo_c(), file_open(), file_opened(), file_set_attribute_double_c(), file_set_attribute_float_c(), file_set_attribute_int_c(), file_set_attribute_text_c(), scale_file_h::file_success_code, and scale_prc::prc_abort().

Referenced by scale_file_cartesc::file_cartesc_def_var().

1531  integer, intent( in) :: fid
1532  character(len=*), intent( in) :: varname
1533  character(len=*), intent( in) :: desc
1534  character(len=*), intent( in) :: units
1535  character(len=*), intent( in) :: standard_name
1536  integer, intent( in) :: ndims
1537  character(len=*), intent( in) :: dims(:)
1538  integer, intent( in) :: dtype
1539  integer, intent(out) :: vid
1540  real(DP), intent( in), optional :: time_int
1541  logical, intent( in), optional :: time_avg
1542  logical, intent(out), optional :: existed
1543 
1544  real(DP) :: tint_
1545  integer :: itavg
1546  integer :: cvid
1547  integer :: error
1548  integer :: n
1549 
1550  !---------------------------------------------------------------------------
1551 
1552  if ( .not. file_opened(fid) ) then
1553  log_error("FILE_def_variable",*) 'File is not opened. fid = ', fid
1554  call prc_abort
1555  end if
1556 
1557  vid = -1
1558  do n = 1, file_nvars
1559  if ( file_vars(n)%fid == fid .and. file_vars(n)%name == varname ) then
1560  vid = n
1561  end if
1562  enddo
1563 
1564  if ( vid < 0 ) then ! variable registration
1565 
1566  if ( present(time_int) ) then
1567  tint_ = time_int
1568  else
1569  tint_ = -1.0_dp
1570  endif
1571 
1572  if ( present(time_avg) ) then
1573  if ( time_avg ) then
1574  itavg = 1
1575  else
1576  itavg = 0
1577  end if
1578  else
1579  itavg = 0
1580  end if
1581 
1582  call file_add_variable_c( file_files(fid)%fid, & ! (in)
1583  varname, desc, units, standard_name, & ! (in)
1584  dims, ndims, dtype, & ! (in)
1585  tint_, itavg, & ! (in)
1586  cvid, error ) ! (out)
1587  if ( error /= file_success_code ) then
1588  log_error("FILE_def_variable",*) 'failed to add variable: '//trim(varname)
1589  call prc_abort
1590  end if
1591 
1592  file_nvars = file_nvars + 1
1593  vid = file_nvars
1594  file_vars(vid)%name = varname
1595  file_vars(vid)%vid = cvid
1596  file_vars(vid)%fid = fid
1597 
1598  log_info("FILE_def_variable",'(1x,A,I3.3,A,I4.4,2A)') &
1599  'Variable registration : NO.', fid, ', vid = ', vid, ', name = ', trim(varname)
1600 
1601  if ( present(existed) ) existed = .false.
1602  else
1603  if ( present(existed) ) existed = .true.
1604  endif
1605 
1606  return
int32_t file_add_variable_c(const int32_t fid, const char *varname, const char *desc, const char *units, const char *stdname, const char **dims, const int32_t ndims, const int32_t dtype, const real64_t tint, const int32_t tavg, int32_t *vid)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_get_stepsize()

subroutine, public scale_file::file_get_stepsize ( integer, intent(in)  fid,
character(len=*), intent(in)  varname,
integer, intent(out)  len,
logical, intent(out), optional  error 
)

get number of steps

Definition at line 2240 of file scale_file.F90.

References scale_precision::dp, scale_file_h::file_already_existed_code, file_get_datainfo_c(), file_get_step_size_c(), file_open(), file_opened(), file_read_data_c(), scale_file_h::file_rmiss, scale_file_h::file_success_code, file_write_data_c(), scale_prc::prc_abort(), and scale_precision::sp.

2240  integer, intent(in) :: fid
2241  character(len=*), intent(in) :: varname
2242 
2243  integer, intent(out) :: len
2244 
2245  logical, intent(out), optional :: error
2246 
2247  integer :: ierror
2248 
2249  if ( .not. file_opened(fid) ) then
2250  log_error("FILE_get_stepSize",*) 'File is not opened. fid = ', fid
2251  call prc_abort
2252  end if
2253 
2254  call file_get_step_size_c( file_files(fid)%fid, varname, & ! (in)
2255  len, ierror ) ! (out)
2256  if ( ierror /= file_success_code .and. ierror /= file_already_existed_code ) then
2257  if ( present(error) ) then
2258  error = .true.
2259  else
2260  log_error("FILE_get_stepSize",*) 'failed to get number of steps'
2261  call prc_abort
2262  end if
2263  else
2264  if ( present(error) ) error = .false.
2265  end if
2266 
2267  return
int32_t file_get_step_size_c(const int32_t fid, const char *varname, int32_t *len)
Here is the call graph for this function:

◆ file_enddef()

subroutine, public scale_file::file_enddef ( integer, intent(in)  fid)

Definition at line 4393 of file scale_file.F90.

References file_enddef_c(), file_opened(), scale_file_h::file_success_code, and scale_prc::prc_abort().

Referenced by scale_file_cartesc::file_cartesc_enddef(), scale_file_history::file_history_query_id(), and scale_file_history::file_history_write().

4393  implicit none
4394 
4395  integer, intent(in) :: fid
4396 
4397  integer :: error
4398  !---------------------------------------------------------------------------
4399 
4400  if ( .not. file_opened(fid) ) return
4401 
4402  call file_enddef_c( file_files(fid)%fid, error )
4403 
4404  if ( error == file_success_code ) then
4405 
4406  log_newline
4407  log_info("FILE_enddef",'(1x,A,I3.3,2A)') &
4408  'End define mode : No.', fid, ', name = ', trim(file_files(fid)%name)
4409 
4410  else
4411  log_error("FILE_enddef",*) 'failed to exit define mode'
4412  call prc_abort
4413  end if
4414 
4415  return
int32_t file_enddef_c(const int32_t fid)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_attach_buffer()

subroutine, public scale_file::file_attach_buffer ( integer, intent(in)  fid,
integer(8), intent(in)  buf_amount 
)

Definition at line 4423 of file scale_file.F90.

References file_attach_buffer_c(), file_opened(), scale_file_h::file_success_code, and scale_prc::prc_abort().

Referenced by scale_file_cartesc::file_cartesc_enddef(), and scale_file_history::file_history_finalize().

4423  implicit none
4424 
4425  integer, intent(in) :: fid
4426  integer(8), intent(in) :: buf_amount
4427 
4428  integer :: error
4429  !---------------------------------------------------------------------------
4430 
4431  if ( .not. file_opened(fid) ) return
4432 
4433  call file_attach_buffer_c( file_files(fid)%fid, buf_amount, error )
4434 
4435  if ( error == file_success_code ) then
4436 
4437  log_newline
4438  log_info("FILE_attach_buffer",'(1x,A,I3.3,3A,I10)') &
4439  'Attach buffer : No.', fid, ', name = ', trim(file_files(fid)%name), &
4440  ', size = ', buf_amount
4441  else
4442  log_error("FILE_attach_buffer",*) 'failed to attach buffer in PnetCDF'
4443  call prc_abort
4444  end if
4445 
4446  return
int32_t file_attach_buffer_c(const int32_t fid, const int64_t buf_amount)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_detach_buffer()

subroutine, public scale_file::file_detach_buffer ( integer, intent(in)  fid)

Definition at line 4452 of file scale_file.F90.

References file_detach_buffer_c(), file_opened(), scale_file_h::file_success_code, and scale_prc::prc_abort().

Referenced by scale_file_cartesc::file_cartesc_close(), and scale_file_history::file_history_finalize().

4452  implicit none
4453 
4454  integer, intent(in) :: fid
4455 
4456  integer :: error
4457  !---------------------------------------------------------------------------
4458 
4459  if ( .not. file_opened(fid) ) return
4460 
4461  if ( file_files(fid)%fid < 0 ) return ! already closed
4462 
4463  call file_detach_buffer_c( file_files(fid)%fid, error )
4464 
4465  if ( error == file_success_code ) then
4466 
4467  log_newline
4468  log_info("FILE_detach_buffer",'(1x,A,I3.3,2A)') &
4469  'Detach buffer : No.', fid, ', name = ', trim(file_files(fid)%name)
4470 
4471  else
4472  log_error("FILE_detach_buffer",*) 'failed to detach buffer in PnetCDF'
4473  call prc_abort
4474  end if
4475 
4476  return
int32_t file_detach_buffer_c(const int32_t fid)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_flush()

subroutine, public scale_file::file_flush ( integer, intent(in)  fid)

Definition at line 4482 of file scale_file.F90.

References file_flush_c(), file_opened(), scale_file_h::file_success_code, and scale_prc::prc_abort().

Referenced by scale_file_cartesc::file_cartesc_close(), scale_file_cartesc::file_cartesc_enddef(), scale_file_cartesc::file_cartesc_flush(), scale_file_cartesc::file_cartesc_write_var_4d(), scale_file_history::file_history_query_id(), and scale_file_history::file_history_write().

4482  implicit none
4483 
4484  integer, intent(in) :: fid
4485 
4486  integer :: error
4487  !---------------------------------------------------------------------------
4488 
4489  if ( .not. file_opened(fid) ) return
4490 
4491  if ( file_files(fid)%fid < 0 ) return ! already closed
4492 
4493  call file_flush_c( file_files(fid)%fid, error )
4494 
4495  if ( error == file_success_code ) then
4496 
4497 !!$ LOG_NEWLINE
4498 !!$ LOG_INFO("FILE_flush",'(1xA,I3.3,2A)') &
4499 !!$ 'Flush : No.', fid, ', name = ', trim(FILE_files(fid)%name)
4500 
4501  else
4502  log_error("FILE_flush",*) 'failed to flush PnetCDF pending requests'
4503  call prc_abort
4504  end if
4505 
4506  return
int32_t file_flush_c(const int32_t fid)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_close()

subroutine, public scale_file::file_close ( integer, intent(in)  fid,
logical, intent(in), optional  skip_abort 
)

Definition at line 4511 of file scale_file.F90.

References scale_file_h::file_already_closed_code, file_close_c(), file_opened(), scale_file_h::file_success_code, and scale_prc::prc_abort().

Referenced by scale_atmos_phy_rd_profile::atmos_phy_rd_profile_setup(), mod_copytopo::copytopo(), scale_file_cartesc::file_cartesc_close(), file_close_all(), and scale_file_history::file_history_finalize().

4511  implicit none
4512  integer, intent(in) :: fid
4513  logical, intent(in), optional :: skip_abort
4514 
4515  logical :: skip_abort_
4516  integer :: error
4517  integer :: n
4518  !---------------------------------------------------------------------------
4519 
4520  if ( .not. file_opened(fid) ) return
4521 
4522  if ( file_files(fid)%fid < 0 ) return ! already closed
4523 
4524  if ( present(skip_abort) ) then
4525  skip_abort_ = skip_abort
4526  else
4527  skip_abort_ = .false.
4528  end if
4529 
4530  call file_close_c( file_files(fid)%fid, error )
4531 
4532  if ( error == file_success_code ) then
4533 
4534  log_newline
4535  log_info("FILE_close",'(1x,A,I3.3,2A)') &
4536  'Close : No.', fid, ', name = ', trim(file_files(fid)%name)
4537 
4538  elseif( error /= file_already_closed_code ) then
4539  log_error("FILE_close",*) 'failed to close file'
4540  if ( .not. skip_abort_ ) call prc_abort
4541  end if
4542 
4543  file_files(fid)%fid = -1
4544  file_files(fid)%name = ''
4545  file_files(fid)%aggregate = .false.
4546 
4547  do n = 1, file_nvars
4548  if ( file_vars(n)%fid == fid ) then
4549  file_vars(n)%vid = -1
4550  file_vars(n)%name = ''
4551  end if
4552  end do
4553 
4554  return
int32_t file_close_c(const int32_t fid)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_close_all()

subroutine, public scale_file::file_close_all ( logical, intent(in), optional  skip_abort)

Definition at line 4559 of file scale_file.F90.

References file_close().

Referenced by file_setup(), mod_rm_driver::rm_driver(), mod_rm_prep::rm_prep(), and scale::scale_finalize().

4559  implicit none
4560  logical, intent(in), optional :: skip_abort
4561 
4562  integer :: fid
4563  !---------------------------------------------------------------------------
4564 
4565  do fid = 1, file_nfiles
4566  call file_close( fid, skip_abort )
4567  enddo
4568 
4569  return
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_make_fname()

subroutine, public scale_file::file_make_fname ( character(len=*), intent(in)  basename,
character(len=*), intent(in)  prefix,
integer, intent(in)  rankid,
integer, intent(in)  len,
character(len=*), intent(out)  fname 
)

Definition at line 4578 of file scale_file.F90.

References scale_prc::prc_abort().

Referenced by file_get_aggregate().

4578  character(len=*), intent( in) :: basename
4579  character(len=*), intent( in) :: prefix
4580  integer, intent( in) :: rankid
4581  integer, intent( in) :: len
4582  character(len=*), intent(out) :: fname
4583 
4584  ! 12345678901234567
4585  character(len=17) :: fmt = "(A, '.', A, I*.*)"
4586  !---------------------------------------------------------------------------
4587 
4588  if ( len < 1 .or. len > 9 ) then
4589  log_error("FILE_make_fname",*) 'len is invalid'
4590  call prc_abort
4591  end if
4592 
4593  write(fmt(14:14),'(I1)') len
4594  write(fmt(16:16),'(I1)') len
4595  write(fname, fmt) trim(basename), trim(prefix), rankid
4596 
4597  return
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_get_cftunits()

subroutine, public scale_file::file_get_cftunits ( integer, dimension(6), intent(in)  date,
character(len=*), intent(out)  tunits 
)

get unit of time

Definition at line 4604 of file scale_file.F90.

Referenced by scale_file_cartesc::file_cartesc_create(), and scale_file_history_cartesc::file_history_cartesc_truncate_3d().

4604  implicit none
4605 
4606  integer, intent(in) :: date(6)
4607  character(len=*), intent(out) :: tunits
4608  !---------------------------------------------------------------------------
4609 
4610  write(tunits,'(a,i4.4,"-",i2.2,"-",i2.2," ",i2.2,":",i2.2,":",i2.2)') 'seconds since ', date
4611 
4612  return
Here is the caller graph for this function:

◆ file_get_aggregate()

logical function, public scale_file::file_get_aggregate ( integer, intent(in)  fid)

Definition at line 4616 of file scale_file.F90.

References file_aggregate, file_make_fname(), file_open_c(), file_opened(), scale_file_h::file_success_code, scale_prc::prc_comm_null, and scale_prc::prc_local_comm_world.

Referenced by mod_atmos_dyn_vars::atmos_dyn_vars_restart_read(), mod_atmos_phy_ae_vars::atmos_phy_ae_vars_restart_read(), mod_atmos_phy_ch_vars::atmos_phy_ch_vars_restart_read(), mod_atmos_phy_cp_vars::atmos_phy_cp_vars_restart_read(), mod_atmos_phy_mp_vars::atmos_phy_mp_vars_restart_read(), mod_atmos_phy_rd_vars::atmos_phy_rd_vars_restart_read(), mod_atmos_phy_sf_vars::atmos_phy_sf_vars_restart_read(), mod_atmos_vars::atmos_vars_restart_check(), mod_atmos_vars::atmos_vars_restart_read(), scale_file_cartesc::file_cartesc_close(), scale_file_cartesc::file_cartesc_def_axes(), scale_file_cartesc::file_cartesc_enddef(), scale_file_cartesc::file_cartesc_flush(), scale_file_cartesc::file_cartesc_read_1d(), scale_file_cartesc::file_cartesc_read_var_2d(), scale_file_cartesc::file_cartesc_read_var_3d(), scale_file_cartesc::file_cartesc_read_var_4d(), scale_file_cartesc::file_cartesc_write_axes(), scale_file_cartesc::file_cartesc_write_var_1d(), scale_file_cartesc::file_cartesc_write_var_2d(), scale_file_cartesc::file_cartesc_write_var_3d(), scale_file_cartesc::file_cartesc_write_var_3d_t(), scale_file_cartesc::file_cartesc_write_var_4d(), mod_land_vars::land_vars_restart_read(), mod_ocean_vars::ocean_vars_restart_read(), and mod_urban_vars::urban_vars_restart_read().

4616  integer, intent(in) :: fid
4617  logical :: file_get_aggregate
4618 
4619  if ( .not. file_opened(fid) ) then
4620  file_get_aggregate = .false.
4621  else
4622  file_get_aggregate = file_files(fid)%aggregate
4623  end if
4624 
4625  return
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ file_aggregate

logical, public scale_file::file_aggregate = .false.

◆ do

logical, public scale_file::do

Definition at line 171 of file scale_file.F90.

◆ parallel

logical, public scale_file::parallel

Definition at line 171 of file scale_file.F90.

◆ i

logical, public scale_file::i

Definition at line 171 of file scale_file.F90.

Referenced by file_close_c(), and file_get_step_size_c().

◆ o

logical, public scale_file::o

Definition at line 171 of file scale_file.F90.

◆ through

logical, public scale_file::through

Definition at line 171 of file scale_file.F90.

◆ pnetcdf

logical, dimension (default setting), public scale_file::pnetcdf

Definition at line 171 of file scale_file.F90.