10#include "scaleFElib.h"
18 use scale_prc,
only: &
21 use scale_file_history,
only: &
23 file_history_set_nowdate, &
24 file_history_truncate_1d, &
25 file_history_truncate_2d, &
26 file_history_truncate_3d, &
29 file_history_set_dim, &
30 file_history_set_axis, &
58 integer,
parameter :: nzs = 1
60 type :: filehistorymeshfieldcomp
61 class(MeshBase1D),
pointer :: mesh1D
62 class(MeshRectDom2D),
pointer :: mesh2D
63 class(MeshCubeDom3D),
pointer :: mesh3D
64 class(MeshCubedSphereDom2D),
pointer :: meshCubedSphere2D
65 class(MeshCubedSphereDom3D),
pointer :: meshCubedSphere3D
67 integer :: dims1D_size(1)
68 integer :: dims2D_size(2)
69 integer :: dims3D_size(3,nzs)
71 character(len=H_SHORT) :: dim_name_postfix
73 procedure :: Init => filehistorymeshfieldcomp_init
74 procedure :: Final => filehistorymeshfieldcomp_final
75 procedure,
private :: set_dim_axis1D
76 procedure,
private :: set_dim_axis2D
77 procedure,
private :: set_dim_axis3D
78 procedure,
private :: set_dim_axis2D_cubedsphere
79 procedure,
private :: set_dim_axis3D_cubedsphere
80 end type filehistorymeshfieldcomp
92 module procedure file_history_meshfield_put1d
93 module procedure file_history_meshfield_put2d
94 module procedure file_history_meshfield_put3d
98 module procedure file_history_meshfield_in1d
99 module procedure file_history_meshfield_in2d
100 module procedure file_history_meshfield_in3d
111 private :: history_in_regvar
119 integer :: comp_num = 0
120 type(FileHistoryMeshFieldComp),
pointer :: default_comp
122 character(len=8),
parameter :: zs(nzs) = (/
"model " /)
124 integer :: FILE_HISTORY_MESHFIELD_STARTDATE(6)
125 real(DP) :: FILE_HISTORY_MESHFIELD_STARTSUBSEC
128 logical,
private :: FILE_HISTORY_FILEMESHFILED_DISABLE = .true.
134 subroutine filehistorymeshfieldcomp_init( this, &
135 mesh1D_, mesh2D_, mesh3D_, &
136 meshcubedsphere2D_, meshcubedsphere3D_, &
139 class(FileHistoryMeshFieldComp),
intent(inout) :: this
141 class(MeshBase1d),
intent(in),
target,
optional :: mesh1D_
142 class(MeshRectDom2d),
intent(in),
target,
optional :: mesh2D_
143 class(MeshCubeDom3D),
intent(in),
target,
optional :: mesh3D_
144 class(MeshCubedSphereDom2D),
intent(in),
target,
optional :: meshCubedsphere2D_
145 class(MeshCubedSphereDom3D),
intent(in),
target,
optional :: meshCubedsphere3D_
146 character(len=*),
intent(in),
optional :: dim_name_postfix
149 if (
present(dim_name_postfix) )
then
150 this%dim_name_postfix = dim_name_postfix
152 this%dim_name_postfix =
''
158 nullify( this%mesh1D, this%mesh2D, this%mesh3D )
159 nullify( this%meshCubedSphere2D, this%meshCubedsphere3D )
161 if (
present(mesh1d_) )
then
162 this%mesh1D => mesh1d_
163 call this%set_dim_axis1D()
164 else if (
present(mesh2d_) )
then
165 this%mesh2D => mesh2d_
166 call this%set_dim_axis2D()
167 else if (
present(mesh3d_) )
then
168 this%mesh3D => mesh3d_
169 this%mesh2D => mesh3d_%mesh2D
170 call this%set_dim_axis3D()
171 else if (
present(meshcubedsphere2d_) )
then
172 this%meshCubedSphere2D => meshcubedsphere2d_
173 call this%set_dim_axis2D_cubedsphere()
174 else if (
present(meshcubedsphere3d_) )
then
175 this%meshCubedSphere3D => meshcubedsphere3d_
176 this%meshCubedSphere2D => meshcubedsphere3d_%mesh2D
177 call this%set_dim_axis3D_cubedsphere()
179 log_error(
"FileHistoryMeshFieldComp_Init",*)
"Any mesh (mesh1d/2d/3d) are not specified."
184 end subroutine filehistorymeshfieldcomp_init
187 subroutine filehistorymeshfieldcomp_final( this )
189 class(FileHistoryMeshFieldComp),
intent(inout) :: this
192 end subroutine filehistorymeshfieldcomp_final
197 mesh1D_, mesh2D_, mesh3D_, &
198 meshcubedsphere2D_, meshcubedsphere3D_, &
202 use scale_file_h,
only: &
204 use scale_prc,
only: &
208 use scale_time,
only: &
214 use scale_calendar,
only: &
218 class(
meshbase1d),
intent(in),
target,
optional :: mesh1d_
219 class(
meshrectdom2d) ,
intent(in),
target,
optional :: mesh2d_
220 class(
meshcubedom3d) ,
intent(in),
target,
optional :: mesh3d_
223 character(len=*),
intent(in),
optional :: dim_name_postfix_
224 integer,
intent(out),
optional :: registered_comp_id
226 character(len=H_MID) :: file_history_meshfiled_h_title =
'SCALE-DG FILE_HISTORY_MESHFIELD'
227 character(len=H_MID) :: file_history_meshfield_t_since
229 character(len=FILE_HSHORT) :: calendar
230 real(dp) :: start_daysec
232 type(filehistorymeshfieldcomp),
pointer :: target_comp
233 integer :: registered_comp_id_
238 log_error(
"FILE_base_meshfield_register_comp",*)
'Exceeding maximum number of components. Check!'
242 comp_num = comp_num + 1
243 registered_comp_id_ = comp_num
244 if (
present(registered_comp_id) )
then
245 registered_comp_id = registered_comp_id_
248 target_comp => comp(registered_comp_id_)
249 call target_comp%Init( mesh1d_, mesh2d_, mesh3d_, &
250 meshcubedsphere2d_, meshcubedsphere3d_ , &
254 if ( registered_comp_id_ == 1 )
then
255 default_comp => comp(registered_comp_id_)
257 file_history_meshfield_startdate(:) = time_nowdate
258 file_history_meshfield_startsubsec = time_nowsubsec
260 start_daysec = time_startdaysec
261 if ( time_nowdate(1) > 0 )
then
262 write(file_history_meshfield_t_since,
'(I4.4,5(A1,I2.2))') time_nowdate(1), &
263 '-', time_nowdate(2), &
264 '-', time_nowdate(3), &
265 ' ', time_nowdate(4), &
266 ':', time_nowdate(5), &
268 start_daysec = time_nowsubsec
270 file_history_meshfield_t_since =
''
274 call calendar_get_name( calendar )
276 call file_history_setup( file_history_meshfiled_h_title, &
277 h_source, h_institute, &
278 start_daysec, time_dtsec, &
279 time_since = file_history_meshfield_t_since, &
280 calendar = calendar, &
281 default_zcoord =
'model', &
282 myrank = prc_myrank )
284 call file_history_set_nowdate( time_nowdate, time_nowsubsec, time_nowstep )
286 file_history_filemeshfiled_disable = .false.
298 call file_history_write
308 call file_history_finalize()
309 call default_comp%Final()
316 subroutine file_history_meshfield_put1d(hstid, field1d, &
321 integer,
intent(in) :: hstid
323 integer,
intent(in),
optional :: registered_comp_id
327 real(RP),
allocatable :: buf(:)
329 type(filehistorymeshfieldcomp),
pointer :: target_comp
332 call history_get_comp( registered_comp_id, &
335 call file_history_query( hstid, do_put )
336 if ( .not. do_put )
return
340 do ldomid=1, field1d%mesh%LOCAL_MESH_NUM
346 allocate( buf(target_comp%dims1D_size(1)) )
349 call file_history_put( hstid, buf )
352 end subroutine file_history_meshfield_put1d
355 subroutine file_history_meshfield_in1d( field1d, desc, standard_name, &
359 character(len=*),
intent(in) :: desc
360 character(len=*),
intent(in),
optional :: standard_name
361 integer,
intent(in),
optional :: registered_comp_id
367 call history_in_regvar( hstid, do_put, &
368 field1d, desc, 1, standard_name,
'XYZ' )
373 end subroutine file_history_meshfield_in1d
378 subroutine file_history_meshfield_put2d(hstid, field2d, &
385 integer,
intent(in) :: hstid
387 integer,
intent(in),
optional :: registered_comp_id
391 real(RP),
allocatable :: buf(:,:)
393 type(filehistorymeshfieldcomp),
pointer :: target_comp
396 call history_get_comp( registered_comp_id, &
399 call file_history_query( hstid, do_put )
400 if ( .not. do_put )
return
404 do ldomid=1, field2d%mesh%LOCAL_MESH_NUM
409 allocate( buf(target_comp%dims2D_size(1),target_comp%dims2D_size(2)) )
411 if (
associated(target_comp%mesh2D) )
then
413 else if (
associated(target_comp%meshCubedSphere2D) )
then
415 target_comp%meshCubedSphere2D, field2d, buf )
417 call file_history_put( hstid, buf )
420 end subroutine file_history_meshfield_put2d
423 subroutine file_history_meshfield_in2d( field2d, desc, standard_name, &
427 character(len=*),
intent(in) :: desc
428 character(len=*),
intent(in),
optional :: standard_name
429 integer,
intent(in),
optional :: registered_comp_id
435 call history_in_regvar( hstid, do_put, &
436 field2d, desc, 2, standard_name,
'XY' )
441 end subroutine file_history_meshfield_in2d
446 subroutine file_history_meshfield_put3d(hstid, field3d, &
453 integer,
intent(in) :: hstid
455 integer,
intent(in),
optional :: registered_comp_id
459 real(RP),
allocatable :: buf(:,:,:)
461 type(filehistorymeshfieldcomp),
pointer :: target_comp
464 call history_get_comp( registered_comp_id, &
467 call file_history_query( hstid, do_put )
468 if ( .not. do_put )
return
472 do ldomid=1, field3d%mesh%LOCAL_MESH_NUM
478 allocate( buf(target_comp%dims3D_size(1,1),target_comp%dims3D_size(2,1),target_comp%dims3D_size(3,1)) )
480 if (
associated(target_comp%mesh3D) )
then
482 else if (
associated(target_comp%meshCubedSphere3D) )
then
484 target_comp%meshCubedSphere3D, field3d, buf )
486 call file_history_put( hstid, buf )
489 end subroutine file_history_meshfield_put3d
492 subroutine file_history_meshfield_in3d( field3d, desc, standard_name, &
496 character(len=*),
intent(in) :: desc
497 character(len=*),
intent(in),
optional :: standard_name
498 integer,
intent(in),
optional :: registered_comp_id
504 call history_in_regvar( hstid, do_put, &
505 field3d, desc, 3, standard_name,
'XYZ' )
510 end subroutine file_history_meshfield_in3d
515 subroutine history_in_regvar( hstid, do_put, &
516 field, desc, ndim, standard_name, dim_type )
518 use scale_file_history,
only: &
523 integer,
intent(out) :: hstid
524 logical,
intent(out) :: do_put
526 character(len=*),
intent(in) :: desc
527 integer,
intent(in) :: ndim
528 character(len=*),
intent(in),
optional :: standard_name
529 character(len=*),
intent(in),
optional :: dim_type
531 logical,
parameter :: fill_halo = .false.
537 if ( file_history_filemeshfiled_disable )
return
540 call file_history_reg( field%varname, desc, field%unit, &
542 standard_name=standard_name, &
545 fill_halo=fill_halo )
547 if ( hstid < 0 )
return
550 call file_history_query( hstid, do_put )
553 end subroutine history_in_regvar
556 subroutine history_get_comp( comp_id, & ! (in)
559 integer,
intent(in),
optional :: comp_id
560 type(filehistorymeshfieldcomp),
intent(out),
pointer :: comp_ptr
563 if ( .not.
present(comp_id) )
then
564 comp_ptr => default_comp
568 if ( comp_id < 1 .or. comp_id > comp_num )
then
569 log_error(
"FILE_history_get_comp",*)
'Invalid component ID. Check!'
572 comp_ptr => comp(comp_id)
574 end subroutine history_get_comp
577 subroutine set_dim_axis1d( comp )
587 class(filehistorymeshfieldcomp),
intent(inout) :: comp
590 real(RP),
allocatable :: x(:)
591 integer :: start(1,1), count(1,1)
592 character(len=H_SHORT) :: dims(1,1)
599 comp%dims1D_size(1) = dimsinfo(dimtype_x)%size
600 allocate( x(comp%dims1D_size(1)) )
606 ndim = dimsinfo(n)%ndim
607 dims(1:ndim,1) = dimsinfo(n)%dims(1:ndim)
608 count(1:ndim,1) = dimsinfo(n)%count(1:ndim)
609 call file_history_set_dim ( dimsinfo(n)%type, ndim, 1, dims(1:ndim,:), zs(:), start(1:ndim,:), count(1:ndim,:))
612 call file_history_set_axis( dimsinfo(dimtype_x)%name, dimsinfo(dimtype_x)%desc, &
613 dimsinfo(dimtype_x)%unit, dimsinfo(dimtype_x)%name, x )
616 end subroutine set_dim_axis1d
619 subroutine set_dim_axis2d( comp )
630 class(filehistorymeshfieldcomp),
intent(inout) :: comp
633 real(RP),
allocatable :: x(:), y(:)
634 integer :: start(2,1), count(2,1)
635 character(len=H_SHORT) :: dims(2,1)
642 comp%dims2D_size(1) = dimsinfo(dimtype_x)%size
643 comp%dims2D_size(2) = dimsinfo(dimtype_y)%size
644 allocate( x(comp%dims2D_size(1)), y(comp%dims2D_size(2)) )
651 ndim = dimsinfo(n)%ndim
652 dims(1:ndim,1) = dimsinfo(n)%dims(1:ndim)
653 count(1:ndim,1) = dimsinfo(n)%count(1:ndim)
654 call file_history_set_dim ( dimsinfo(n)%type, ndim, 1, dims(1:ndim,:), zs(:), start(1:ndim,:), count(1:ndim,:))
657 call file_history_set_axis( dimsinfo(dimtype_x)%name, dimsinfo(dimtype_x)%desc, dimsinfo(dimtype_x)%unit, dimsinfo(dimtype_x)%name, x(:))
658 call file_history_set_axis( dimsinfo(dimtype_y)%name, dimsinfo(dimtype_y)%desc, dimsinfo(dimtype_y)%unit, dimsinfo(dimtype_y)%name, y(:))
661 end subroutine set_dim_axis2d
664 subroutine set_dim_axis3d( comp )
676 class(filehistorymeshfieldcomp),
intent(inout) :: comp
679 real(RP),
allocatable :: x(:), y(:), z(:)
680 integer :: start(3,1), count(3,1)
681 character(len=H_SHORT) :: dims(3,1)
688 comp%dims2D_size(1) = dimsinfo(dimtype_x)%size
689 comp%dims2D_size(2) = dimsinfo(dimtype_y)%size
690 comp%dims3D_size(1,1) = dimsinfo(dimtype_x)%size
691 comp%dims3D_size(2,1) = dimsinfo(dimtype_y)%size
692 comp%dims3D_size(3,1) = dimsinfo(dimtype_z)%size
693 allocate( x(comp%dims3D_size(1,1)), y(comp%dims3D_size(2,1)), z(comp%dims3D_size(3,1)) )
699 ndim = dimsinfo(n)%ndim
700 dims(1:ndim,1) = dimsinfo(n)%dims(1:ndim)
701 count(1:ndim,1) = dimsinfo(n)%count(1:ndim)
702 call file_history_set_dim ( dimsinfo(n)%type, ndim, 1, dims(1:ndim,:), zs(:), start(1:ndim,:), count(1:ndim,:))
705 call file_history_set_axis( dimsinfo(dimtype_x)%name, dimsinfo(dimtype_x)%desc, dimsinfo(dimtype_x)%unit, dimsinfo(dimtype_x)%name, x(:) )
706 call file_history_set_axis( dimsinfo(dimtype_y)%name, dimsinfo(dimtype_y)%desc, dimsinfo(dimtype_y)%unit, dimsinfo(dimtype_y)%name, y(:) )
707 call file_history_set_axis( dimsinfo(dimtype_z)%name, dimsinfo(dimtype_z)%desc, dimsinfo(dimtype_z)%unit, dimsinfo(dimtype_z)%name, z(:), &
708 down=dimsinfo(dimtype_z)%positive_down(1) )
711 end subroutine set_dim_axis3d
714 subroutine set_dim_axis2d_cubedsphere( comp )
725 class(filehistorymeshfieldcomp),
intent(inout) :: comp
728 real(RP),
allocatable :: x(:), y(:)
729 integer :: start(2,1), count(2,1)
730 character(len=H_SHORT) :: dims(2,1)
737 comp%dims2D_size(1) = dimsinfo(dimtype_x)%size
738 comp%dims2D_size(2) = dimsinfo(dimtype_y)%size
739 allocate( x(comp%dims2D_size(1)), y(comp%dims2D_size(2)) )
747 ndim = dimsinfo(n)%ndim
748 dims(1:ndim,1) = dimsinfo(n)%dims(1:ndim)
749 count(1:ndim,1) = dimsinfo(n)%count(1:ndim)
750 call file_history_set_dim ( dimsinfo(n)%type, ndim, 1, dims(1:ndim,:), zs(:), start(1:ndim,:), count(1:ndim,:))
753 call file_history_set_axis( dimsinfo(dimtype_x)%name, dimsinfo(dimtype_x)%desc, dimsinfo(dimtype_x)%unit, dimsinfo(dimtype_x)%name, x )
754 call file_history_set_axis( dimsinfo(dimtype_y)%name, dimsinfo(dimtype_y)%desc, dimsinfo(dimtype_y)%unit, dimsinfo(dimtype_y)%name, y )
757 end subroutine set_dim_axis2d_cubedsphere
760 subroutine set_dim_axis3d_cubedsphere( comp )
772 class(filehistorymeshfieldcomp),
intent(inout) :: comp
775 real(RP),
allocatable :: x(:), y(:), z(:)
776 integer :: start(3,1), count(3,1)
777 character(len=H_SHORT) :: dims(3,1)
784 comp%dims2D_size(1) = dimsinfo(dimtype_x)%size
785 comp%dims2D_size(2) = dimsinfo(dimtype_y)%size
786 comp%dims3D_size(1,1) = dimsinfo(dimtype_x)%size
787 comp%dims3D_size(2,1) = dimsinfo(dimtype_y)%size
788 comp%dims3D_size(3,1) = dimsinfo(dimtype_z)%size
789 allocate( x(comp%dims3D_size(1,1)), y(comp%dims3D_size(2,1)), z(comp%dims3D_size(3,1)) )
795 ndim = dimsinfo(n)%ndim
796 dims(1:ndim,1) = dimsinfo(n)%dims(1:ndim)
797 count(1:ndim,1) = dimsinfo(n)%count(1:ndim)
798 call file_history_set_dim ( dimsinfo(n)%type, ndim, 1, dims(1:ndim,:), zs(:), start(1:ndim,:), count(1:ndim,:))
801 call file_history_set_axis( dimsinfo(dimtype_x)%name, dimsinfo(dimtype_x)%desc, dimsinfo(dimtype_x)%unit, dimsinfo(dimtype_x)%name, x )
802 call file_history_set_axis( dimsinfo(dimtype_y)%name, dimsinfo(dimtype_y)%desc, dimsinfo(dimtype_y)%unit, dimsinfo(dimtype_y)%name, y )
803 call file_history_set_axis( dimsinfo(dimtype_z)%name, dimsinfo(dimtype_z)%desc, dimsinfo(dimtype_z)%unit, dimsinfo(dimtype_z)%name, z, &
804 down=dimsinfo(dimtype_z)%positive_down(1) )
807 end subroutine set_dim_axis3d_cubedsphere
module FElib / Element / Base
module FElib / File / Common
subroutine, public file_common_meshfield_get_axis1d(mesh1d, dimsinfo, x, force_uniform_grid)
subroutine, public file_common_meshfield_get_axis3d(mesh3d, dimsinfo, x, y, z, force_uniform_grid)
subroutine, public file_common_meshfield_get_dims1d(mesh1d, dim_name_postfix, dimsinfo)
subroutine, public file_common_meshfield_put_field3d_cubedsphere_cartesbuf(mesh3d, field3d, buf)
subroutine, public file_common_meshfield_put_field2d_cubedsphere_cartesbuf(mesh2d, field2d, buf)
subroutine, public file_common_meshfield_put_field2d_cartesbuf(mesh2d, field2d, buf, force_uniform_grid)
subroutine, public file_common_meshfield_put_field1d_cartesbuf(mesh1d, field1d, buf, force_uniform_grid)
subroutine, public file_common_meshfield_get_dims2d(mesh2d, dim_name_postfix, dimsinfo)
subroutine, public file_common_meshfield_get_dims3d(mesh3d, dim_name_postfix, dimsinfo)
subroutine, public file_common_meshfield_get_axis2d(mesh2d, dimsinfo, x, y, force_uniform_grid)
subroutine, public file_common_meshfield_put_field3d_cartesbuf(mesh3d, field3d, buf, force_uniform_grid)
module FElib / File / History
integer, parameter component_num_max
subroutine, public file_history_meshfield_setup(mesh1d_, mesh2d_, mesh3d_, meshcubedsphere2d_, meshcubedsphere3d_, dim_name_postfix_, registered_comp_id)
Setup a module for file history.
subroutine, public file_history_meshfield_write()
Write history data to the file.
subroutine, public file_history_meshfield_finalize()
Finalize the file history module.
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
Derived type representing a 1D reference element.
Derived type representing a 2D reference element.
Derived type representing a 3D reference element.
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)