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

module GTOOL_FILE More...

Functions/Subroutines

subroutine, public filecreate (fid, existed, basename, title, source, institution, master, myrank, rankidx, single, time_units, append)
 
subroutine, public filesetoption (fid, filetype, key, val)
 
subroutine, public fileopen (fid, basename, mode, single)
 
subroutine, public filedefaxis (fid, name, desc, units, dim_name, dtype, dim_size)
 
subroutine, public filedefassociatedcoordinates (fid, name, desc, units, dim_names, dtype)
 
subroutine, public filedefinevariable (fid, vid, varname, desc, units, ndims, dims, dtype, tint, tavg)
 
subroutine, public filesettattr (fid, vname, key, val)
 
subroutine, public filegetshape (dims, basename, varname, myrank, single)
 
subroutine, public filegetdatainfo (basename, varname, myrank, istep, single, description, units, datatype, dim_rank, dim_name, dim_size, time_start, time_end, time_units)
 
subroutine, public filegetalldatainfo (step_limit, dim_limit, basename, varname, myrank, step_nmax, description, units, datatype, dim_rank, dim_name, dim_size, time_start, time_end, time_units, single)
 
subroutine, public fileenddef (fid)
 
subroutine, public fileclose (fid)
 
subroutine, public filecloseall
 
subroutine, public filemakefname (fname, basename, prefix, myrank, len)
 

Variables

real(dp), parameter, public rmiss = -9.9999e+30
 

Detailed Description

module GTOOL_FILE

Description
unified hundring of various kinds of files
Author
Team SCALE
History
  • 2012-06-12 (S.Nishizawa) [new] Imported from SCALE-LES

Function/Subroutine Documentation

◆ filecreate()

subroutine, public gtool_file::filecreate ( integer, intent(out)  fid,
logical, intent(out)  existed,
character(len=*), intent(in)  basename,
character(len=*), intent(in)  title,
character(len=*), intent(in)  source,
character(len=*), intent(in)  institution,
integer, intent(in)  master,
integer, intent(in)  myrank,
integer, dimension(:), intent(in)  rankidx,
logical, intent(in), optional  single,
character(len=*), intent(in), optional  time_units,
logical, intent(in), optional  append 
)

Definition at line 181 of file gtool_file.f90.

References gtool_file_h::file_fappend, gtool_file_h::file_fwrite, file_get_global_attribute_double(), file_get_global_attribute_float(), file_get_global_attribute_int(), file_get_global_attribute_text(), file_set_global_attribute_double(), file_set_global_attribute_float(), file_set_global_attribute_int(), file_set_global_attribute_text(), file_set_tunits(), dc_log::log(), and gtool_file_h::success_code.

Referenced by scale_fileio::fileio_create(), scale_fileio::fileio_write_1d(), scale_fileio::fileio_write_2d(), scale_fileio::fileio_write_3d(), scale_fileio::fileio_write_3d_t(), scale_fileio::fileio_write_4d(), and gtool_history::historyaddvariable().

