11#include "scaleFElib.h"
19 use scale_prc,
only: &
22 use scale_file_h,
only: &
67 type :: file_restart_meshfield
68 type(FILE_base_meshfield),
pointer :: file_ptr => null()
69 logical :: is_file_ptr_main
71 logical :: flag_output
72 character(len=H_LONG) :: in_basename
73 logical :: in_postfix_timelabel
75 character(len=H_LONG) :: out_basename
76 logical :: out_postfix_timelabel
77 character(len=H_MID) :: out_title
78 character(len=H_SHORT) :: out_dtype
80 procedure,
private :: Set_information => file_restart_meshfield_component_set_information
81 end type file_restart_meshfield
86 integer :: registered_comp_id
88 procedure :: init1 => file_restart_meshfield_component_init1
89 procedure :: init2 => file_restart_meshfield_component_init2
90 generic :: init => init1, init2
91 procedure :: open => file_restart_meshfield_component_open
92 procedure :: file_restart_meshfield_component_create
93 generic :: create => file_restart_meshfield_component_create
94 procedure :: file_restart_meshfield_component_def_var
95 generic :: def_var => file_restart_meshfield_component_def_var
96 procedure :: end_def => file_restart_meshfield_component_enddef
97 procedure :: file_restart_meshfield_component_write_var2d
98 procedure :: file_restart_meshfield_component_write_var3d
99 generic :: write_var => &
100 file_restart_meshfield_component_write_var2d, &
101 file_restart_meshfield_component_write_var3d
102 procedure :: close => file_restart_meshfield_component_close
103 procedure :: file_restart_meshfield_component_read_var2d
104 procedure :: file_restart_meshfield_component_read_var3d
105 generic :: read_var => &
106 file_restart_meshfield_component_read_var2d, &
107 file_restart_meshfield_component_read_var3d
108 procedure :: final => file_restart_meshfield_component_final
126 logical :: is_file_main_opened
127 logical :: is_file_main_created
128 logical :: is_file_main_enddef
129 logical :: is_file_main_closed
139 logical :: output_flag = .false.
140 character(len=H_LONG) :: in_basename =
''
141 logical :: in_postfix_timelabel = .false.
142 character(len=H_LONG) :: out_basename =
''
143 logical :: out_postfix_timelabel = .true.
144 character(len=H_MID) :: out_title =
''
145 character(len=H_SHORT) :: out_dtype =
'DEFAULT'
147 namelist / param_restart / &
150 in_postfix_timelabel, &
152 out_postfix_timelabel, &
163 read(io_fid_conf,nml=param_restart,iostat=ierr)
165 log_info(
"FILE_restart_meshfield_setup",*)
'Not found namelist. Default used.'
166 elseif( ierr > 0 )
then
167 log_error(
"FILE_restart_meshfield_setup",*)
'Not appropriate names in namelist PARAM_RESTART. Check!'
170 log_nml(param_restart)
174 call restart_file%Set_information( in_basename, in_postfix_timelabel, &
175 out_basename, out_postfix_timelabel, out_dtype, out_title )
180 is_file_main_opened = .false.
181 is_file_main_created = .false.
182 is_file_main_enddef = .false.
183 is_file_main_closed = .false.
202 subroutine file_restart_meshfield_component_init1( this, &
203 comp_name, var_num, dim_name_postfix, &
204 mesh1D, mesh2D, meshCubedSphere2D, &
205 mesh3D, meshCubedSphere3D )
212 character(*),
intent(in) :: comp_name
213 integer,
intent(in) :: var_num
214 character(len=*),
optional,
intent(in) :: dim_name_postfix
215 class(
meshbase1d),
target,
optional,
intent(in) :: mesh1d
221 character(len=H_SHORT) :: dim_name_postfix_
226 if (
present(dim_name_postfix))
then
227 dim_name_postfix_ = trim(dim_name_postfix)
229 dim_name_postfix_ =
""
234 call file_main%Init( var_num, comp_name, dim_name_postfix_, &
235 mesh1d, mesh2d, meshcubedsphere2d, mesh3d, meshcubedsphere3d )
239 this%registered_comp_id = 1
242 call file_main%Register_comp( this%registered_comp_id, &
243 comp_name, var_num, dim_name_postfix_, &
244 mesh1d, mesh2d, meshcubedsphere2d, mesh3d, meshcubedsphere3d )
248 this%is_file_ptr_main = .true.
251 call this%Set_information( &
257 end subroutine file_restart_meshfield_component_init1
263 subroutine file_restart_meshfield_component_init2( this, &
265 in_basename, in_postfix_timelabel, &
266 out_basename, out_postfix_timelabel, &
267 out_dtype, out_title, &
268 var_num, dim_name_postfix, &
270 mesh2D, meshCubedSphere2D, &
271 mesh3D, meshCubedSphere3D )
276 character(*),
intent(in) :: comp_name
277 character(*),
intent(in) :: in_basename
278 logical,
intent(in) :: in_postfix_timelabel
279 character(*),
intent(in) :: out_basename
280 logical,
intent(in) :: out_postfix_timelabel
281 character(*),
intent(in) :: out_title
282 character(*),
intent(in) :: out_dtype
283 integer,
intent(in) :: var_num
284 character(len=*),
intent(in) :: dim_name_postfix
285 class(
meshbase1d),
target,
optional,
intent(in) :: mesh1d
292 call this%Set_information( in_basename, in_postfix_timelabel, &
293 out_basename, out_postfix_timelabel, out_dtype, out_title )
295 if ( .not.
associated(this%file_ptr) )
then
298 allocate( this%file_ptr )
299 call this%file_ptr%Init( var_num, comp_name, dim_name_postfix, &
300 mesh1d, mesh2d, meshcubedsphere2d, mesh3d, meshcubedsphere3d )
302 this%registered_comp_id = 1
303 this%is_file_ptr_main = .false.
305 log_info(
"FILE_restart_meshfield_component_Init2",*)
'File object for this component is already associated, which is unexpected. Check!'
310 end subroutine file_restart_meshfield_component_init2
314 subroutine file_restart_meshfield_component_open( &
317 use scale_time,
only: &
323 character(len=19) :: timelabel
324 character(len=H_LONG) :: basename
327 if ( this%in_basename ==
'' )
then
328 log_info(
"FILE_restart_meshfield_component_open",*)
'Restart file is not specified. Check!'
333 if ( this%is_file_ptr_main )
then
334 if ( is_file_main_opened )
then
335 log_info(
"FILE_restart_meshfield_component_open",*)
'Main restart file is already opened. Skipping opening.'
337 is_file_main_opened = .true.
343 if ( this%in_postfix_timelabel )
then
344 call time_gettimelabel( timelabel )
345 basename = trim(this%in_basename)//
'_'//trim(timelabel)
347 basename = trim(this%in_basename)
353 log_info(
"FILE_restart_meshfield_component_open",*)
'Open restart file'
354 call this%file_ptr%open( basename, myrank=prc_myrank )
357 end subroutine file_restart_meshfield_component_open
361 subroutine file_restart_meshfield_component_create( &
364 use scale_time,
only: &
366 nowdate => time_nowdate, &
367 nowsubsec => time_nowsubsec
372 character(len=19) :: timelabel
373 character(len=H_LONG) :: basename
374 character(len=34) :: tunits
375 character(len=H_SHORT) :: calendar
376 logical :: fileexisted
379 if ( this%out_basename ==
'' )
return
381 if ( this%is_file_ptr_main )
then
382 if ( is_file_main_created )
then
383 log_info(
"FILE_restart_meshfield_component_create",*)
'Main restart file is already created. Skipping creation.'
385 is_file_main_created = .true.
392 log_info(
"FILE_restart_meshfield_component_create",*)
'Create restart file'
394 if ( this%out_postfix_timelabel )
then
395 call time_gettimelabel( timelabel )
396 basename = trim(this%out_basename)//
'_'//trim(timelabel)
398 basename = trim(this%out_basename)
401 log_info(
"FILE_restart_meshfield_component_create",*)
'basename: ', trim(basename)
404 call this%file_ptr%Create( basename, this%out_title, this%out_dtype, &
406 myrank=prc_myrank, tunits=tunits, calendar=calendar )
408 if ( .not. fileexisted )
then
409 call this%file_ptr%Put_GlobalAttribute_time( nowdate, nowsubsec )
413 end subroutine file_restart_meshfield_component_create
417 subroutine file_restart_meshfield_component_def_var( this, &
418 field, desc, vid, dim_type_id )
423 character(len=*),
intent(in) :: desc
424 integer,
intent(in) :: vid
425 integer,
intent(in) :: dim_type_id
428 call this%file_ptr%Def_var( &
429 field, desc, vid, dim_type_id, this%out_dtype, &
430 comp_id=this%registered_comp_id )
433 end subroutine file_restart_meshfield_component_def_var
437 subroutine file_restart_meshfield_component_enddef( this )
442 if ( this%is_file_ptr_main )
then
443 if ( is_file_main_enddef )
then
444 log_info(
"FILE_restart_meshfield_component_enddef",*)
'Main restart file is already in enddef mode. Skipping enddef.'
446 is_file_main_enddef = .true.
450 call this%file_ptr%End_def()
452 end subroutine file_restart_meshfield_component_enddef
456 subroutine file_restart_meshfield_component_write_var2d( this, &
459 use scale_time,
only: time_nowdaysec
463 integer,
intent(in) :: vid
467 call this%file_ptr%Write_var2D( vid, field2d, time_nowdaysec, time_nowdaysec, &
468 comp_id=this%registered_comp_id )
471 end subroutine file_restart_meshfield_component_write_var2d
475 subroutine file_restart_meshfield_component_write_var3d( this, &
478 use scale_time,
only: time_nowdaysec
482 integer,
intent(in) :: vid
486 call this%file_ptr%Write_var3D( vid, field3d, time_nowdaysec, time_nowdaysec, &
487 comp_id=this%registered_comp_id )
490 end subroutine file_restart_meshfield_component_write_var3d
494 subroutine file_restart_meshfield_component_read_var2d( this, &
495 dim_typeid, varname, field2d, step, allow_missing )
501 integer,
intent(in) :: dim_typeid
502 character(*),
intent(in) :: varname
504 integer,
intent(in),
optional :: step
505 logical,
intent(in),
optional :: allow_missing
508 call this%file_ptr%Read_Var( &
509 dim_typeid, varname, field2d, step, allow_missing, &
510 comp_id=this%registered_comp_id )
513 end subroutine file_restart_meshfield_component_read_var2d
517 subroutine file_restart_meshfield_component_read_var3d( this, &
518 dim_typeid, varname, field3d, step, allow_missing )
524 integer,
intent(in) :: dim_typeid
525 character(*),
intent(in) :: varname
527 integer,
intent(in),
optional :: step
528 logical,
intent(in),
optional :: allow_missing
531 call this%file_ptr%Read_Var( &
532 dim_typeid, varname, field3d, step, allow_missing, &
533 comp_id=this%registered_comp_id )
536 end subroutine file_restart_meshfield_component_read_var3d
540 subroutine file_restart_meshfield_component_close( this )
546 if ( this%is_file_ptr_main )
then
547 if ( is_file_main_closed )
then
548 log_info(
"FILE_restart_meshfield_component_close",*)
'Main restart file is already closed. Skipping closure.'
550 is_file_main_closed = .true.
554 if ( this%file_ptr%fid /= -1 )
then
556 log_info(
"FILE_restart_meshfield_component_close",*)
'Close restart file'
557 call this%file_ptr%Close()
561 end subroutine file_restart_meshfield_component_close
565 subroutine file_restart_meshfield_component_final( this )
572 if ( .not. this%is_file_ptr_main )
then
573 call this%file_ptr%Final()
574 deallocate( this%file_ptr )
577 nullify( this%file_ptr )
579 end subroutine file_restart_meshfield_component_final
585 subroutine file_restart_meshfield_component_set_information( this, &
586 in_basename, in_postfix_timelabel, &
587 out_basename, out_postfix_timelabel, &
588 out_dtype, out_title )
591 class(file_restart_meshfield),
intent(inout) :: this
592 character(*),
intent(in) :: in_basename
593 logical,
intent(in) :: in_postfix_timelabel
594 character(*),
intent(in) :: out_basename
595 logical,
intent(in) :: out_postfix_timelabel
596 character(*),
intent(in) :: out_title
597 character(*),
intent(in) :: out_dtype
600 this%in_basename = in_basename
601 this%in_postfix_timelabel = in_postfix_timelabel
603 this%out_basename = out_basename
604 this%out_postfix_timelabel = out_postfix_timelabel
605 this%out_title = out_title
606 this%out_dtype = out_dtype
608 end subroutine file_restart_meshfield_component_set_information
module FElib / Element / Base
module FElib / File / Base
module FElib / File / Common
module FElib / File / Restart
subroutine, public file_restart_meshfield_finalize()
Finalize the main restart file.
type(file_base_meshfield), target file_main
A file object to manage main restart file.
subroutine, public file_restart_meshfield_setup()
Setup the main restart file.
type(file_restart_meshfield), public restart_file
An object to manage main restart file.
module FElib / Mesh / Local 1D
module FElib / Mesh / Local 2D
module FElib / Mesh / Local 3D
module FElib / Mesh / Base 1D
integer, public meshbase1d_dimtype_num
integer, public meshbase1d_dimtypeid_x
module FElib / Mesh / Base 2D
integer, public meshbase2d_dimtypeid_x
integer, public meshbase2d_dimtype_num
integer, public meshbase2d_dimtypeid_y
module FElib / Mesh / Base 3D
integer, public meshbase3d_dimtypeid_y
integer, public meshbase3d_dimtypeid_z
integer, public meshbase3d_dimtype_num
integer, public meshbase3d_dimtypeid_x
module FElib / Mesh / Cubic 3D domain
module FElib / Mesh / Cubed-sphere 2D domain
module FElib / Mesh / Cubed-sphere 3D domain
module FElib / Mesh / Rectangle 2D domain
module FElib / Data / base
module FElib / Data / base
Derived type representing a 1D reference element.
Derived type representing a 2D reference element.
Derived type representing a 3D reference element.
Derived type to manage file output with MeshField data.
Derived type to manage restart file with each component.
Derived type representing a local mesh for 1D domain.
Derived type representing a local mesh for 2D domain.
Derived type to manage a local 3D computational domain.
Derived type to manage a computational mesh (base type for 1D domain)
Derived type to manage a computational mesh (base type for 2D domain)
Derived type to manage a computational mesh (base type for 3D domain)
Derived type to manage a cubic 3D computational domain.
Derived type to manage a cubed-sphere 2D computational domain.
Derived type to manage a cubed-sphere 3D computational domain.
Derived type to manage a rectangular 2D computational domain.
Derived type representing a field with 1D mesh.
Derived type representing a field with 2D mesh.
Derived type representing a field with 3D mesh.
Derived type representing a field (base type)