10#include "scaleFElib.h"
19 use scale_prc,
only: &
21 use scale_file_h,
only: &
64 type :: filebasemeshfieldcomp
65 character(len=H_SHORT) :: comp_name
66 integer,
allocatable :: vars_ncid(:)
67 character(len=H_SHORT) :: dim_name_postfix
69 integer :: write_buf_amount
71 integer :: mesh_type_id
72 class(MeshBase1D),
pointer :: mesh1D
73 class(MeshRectDom2D),
pointer :: mesh2D
74 class(MeshCubedSphereDom2D),
pointer :: meshCS2D
75 class(MeshCubeDom3D),
pointer :: mesh3D
76 class(MeshCubedSphereDom3D),
pointer :: meshCS3D
77 type(FILE_common_meshfield_diminfo),
allocatable :: dimsinfo(:)
79 logical :: force_uniform_grid
80 end type filebasemeshfieldcomp
92 integer :: main_comp_id
94 logical :: file_axes_written
96 procedure :: init => file_base_meshfield_init
97 procedure :: register_comp => file_base_meshfield_register_comp
98 procedure :: open => file_base_meshfield_open
99 procedure :: create => file_base_meshfield_create
102 procedure :: file_base_meshfield_def_var1
103 procedure :: file_base_meshfield_def_var2
104 generic :: def_var => file_base_meshfield_def_var1, file_base_meshfield_def_var2
105 procedure :: end_def => file_base_meshfield_enddef
107 procedure :: file_base_meshfield_write_var1d
108 generic :: write_var1d => file_base_meshfield_write_var1d
109 procedure :: file_base_meshfield_write_var2d
110 generic :: write_var2d => file_base_meshfield_write_var2d
111 procedure :: file_base_meshfield_write_var3d
112 generic :: write_var3d => file_base_meshfield_write_var3d
114 procedure :: put_globalattribute_time => file_base_meshfield_put_global_attribute_time
116 procedure :: file_base_meshfield_read_var1d
117 procedure :: file_base_meshfield_read_var1d_local
118 procedure :: file_base_meshfield_read_var2d
119 procedure :: file_base_meshfield_read_var2d_local
120 procedure :: file_base_meshfield_read_var3d
121 procedure :: file_base_meshfield_read_var3d_local
122 generic :: read_var => &
123 file_base_meshfield_read_var1d, file_base_meshfield_read_var1d_local, &
124 file_base_meshfield_read_var2d, file_base_meshfield_read_var2d_local, &
125 file_base_meshfield_read_var3d, file_base_meshfield_read_var3d_local
128 procedure :: get_commoninfo => file_base_meshfield_get_commoninfo
129 procedure :: get_datainfo => file_base_meshfield_get_datainfo
130 procedure :: get_varstepsize => file_base_meshfield_get_varstepsize
132 procedure :: close => file_base_meshfield_close
133 procedure :: final => file_base_meshfield_final
136 procedure,
private :: get_comp_ptr => file_base_meshfield_get_comp
150 private :: write_axes
153 integer,
parameter :: meshtype_2d_rectdom = 2
154 integer,
parameter :: meshtype_2d_cubedsphere = 3
155 integer,
parameter :: meshtype_3d_cubedom = 4
156 integer,
parameter :: meshtype_3d_cubedsphere = 5
162 subroutine file_base_meshfield_init( this, & ! (inout)
167 mesh2d, meshcubedsphere2d, &
168 mesh3d, meshcubedsphere3d, &
173 integer,
intent(in) :: var_num
174 character(len=*),
optional,
intent(in) :: comp_name
175 character(len=*),
optional,
intent(in) :: dim_name_postfix
176 class(
meshbase1d),
target,
optional,
intent(in) :: mesh1d
181 logical,
intent(in),
optional :: force_uniform_grid
183 character(len=H_MID) :: comp_name_
184 character(len=H_SHORT) :: dim_name_postfix_
190 if (
present(comp_name))
then
191 comp_name_ = comp_name
193 comp_name_ =
"main component"
196 if (
present(dim_name_postfix))
then
197 dim_name_postfix_ = dim_name_postfix
199 dim_name_postfix_ =
""
203 call this%Register_comp( this%main_comp_id, &
204 comp_name_, var_num, dim_name_postfix_, &
205 mesh1d, mesh2d, meshcubedsphere2d, mesh3d, meshcubedsphere3d, &
209 this%File_axes_written = .false.
212 end subroutine file_base_meshfield_init
215 subroutine file_base_meshfield_register_comp( this, &
216 registered_comp_id, & ! (out)
221 mesh2d, meshcubedsphere2d, &
222 mesh3d, meshcubedsphere3d, &
229 integer,
intent(out) :: registered_comp_id
230 integer,
intent(in) :: var_num
231 character(len=*),
intent(in) :: comp_name
232 character(len=*),
intent(in) :: dim_name_postfix
233 class(
meshbase1d),
target,
optional,
intent(in) :: mesh1d
238 logical,
intent(in),
optional :: force_uniform_grid
240 type(filebasemeshfieldcomp),
pointer :: comp_ptr
242 logical :: check_specify_mesh
246 log_error(
"FILE_base_meshfield_register_comp",*)
'Exceeding maximum number of components. Check!'
250 this%comp_num = this%comp_num + 1
251 registered_comp_id = this%comp_num
253 comp_ptr => this%comp(registered_comp_id)
254 comp_ptr%comp_name = trim(comp_name)
255 comp_ptr%write_buf_amount = 0
256 comp_ptr%dim_name_postfix = trim(dim_name_postfix)
259 allocate( comp_ptr%vars_ncid(var_num) )
260 comp_ptr%vars_ncid(:) = -1
265 check_specify_mesh = .false.
266 nullify( comp_ptr%mesh1D, comp_ptr%mesh2D, comp_ptr%mesh3D )
267 nullify( comp_ptr%meshCS2D, comp_ptr%meshCS3D )
269 if (
present(mesh1d))
then
270 comp_ptr%mesh1D => mesh1d
272 check_specify_mesh = .true.
274 allocate( comp_ptr%dimsinfo(mf1d_dtype_num) )
276 comp_ptr%dimsinfo(:) )
278 if (
present(mesh2d))
then
279 comp_ptr%mesh2D => mesh2d
280 comp_ptr%mesh_type_id = meshtype_2d_rectdom
281 check_specify_mesh = .true.
283 allocate( comp_ptr%dimsinfo(mf2d_dtype_num) )
285 comp_ptr%dimsinfo(:) )
287 if (
present(meshcubedsphere2d))
then
288 comp_ptr%meshCS2D => meshcubedsphere2d
289 comp_ptr%mesh_type_id = meshtype_2d_cubedsphere
290 check_specify_mesh = .true.
292 allocate( comp_ptr%dimsinfo(mf2d_dtype_num) )
294 comp_ptr%dimsinfo(:) )
296 if (
present(mesh3d))
then
297 comp_ptr%mesh3D => mesh3d
298 comp_ptr%mesh2D => mesh3d%mesh2D
299 comp_ptr%mesh_type_id = meshtype_3d_cubedom
300 check_specify_mesh = .true.
302 allocate( comp_ptr%dimsinfo(mf3d_dtype_num) )
304 comp_ptr%dimsinfo(:) )
306 if (
present(meshcubedsphere3d))
then
307 comp_ptr%meshCS3D => meshcubedsphere3d
308 comp_ptr%meshCS2D => meshcubedsphere3d%mesh2D
309 comp_ptr%mesh_type_id = meshtype_3d_cubedsphere
310 check_specify_mesh = .true.
312 allocate( comp_ptr%dimsinfo(mf3d_dtype_num) )
314 comp_ptr%dimsinfo(:) )
317 if (
present(force_uniform_grid) )
then
318 comp_ptr%force_uniform_grid = force_uniform_grid
320 comp_ptr%force_uniform_grid = .false.
323 if (.not. check_specify_mesh)
then
324 log_error(
"FILE_base_meshfield_register_comp",*)
'Specify a mesh among mesh1D, 2D, and 3D. Check!'
329 end subroutine file_base_meshfield_register_comp
332 subroutine file_base_meshfield_open( this, & ! (inout)
335 use scale_file,
only: &
340 character(*),
intent(in) :: basename
341 integer,
intent(in),
optional :: myrank
344 call file_open( basename, &
349 end subroutine file_base_meshfield_open
352 subroutine file_base_meshfield_create( &
353 this, basename, title, dtype, &
355 myrank, tunits, calendar )
357 use scale_file,
only: &
362 character(*),
intent(in) :: basename
363 character(*),
intent(in) :: title
364 character(*),
intent(in) :: dtype
365 logical,
intent(out) :: fileexisted
366 integer,
intent(in),
optional :: myrank
367 character(*),
intent(in),
optional :: calendar
368 character(*),
intent(in),
optional :: tunits
373 call file_create( basename, &
380 time_units = tunits, &
381 aggregate = .false., &
382 calendar = calendar )
384 if ( .not. fileexisted )
then
385 do i=1, this%comp_num
386 call def_axes( this%comp(i), this%fid, dtype )
388 this%File_axes_written = .false.
392 end subroutine file_base_meshfield_create
395 subroutine file_base_meshfield_def_var1( this, & ! (inout)
396 field, desc, vid, dim_type_id, datatype, &
397 standard_name, timeinv, nsteps, &
403 character(len=*),
intent(in) :: desc
404 integer,
intent(in) :: dim_type_id
405 integer,
intent(in) :: vid
406 character(len=*),
intent(in) :: datatype
407 character(len=*),
optional,
intent(in) :: standard_name
408 real(dp),
optional,
intent(in) :: timeinv
409 integer,
optional,
intent(in) :: nsteps
410 integer,
optional,
intent(in) :: comp_id
413 call this%Def_Var( field%varname, field%unit, &
414 desc, vid, dim_type_id, datatype, standard_name, timeinv, nsteps, comp_id )
417 end subroutine file_base_meshfield_def_var1
420 subroutine file_base_meshfield_def_var2( this, & ! (inout)
421 varname, units, desc, vid, dim_type_id, datatype, &
422 standard_name, timeinv, nsteps, comp_id )
424 use scale_file,
only: &
431 character(len=*),
intent(in) :: varname
432 character(len=*),
intent(in) :: units
433 character(len=*),
intent(in) :: desc
434 integer,
intent(in) :: dim_type_id
435 integer,
intent(in) :: vid
436 character(len=*),
intent(in) :: datatype
437 character(len=*),
optional,
intent(in) :: standard_name
438 real(dp),
optional,
intent(in) :: timeinv
439 integer,
optional,
intent(in) :: nsteps
440 integer,
optional,
intent(in) :: comp_id
444 character(len=H_MID) :: standard_name_
446 type(filebasemeshfieldcomp),
pointer :: comp_ptr
449 call this%get_comp_ptr( comp_id, &
452 i_dtype = get_dtype(datatype)
454 if (
present(nsteps) )
then
455 comp_ptr%write_buf_amount = comp_ptr%write_buf_amount + comp_ptr%dimsinfo(dim_type_id)%size * nsteps
457 comp_ptr%write_buf_amount = comp_ptr%write_buf_amount + comp_ptr%dimsinfo(dim_type_id)%size
459 if (
present(standard_name) )
then
460 standard_name_ = standard_name
465 ndim = comp_ptr%dimsinfo(dim_type_id)%ndim
466 if (
present(timeinv) )
then
467 call file_def_variable( this%fid, varname, desc, units, standard_name_, &
468 ndim, comp_ptr%dimsinfo(dim_type_id)%dims(1:ndim), i_dtype, comp_ptr%vars_ncid(vid), &
471 call file_def_variable( this%fid, varname, desc, units, standard_name_, &
472 ndim, comp_ptr%dimsinfo(dim_type_id)%dims(1:ndim), i_dtype, comp_ptr%vars_ncid(vid) )
476 end subroutine file_base_meshfield_def_var2
479 subroutine file_base_meshfield_enddef( this )
481 use scale_file,
only: &
491 if (this%fid == -1)
return
493 call file_enddef( this%fid )
495 if ( .not. this%File_axes_written )
then
497 do i=1, this%comp_num
498 call write_axes( this%comp(i), this%fid, start(:) )
500 this%File_axes_written = .true.
504 end subroutine file_base_meshfield_enddef
508 subroutine file_base_meshfield_write_var1d( this, & ! (inout)
509 vid, field1d, sec_str, sec_end, &
512 use scale_file,
only: &
520 integer,
intent(in) :: vid
522 real(dp),
intent(in) :: sec_str
523 real(dp),
intent(in) :: sec_end
524 integer,
intent(in),
optional :: comp_id
526 real(rp),
allocatable :: buf(:)
532 type(filebasemeshfieldcomp),
pointer :: comp_ptr
535 call this%get_comp_ptr( comp_id, &
538 if ( this%fid /= -1 )
then
540 dims(1) = comp_ptr%dimsinfo(mf1d_dimtype_x)%size
541 allocate( buf(dims(1)) )
544 do ldomid=1, field1d%mesh%LOCAL_MESH_NUM
551 comp_ptr%force_uniform_grid )
553 call file_write( comp_ptr%vars_ncid(vid), buf(:), &
554 sec_str, sec_end, start=start )
558 end subroutine file_base_meshfield_write_var1d
562 subroutine file_base_meshfield_write_var2d( this, & ! (inout)
563 vid, field2d, sec_str, sec_end, &
566 use scale_file,
only: &
575 integer,
intent(in) :: vid
577 real(dp),
intent(in) :: sec_str
578 real(dp),
intent(in) :: sec_end
579 integer,
intent(in),
optional :: comp_id
580 real(rp),
allocatable :: buf(:,:)
586 type(filebasemeshfieldcomp),
pointer :: comp_ptr
589 call this%get_comp_ptr( comp_id, &
592 if ( this%fid /= -1 )
then
594 dims(1) = comp_ptr%dimsinfo(mf2d_dimtype_x)%size
595 dims(2) = comp_ptr%dimsinfo(mf2d_dimtype_y)%size
596 allocate( buf(dims(1),dims(2)) )
599 do ldomid=1, field2d%mesh%LOCAL_MESH_NUM
605 if (
associated(comp_ptr%mesh2D) )
then
607 comp_ptr%force_uniform_grid )
608 else if (
associated(comp_ptr%meshCS2D) )
then
611 call file_write( comp_ptr%vars_ncid(vid), buf(:,:), &
612 sec_str, sec_end, start=start )
616 end subroutine file_base_meshfield_write_var2d
620 subroutine file_base_meshfield_write_var3d( this, & ! (inout)
621 vid, field3d, sec_str, sec_end, &
624 use scale_file,
only: &
634 integer,
intent(in) :: vid
636 real(dp),
intent(in) :: sec_str
637 real(dp),
intent(in) :: sec_end
638 integer,
intent(in),
optional :: comp_id
640 real(rp),
allocatable :: buf(:,:,:)
646 type(filebasemeshfieldcomp),
pointer :: comp_ptr
649 call this%get_comp_ptr( comp_id, &
652 if ( this%fid /= -1 )
then
654 dims(1) = comp_ptr%dimsinfo(mf3d_dimtype_x)%size
655 dims(2) = comp_ptr%dimsinfo(mf3d_dimtype_y)%size
656 dims(3) = comp_ptr%dimsinfo(mf3d_dimtype_z)%size
657 allocate( buf(dims(1),dims(2),dims(3)) )
660 do ldomid=1, field3d%mesh%LOCAL_MESH_NUM
666 if (
associated(comp_ptr%mesh3D) )
then
668 comp_ptr%force_uniform_grid )
669 else if (
associated(comp_ptr%meshCS3D) )
then
673 call file_write( comp_ptr%vars_ncid(vid), buf(:,:,:), &
674 sec_str, sec_end, start )
678 end subroutine file_base_meshfield_write_var3d
681 subroutine file_base_meshfield_get_commoninfo( this, & ! (in)
682 title, source, institution )
683 use scale_file,
only: &
688 character(len=FILE_HMID),
intent(out),
optional :: title
689 character(len=FILE_HMID),
intent(out),
optional :: source
690 character(len=FILE_HMID),
intent(out),
optional :: institution
693 if (
present(title) )
call file_get_attribute( this%fid,
'global',
'title', title )
694 if (
present(source) )
call file_get_attribute( this%fid,
'global',
'source', source )
695 if (
present(institution) )
call file_get_attribute( this%fid,
'global',
'institution', institution )
698 end subroutine file_base_meshfield_get_commoninfo
701 subroutine file_base_meshfield_get_varstepsize( this, varname, & ! (in)
703 use scale_file,
only: &
708 character(*),
intent(in) :: varname
709 integer,
intent(out) :: len
712 call file_get_stepsize( this%fid, varname, &
716 end subroutine file_base_meshfield_get_varstepsize
719 subroutine file_base_meshfield_get_datainfo( this, varname, istep, & ! (in)
720 description, units, standard_name, &
721 time_start, time_end, time_units, calendar )
722 use scale_file,
only: &
727 character(*),
intent(in) :: varname
728 integer,
intent(in),
optional :: istep
729 character(len=FILE_HMID),
intent(out),
optional :: description
730 character(len=FILE_HSHORT),
intent(out),
optional :: units
731 character(len=FILE_HMID),
intent(out),
optional :: standard_name
732 real(dp),
intent(out),
optional :: time_start
733 real(dp),
intent(out),
optional :: time_end
734 character(len=FILE_HMID),
intent(out),
optional :: time_units
735 character(len=FILE_HSHORT),
intent(out),
optional :: calendar
738 call file_get_datainfo( this%fid, varname, istep=istep, &
739 description=description, units=units, standard_name=standard_name, &
740 time_start=time_start, time_end=time_end, time_units=time_units, calendar=calendar )
743 end subroutine file_base_meshfield_get_datainfo
747 subroutine file_base_meshfield_read_var1d( this, & ! (inout)
748 dim_typeid, varname, &
750 step, allow_missing, comp_id )
752 use scale_file,
only: &
760 integer,
intent(in) :: dim_typeid
761 character(*),
intent(in) :: varname
763 integer,
intent(in),
optional :: step
764 logical,
intent(in),
optional :: allow_missing
765 integer,
intent(in),
optional :: comp_id
767 real(rp),
allocatable :: buf(:)
771 type(filebasemeshfieldcomp),
pointer :: comp_ptr
774 if ( this%fid /= -1 )
then
775 call this%get_comp_ptr( comp_id, &
779 dims(1) = comp_ptr%dimsinfo(dim_typeid)%size
780 allocate( buf(dims(1)) )
782 call file_read( this%fid, varname, &
784 step=step, allow_missing=allow_missing )
791 end subroutine file_base_meshfield_read_var1d
795 subroutine file_base_meshfield_read_var1d_local( this, & ! (inout)
796 dim_typeid, varname, lcmesh, i0_s, &
798 step, allow_missing, comp_id )
800 use scale_file,
only: &
808 integer,
intent(in) :: dim_typeid
809 character(*),
intent(in) :: varname
811 integer,
intent(in) :: i0_s
812 real(rp),
intent(out) :: val(lcmesh%refelem1d%np,lcmesh%nea)
813 integer,
intent(in),
optional :: step
814 logical,
intent(in),
optional :: allow_missing
815 integer,
intent(in),
optional :: comp_id
816 real(rp),
allocatable :: buf(:)
820 type(filebasemeshfieldcomp),
pointer :: comp_ptr
823 if ( this%fid /= -1 )
then
824 call this%get_comp_ptr( comp_id, &
828 dims(1) = comp_ptr%dimsinfo(dim_typeid)%size
829 allocate( buf(dims(1)) )
831 call file_read( this%fid, varname, &
833 step=step, allow_missing=allow_missing )
836 lcmesh, buf(:), i0_s, &
841 end subroutine file_base_meshfield_read_var1d_local
845 subroutine file_base_meshfield_read_var2d( this, & ! (inout)
846 dim_typeid, varname, &
848 step, allow_missing, comp_id )
850 use scale_file,
only: &
859 integer,
intent(in) :: dim_typeid
860 character(*),
intent(in) :: varname
862 integer,
intent(in),
optional :: step
863 logical,
intent(in),
optional :: allow_missing
864 integer,
intent(in),
optional :: comp_id
866 real(rp),
allocatable :: buf(:,:)
870 type(filebasemeshfieldcomp),
pointer :: comp_ptr
873 if ( this%fid /= -1 )
then
874 call this%get_comp_ptr( comp_id, &
878 dims(1) = comp_ptr%dimsinfo(mf2d_dimtype_x)%size
879 dims(2) = comp_ptr%dimsinfo(mf2d_dimtype_y)%size
880 allocate( buf(dims(1),dims(2)) )
882 call file_read( this%fid, varname, &
884 step=step, allow_missing=allow_missing )
886 if (
associated( comp_ptr%meshCS2D) )
then
888 comp_ptr%meshCS2D, buf(:,:), &
890 else if (
associated( comp_ptr%mesh2D) )
then
897 end subroutine file_base_meshfield_read_var2d
901 subroutine file_base_meshfield_read_var2d_local( this, & ! (inout)
902 dim_typeid, varname, lcmesh, i0_s, j0_s, &
904 step, allow_missing, comp_id )
906 use scale_file,
only: &
914 integer,
intent(in) :: dim_typeid
915 character(*),
intent(in) :: varname
917 integer,
intent(in) :: i0_s, j0_s
918 real(rp),
intent(out) :: val(lcmesh%refelem2d%np,lcmesh%nea)
919 integer,
intent(in),
optional :: step
920 logical,
intent(in),
optional :: allow_missing
921 integer,
intent(in),
optional :: comp_id
923 real(rp),
allocatable :: buf(:,:)
927 type(filebasemeshfieldcomp),
pointer :: comp_ptr
930 if ( this%fid /= -1 )
then
931 call this%get_comp_ptr( comp_id, &
935 dims(1) = comp_ptr%dimsinfo(mf2d_dimtype_x)%size
936 dims(2) = comp_ptr%dimsinfo(mf2d_dimtype_y)%size
937 allocate( buf(dims(1),dims(2)) )
939 call file_read( this%fid, varname, &
941 step=step, allow_missing=allow_missing )
944 lcmesh, buf(:,:), i0_s, j0_s, &
949 end subroutine file_base_meshfield_read_var2d_local
953 subroutine file_base_meshfield_read_var3d( this, & ! (inout)
954 dim_typeid, varname, &
956 step, allow_missing, comp_id )
958 use scale_file,
only: &
968 integer,
intent(in) :: dim_typeid
969 character(*),
intent(in) :: varname
971 integer,
intent(in),
optional :: step
972 logical,
intent(in),
optional :: allow_missing
973 integer,
intent(in),
optional :: comp_id
975 real(rp),
allocatable :: buf(:,:,:)
979 type(filebasemeshfieldcomp),
pointer :: comp_ptr
982 if ( this%fid /= -1 )
then
983 call this%get_comp_ptr( comp_id, &
987 dims(1) = comp_ptr%dimsinfo(mf3d_dimtype_x)%size
988 dims(2) = comp_ptr%dimsinfo(mf3d_dimtype_y)%size
989 dims(3) = comp_ptr%dimsinfo(mf3d_dimtype_z)%size
990 allocate( buf(dims(1),dims(2),dims(3)) )
992 call file_read( this%fid, varname, &
994 step=step, allow_missing=allow_missing )
996 if (
associated(comp_ptr%meshCS3D) )
then
998 comp_ptr%meshCS3D, buf(:,:,:), &
1000 else if (
associated(comp_ptr%mesh3D) )
then
1007 end subroutine file_base_meshfield_read_var3d
1011 subroutine file_base_meshfield_read_var3d_local( this, & ! (inout)
1012 dim_typeid, varname, lcmesh, i0_s, j0_s, k0_s, &
1014 step, allow_missing, comp_id )
1016 use scale_file,
only: &
1024 integer,
intent(in) :: dim_typeid
1025 character(*),
intent(in) :: varname
1027 integer,
intent(in) :: i0_s, j0_s, k0_s
1028 real(rp),
intent(out) :: val(lcmesh%refelem3d%np,lcmesh%nea)
1029 integer,
intent(in),
optional :: step
1030 logical,
intent(in),
optional :: allow_missing
1031 integer,
intent(in),
optional :: comp_id
1033 real(rp),
allocatable :: buf(:,:,:)
1037 type(filebasemeshfieldcomp),
pointer :: comp_ptr
1040 if ( this%fid /= -1 )
then
1041 call this%get_comp_ptr( comp_id, &
1045 dims(1) = comp_ptr%dimsinfo(mf3d_dimtype_x)%size
1046 dims(2) = comp_ptr%dimsinfo(mf3d_dimtype_y)%size
1047 dims(3) = comp_ptr%dimsinfo(mf3d_dimtype_z)%size
1048 allocate( buf(dims(1),dims(2),dims(3)) )
1050 call file_read( this%fid, varname, &
1052 step=step, allow_missing=allow_missing )
1055 lcmesh, buf(:,:,:), i0_s, j0_s, k0_s, &
1060 end subroutine file_base_meshfield_read_var3d_local
1063 subroutine file_base_meshfield_close( this )
1064 use scale_file,
only: file_close
1070 if ( this%fid /= -1 )
then
1071 call file_close( this%fid )
1076 end subroutine file_base_meshfield_close
1080 subroutine file_base_meshfield_final( this )
1085 type(filebasemeshfieldcomp),
pointer :: comp_ptr
1088 do i=1, this%comp_num
1089 call this%get_comp_ptr( i, comp_ptr )
1090 if (
allocated(comp_ptr%vars_ncid) )
deallocate( comp_ptr%vars_ncid )
1091 if (
allocated(comp_ptr%dimsinfo) )
deallocate( comp_ptr%dimsinfo )
1092 nullify( comp_ptr%mesh1D, comp_ptr%mesh2D, comp_ptr%mesh3D )
1093 nullify( comp_ptr%meshCS2D, comp_ptr%meshCS3D )
1097 end subroutine file_base_meshfield_final
1100 subroutine file_base_meshfield_put_global_attribute_time( &
1101 this, date, subsec )
1103 use scale_file,
only: &
1104 file_set_attribute, &
1106 use scale_calendar,
only: &
1112 integer,
intent(in) :: date(6)
1113 real(dp),
intent(in) :: subsec
1115 character(34) :: tunits
1116 character(len=H_SHORT) :: calendar_name
1119 call file_set_attribute( this%fid,
"global",
"Conventions",
"CF-1.6" )
1120 call file_set_attribute( this%fid,
"global",
"grid_name",
"hoge" )
1124 if ( date(1) > 0 )
then
1125 call file_get_cftunits( date(:), tunits )
1126 call calendar_get_name( calendar_name )
1132 if ( calendar_name /=
"" ) &
1133 call file_set_attribute( this%fid,
"global",
"calendar", calendar_name )
1134 call file_set_attribute( this%fid,
"global",
"time_units", tunits )
1135 call file_set_attribute( this%fid,
"global",
"time_start", (/ subsec /) )
1138 end subroutine file_base_meshfield_put_global_attribute_time
1142 subroutine def_axes( this, & ! (in)
1144 use scale_const,
only: &
1145 undef => const_undef
1146 use scale_file,
only: &
1148 file_set_attribute, &
1149 file_def_associatedcoordinate, &
1150 file_add_associatedvariable
1154 class(filebasemeshfieldcomp),
intent(in) :: this
1155 integer,
intent(in) :: fid
1157 character(*),
intent(in) :: dtype
1163 i_dtype = get_dtype( dtype )
1165 select case ( this%mesh_type_id )
1168 case ( meshtype_2d_rectdom, meshtype_2d_cubedsphere )
1170 case ( meshtype_3d_cubedom, meshtype_3d_cubedsphere )
1176 call file_def_axis( fid, &
1177 this%dimsinfo(d)%name, this%dimsinfo(d)%desc, this%dimsinfo(d)%unit, &
1178 this%dimsinfo(d)%name, i_dtype, this%dimsinfo(d)%size )
1181 end subroutine def_axes
1183 subroutine write_axes( this, & ! (in)
1185 use scale_const,
only: &
1186 undef => const_undef
1187 use scale_file,
only: &
1194 class(filebasemeshfieldcomp),
intent(in) :: this
1195 integer,
intent(in) :: fid
1196 integer,
intent(in) :: start(3)
1198 real(rp),
allocatable :: x(:)
1199 real(rp),
allocatable :: y(:)
1200 real(rp),
allocatable :: z(:)
1203 select case ( this%mesh_type_id )
1205 allocate( x(this%dimsinfo(1)%size) )
1206 case ( meshtype_2d_rectdom, meshtype_2d_cubedsphere )
1207 allocate( x(this%dimsinfo(1)%size), y(this%dimsinfo(2)%size) )
1208 case ( meshtype_3d_cubedom, meshtype_3d_cubedsphere )
1209 allocate( x(this%dimsinfo(1)%size), y(this%dimsinfo(2)%size), z(this%dimsinfo(3)%size) )
1213 select case ( this%mesh_type_id )
1216 case ( meshtype_2d_rectdom )
1218 case ( meshtype_2d_cubedsphere )
1220 case ( meshtype_3d_cubedom )
1222 case ( meshtype_3d_cubedsphere )
1227 select case ( this%mesh_type_id )
1229 call file_write_axis( fid, this%dimsinfo(1)%name, x(:), start(1:1) )
1230 case ( meshtype_2d_rectdom, meshtype_2d_cubedsphere )
1231 call file_write_axis( fid, this%dimsinfo(1)%name, x(:), start(1:1) )
1232 call file_write_axis( fid, this%dimsinfo(2)%name, y(:), start(2:2) )
1233 case ( meshtype_3d_cubedom, meshtype_3d_cubedsphere )
1234 call file_write_axis( fid, this%dimsinfo(1)%name, x(:), start(1:1) )
1235 call file_write_axis( fid, this%dimsinfo(2)%name, y(:), start(2:2) )
1236 call file_write_axis( fid, this%dimsinfo(3)%name, z(:), start(3:3) )
1237 if ( this%dimsinfo(3)%positive_down(1) ) &
1238 call file_set_attribute( fid, this%dimsinfo(3)%name,
"positive",
"down" )
1242 end subroutine write_axes
1245 subroutine file_base_meshfield_get_comp( this, comp_id, & ! (in)
1249 integer,
intent(in),
optional :: comp_id
1250 type(filebasemeshfieldcomp),
intent(out),
pointer :: comp_ptr
1253 if (
present(comp_id) )
then
1254 if ( comp_id < 1 .or. comp_id > this%comp_num )
then
1255 log_error(
"FILE_base_meshfield_get_comp",*)
'Invalid component ID. Check!'
1258 comp_ptr => this%comp(comp_id)
1260 comp_ptr => this%comp(this%main_comp_id)
1263 end subroutine file_base_meshfield_get_comp
module FElib / Element / Base
module FElib / File / Base
integer, parameter component_num_max
Maximum number of components to be registered.
integer, parameter meshtype_1d
module FElib / File / Common
subroutine, public file_common_meshfield_set_cartesbuf_field1d(mesh1d, buf, field1d)
subroutine, public file_common_meshfield_set_cartesbuf_field2d(mesh2d, buf, field2d)
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_set_cartesbuf_field3d(mesh3d, buf, field3d)
subroutine, public file_common_meshfield_put_field1d_cartesbuf(mesh1d, field1d, buf, force_uniform_grid)
subroutine, public file_common_meshfield_set_cartesbuf_field2d_local(lcmesh, buf, i0_s, j0_s, val)
subroutine, public file_common_meshfield_set_cartesbuf_field3d_local(lcmesh, buf, i0_s, j0_s, k0_s, val)
subroutine, public file_common_meshfield_put_field3d_cartesbuf(mesh3d, field3d, buf, force_uniform_grid)
subroutine, public file_common_meshfield_set_cartesbuf_field1d_local(lcmesh, buf, i0_s, val)
subroutine, public file_common_meshfield_set_cartesbuf_field3d_cubedsphere(mesh3d, buf, field3d)
subroutine, public file_common_meshfield_set_cartesbuf_field2d_cubedsphere(mesh2d, buf, field2d)
integer function, public file_common_meshfield_get_dtype(datatype)
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 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)