181  implicit none
182 
183  integer, intent(out) :: fid
184  logical, intent(out) :: existed
185  character(LEN=*), intent( in) :: basename
186  character(LEN=*), intent( in) :: title
187  character(LEN=*), intent( in) :: source
188  character(LEN=*), intent( in) :: institution
189  integer, intent( in) :: master
190  integer, intent( in) :: myrank
191  integer, intent( in) :: rankidx(:)
192  character(LEN=*), intent( in), optional :: time_units
193  logical, intent( in), optional :: single
194  logical, intent( in), optional :: append
195 
196  character(len=File_HMID) :: time_units_
197  logical :: single_
198  integer :: mode
199  integer :: error
200 
201  intrinsic size
202 
203  if ( present(time_units) ) then
204  time_units_ = time_units
205  else
206  time_units_ = 'seconds'
207  end if
208 
209  mpi_myrank = myrank
210 
211  if ( present(single) ) then
212  if ( single .and. (myrank .ne. master) ) return
213  single_ = single
214  else
215  single_ = .false.
216  endif
217 
218  mode = file_fwrite
219  if ( present(append) ) then
220  if ( append ) mode = file_fappend
221  end if
222 
223  call filegetfid( &
224  fid, & ! (out)
225  existed, & ! (out)
226  basename, & ! (in)
227  mode, & ! (in)
228  single_ & ! (in)
229  )
230 
231  if ( existed ) return
232 
233  !--- append package header to the file
234  call filesetglobalattribute( fid, & ! (in)
235  "title", title ) ! (in)
236  call filesetglobalattribute( fid, & ! (in)
237  "source", source ) ! (in)
238  call filesetglobalattribute( fid, & ! (in)
239  "institution", institution ) ! (in)
240  call filesetglobalattribute( fid, & ! (in)
241  "myrank", (/myrank/) ) ! (in)
242  call filesetglobalattribute( fid, & ! (in)
243  "rankidx", rankidx ) ! (in)
244 
245  call file_set_tunits( fid, & ! (in)
246  time_units_, & ! (in)
247  error ) ! (out)
248  if ( error /= success_code ) then
249  call log('E', 'xxx failed to set time units')
250  end if
251 
252  return
int32_t file_set_tunits(int32_t fid, char *time_units)
Definition: gtool_netcdf.c:455
subroutine, public log(type, message)
Definition: dc_log.f90:133
Here is the call graph for this function:
Here is the caller graph for this function:

◆ filesetoption()

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

Definition at line 453 of file gtool_file.f90.

References file_set_option(), dc_log::log(), and gtool_file_h::success_code.

Referenced by gtool_history::historyaddvariable().

453  integer, intent(in) :: fid
454  character(LEN=*), intent(in) :: filetype
455  character(LEN=*), intent(in) :: key
456  character(LEN=*), intent(in) :: val
457 
458  integer error
459 
460  call file_set_option( fid, & ! (in)
461  filetype, key, val, & ! (in)
462  error ) ! (out)
463  if ( error /= success_code ) then
464  call log('E', 'xxx failed to set option')
465  end if
466 
467  return
subroutine, public log(type, message)
Definition: dc_log.f90:133
int32_t file_set_option(int32_t fid, char *filetype, char *key, char *val)
Definition: gtool_netcdf.c:146
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fileopen()

subroutine, public gtool_file::fileopen ( integer, intent(out)  fid,
character(len=*), intent(in)  basename,
integer, intent(in)  mode,
logical, intent(in), optional  single 
)

Definition at line 477 of file gtool_file.f90.

References gtool_file_h::already_existed_code, dc_types::dp, file_put_axis(), dc_log::log(), dc_types::sp, and gtool_file_h::success_code.

Referenced by filegetalldatainfo(), filegetdatainfo(), and filegetshape().

477  implicit none
478 
479  integer, intent(out) :: fid
480  character(LEN=*), intent( in) :: basename
481  integer, intent( in) :: mode
482  logical, intent( in), optional :: single
483 
484  logical :: existed
485  logical :: single_ = .false.
486 
487  if ( present(single) ) single_ = single
488 
489  call filegetfid( fid, & ! (out)
490  existed, & ! (out)
491  basename, mode, single_ ) ! (in)
492 
493  return
Here is the call graph for this function:
Here is the caller graph for this function:

◆ filedefaxis()

subroutine, public gtool_file::filedefaxis ( 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 
)

Definition at line 564 of file gtool_file.f90.

References gtool_file_h::already_existed_code, dc_types::dp, file_def_axis(), file_put_associated_coordinates(), file_write_axis(), dc_log::log(), dc_types::sp, and gtool_file_h::success_code.

Referenced by scale_fileio::fileio_def_axes(), and gtool_history::historyaddvariable().

564  integer, intent(in) :: fid
565  character(len=*), intent(in) :: name
566  character(len=*), intent(in) :: desc
567  character(len=*), intent(in) :: units
568  character(len=*), intent(in) :: dim_name
569  integer, intent(in) :: dtype
570  integer, intent(in) :: dim_size
571 
572  integer error
573  intrinsic size
574 
575  call file_def_axis( fid, name, desc, units, dim_name, dtype, dim_size, & ! (in)
576  error ) ! (out)
577  if ( error /= success_code .and. error /= already_existed_code ) then
578  call log('E', 'xxx failed to define axis')
579  end if
580 
581  return
int32_t file_def_axis(int32_t fid, char *name, char *desc, char *units, char *dim_name, int32_t dtype, int32_t dim_size)
Definition: gtool_netcdf.c:546
subroutine, public log(type, message)
Definition: dc_log.f90:133
Here is the call graph for this function:
Here is the caller graph for this function:

◆ filedefassociatedcoordinates()

subroutine, public gtool_file::filedefassociatedcoordinates ( 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 869 of file gtool_file.f90.

References gtool_file_h::already_existed_code, dc_types::dp, file_add_variable(), file_def_associated_coordinates(), file_write_associated_coordinates(), dc_log::log(), dc_types::sp, and gtool_file_h::success_code.

Referenced by scale_fileio::fileio_def_axes(), and gtool_history::historyaddvariable().

869  integer, intent(in) :: fid
870  character(len=*), intent(in) :: name
871  character(len=*), intent(in) :: desc
872  character(len=*), intent(in) :: units
873  character(len=*), intent(in) :: dim_names(:)
874  integer, intent(in) :: dtype
875 
876  integer error
877  intrinsic size
878 
879  call file_def_associated_coordinates( fid, & ! (in)
880  name, desc, units, dim_names, size(dim_names), dtype, & ! (in)
881  error ) ! (out)
882  if ( error /= success_code .and. error /= already_existed_code ) then
883  call log('E', 'xxx failed to put associated coordinates')
884  end if
885 
886  return
subroutine, public log(type, message)
Definition: dc_log.f90:133
int32_t file_def_associated_coordinates(int32_t fid, char *name, char *desc, char *units, char **dim_names, int32_t ndims, int32_t dtype)
Definition: gtool_netcdf.c:673
Here is the call graph for this function:
Here is the caller graph for this function:

◆ filedefinevariable()

subroutine, public gtool_file::filedefinevariable ( integer, intent(in)  fid,
integer, intent(out)  vid,
character(len=*), intent(in)  varname,
character(len=*), intent(in)  desc,
character(len=*), intent(in)  units,
integer, intent(in)  ndims,
character(len=*), dimension(:), intent(in)  dims,
integer, intent(in)  dtype,
real(dp), intent(in), optional  tint,
logical, intent(in), optional  tavg 
)

Definition at line 1229 of file gtool_file.f90.

References file_add_variable(), dc_log::log(), and gtool_file_h::success_code.

Referenced by scale_fileio::fileio_def_var().

1229  integer, intent(out) :: vid
1230  integer, intent( in) :: fid
1231  character(len=*), intent( in) :: varname
1232  character(len=*), intent( in) :: desc
1233  character(len=*), intent( in) :: units
1234  integer, intent( in) :: ndims
1235  character(len=*), intent( in) :: dims(:)
1236  integer, intent( in) :: dtype
1237  real(DP), intent( in), optional :: tint
1238  logical, intent( in), optional :: tavg
1239 
1240  real(DP) :: tint_
1241  integer :: itavg
1242  integer :: error
1243  integer :: n
1244 
1245  intrinsic size
1246  !---------------------------------------------------------------------------
1247 
1248  vid = -1
1249  do n = 1, file_vid_count
1250  if ( file_vid_fid_list(n) == fid .and. &
1251  varname == file_vname_list(n) ) then
1252  vid = file_vid_list(n)
1253  end if
1254  enddo
1255 
1256  if ( vid < 0 ) then ! variable registration
1257  !--- register new variable
1258  write(message,*) '*** [File] Var registration'
1259  call log("I", message)
1260  write(message,*) '*** variable name: ', trim(varname)
1261  call log("I", message)
1262 
1263  if ( .NOT. present(tint) ) then
1264  tint_ = -1.0_dp
1265  endif
1266 
1267  if ( present(tavg) ) then
1268  if ( tavg ) then
1269  itavg = 1
1270  else
1271  itavg = 0
1272  end if
1273  else
1274  itavg = 0
1275  end if
1276 
1277  call file_add_variable( vid, & ! (out)
1278  fid, varname, desc, units, dims, ndims, dtype, & ! (in)
1279  tint_, itavg, & ! (in)
1280  error ) ! (out)
1281  if ( error /= success_code ) then
1282  call log('E', 'xxx failed to add variable: '//trim(varname))
1283  end if
1284 
1285  file_vname_list(file_vid_count) = trim(varname)
1286  file_vid_list(file_vid_count) = vid
1287  file_vid_fid_list(file_vid_count) = fid
1288  file_vid_count = file_vid_count + 1
1289  endif
1290 
1291  return
subroutine, public log(type, message)
Definition: dc_log.f90:133
int32_t file_add_variable(int32_t *vid, int32_t fid, char *varname, char *desc, char *units, char **dims, int32_t ndims, int32_t dtype, real64_t tint, int32_t tavg)
Definition: gtool_netcdf.c:746
Here is the call graph for this function:
Here is the caller graph for this function:

◆ filesettattr()

subroutine, public gtool_file::filesettattr ( integer, intent(in)  fid,
character(len=*), intent(in)  vname,
character(len=*), intent(in)  key,
character(len=*), intent(in)  val 
)

Definition at line 1303 of file gtool_file.f90.

References gtool_file_h::already_existed_code, file_set_tattr(), dc_log::log(), and gtool_file_h::success_code.

Referenced by scale_fileio::fileio_def_axes(), scale_fileio::fileio_set_axes(), gtool_history::historyaddvariable(), and gtool_history::historysettattr().

1303  integer, intent(in) :: fid
1304  character(len=*), intent(in) :: vname
1305  character(len=*), intent(in) :: key
1306  character(len=*), intent(in) :: val
1307 
1308  integer :: error
1309 
1310  call file_set_tattr( &
1311  fid, vname, & ! (in)
1312  key, val, & ! (in)
1313  error ) ! (out)
1314  if ( error /= success_code .and. error /= already_existed_code ) then
1315  call log('E', 'xxx failed to set attr for axis')
1316  end if
1317 
1318  return
int32_t file_set_tattr(int32_t fid, char *vname, char *key, char *val)
Definition: gtool_netcdf.c:463
subroutine, public log(type, message)
Definition: dc_log.f90:133
Here is the call graph for this function:
Here is the caller graph for this function:

◆ filegetshape()

subroutine, public gtool_file::filegetshape ( integer, dimension(:), intent(out)  dims,
character(len=*), intent(in)  basename,
character(len=*), intent(in)  varname,
integer, intent(in)  myrank,
logical, intent(in), optional  single 
)

Definition at line 1331 of file gtool_file.f90.

References gtool_file_h::file_fread, file_get_datainfo(), fileopen(), dc_log::log(), and gtool_file_h::success_code.

Referenced by mod_realinput_nicam::parentatomsetupnicam(), mod_realinput_nicam::parentlandsetupnicam(), mod_realinput_nicam::parentoceansetupnicam(), and mod_mkinit::read_sounding().

1331  implicit none
1332 
1333  integer, intent(out) :: dims(:)
1334  character(LEN=*), intent( in) :: basename
1335  character(LEN=*), intent( in) :: varname
1336  integer, intent( in) :: myrank
1337  logical, intent( in), optional :: single
1338 
1339  integer :: fid
1340  type(datainfo) :: dinfo
1341  integer :: error
1342  integer :: n
1343 
1344  logical :: single_ = .false.
1345 
1346  intrinsic size
1347  intrinsic shape
1348  !---------------------------------------------------------------------------
1349 
1350  mpi_myrank = myrank
1351 
1352  if ( present(single) ) single_ = single
1353 
1354  !--- search/register file
1355  call fileopen( fid, & ! (out)
1356  basename, file_fread, single_ ) ! (in)
1357 
1358  !--- get data information
1359  call file_get_datainfo( dinfo, & ! (out)
1360  fid, varname, 1, .false., & ! (in)
1361  error ) ! (out)
1362 
1363  !--- verify
1364  if ( error /= success_code ) then
1365  call log('E', 'xxx failed to get data information :'//trim(varname))
1366  end if
1367 
1368  if ( dinfo%rank /= size(dims) ) then
1369  write(message,*) 'xxx rank is different, ', size(dims), dinfo%rank
1370  call log('E', message)
1371  end if
1372  do n = 1, size(dims)
1373  dims(n) = dinfo%dim_size(n)
1374  end do
1375 
1376  return
int32_t file_get_datainfo(datainfo_t *dinfo, int32_t fid, char *varname, int32_t step, int32_t suppress)
Definition: gtool_netcdf.c:162
subroutine, public log(type, message)
Definition: dc_log.f90:133
Here is the call graph for this function:
Here is the caller graph for this function:

◆ filegetdatainfo()

subroutine, public gtool_file::filegetdatainfo ( character(len=*), intent(in)  basename,
character(len=*), intent(in)  varname,
integer, intent(in)  myrank,
integer, intent(in)  istep,
logical, intent(in), optional  single,
character(len=file_hmid), intent(out), optional  description,
character(len=file_hshort), intent(out), optional  units,
integer, intent(out), optional  datatype,
integer, intent(out), optional  dim_rank,
character(len=file_hshort), dimension(:), intent(out), optional  dim_name,
integer, dimension(:), intent(out), optional  dim_size,
real(dp), intent(out), optional  time_start,
real(dp), intent(out), optional  time_end,
character(len=file_hmid), intent(out), optional  time_units 
)

Definition at line 1397 of file gtool_file.f90.

References gtool_file_h::file_fread, file_get_datainfo(), fileopen(), dc_log::log(), and gtool_file_h::success_code.

Referenced by mod_admin_time::admin_time_setup().

1397  implicit none
1398  character(len=*), intent(in) :: basename
1399  character(len=*), intent(in) :: varname
1400  integer, intent(in) :: myrank
1401  integer, intent(in) :: istep
1402  logical, intent(in), optional :: single
1403 
1404  character(len=File_HMID), intent(out), optional :: description
1405  character(len=File_HSHORT), intent(out), optional :: units
1406  integer, intent(out), optional :: datatype
1407  integer, intent(out), optional :: dim_rank
1408  character(len=File_HSHORT), intent(out), optional :: dim_name(:)
1409  integer, intent(out), optional :: dim_size(:)
1410  real(DP), intent(out), optional :: time_start
1411  real(DP), intent(out), optional :: time_end
1412  character(len=File_HMID), intent(out), optional :: time_units
1413 
1414  integer :: fid
1415  type(datainfo) :: dinfo
1416 
1417  integer :: ndim, idim
1418  real(DP):: time(1)
1419 
1420  integer :: error
1421  logical :: single_ = .false.
1422 
1423  intrinsic size
1424  !---------------------------------------------------------------------------
1425 
1426  mpi_myrank = myrank
1427 
1428  if ( present(single) ) single_ = single
1429 
1430  !--- search/register file
1431  call fileopen( fid, & ! [OUT]
1432  basename, & ! [IN]
1433  file_fread, & ! [IN]
1434  single_ ) ! [IN]
1435 
1436  !--- get data information
1437  call file_get_datainfo( dinfo, & ! [OUT]
1438  fid, & ! [IN]
1439  varname, & ! [IN]
1440  istep, & ! [IN]
1441  .false., & ! [IN]
1442  error ) ! [OUT]
1443 
1444  !--- verify and exit
1445  if ( error /= success_code ) then
1446  call log('E', 'xxx data info not found in '//trim(basename))
1447  endif
1448 
1449  if ( present(description) ) description = dinfo%description
1450  if ( present(units) ) units = dinfo%units
1451  if ( present(datatype) ) datatype = dinfo%datatype
1452  if ( present(dim_rank) ) dim_rank = dinfo%rank
1453 
1454  if ( present(dim_name) ) then
1455  ndim = min( dinfo%rank, size(dim_name) ) ! limit dimension rank
1456  do idim = 1, ndim
1457  dim_name(idim) = dinfo%dim_name(idim)
1458  enddo
1459  end if
1460  if ( present(dim_size) ) then
1461  ndim = min( dinfo%rank, size(dim_size) ) ! limit dimension rank
1462  do idim = 1, ndim
1463  dim_size(idim) = dinfo%dim_size(idim)
1464  enddo
1465  end if
1466 
1467  if ( present(time_units) ) then
1468  if ( dinfo%time_units == "" ) then
1469  call filegetglobalattribute( fid, "time_units", time_units )
1470  else
1471  time_units = dinfo%time_units
1472  end if
1473  end if
1474  if ( present(time_start) ) then
1475  if ( dinfo%time_units == "" ) then
1476  call filegetglobalattribute( fid, "time", time )
1477  time_start = time(1)
1478  else
1479  time_start = dinfo%time_start
1480  end if
1481  end if
1482  if ( present(time_end) ) then
1483  if ( dinfo%time_units == "" ) then
1484  call filegetglobalattribute( fid, "time", time )
1485  time_end = time(1)
1486  else
1487  time_end = dinfo%time_end
1488  end if
1489  end if
1490 
1491  return
int32_t file_get_datainfo(datainfo_t *dinfo, int32_t fid, char *varname, int32_t step, int32_t suppress)
Definition: gtool_netcdf.c:162
subroutine, public log(type, message)
Definition: dc_log.f90:133
Here is the call graph for this function:
Here is the caller graph for this function:

◆ filegetalldatainfo()

subroutine, public gtool_file::filegetalldatainfo ( integer, intent(in)  step_limit,
integer, intent(in)  dim_limit,
character(len=*), intent(in)  basename,
character(len=*), intent(in)  varname,
integer, intent(in)  myrank,
integer, intent(out)  step_nmax,
character(len=file_hmid), intent(out)  description,
character(len=file_hshort), intent(out)  units,
integer, intent(out)  datatype,
integer, intent(out)  dim_rank,
character(len=file_hshort), dimension (dim_limit), intent(out)  dim_name,
integer, dimension (dim_limit), intent(out)  dim_size,
real(dp), dimension(step_limit), intent(out)  time_start,
real(dp), dimension (step_limit), intent(out)  time_end,
character(len=file_hmid), intent(out)  time_units,
logical, intent(in), optional  single 
)

Definition at line 1514 of file gtool_file.f90.

References dc_types::dp, gtool_file_h::file_fread, file_get_datainfo(), file_read_data(), file_write_data(), file_write_var(), fileopen(), dc_log::log(), rmiss, dc_types::sp, and gtool_file_h::success_code.

Referenced by scale_external_input::extin_setup().

1514  implicit none
1515 
1516  integer, intent(in) :: step_limit
1517  integer, intent(in) :: dim_limit
1518  character(len=*), intent(in) :: basename
1519  character(len=*), intent(in) :: varname
1520  integer, intent(in) :: myrank
1521  integer, intent(out) :: step_nmax
1522  character(len=File_HMID), intent(out) :: description
1523  character(len=File_HSHORT), intent(out) :: units
1524  integer, intent(out) :: datatype
1525  integer, intent(out) :: dim_rank
1526  character(len=File_HSHORT), intent(out) :: dim_name (dim_limit)
1527  integer, intent(out) :: dim_size (dim_limit)
1528  real(DP), intent(out) :: time_start(step_limit)
1529  real(DP), intent(out) :: time_end (step_limit)
1530  character(len=File_HMID), intent(out) :: time_units
1531 
1532  logical, intent(in), optional :: single
1533 
1534  integer :: fid
1535  type(datainfo) :: dinfo
1536 
1537  integer :: ndim
1538  integer :: istep, idim
1539  logical :: flag_first = .true.
1540 
1541  integer :: error
1542  logical :: single_ = .false.
1543  !---------------------------------------------------------------------------
1544 
1545  mpi_myrank = myrank
1546 
1547  if ( present(single) ) single_ = single
1548 
1549  !--- search/register file
1550  call fileopen( fid, & ! [OUT]
1551  basename, & ! [IN]
1552  file_fread, & ! [IN]
1553  single_ ) ! [IN]
1554 
1555  ! initialize
1556  description = ""
1557  units = ""
1558  datatype = -1
1559  dim_rank = -1
1560  dim_name(:) = ""
1561  dim_size(:) = -1
1562  time_start(:) = rmiss
1563  time_end(:) = rmiss
1564 
1565  do istep = 1, step_limit
1566  !--- get data information
1567  call file_get_datainfo( dinfo, & ! [OUT]
1568  fid, & ! [IN]
1569  varname, & ! [IN]
1570  istep, & ! [IN]
1571  .true., & ! [IN]
1572  error ) ! [OUT]
1573 
1574  !--- verify and exit
1575  if ( error /= success_code ) then
1576  step_nmax = istep - 1
1577  exit
1578  endif
1579 
1580  if ( flag_first ) then
1581  flag_first = .false.
1582 
1583  description = dinfo%description
1584  units = dinfo%units
1585  datatype = dinfo%datatype
1586  dim_rank = dinfo%rank
1587 
1588  ndim = min( dinfo%rank, dim_limit ) ! limit dimension rank
1589  do idim = 1, ndim
1590  dim_name(idim) = dinfo%dim_name(idim)
1591  dim_size(idim) = dinfo%dim_size(idim)
1592  enddo
1593 
1594  time_units = dinfo%time_units
1595  endif
1596 
1597  time_start(istep) = dinfo%time_start
1598  time_end(istep) = dinfo%time_end
1599  enddo
1600 
1601  return
int32_t file_get_datainfo(datainfo_t *dinfo, int32_t fid, char *varname, int32_t step, int32_t suppress)
Definition: gtool_netcdf.c:162
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fileenddef()

subroutine, public gtool_file::fileenddef ( integer, intent(in)  fid)

Definition at line 2844 of file gtool_file.f90.

References file_enddef(), dc_log::log(), and gtool_file_h::success_code.

Referenced by scale_fileio::fileio_enddef(), and gtool_history::historywriteaxes().

2844  implicit none
2845 
2846  integer, intent(in) :: fid
2847 
2848  integer :: error, n
2849  !---------------------------------------------------------------------------
2850 
2851  if ( fid < 0 ) return
2852 
2853  do n = 1, file_fid_count-1
2854  if ( file_fid_list(n) == fid ) exit
2855  end do
2856  if ( fid .NE. file_fid_list(n) ) then
2857  write(message,*) 'xxx in FileEndDef invalid fid' , fid
2858  call log('E', message)
2859  end if
2860  call file_enddef( fid , & ! (in)
2861  error ) ! (out)
2862  if ( error .EQ. success_code ) then
2863  write(message, '(1x,A,i3)') '*** [File] File enddef : NO.', n
2864  call log('I', message)
2865  call log('I', '*** enddef filename: ' // trim(file_fname_list(n)))
2866  else
2867  call log('E', 'xxx failed to exit define mode')
2868  end if
2869 
2870  return
int32_t file_enddef(int32_t fid)
subroutine, public log(type, message)
Definition: dc_log.f90:133
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fileclose()

subroutine, public gtool_file::fileclose ( integer, intent(in)  fid)

Definition at line 2877 of file gtool_file.f90.

References gtool_file_h::already_closed_code, file_close(), dc_log::log(), and gtool_file_h::success_code.

Referenced by filecloseall(), scale_fileio::fileio_close(), and gtool_history::historyfinalize().

2877  implicit none
2878 
2879  integer, intent(in) :: fid
2880 
2881  character(LEN=File_HLONG) :: fname
2882  integer :: error
2883  integer :: n
2884  !---------------------------------------------------------------------------
2885 
2886  if ( fid < 0 ) return
2887 
2888  do n = 1, file_fid_count-1
2889  if ( file_fid_list(n) == fid ) exit
2890  end do
2891  if ( n .EQ. file_fid_count ) return ! already closed
2892 
2893  if ( fid /= file_fid_list(n) ) then
2894  write(message,*) 'xxx in FileClose invalid fid ', fid
2895  call log('E', message)
2896  end if
2897  call file_close( fid , & ! (in)
2898  error ) ! (out)
2899  if ( error == success_code ) then
2900  write(message, '(1x,A,i3)') '*** [File] File Close : NO.', n
2901  call log('I', message)
2902  call log('I', '*** closed filename: ' // trim(file_fname_list(n)))
2903  else if ( error /= already_closed_code ) then
2904  call log('E', 'xxx failed to close file')
2905  end if
2906 
2907  do n = 1, file_fid_count-1
2908  if ( file_fid_list(n) == fid ) then
2909  file_fid_list(n) = -1
2910  file_fname_list(n) = ''
2911  end if
2912  end do
2913 
2914  return
subroutine, public log(type, message)
Definition: dc_log.f90:133
int32_t file_close(int32_t fid)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ filecloseall()

subroutine, public gtool_file::filecloseall ( )

Definition at line 2918 of file gtool_file.f90.

References fileclose().

Referenced by scale_process::prc_mpitimestat(), mod_rm_driver::scalerm(), scalerm_launcher(), and mod_rm_prep::scalerm_prep().

2918  implicit none
2919 
2920  integer n
2921  !---------------------------------------------------------------------------
2922 
2923  do n = 1, file_fid_count-1
2924  call fileclose( file_fid_list(n) )
2925  enddo
2926 
2927  return
Here is the call graph for this function:
Here is the caller graph for this function:

◆ filemakefname()

subroutine, public gtool_file::filemakefname ( character(len=*), intent(out)  fname,
character(len=*), intent(in)  basename,
character(len=*), intent(in)  prefix,
integer, intent(in)  myrank,
integer, intent(in)  len 
)

Definition at line 2939 of file gtool_file.f90.

References file_open(), dc_log::log(), and gtool_file_h::success_code.

Referenced by scale_external_io::externalfilereadoffset4drealdp().

2939  character(len=*), intent(out) :: fname
2940  character(len=*), intent( in) :: basename
2941  character(len=*), intent( in) :: prefix
2942  integer, intent( in) :: myrank
2943  integer, intent( in) :: len
2944 
2945  ! 12345678901234567
2946  character(len=17) :: fmt = "(A, '.', A, I*.*)"
2947  !---------------------------------------------------------------------------
2948 
2949  if ( len < 1 .or. len > 9 ) then
2950  call log('E', 'xxx len is invalid')
2951  end if
2952 
2953  write(fmt(14:14),'(I1)') len
2954  write(fmt(16:16),'(I1)') len
2955  write(fname, fmt) trim(basename), trim(prefix), myrank
2956 
2957  return
subroutine, public log(type, message)
Definition: dc_log.f90:133
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ rmiss

real(dp), parameter, public gtool_file::rmiss = -9.9999e+30