34 include
'scale_file_c.inc'
49 public :: file_put_axis
50 public :: file_write_axis
52 public :: file_put_associatedcoordinate
53 public :: file_write_associatedcoordinate
54 public :: file_add_variable
56 public :: file_get_shape
58 public :: file_get_commoninfo
59 public :: file_get_datainfo
60 public :: file_get_all_datainfo
63 public :: file_get_attribute
64 public :: file_set_attribute
76 interface file_get_commoninfo
77 module procedure file_get_commoninfo_fid
78 module procedure file_get_commoninfo_fname
79 end interface file_get_commoninfo
81 interface file_get_shape
82 module procedure file_get_shape_fid
83 module procedure file_get_shape_fname
84 end interface file_get_shape
86 interface file_get_datainfo
87 module procedure file_get_datainfo_fid
88 module procedure file_get_datainfo_fname
89 end interface file_get_datainfo
91 interface file_get_all_datainfo
92 module procedure file_get_all_datainfo_fid
93 module procedure file_get_all_datainfo_fname
94 end interface file_get_all_datainfo
96 interface file_put_axis
97 module procedure file_put_axis_realsp
98 module procedure file_put_axis_realdp
99 end interface file_put_axis
100 interface file_write_axis
101 module procedure file_write_axis_realsp
102 module procedure file_write_axis_realdp
103 end interface file_write_axis
104 interface file_put_associatedcoordinate
105 module procedure file_put_associatedcoordinate_realsp_1d
106 module procedure file_put_associatedcoordinate_realdp_1d
107 module procedure file_put_associatedcoordinate_realsp_2d
108 module procedure file_put_associatedcoordinate_realdp_2d
109 module procedure file_put_associatedcoordinate_realsp_3d
110 module procedure file_put_associatedcoordinate_realdp_3d
111 module procedure file_put_associatedcoordinate_realsp_4d
112 module procedure file_put_associatedcoordinate_realdp_4d
113 end interface file_put_associatedcoordinate
114 interface file_write_associatedcoordinate
115 module procedure file_write_associatedcoordinate_realsp_1d
116 module procedure file_write_associatedcoordinate_realdp_1d
117 module procedure file_write_associatedcoordinate_realsp_2d
118 module procedure file_write_associatedcoordinate_realdp_2d
119 module procedure file_write_associatedcoordinate_realsp_3d
120 module procedure file_write_associatedcoordinate_realdp_3d
121 module procedure file_write_associatedcoordinate_realsp_4d
122 module procedure file_write_associatedcoordinate_realdp_4d
123 end interface file_write_associatedcoordinate
124 interface file_add_variable
125 module procedure file_add_variable_no_time
126 module procedure file_add_variable_with_time
127 end interface file_add_variable
129 module procedure file_read_realsp_1d
130 module procedure file_read_realdp_1d
131 module procedure file_read_realsp_2d
132 module procedure file_read_realdp_2d
133 module procedure file_read_realsp_3d
134 module procedure file_read_realdp_3d
135 module procedure file_read_realsp_4d
136 module procedure file_read_realdp_4d
137 module procedure file_read_var_realsp_1d
138 module procedure file_read_var_realdp_1d
139 module procedure file_read_var_realsp_2d
140 module procedure file_read_var_realdp_2d
141 module procedure file_read_var_realsp_3d
142 module procedure file_read_var_realdp_3d
143 module procedure file_read_var_realsp_4d
144 module procedure file_read_var_realdp_4d
145 end interface file_read
147 module procedure file_write_realsp_1d
148 module procedure file_write_realdp_1d
149 module procedure file_write_realsp_2d
150 module procedure file_write_realdp_2d
151 module procedure file_write_realsp_3d
152 module procedure file_write_realdp_3d
153 module procedure file_write_realsp_4d
154 module procedure file_write_realdp_4d
155 end interface file_write
156 interface file_get_attribute
157 module procedure file_get_attribute_text_fname
158 module procedure file_get_attribute_logical_fname
159 module procedure file_get_attribute_int_fname_ary
160 module procedure file_get_attribute_int_fname
161 module procedure file_get_attribute_float_fname_ary
162 module procedure file_get_attribute_float_fname
163 module procedure file_get_attribute_double_fname_ary
164 module procedure file_get_attribute_double_fname
165 module procedure file_get_attribute_text_fid
166 module procedure file_get_attribute_logical_fid
167 module procedure file_get_attribute_int_fid_ary
168 module procedure file_get_attribute_int_fid
169 module procedure file_get_attribute_float_fid_ary
170 module procedure file_get_attribute_float_fid
171 module procedure file_get_attribute_double_fid_ary
172 module procedure file_get_attribute_double_fid
173 end interface file_get_attribute
174 interface file_set_attribute
175 module procedure file_set_attribute_text
176 module procedure file_set_attribute_logical
177 module procedure file_set_attribute_int_ary
178 module procedure file_set_attribute_int
179 module procedure file_set_attribute_float_ary
180 module procedure file_set_attribute_float
181 module procedure file_set_attribute_double_ary
182 module procedure file_set_attribute_double
183 end interface file_set_attribute
185 #if defined(__GFORTRAN__) && __GNUC__ < 7
187 module procedure cloc_sp
188 module procedure cloc_dp
202 private :: file_get_fid
209 character(len=FILE_HLONG) :: name
214 integer(8) :: buffer_size
217 integer :: file_nfiles = 0
220 character(len=FILE_HLONG) :: name
225 integer :: file_nvars = 0
227 integer :: mpi_myrank
240 integer,
intent(in) :: myrank
242 namelist / param_file / &
254 log_info(
"FILE_setup",*)
'Not found namelist. Default used.'
255 elseif( ierr > 0 )
then
256 log_error(
"FILE_setup",*)
'Not appropriate names in namelist PARAM_FILE. Check!'
266 file_files(fid)%fid = -1
267 file_files(fid)%name =
""
290 title, source, institution, &
292 rankid, single, aggregate, &
293 time_units, calendar, &
297 character(len=*),
intent(in) :: basename
298 character(len=*),
intent(in) :: title
299 character(len=*),
intent(in) :: source
300 character(len=*),
intent(in) :: institution
302 integer,
intent(out) :: fid
303 logical,
intent(out) :: existed
305 integer,
intent(in),
optional :: rankid
306 logical,
intent(in),
optional :: single
307 logical,
intent(in),
optional :: aggregate
308 character(len=*),
intent(in),
optional :: time_units
309 character(len=*),
intent(in),
optional :: calendar
310 logical,
intent(in),
optional :: allnodes
311 logical,
intent(in),
optional :: append
313 character(len=FILE_HMID) :: time_units_
314 character(len=FILE_HSHORT) :: calendar_
323 if (
present(rankid) )
then
330 if (
present(single) )
then
334 if (
present(time_units) )
then
335 time_units_ = time_units
337 time_units_ =
'seconds'
340 if (
present(calendar) )
then
347 if (
present(append) )
then
351 if ( single_ .and. rankid_ /= 0 )
then
357 call file_get_fid( basename, mode, &
361 aggregate=aggregate )
365 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
368 call file_set_attribute( fid,
"global",
"title" , title )
369 call file_set_attribute( fid,
"global",
"source" , source )
370 call file_set_attribute( fid,
"global",
"institution", institution )
372 if ( ( .not.
present(aggregate) ) .or. .not. aggregate )
then
374 call file_set_attribute( fid,
"global",
"rankid" , (/rankid_/) )
382 log_error(
"FILE_create",*)
'failed to set time units'
386 call prof_rapend(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
392 subroutine file_get_var_num( &
397 integer,
intent(in) :: fid
398 integer,
intent(in) :: nvars_limit
399 integer,
intent(out) :: nvars
405 log_error(
"FILE_get_var_num",*)
'File is not opened. fid = ', fid
409 call prof_rapstart(
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
412 file_files(fid)%fid )
414 log_error(
"FILE_get_var_num",*)
'failed to get varnum. fid = ', fid
418 if ( nvars > nvars_limit )
then
419 log_error(
"FILE_get_var_num",*)
'number of variables exceeds the requested size.', nvars, nvars_limit
423 call prof_rapend (
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
426 end subroutine file_get_var_num
429 subroutine file_get_var_name( &
434 integer,
intent(in) :: fid
435 integer,
intent(in) :: cvid
436 character(len=*),
intent(out) :: varname
442 log_error(
"FILE_get_var_name",*)
'File is not opened. fid = ', fid
446 call prof_rapstart(
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
449 file_files(fid)%fid, cvid, len(varname) )
453 log_error(
"FILE_get_var_name",*)
'failed to get varname. cvid = ', cvid
457 call prof_rapend (
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
460 end subroutine file_get_var_name
464 integer,
intent(in) :: fid
465 character(len=*),
intent(in) :: vname
466 logical,
optional,
intent(out) :: existed
471 log_error(
"FILE_add_associatedVariable",*)
'File is not opened. fid = ', fid
475 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
479 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
481 if (
present(existed) )
then
490 log_error(
"FILE_add_associatedvariable",*)
'failed to add associated variable: '//trim(vname)
501 integer,
intent(in) :: fid
502 character(len=*),
intent(in) :: filetype
503 character(len=*),
intent(in) :: key
504 character(len=*),
intent(in) :: val
509 log_error(
"FILE_set_option",*)
'File is not opened. fid = ', fid
513 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
517 log_error(
"FILE_set_option",*)
'failed to set option'
521 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
538 character(len=*),
intent( in) :: basename
539 integer,
intent(out) :: fid
540 integer,
intent( in),
optional :: mode
541 logical,
intent( in),
optional :: single
542 logical,
intent( in),
optional :: allnodes
543 logical,
intent( in),
optional :: aggregate
544 integer,
intent( in),
optional :: rankid
545 character(len=*),
intent( in),
optional :: postfix
554 if (
present(mode) )
then
560 if (
present(single) ) single_ = single
561 if (
present(rankid) )
then
567 call file_get_fid( basename, mode_, rankid_, single_, &
570 aggregate=aggregate, postfix=postfix )
580 integer,
intent( in) :: fid
597 integer,
intent( in) :: fid
614 integer,
intent( in) :: fid
633 integer,
intent(in) :: fid
634 character(len=*),
intent(in) :: dimname
636 integer,
intent(out) :: len
638 logical,
intent(out),
optional :: error
640 logical(c_bool) :: suppress
645 log_error(
"FILE_get_dimLength",*)
'File is not opened. fid = ', fid
649 call prof_rapstart(
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
651 if (
present(error) )
then
658 file_files(fid)%fid, &
662 if (
present(error) )
then
665 log_error(
"FILE_get_dimLength",*)
'failed to get dimension length'
669 if (
present(error) ) error = .false.
672 call prof_rapend (
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
680 subroutine file_put_axis_realsp( &
685 integer,
intent(in) :: fid
686 character(len=*),
intent(in) :: name
687 character(len=*),
intent(in) :: desc
688 character(len=*),
intent(in) :: units
689 character(len=*),
intent(in) :: dim_name
690 integer,
intent(in) :: dtype
691 real(
sp),
intent(in),
target,
contiguous :: val(:)
697 log_error(
"FILE_put_axis_real",*)
'File is not opened. fid = ', fid
701 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
707 cstr(dim_name), dtype, &
708 #if defined(__GFORTRAN__) && __GNUC__ < 7
709 cloc(val(1)),
size(val),
sp )
711 c_loc(val),
size(val),
sp )
714 log_error(
"FILE_put_axis_realSP",*)
'failed to put axis'
718 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
721 end subroutine file_put_axis_realsp
722 subroutine file_put_axis_realdp( &
727 integer,
intent(in) :: fid
728 character(len=*),
intent(in) :: name
729 character(len=*),
intent(in) :: desc
730 character(len=*),
intent(in) :: units
731 character(len=*),
intent(in) :: dim_name
732 integer,
intent(in) :: dtype
733 real(
dp),
intent(in),
target,
contiguous :: val(:)
739 log_error(
"FILE_put_axis_real",*)
'File is not opened. fid = ', fid
743 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
749 cstr(dim_name), dtype, &
750 #if defined(__GFORTRAN__) && __GNUC__ < 7
751 cloc(val(1)),
size(val),
dp )
753 c_loc(val),
size(val),
dp )
756 log_error(
"FILE_put_axis_realDP",*)
'failed to put axis'
760 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
763 end subroutine file_put_axis_realdp
768 dim_name, dtype, dim_size, &
770 integer,
intent(in) :: fid
771 character(len=*),
intent(in) :: name
772 character(len=*),
intent(in) :: desc
773 character(len=*),
intent(in) :: units
774 character(len=*),
intent(in) :: dim_name
775 integer,
intent(in) :: dtype
776 integer,
intent(in) :: dim_size
778 logical,
intent(in),
optional :: bounds
784 if (
present(bounds) )
then
785 if ( bounds ) bounds_ = 1
789 log_error(
"FILE_def_axis",*)
'File is not opened. fid = ', fid
793 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
797 cstr(dim_name), dtype, dim_size, bounds_ )
799 log_error(
"FILE_def_axis",*)
'failed to define axis'
803 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
811 subroutine file_write_axis_realsp( &
816 integer,
intent(in) :: fid
817 character(len=*),
intent(in) :: name
818 real(
sp),
intent(in),
target,
contiguous :: val(:)
819 integer,
intent(in),
optional :: start(:)
825 log_error(
"FILE_write_axis_realSP",*)
'File is not opened. fid = ', fid
829 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
833 if (
present(start) )
then
835 #if defined(__GFORTRAN__) && __GNUC__ < 7
836 cloc(val(1)),
sp, start-1, shape(val) )
838 c_loc(val),
sp, start-1, shape(val) )
842 #if defined(__GFORTRAN__) && __GNUC__ < 7
843 cloc(val(1)),
sp, (/0/), shape(val) )
845 c_loc(val),
sp, (/0/), shape(val) )
849 log_error(
"FILE_write_axis_realSP",*)
'failed to write axis: '//trim(name)
853 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
856 end subroutine file_write_axis_realsp
857 subroutine file_write_axis_realdp( &
862 integer,
intent(in) :: fid
863 character(len=*),
intent(in) :: name
864 real(
dp),
intent(in),
target,
contiguous :: val(:)
865 integer,
intent(in),
optional :: start(:)
871 log_error(
"FILE_write_axis_realDP",*)
'File is not opened. fid = ', fid
875 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
879 if (
present(start) )
then
881 #if defined(__GFORTRAN__) && __GNUC__ < 7
882 cloc(val(1)),
dp, start-1, shape(val) )
884 c_loc(val),
dp, start-1, shape(val) )
888 #if defined(__GFORTRAN__) && __GNUC__ < 7
889 cloc(val(1)),
dp, (/0/), shape(val) )
891 c_loc(val),
dp, (/0/), shape(val) )
895 log_error(
"FILE_write_axis_realDP",*)
'failed to write axis: '//trim(name)
899 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
902 end subroutine file_write_axis_realdp
907 subroutine file_put_associatedcoordinate_realsp_1d( &
912 integer,
intent(in) :: fid
913 character(len=*),
intent(in) :: name
914 character(len=*),
intent(in) :: desc
915 character(len=*),
intent(in) :: units
916 character(len=*),
intent(in) :: dim_names(:)
917 integer,
intent(in) :: dtype
919 real(
sp),
intent(in) :: val(:)
921 real(
sp),
intent(in),
target,
contiguous :: val(:)
924 type(c_ptr) :: dim_names_(size(dim_names))
926 character(len=H_SHORT),
allocatable,
target :: cptr(:)
933 log_error(
"FILE_put_associatedCoordinate_realSP_1D",*)
'File is not opened. fid = ', fid
937 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
940 allocate( cptr(
size(dim_names)) )
941 do i = 1,
size(dim_names)
942 cptr(
i) =
cstr(dim_names(
i))
943 dim_names_(
i) = c_loc(cptr(
i))
950 real(
sp),
allocatable,
target :: work(:)
951 allocate(work, source=val)
954 file_files(fid)%fid, &
956 dim_names_,
size(dim_names), dtype, &
957 #if defined(__GFORTRAN__) && __GNUC__ < 7
959 #elif defined(NVIDIA)
965 log_error(
"FILE_put_associatedCoordinate_realSP_1D",*)
'failed to put associated coordinate: '//trim(name)
973 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
976 end subroutine file_put_associatedcoordinate_realsp_1d
977 subroutine file_put_associatedcoordinate_realdp_1d( &
982 integer,
intent(in) :: fid
983 character(len=*),
intent(in) :: name
984 character(len=*),
intent(in) :: desc
985 character(len=*),
intent(in) :: units
986 character(len=*),
intent(in) :: dim_names(:)
987 integer,
intent(in) :: dtype
989 real(dp),
intent(in) :: val(:)
991 real(dp),
intent(in),
target,
contiguous :: val(:)
994 type(c_ptr) :: dim_names_(size(dim_names))
996 character(len=H_SHORT),
allocatable,
target :: cptr(:)
1003 log_error(
"FILE_put_associatedCoordinate_realDP_1D",*)
'File is not opened. fid = ', fid
1007 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1010 allocate( cptr(
size(dim_names)) )
1011 do i = 1,
size(dim_names)
1012 cptr(
i) = cstr(dim_names(
i))
1013 dim_names_(
i) = c_loc(cptr(
i))
1020 real(dp),
allocatable,
target :: work(:)
1021 allocate(work, source=val)
1024 file_files(fid)%fid, &
1025 cstr(name), cstr(desc), cstr(units), &
1026 dim_names_,
size(dim_names), dtype, &
1027 #if defined(__GFORTRAN__) && __GNUC__ < 7
1029 #elif defined(NVIDIA)
1034 if ( error /= file_success_code .and. error /= file_already_existed_code )
then
1035 log_error(
"FILE_put_associatedCoordinate_realDP_1D",*)
'failed to put associated coordinate: '//trim(name)
1043 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1046 end subroutine file_put_associatedcoordinate_realdp_1d
1047 subroutine file_put_associatedcoordinate_realsp_2d( &
1049 name, desc, units, &
1052 integer,
intent(in) :: fid
1053 character(len=*),
intent(in) :: name
1054 character(len=*),
intent(in) :: desc
1055 character(len=*),
intent(in) :: units
1056 character(len=*),
intent(in) :: dim_names(:)
1057 integer,
intent(in) :: dtype
1059 real(sp),
intent(in) :: val(:,:)
1061 real(sp),
intent(in),
target,
contiguous :: val(:,:)
1064 type(c_ptr) :: dim_names_(size(dim_names))
1066 character(len=H_SHORT),
allocatable,
target :: cptr(:)
1073 log_error(
"FILE_put_associatedCoordinate_realSP_2D",*)
'File is not opened. fid = ', fid
1077 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1080 allocate( cptr(
size(dim_names)) )
1081 do i = 1,
size(dim_names)
1082 cptr(
i) = cstr(dim_names(
i))
1083 dim_names_(
i) = c_loc(cptr(
i))
1090 real(sp),
allocatable,
target :: work(:,:)
1091 allocate(work, source=val)
1094 file_files(fid)%fid, &
1095 cstr(name), cstr(desc), cstr(units), &
1096 dim_names_,
size(dim_names), dtype, &
1097 #if defined(__GFORTRAN__) && __GNUC__ < 7
1098 cloc(val(1,1)), sp )
1099 #elif defined(NVIDIA)
1104 if ( error /= file_success_code .and. error /= file_already_existed_code )
then
1105 log_error(
"FILE_put_associatedCoordinate_realSP_2D",*)
'failed to put associated coordinate: '//trim(name)
1113 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1116 end subroutine file_put_associatedcoordinate_realsp_2d
1117 subroutine file_put_associatedcoordinate_realdp_2d( &
1119 name, desc, units, &
1122 integer,
intent(in) :: fid
1123 character(len=*),
intent(in) :: name
1124 character(len=*),
intent(in) :: desc
1125 character(len=*),
intent(in) :: units
1126 character(len=*),
intent(in) :: dim_names(:)
1127 integer,
intent(in) :: dtype
1129 real(dp),
intent(in) :: val(:,:)
1131 real(dp),
intent(in),
target,
contiguous :: val(:,:)
1134 type(c_ptr) :: dim_names_(size(dim_names))
1136 character(len=H_SHORT),
allocatable,
target :: cptr(:)
1143 log_error(
"FILE_put_associatedCoordinate_realDP_2D",*)
'File is not opened. fid = ', fid
1147 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1150 allocate( cptr(
size(dim_names)) )
1151 do i = 1,
size(dim_names)
1152 cptr(
i) = cstr(dim_names(
i))
1153 dim_names_(
i) = c_loc(cptr(
i))
1160 real(dp),
allocatable,
target :: work(:,:)
1161 allocate(work, source=val)
1164 file_files(fid)%fid, &
1165 cstr(name), cstr(desc), cstr(units), &
1166 dim_names_,
size(dim_names), dtype, &
1167 #if defined(__GFORTRAN__) && __GNUC__ < 7
1168 cloc(val(1,1)), dp )
1169 #elif defined(NVIDIA)
1174 if ( error /= file_success_code .and. error /= file_already_existed_code )
then
1175 log_error(
"FILE_put_associatedCoordinate_realDP_2D",*)
'failed to put associated coordinate: '//trim(name)
1183 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1186 end subroutine file_put_associatedcoordinate_realdp_2d
1187 subroutine file_put_associatedcoordinate_realsp_3d( &
1189 name, desc, units, &
1192 integer,
intent(in) :: fid
1193 character(len=*),
intent(in) :: name
1194 character(len=*),
intent(in) :: desc
1195 character(len=*),
intent(in) :: units
1196 character(len=*),
intent(in) :: dim_names(:)
1197 integer,
intent(in) :: dtype
1199 real(sp),
intent(in) :: val(:,:,:)
1201 real(sp),
intent(in),
target,
contiguous :: val(:,:,:)
1204 type(c_ptr) :: dim_names_(size(dim_names))
1206 character(len=H_SHORT),
allocatable,
target :: cptr(:)
1213 log_error(
"FILE_put_associatedCoordinate_realSP_3D",*)
'File is not opened. fid = ', fid
1217 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1220 allocate( cptr(
size(dim_names)) )
1221 do i = 1,
size(dim_names)
1222 cptr(
i) = cstr(dim_names(
i))
1223 dim_names_(
i) = c_loc(cptr(
i))
1230 real(sp),
allocatable,
target :: work(:,:,:)
1231 allocate(work, source=val)
1234 file_files(fid)%fid, &
1235 cstr(name), cstr(desc), cstr(units), &
1236 dim_names_,
size(dim_names), dtype, &
1237 #if defined(__GFORTRAN__) && __GNUC__ < 7
1238 cloc(val(1,1,1)), sp )
1239 #elif defined(NVIDIA)
1244 if ( error /= file_success_code .and. error /= file_already_existed_code )
then
1245 log_error(
"FILE_put_associatedCoordinate_realSP_3D",*)
'failed to put associated coordinate: '//trim(name)
1253 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1256 end subroutine file_put_associatedcoordinate_realsp_3d
1257 subroutine file_put_associatedcoordinate_realdp_3d( &
1259 name, desc, units, &
1262 integer,
intent(in) :: fid
1263 character(len=*),
intent(in) :: name
1264 character(len=*),
intent(in) :: desc
1265 character(len=*),
intent(in) :: units
1266 character(len=*),
intent(in) :: dim_names(:)
1267 integer,
intent(in) :: dtype
1269 real(dp),
intent(in) :: val(:,:,:)
1271 real(dp),
intent(in),
target,
contiguous :: val(:,:,:)
1274 type(c_ptr) :: dim_names_(size(dim_names))
1276 character(len=H_SHORT),
allocatable,
target :: cptr(:)
1283 log_error(
"FILE_put_associatedCoordinate_realDP_3D",*)
'File is not opened. fid = ', fid
1287 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1290 allocate( cptr(
size(dim_names)) )
1291 do i = 1,
size(dim_names)
1292 cptr(
i) = cstr(dim_names(
i))
1293 dim_names_(
i) = c_loc(cptr(
i))
1300 real(dp),
allocatable,
target :: work(:,:,:)
1301 allocate(work, source=val)
1304 file_files(fid)%fid, &
1305 cstr(name), cstr(desc), cstr(units), &
1306 dim_names_,
size(dim_names), dtype, &
1307 #if defined(__GFORTRAN__) && __GNUC__ < 7
1308 cloc(val(1,1,1)), dp )
1309 #elif defined(NVIDIA)
1314 if ( error /= file_success_code .and. error /= file_already_existed_code )
then
1315 log_error(
"FILE_put_associatedCoordinate_realDP_3D",*)
'failed to put associated coordinate: '//trim(name)
1323 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1326 end subroutine file_put_associatedcoordinate_realdp_3d
1327 subroutine file_put_associatedcoordinate_realsp_4d( &
1329 name, desc, units, &
1332 integer,
intent(in) :: fid
1333 character(len=*),
intent(in) :: name
1334 character(len=*),
intent(in) :: desc
1335 character(len=*),
intent(in) :: units
1336 character(len=*),
intent(in) :: dim_names(:)
1337 integer,
intent(in) :: dtype
1339 real(sp),
intent(in) :: val(:,:,:,:)
1341 real(sp),
intent(in),
target,
contiguous :: val(:,:,:,:)
1344 type(c_ptr) :: dim_names_(size(dim_names))
1346 character(len=H_SHORT),
allocatable,
target :: cptr(:)
1353 log_error(
"FILE_put_associatedCoordinate_realSP_4D",*)
'File is not opened. fid = ', fid
1357 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1360 allocate( cptr(
size(dim_names)) )
1361 do i = 1,
size(dim_names)
1362 cptr(
i) = cstr(dim_names(
i))
1363 dim_names_(
i) = c_loc(cptr(
i))
1370 real(sp),
allocatable,
target :: work(:,:,:,:)
1371 allocate(work, source=val)
1374 file_files(fid)%fid, &
1375 cstr(name), cstr(desc), cstr(units), &
1376 dim_names_,
size(dim_names), dtype, &
1377 #if defined(__GFORTRAN__) && __GNUC__ < 7
1378 cloc(val(1,1,1,1)), sp )
1379 #elif defined(NVIDIA)
1384 if ( error /= file_success_code .and. error /= file_already_existed_code )
then
1385 log_error(
"FILE_put_associatedCoordinate_realSP_4D",*)
'failed to put associated coordinate: '//trim(name)
1393 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1396 end subroutine file_put_associatedcoordinate_realsp_4d
1397 subroutine file_put_associatedcoordinate_realdp_4d( &
1399 name, desc, units, &
1402 integer,
intent(in) :: fid
1403 character(len=*),
intent(in) :: name
1404 character(len=*),
intent(in) :: desc
1405 character(len=*),
intent(in) :: units
1406 character(len=*),
intent(in) :: dim_names(:)
1407 integer,
intent(in) :: dtype
1409 real(dp),
intent(in) :: val(:,:,:,:)
1411 real(dp),
intent(in),
target,
contiguous :: val(:,:,:,:)
1414 type(c_ptr) :: dim_names_(size(dim_names))
1416 character(len=H_SHORT),
allocatable,
target :: cptr(:)
1423 log_error(
"FILE_put_associatedCoordinate_realDP_4D",*)
'File is not opened. fid = ', fid
1427 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1430 allocate( cptr(
size(dim_names)) )
1431 do i = 1,
size(dim_names)
1432 cptr(
i) = cstr(dim_names(
i))
1433 dim_names_(
i) = c_loc(cptr(
i))
1440 real(dp),
allocatable,
target :: work(:,:,:,:)
1441 allocate(work, source=val)
1444 file_files(fid)%fid, &
1445 cstr(name), cstr(desc), cstr(units), &
1446 dim_names_,
size(dim_names), dtype, &
1447 #if defined(__GFORTRAN__) && __GNUC__ < 7
1448 cloc(val(1,1,1,1)), dp )
1449 #elif defined(NVIDIA)
1454 if ( error /= file_success_code .and. error /= file_already_existed_code )
then
1455 log_error(
"FILE_put_associatedCoordinate_realDP_4D",*)
'failed to put associated coordinate: '//trim(name)
1463 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1466 end subroutine file_put_associatedcoordinate_realdp_4d
1470 name, desc, units, &
1472 integer,
intent(in) :: fid
1473 character(len=*),
intent(in) :: name
1474 character(len=*),
intent(in) :: desc
1475 character(len=*),
intent(in) :: units
1476 character(len=*),
intent(in) :: dim_names(:)
1477 integer,
intent(in) :: dtype
1479 type(c_ptr) :: dim_names_(size(dim_names))
1481 character(len=H_SHORT+1),
allocatable,
target :: cptr(:)
1488 log_error(
"FILE_def_associatedCoordinate",*)
'File is not opened. fid = ', fid
1492 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1495 allocate( cptr(
size(dim_names)) )
1496 do i = 1,
size(dim_names)
1497 cptr(
i) = cstr(dim_names(
i))
1498 dim_names_(
i) = c_loc(cptr(
i))
1502 file_files(fid)%fid, &
1503 cstr(name), cstr(desc), cstr(units), &
1504 dim_names_,
size(dim_names), dtype )
1505 if ( error /= file_success_code .and. error /= file_already_existed_code )
then
1506 log_error(
"FILE_def_associatedCoordinate",*)
'failed to define associated coordinate: '//trim(name)
1510 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1518 subroutine file_write_associatedcoordinate_realsp_1d( &
1524 integer,
intent(in) :: fid
1525 character(len=*),
intent(in) :: name
1527 real(sp),
intent(in) :: val(:)
1529 real(sp),
intent(in),
target,
contiguous :: val(:)
1531 integer,
intent(in),
optional :: start(:)
1532 integer,
intent(in),
optional :: count(:)
1533 integer,
intent(in),
optional :: ndims
1536 integer,
allocatable :: start_(:), count_(:)
1539 intrinsic shape,
size
1542 log_error(
"FILE_write_associatedCoordinate_realSP_1D",*)
'File is not opened. fid = ', fid
1546 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1548 if (
present(ndims) )
then
1553 allocate( start_(ndims_), count_(ndims_) )
1555 if (
present(ndims) )
then
1559 start_(
i) = start(ndims_-
i+1) - 1
1560 count_(
i) = count(ndims_-
i+1)
1562 else if (
present(start) )
then
1565 start_(
i) = start(1-
i+1) - 1
1566 count_(
i) =
size(val, 1-
i+1)
1572 count_(
i) =
size(val, 1-
i+1)
1580 real(sp),
allocatable,
target :: work(:)
1581 allocate(work, source=val)
1584 file_files(fid)%fid, cstr(name), &
1585 #if defined(__GFORTRAN__) && __GNUC__ < 7
1587 #elif defined(NVIDIA)
1595 if ( error /= file_success_code .and. error /= file_already_existed_code )
then
1596 log_error(
"FILE_write_associatedCoordinate_realSP_1D",*)
'failed to write associated coordinate: '//trim(name)
1604 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1607 end subroutine file_write_associatedcoordinate_realsp_1d
1608 subroutine file_write_associatedcoordinate_realdp_1d( &
1614 integer,
intent(in) :: fid
1615 character(len=*),
intent(in) :: name
1617 real(dp),
intent(in) :: val(:)
1619 real(dp),
intent(in),
target,
contiguous :: val(:)
1621 integer,
intent(in),
optional :: start(:)
1622 integer,
intent(in),
optional :: count(:)
1623 integer,
intent(in),
optional :: ndims
1626 integer,
allocatable :: start_(:), count_(:)
1629 intrinsic shape,
size
1632 log_error(
"FILE_write_associatedCoordinate_realDP_1D",*)
'File is not opened. fid = ', fid
1636 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1638 if (
present(ndims) )
then
1643 allocate( start_(ndims_), count_(ndims_) )
1645 if (
present(ndims) )
then
1649 start_(
i) = start(ndims_-
i+1) - 1
1650 count_(
i) = count(ndims_-
i+1)
1652 else if (
present(start) )
then
1655 start_(
i) = start(1-
i+1) - 1
1656 count_(
i) =
size(val, 1-
i+1)
1662 count_(
i) =
size(val, 1-
i+1)
1670 real(dp),
allocatable,
target :: work(:)
1671 allocate(work, source=val)
1674 file_files(fid)%fid, cstr(name), &
1675 #if defined(__GFORTRAN__) && __GNUC__ < 7
1677 #elif defined(NVIDIA)
1685 if ( error /= file_success_code .and. error /= file_already_existed_code )
then
1686 log_error(
"FILE_write_associatedCoordinate_realDP_1D",*)
'failed to write associated coordinate: '//trim(name)
1694 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1697 end subroutine file_write_associatedcoordinate_realdp_1d
1698 subroutine file_write_associatedcoordinate_realsp_2d( &
1704 integer,
intent(in) :: fid
1705 character(len=*),
intent(in) :: name
1707 real(sp),
intent(in) :: val(:,:)
1709 real(sp),
intent(in),
target,
contiguous :: val(:,:)
1711 integer,
intent(in),
optional :: start(:)
1712 integer,
intent(in),
optional :: count(:)
1713 integer,
intent(in),
optional :: ndims
1716 integer,
allocatable :: start_(:), count_(:)
1719 intrinsic shape,
size
1722 log_error(
"FILE_write_associatedCoordinate_realSP_2D",*)
'File is not opened. fid = ', fid
1726 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1728 if (
present(ndims) )
then
1733 allocate( start_(ndims_), count_(ndims_) )
1735 if (
present(ndims) )
then
1739 start_(
i) = start(ndims_-
i+1) - 1
1740 count_(
i) = count(ndims_-
i+1)
1742 else if (
present(start) )
then
1745 start_(
i) = start(2-
i+1) - 1
1746 count_(
i) =
size(val, 2-
i+1)
1752 count_(
i) =
size(val, 2-
i+1)
1760 real(sp),
allocatable,
target :: work(:,:)
1761 allocate(work, source=val)
1764 file_files(fid)%fid, cstr(name), &
1765 #if defined(__GFORTRAN__) && __GNUC__ < 7
1767 #elif defined(NVIDIA)
1775 if ( error /= file_success_code .and. error /= file_already_existed_code )
then
1776 log_error(
"FILE_write_associatedCoordinate_realSP_2D",*)
'failed to write associated coordinate: '//trim(name)
1784 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1787 end subroutine file_write_associatedcoordinate_realsp_2d
1788 subroutine file_write_associatedcoordinate_realdp_2d( &
1794 integer,
intent(in) :: fid
1795 character(len=*),
intent(in) :: name
1797 real(dp),
intent(in) :: val(:,:)
1799 real(dp),
intent(in),
target,
contiguous :: val(:,:)
1801 integer,
intent(in),
optional :: start(:)
1802 integer,
intent(in),
optional :: count(:)
1803 integer,
intent(in),
optional :: ndims
1806 integer,
allocatable :: start_(:), count_(:)
1809 intrinsic shape,
size
1812 log_error(
"FILE_write_associatedCoordinate_realDP_2D",*)
'File is not opened. fid = ', fid
1816 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1818 if (
present(ndims) )
then
1823 allocate( start_(ndims_), count_(ndims_) )
1825 if (
present(ndims) )
then
1829 start_(
i) = start(ndims_-
i+1) - 1
1830 count_(
i) = count(ndims_-
i+1)
1832 else if (
present(start) )
then
1835 start_(
i) = start(2-
i+1) - 1
1836 count_(
i) =
size(val, 2-
i+1)
1842 count_(
i) =
size(val, 2-
i+1)
1850 real(dp),
allocatable,
target :: work(:,:)
1851 allocate(work, source=val)
1854 file_files(fid)%fid, cstr(name), &
1855 #if defined(__GFORTRAN__) && __GNUC__ < 7
1857 #elif defined(NVIDIA)
1865 if ( error /= file_success_code .and. error /= file_already_existed_code )
then
1866 log_error(
"FILE_write_associatedCoordinate_realDP_2D",*)
'failed to write associated coordinate: '//trim(name)
1874 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1877 end subroutine file_write_associatedcoordinate_realdp_2d
1878 subroutine file_write_associatedcoordinate_realsp_3d( &
1884 integer,
intent(in) :: fid
1885 character(len=*),
intent(in) :: name
1887 real(sp),
intent(in) :: val(:,:,:)
1889 real(sp),
intent(in),
target,
contiguous :: val(:,:,:)
1891 integer,
intent(in),
optional :: start(:)
1892 integer,
intent(in),
optional :: count(:)
1893 integer,
intent(in),
optional :: ndims
1896 integer,
allocatable :: start_(:), count_(:)
1899 intrinsic shape,
size
1902 log_error(
"FILE_write_associatedCoordinate_realSP_3D",*)
'File is not opened. fid = ', fid
1906 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1908 if (
present(ndims) )
then
1913 allocate( start_(ndims_), count_(ndims_) )
1915 if (
present(ndims) )
then
1919 start_(
i) = start(ndims_-
i+1) - 1
1920 count_(
i) = count(ndims_-
i+1)
1922 else if (
present(start) )
then
1925 start_(
i) = start(3-
i+1) - 1
1926 count_(
i) =
size(val, 3-
i+1)
1932 count_(
i) =
size(val, 3-
i+1)
1940 real(sp),
allocatable,
target :: work(:,:,:)
1941 allocate(work, source=val)
1944 file_files(fid)%fid, cstr(name), &
1945 #if defined(__GFORTRAN__) && __GNUC__ < 7
1947 #elif defined(NVIDIA)
1955 if ( error /= file_success_code .and. error /= file_already_existed_code )
then
1956 log_error(
"FILE_write_associatedCoordinate_realSP_3D",*)
'failed to write associated coordinate: '//trim(name)
1964 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1967 end subroutine file_write_associatedcoordinate_realsp_3d
1968 subroutine file_write_associatedcoordinate_realdp_3d( &
1974 integer,
intent(in) :: fid
1975 character(len=*),
intent(in) :: name
1977 real(dp),
intent(in) :: val(:,:,:)
1979 real(dp),
intent(in),
target,
contiguous :: val(:,:,:)
1981 integer,
intent(in),
optional :: start(:)
1982 integer,
intent(in),
optional :: count(:)
1983 integer,
intent(in),
optional :: ndims
1986 integer,
allocatable :: start_(:), count_(:)
1989 intrinsic shape,
size
1992 log_error(
"FILE_write_associatedCoordinate_realDP_3D",*)
'File is not opened. fid = ', fid
1996 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
1998 if (
present(ndims) )
then
2003 allocate( start_(ndims_), count_(ndims_) )
2005 if (
present(ndims) )
then
2009 start_(
i) = start(ndims_-
i+1) - 1
2010 count_(
i) = count(ndims_-
i+1)
2012 else if (
present(start) )
then
2015 start_(
i) = start(3-
i+1) - 1
2016 count_(
i) =
size(val, 3-
i+1)
2022 count_(
i) =
size(val, 3-
i+1)
2030 real(dp),
allocatable,
target :: work(:,:,:)
2031 allocate(work, source=val)
2034 file_files(fid)%fid, cstr(name), &
2035 #if defined(__GFORTRAN__) && __GNUC__ < 7
2037 #elif defined(NVIDIA)
2045 if ( error /= file_success_code .and. error /= file_already_existed_code )
then
2046 log_error(
"FILE_write_associatedCoordinate_realDP_3D",*)
'failed to write associated coordinate: '//trim(name)
2054 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
2057 end subroutine file_write_associatedcoordinate_realdp_3d
2058 subroutine file_write_associatedcoordinate_realsp_4d( &
2064 integer,
intent(in) :: fid
2065 character(len=*),
intent(in) :: name
2067 real(sp),
intent(in) :: val(:,:,:,:)
2069 real(sp),
intent(in),
target,
contiguous :: val(:,:,:,:)
2071 integer,
intent(in),
optional :: start(:)
2072 integer,
intent(in),
optional :: count(:)
2073 integer,
intent(in),
optional :: ndims
2076 integer,
allocatable :: start_(:), count_(:)
2079 intrinsic shape,
size
2082 log_error(
"FILE_write_associatedCoordinate_realSP_4D",*)
'File is not opened. fid = ', fid
2086 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
2088 if (
present(ndims) )
then
2093 allocate( start_(ndims_), count_(ndims_) )
2095 if (
present(ndims) )
then
2099 start_(
i) = start(ndims_-
i+1) - 1
2100 count_(
i) = count(ndims_-
i+1)
2102 else if (
present(start) )
then
2105 start_(
i) = start(4-
i+1) - 1
2106 count_(
i) =
size(val, 4-
i+1)
2112 count_(
i) =
size(val, 4-
i+1)
2120 real(sp),
allocatable,
target :: work(:,:,:,:)
2121 allocate(work, source=val)
2124 file_files(fid)%fid, cstr(name), &
2125 #if defined(__GFORTRAN__) && __GNUC__ < 7
2126 cloc(val(1,1,1,1)), &
2127 #elif defined(NVIDIA)
2135 if ( error /= file_success_code .and. error /= file_already_existed_code )
then
2136 log_error(
"FILE_write_associatedCoordinate_realSP_4D",*)
'failed to write associated coordinate: '//trim(name)
2144 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
2147 end subroutine file_write_associatedcoordinate_realsp_4d
2148 subroutine file_write_associatedcoordinate_realdp_4d( &
2154 integer,
intent(in) :: fid
2155 character(len=*),
intent(in) :: name
2157 real(dp),
intent(in) :: val(:,:,:,:)
2159 real(dp),
intent(in),
target,
contiguous :: val(:,:,:,:)
2161 integer,
intent(in),
optional :: start(:)
2162 integer,
intent(in),
optional :: count(:)
2163 integer,
intent(in),
optional :: ndims
2166 integer,
allocatable :: start_(:), count_(:)
2169 intrinsic shape,
size
2172 log_error(
"FILE_write_associatedCoordinate_realDP_4D",*)
'File is not opened. fid = ', fid
2176 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
2178 if (
present(ndims) )
then
2183 allocate( start_(ndims_), count_(ndims_) )
2185 if (
present(ndims) )
then
2189 start_(
i) = start(ndims_-
i+1) - 1
2190 count_(
i) = count(ndims_-
i+1)
2192 else if (
present(start) )
then
2195 start_(
i) = start(4-
i+1) - 1
2196 count_(
i) =
size(val, 4-
i+1)
2202 count_(
i) =
size(val, 4-
i+1)
2210 real(dp),
allocatable,
target :: work(:,:,:,:)
2211 allocate(work, source=val)
2214 file_files(fid)%fid, cstr(name), &
2215 #if defined(__GFORTRAN__) && __GNUC__ < 7
2216 cloc(val(1,1,1,1)), &
2217 #elif defined(NVIDIA)
2225 if ( error /= file_success_code .and. error /= file_already_existed_code )
then
2226 log_error(
"FILE_write_associatedCoordinate_realDP_4D",*)
'failed to write associated coordinate: '//trim(name)
2234 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
2237 end subroutine file_write_associatedcoordinate_realdp_4d
2242 subroutine file_add_variable_no_time( &
2244 varname, desc, units, &
2249 integer,
intent( in) :: fid
2250 character(len=*),
intent( in) :: varname
2251 character(len=*),
intent( in) :: desc
2252 character(len=*),
intent( in) :: units
2253 character(len=*),
intent( in) :: standard_name
2254 character(len=*),
intent( in) :: dims(:)
2255 integer,
intent( in) :: dtype
2256 integer,
intent(out) :: vid
2257 character(len=*),
intent( in),
optional :: time_stats
2260 log_error(
"FILE_add_variable_no_time",*)
'File is not opened. fid = ', fid
2264 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
2266 call file_add_variable_with_time( fid, &
2267 varname, desc, units, standard_name, &
2268 dims, dtype, -1.0_dp, &
2270 time_stats = time_stats )
2272 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
2275 end subroutine file_add_variable_no_time
2278 subroutine file_add_variable_with_time( &
2280 varname, desc, units, &
2287 integer,
intent(in) :: fid
2288 character(len=*),
intent(in) :: varname
2289 character(len=*),
intent(in) :: desc
2290 character(len=*),
intent(in) :: units
2291 character(len=*),
intent(in) :: standard_name
2292 character(len=*),
intent(in) :: dims(:)
2293 integer,
intent(in) :: dtype
2294 real(dp),
intent(in) :: time_int
2296 integer,
intent(out) :: vid
2298 character(len=*),
intent(in),
optional :: time_stats
2300 type(c_ptr) :: dims_(size(dims))
2302 character(len=H_SHORT),
allocatable,
target :: cptr(:)
2304 character(len=4) :: ctstats
2315 log_error(
"FILE_add_variable_with_time",*)
'File is not opened. fid = ', fid
2319 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
2322 do n = 1, file_nvars
2323 if ( file_vars(n)%fid == fid .and. file_vars(n)%name == varname )
then
2324 vid = file_vars(n)%vid
2334 if (
present(time_stats) )
then
2335 ctstats = time_stats
2339 allocate( cptr(ndims) )
2341 cptr(n) = cstr(dims(n))
2342 dims_(n) = c_loc(cptr(n))
2346 file_files(fid)%fid, &
2347 cstr(varname), cstr(desc), &
2348 cstr(units), cstr(standard_name), &
2349 dims_, ndims, dtype, &
2350 time_int, cstr(ctstats) )
2352 if ( error /= file_success_code )
then
2353 log_error(
"FILE_add_variable_with_time",*)
'failed to add variable: '//trim(varname)
2357 file_nvars = file_nvars + 1
2359 file_vars(vid)%name = varname
2360 file_vars(vid)%vid = cvid
2361 file_vars(vid)%fid = fid
2363 log_info(
"FILE_add_variable_with_time",
'(1x,A,I3.3,A,I4.4,2A)') &
2364 'Variable registration : NO.', fid,
', vid = ', vid,
', name = ', trim(varname)
2367 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
2370 end subroutine file_add_variable_with_time
2374 varname, desc, units, &
2379 time_int, time_stats, &
2381 integer,
intent( in) :: fid
2382 character(len=*),
intent( in) :: varname
2383 character(len=*),
intent( in) :: desc
2384 character(len=*),
intent( in) :: units
2385 character(len=*),
intent( in) :: standard_name
2386 integer,
intent( in) :: ndims
2387 character(len=*),
intent( in) :: dims(:)
2388 integer,
intent( in) :: dtype
2389 integer,
intent(out) :: vid
2390 real(dp),
intent( in),
optional :: time_int
2391 character(len=*),
intent( in),
optional :: time_stats
2392 logical,
intent(out),
optional :: existed
2394 type(c_ptr) :: dims_(size(dims))
2396 character(len=H_SHORT),
allocatable,
target :: cptr(:)
2398 character(len=4) :: ctstats
2408 log_error(
"FILE_def_variable",*)
'File is not opened. fid = ', fid
2412 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
2415 do n = 1, file_nvars
2416 if ( file_vars(n)%fid == fid .and. file_vars(n)%name == varname )
then
2423 if (
present(time_int) )
then
2430 if (
present(time_stats) )
then
2431 ctstats = time_stats
2435 allocate( cptr(ndims) )
2437 cptr(n) = cstr(dims(n))
2438 dims_(n) = c_loc(cptr(n))
2442 file_files(fid)%fid, &
2443 cstr(varname), cstr(desc), &
2444 cstr(units), cstr(standard_name), &
2445 dims_, ndims, dtype, tint_, cstr(ctstats) )
2447 if ( error /= file_success_code )
then
2448 log_error(
"FILE_def_variable",*)
'failed to add variable: '//trim(varname)
2452 file_nvars = file_nvars + 1
2454 file_vars(vid)%name = varname
2455 file_vars(vid)%vid = cvid
2456 file_vars(vid)%fid = fid
2458 log_info(
"FILE_def_variable",
'(1x,A,I3.3,A,I4.4,2A)') &
2459 'Variable registration : NO.', fid,
', vid = ', vid,
', name = ', trim(varname)
2461 if (
present(existed) ) existed = .false.
2463 if (
present(existed) ) existed = .true.
2466 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
2474 subroutine file_get_attribute_text_fid( &
2479 integer,
intent(in ) :: fid
2480 character(len=*),
intent(in ) :: vname
2481 character(len=*),
intent(in ) :: key
2482 character(len=*),
intent(out) :: val
2484 logical,
intent(out),
optional :: existed
2486 logical(c_bool) :: suppress
2490 log_error(
"FILE_get_attribute_text_fid",*)
'File is not opened. fid = ', fid
2494 call prof_rapstart(
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
2496 if (
present(existed) )
then
2502 file_files(fid)%fid, &
2503 cstr(vname), cstr(key), &
2504 suppress, len(val) )
2505 if ( error == file_success_code )
then
2506 if (
present(existed) ) existed = .true.
2509 if (
present(existed) )
then
2512 log_error(
"FILE_get_attribute_text_fid",*)
'failed to get text attribute for '//trim(vname)//
': '//trim(key)
2517 call prof_rapend (
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
2520 end subroutine file_get_attribute_text_fid
2521 subroutine file_get_attribute_text_fname( &
2522 basename, vname, key, &
2524 single, aggregate, rankid, &
2528 character(len=*),
intent(in) :: basename
2529 character(len=*),
intent(in) :: vname
2530 character(len=*),
intent(in) :: key
2532 character(len=*),
intent(out) :: val
2534 logical,
intent(in),
optional :: single
2535 logical,
intent(in),
optional :: aggregate
2536 integer,
intent(in),
optional :: rankid
2538 logical,
intent(out),
optional :: existed
2544 aggregate=aggregate, &
2547 call file_get_attribute_text_fid( &
2553 end subroutine file_get_attribute_text_fname
2556 subroutine file_get_attribute_logical_fid( &
2561 integer,
intent(in ) :: fid
2562 character(len=*),
intent(in ) :: vname
2563 character(len=*),
intent(in ) :: key
2564 logical,
intent(out) :: val
2566 logical,
intent(out),
optional :: existed
2568 character(len=6) :: buf
2571 log_error(
"FILE_get_attribute_logical_fid",*)
'File is not opened. fid = ', fid
2575 call prof_rapstart(
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
2577 call file_get_attribute_text_fid( fid, vname, key, &
2580 if (
present(existed) )
then
2581 if ( .not. existed )
return
2584 if ( buf ==
"true" )
then
2586 else if ( buf ==
"false" )
then
2589 log_error(
"FILE_get_attribute_logical_fid",*)
'value is not eigher true or false'
2593 call prof_rapend (
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
2596 end subroutine file_get_attribute_logical_fid
2597 subroutine file_get_attribute_logical_fname( &
2598 basename, vname, key, &
2600 single, aggregate, rankid, &
2604 character(len=*),
intent(in) :: basename
2605 character(len=*),
intent(in) :: vname
2606 character(len=*),
intent(in) :: key
2608 logical,
intent(out) :: val
2610 logical,
intent(in),
optional :: single
2611 logical,
intent(in),
optional :: aggregate
2612 integer,
intent(in),
optional :: rankid
2614 logical,
intent(out),
optional :: existed
2620 aggregate=aggregate, &
2623 call file_get_attribute_logical_fid( &
2629 end subroutine file_get_attribute_logical_fname
2632 subroutine file_get_attribute_int_fid_ary( &
2636 integer,
intent(in ) :: fid
2637 character(len=*),
intent(in ) :: vname
2638 character(len=*),
intent(in ) :: key
2639 integer,
intent(out) :: val(:)
2641 logical,
intent(out),
optional :: existed
2643 logical(c_bool) :: suppress
2649 log_error(
"FILE_get_attribute_int_fid",*)
'File is not opened. fid = ', fid
2653 call prof_rapstart(
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
2655 if (
present(existed) )
then
2661 file_files(fid)%fid, &
2662 cstr(vname), cstr(key), &
2663 suppress,
size(val) )
2664 if ( error /= file_success_code )
then
2665 if (
present(existed) )
then
2668 log_error(
"FILE_get_attribute_int_fid",*)
'failed to get integer attribute for '//trim(vname)//
': '//trim(key)
2672 if (
present(existed) ) existed = .true.
2675 call prof_rapend (
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
2678 end subroutine file_get_attribute_int_fid_ary
2679 subroutine file_get_attribute_int_fid( &
2683 integer,
intent(in ) :: fid
2684 character(len=*),
intent(in ) :: vname
2685 character(len=*),
intent(in ) :: key
2686 integer,
intent(out) :: val
2687 logical,
intent(out),
optional :: existed
2690 call file_get_attribute_int_fid_ary( &
2694 if (
present(existed) )
then
2695 if ( .not. existed )
return
2700 end subroutine file_get_attribute_int_fid
2701 subroutine file_get_attribute_int_fname_ary( &
2702 basename, vname, key, &
2704 single, aggregate, rankid, &
2708 character(len=*),
intent(in) :: basename
2709 character(len=*),
intent(in) :: vname
2710 character(len=*),
intent(in) :: key
2712 integer,
intent(out) :: val(:)
2714 logical,
intent(in),
optional :: single
2715 logical,
intent(in),
optional :: aggregate
2716 integer,
intent(in),
optional :: rankid
2718 logical,
intent(out),
optional :: existed
2725 aggregate=aggregate, &
2728 call file_get_attribute_int_fid_ary( &
2734 end subroutine file_get_attribute_int_fname_ary
2735 subroutine file_get_attribute_int_fname( &
2736 basename, vname, key, &
2738 single, aggregate, rankid, &
2741 character(len=*),
intent(in) :: basename
2742 character(len=*),
intent(in) :: vname
2743 character(len=*),
intent(in) :: key
2744 integer,
intent(out) :: val
2745 logical,
intent(in),
optional :: single
2746 logical,
intent(in),
optional :: aggregate
2747 integer,
intent(in),
optional :: rankid
2748 logical,
intent(out),
optional :: existed
2751 call file_get_attribute_int_fname_ary( &
2752 basename, vname, key, &
2754 single, aggregate, rankid, &
2759 end subroutine file_get_attribute_int_fname
2762 subroutine file_get_attribute_float_fid_ary( &
2766 integer,
intent(in ) :: fid
2767 character(len=*),
intent(in ) :: vname
2768 character(len=*),
intent(in ) :: key
2769 real(sp),
intent(out) :: val(:)
2771 logical,
intent(out),
optional :: existed
2773 logical(c_bool) :: suppress
2779 log_error(
"FILE_get_attribute_float_fid",*)
'File is not opened. fid = ', fid
2783 call prof_rapstart(
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
2785 if (
present(existed) )
then
2791 file_files(fid)%fid, &
2792 cstr(vname), cstr(key), &
2793 suppress,
size(val) )
2794 if ( error /= file_success_code )
then
2795 if (
present(existed) )
then
2798 log_error(
"FILE_get_attribute_float_fid",*)
'failed to get float attribute for '//trim(vname)//
': '//trim(key)
2802 if (
present(existed) ) existed = .true.
2805 call prof_rapend (
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
2808 end subroutine file_get_attribute_float_fid_ary
2809 subroutine file_get_attribute_float_fid( &
2813 integer,
intent(in ) :: fid
2814 character(len=*),
intent(in ) :: vname
2815 character(len=*),
intent(in ) :: key
2816 real(sp),
intent(out) :: val
2817 logical,
intent(out),
optional :: existed
2820 call file_get_attribute_float_fid_ary( &
2824 if (
present(existed) )
then
2825 if ( .not. existed )
return
2830 end subroutine file_get_attribute_float_fid
2831 subroutine file_get_attribute_float_fname_ary( &
2832 basename, vname, key, &
2834 single, aggregate, rankid, &
2838 character(len=*),
intent(in) :: basename
2839 character(len=*),
intent(in) :: vname
2840 character(len=*),
intent(in) :: key
2842 real(sp),
intent(out) :: val(:)
2844 logical,
intent(in),
optional :: single
2845 logical,
intent(in),
optional :: aggregate
2846 integer,
intent(in),
optional :: rankid
2848 logical,
intent(out),
optional :: existed
2855 aggregate=aggregate, &
2858 call file_get_attribute_float_fid_ary( &
2864 end subroutine file_get_attribute_float_fname_ary
2865 subroutine file_get_attribute_float_fname( &
2866 basename, vname, key, &
2868 single, aggregate, rankid, &
2871 character(len=*),
intent(in) :: basename
2872 character(len=*),
intent(in) :: vname
2873 character(len=*),
intent(in) :: key
2874 real(sp),
intent(out) :: val
2875 logical,
intent(in),
optional :: single
2876 logical,
intent(in),
optional :: aggregate
2877 integer,
intent(in),
optional :: rankid
2878 logical,
intent(out),
optional :: existed
2881 call file_get_attribute_float_fname_ary( &
2882 basename, vname, key, &
2884 single, aggregate, rankid, &
2889 end subroutine file_get_attribute_float_fname
2890 subroutine file_get_attribute_double_fid_ary( &
2894 integer,
intent(in ) :: fid
2895 character(len=*),
intent(in ) :: vname
2896 character(len=*),
intent(in ) :: key
2897 real(dp),
intent(out) :: val(:)
2899 logical,
intent(out),
optional :: existed
2901 logical(c_bool) :: suppress
2907 log_error(
"FILE_get_attribute_double_fid",*)
'File is not opened. fid = ', fid
2911 call prof_rapstart(
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
2913 if (
present(existed) )
then
2919 file_files(fid)%fid, &
2920 cstr(vname), cstr(key), &
2921 suppress,
size(val) )
2922 if ( error /= file_success_code )
then
2923 if (
present(existed) )
then
2926 log_error(
"FILE_get_attribute_double_fid",*)
'failed to get double attribute for '//trim(vname)//
': '//trim(key)
2930 if (
present(existed) ) existed = .true.
2933 call prof_rapend (
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
2936 end subroutine file_get_attribute_double_fid_ary
2937 subroutine file_get_attribute_double_fid( &
2941 integer,
intent(in ) :: fid
2942 character(len=*),
intent(in ) :: vname
2943 character(len=*),
intent(in ) :: key
2944 real(dp),
intent(out) :: val
2945 logical,
intent(out),
optional :: existed
2948 call file_get_attribute_double_fid_ary( &
2952 if (
present(existed) )
then
2953 if ( .not. existed )
return
2958 end subroutine file_get_attribute_double_fid
2959 subroutine file_get_attribute_double_fname_ary( &
2960 basename, vname, key, &
2962 single, aggregate, rankid, &
2966 character(len=*),
intent(in) :: basename
2967 character(len=*),
intent(in) :: vname
2968 character(len=*),
intent(in) :: key
2970 real(dp),
intent(out) :: val(:)
2972 logical,
intent(in),
optional :: single
2973 logical,
intent(in),
optional :: aggregate
2974 integer,
intent(in),
optional :: rankid
2976 logical,
intent(out),
optional :: existed
2983 aggregate=aggregate, &
2986 call file_get_attribute_double_fid_ary( &
2992 end subroutine file_get_attribute_double_fname_ary
2993 subroutine file_get_attribute_double_fname( &
2994 basename, vname, key, &
2996 single, aggregate, rankid, &
2999 character(len=*),
intent(in) :: basename
3000 character(len=*),
intent(in) :: vname
3001 character(len=*),
intent(in) :: key
3002 real(dp),
intent(out) :: val
3003 logical,
intent(in),
optional :: single
3004 logical,
intent(in),
optional :: aggregate
3005 integer,
intent(in),
optional :: rankid
3006 logical,
intent(out),
optional :: existed
3009 call file_get_attribute_double_fname_ary( &
3010 basename, vname, key, &
3012 single, aggregate, rankid, &
3017 end subroutine file_get_attribute_double_fname
3022 subroutine file_set_attribute_text( &
3025 integer,
intent(in) :: fid
3026 character(len=*),
intent(in) :: vname
3027 character(len=*),
intent(in) :: key
3028 character(len=*),
intent(in) :: val
3033 log_error(
"FILE_set_attribute_text",*)
'File is not opened. fid = ', fid
3037 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
3040 cstr(vname), cstr(key), &
3042 if ( error /= file_success_code .and. error /= file_already_existed_code )
then
3043 log_error(
"FILE_set_attribute_text",*)
'failed to set text attribute for '//trim(vname)//
': '//trim(key)
3047 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
3050 end subroutine file_set_attribute_text
3052 subroutine file_set_attribute_logical( &
3055 integer,
intent(in) :: fid
3056 character(len=*),
intent(in) :: vname
3057 character(len=*),
intent(in) :: key
3058 logical,
intent(in) :: val
3060 character(len=5) :: buf
3063 log_error(
"FILE_set_attribute_logical",*)
'File is not opened. fid = ', fid
3073 call file_set_attribute_text( fid, vname, key, buf )
3076 end subroutine file_set_attribute_logical
3079 subroutine file_set_attribute_int_ary( &
3082 integer,
intent(in) :: fid
3083 character(len=*),
intent(in) :: vname
3084 character(len=*),
intent(in) :: key
3085 integer,
intent(in) :: val(:)
3092 log_error(
"FILE_set_attribute_int",*)
'File is not opened. fid = ', fid
3096 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
3099 cstr(vname), cstr(key), &
3100 val(:),
size(val(:)) )
3101 if ( error /= file_success_code .and. error /= file_already_existed_code )
then
3102 log_error(
"FILE_set_attribute_int",*)
'failed to set integer attribute for '//trim(vname)//
': '//trim(key)
3106 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
3109 end subroutine file_set_attribute_int_ary
3111 subroutine file_set_attribute_int( &
3114 integer,
intent(in) :: fid
3115 character(len=*),
intent(in) :: vname
3116 character(len=*),
intent(in) :: key
3117 integer,
intent(in) :: val
3122 call file_set_attribute_int_ary( fid, vname, &
3126 end subroutine file_set_attribute_int
3129 subroutine file_set_attribute_float_ary( &
3132 integer,
intent(in) :: fid
3133 character(len=*),
intent(in) :: vname
3134 character(len=*),
intent(in) :: key
3135 real(sp),
intent(in) :: val(:)
3142 log_error(
"FILE_set_attributefloat",*)
'File is not opened. fid = ', fid
3146 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
3149 cstr(vname), cstr(key), &
3150 val(:),
size(val(:)) )
3151 if ( error /= file_success_code .and. error /= file_already_existed_code )
then
3152 log_error(
"FILE_set_attribute_float",*)
'failed to set float attribute for '//trim(vname)//
': '//trim(key)
3156 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
3159 end subroutine file_set_attribute_float_ary
3161 subroutine file_set_attribute_float( &
3164 integer,
intent(in) :: fid
3165 character(len=*),
intent(in) :: vname
3166 character(len=*),
intent(in) :: key
3167 real(sp),
intent(in) :: val
3172 call file_set_attribute_float_ary( fid, vname, &
3176 end subroutine file_set_attribute_float
3178 subroutine file_set_attribute_double_ary( &
3181 integer,
intent(in) :: fid
3182 character(len=*),
intent(in) :: vname
3183 character(len=*),
intent(in) :: key
3184 real(dp),
intent(in) :: val(:)
3191 log_error(
"FILE_set_attributedouble",*)
'File is not opened. fid = ', fid
3195 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
3198 cstr(vname), cstr(key), &
3199 val(:),
size(val(:)) )
3200 if ( error /= file_success_code .and. error /= file_already_existed_code )
then
3201 log_error(
"FILE_set_attribute_double",*)
'failed to set double attribute for '//trim(vname)//
': '//trim(key)
3205 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
3208 end subroutine file_set_attribute_double_ary
3210 subroutine file_set_attribute_double( &
3213 integer,
intent(in) :: fid
3214 character(len=*),
intent(in) :: vname
3215 character(len=*),
intent(in) :: key
3216 real(dp),
intent(in) :: val
3221 call file_set_attribute_double_ary( fid, vname, &
3225 end subroutine file_set_attribute_double
3229 subroutine file_get_shape_fname( &
3230 basename, varname, &
3237 character(len=*),
intent( in) :: basename
3238 character(len=*),
intent( in) :: varname
3239 integer,
intent(out) :: dims(:)
3240 integer,
intent( in),
optional :: rankid
3241 logical,
intent( in),
optional :: single
3242 logical,
intent(out),
optional :: has_tdim
3243 logical,
intent(out),
optional :: error
3251 rankid=rankid, single=single )
3253 call file_get_shape_fid( fid, varname, &
3255 has_tdim = has_tdim, &
3259 end subroutine file_get_shape_fname
3261 subroutine file_get_shape_fid( &
3267 integer,
intent( in) :: fid
3268 character(len=*),
intent( in) :: varname
3269 integer,
intent(out) :: dims(:)
3270 logical,
intent(out),
optional :: has_tdim
3271 logical,
intent(out),
optional :: error
3273 type(datainfo) :: dinfo
3277 logical(c_bool) :: suppress
3283 log_error(
"FILE_get_shape_id",*)
'File is not opened. fid = ', fid
3287 call prof_rapstart(
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
3289 if (
present(error) )
then
3297 file_files(fid)%fid, &
3301 call prof_rapend (
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
3304 if ( ierror /= file_success_code )
then
3305 if (
present(error) )
then
3309 log_error(
"FILE_get_shape_fid",*)
'failed to get data information : ', trim(varname)
3314 if ( dinfo%rank /=
size(dims) )
then
3315 log_error(
"FILE_get_shape_fid",*)
'rank is different, ', trim(varname),
size(dims), dinfo%rank
3318 do n = 1,
size(dims)
3319 dims(n) = dinfo%dim_size(n)
3322 if (
present(has_tdim) ) has_tdim = dinfo%has_tdim
3323 if (
present(error) ) error = .false.
3326 end subroutine file_get_shape_fid
3335 integer,
intent(in) :: fid
3336 character(len=*),
intent(in) :: varname
3338 integer,
intent(out) :: len
3340 logical,
intent(out),
optional :: error
3345 log_error(
"FILE_get_stepSize",*)
'File is not opened. fid = ', fid
3349 call prof_rapstart(
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
3352 file_files(fid)%fid, cstr(varname) )
3353 if ( ierror /= file_success_code .and. ierror /= file_already_existed_code )
then
3354 if (
present(error) )
then
3357 log_error(
"FILE_get_stepSize",*)
'failed to get number of steps'
3361 if (
present(error) ) error = .false.
3364 call prof_rapend (
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
3372 subroutine file_get_commoninfo_fname( &
3383 character(len=*),
intent(in) :: basename
3384 integer,
intent(in) :: rankid
3385 integer,
intent(in) :: nvars_limit
3386 character(len=FILE_HMID),
intent(out) :: title
3387 character(len=FILE_HMID),
intent(out) :: source
3388 character(len=FILE_HMID),
intent(out) :: institution
3389 integer,
intent(out) :: nvars
3390 character(len=FILE_HSHORT),
intent(out) :: varname(nvars_limit)
3399 call file_get_commoninfo_fid( fid, &
3408 end subroutine file_get_commoninfo_fname
3410 subroutine file_get_commoninfo_fid( &
3420 integer,
intent(in) :: fid
3421 integer,
intent(in) :: nvars_limit
3422 character(len=FILE_HMID),
intent(out) :: title
3423 character(len=FILE_HMID),
intent(out) :: source
3424 character(len=FILE_HMID),
intent(out) :: institution
3425 integer,
intent(out) :: nvars
3426 character(len=FILE_HSHORT),
intent(out) :: varname(nvars_limit)
3432 log_error(
"FILE_get_commonInfo_fid",*)
'File is not opened. fid = ', fid
3436 call prof_rapstart(
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
3438 call file_get_attribute( fid,
'global',
'title', title )
3439 call file_get_attribute( fid,
'global',
'source', source )
3440 call file_get_attribute( fid,
'global',
'institution', institution )
3442 call file_get_var_num( fid, nvars_limit, nvars )
3445 call file_get_var_name( fid, v, varname(v) )
3448 call prof_rapend (
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
3451 end subroutine file_get_commoninfo_fid
3456 subroutine file_get_datainfo_fname( &
3457 basename, varname, &
3458 rankid, istep, single, &
3460 description, units, standard_name, &
3462 dim_rank, dim_name, dim_size, &
3463 natts, att_name, att_type, att_len, &
3465 time_start, time_end, time_units, &
3469 character(len=*),
intent(in) :: basename
3470 character(len=*),
intent(in) :: varname
3472 integer,
intent(in),
optional :: rankid
3473 integer,
intent(in),
optional :: istep
3474 logical,
intent(in),
optional :: single
3475 logical,
intent(out),
optional :: existed
3476 character(len=FILE_HMID),
intent(out),
optional :: description
3477 character(len=FILE_HSHORT),
intent(out),
optional :: units
3478 character(len=FILE_HMID),
intent(out),
optional :: standard_name
3479 integer,
intent(out),
optional :: datatype
3480 integer,
intent(out),
optional :: dim_rank
3481 character(len=FILE_HSHORT),
intent(out),
optional :: dim_name(:)
3482 integer,
intent(out),
optional :: dim_size(:)
3483 integer,
intent(out),
optional :: natts
3484 character(len=FILE_HSHORT),
intent(out),
optional :: att_name(:)
3485 integer,
intent(out),
optional :: att_type(:)
3486 integer,
intent(out),
optional :: att_len (:)
3487 logical,
intent(out),
optional :: has_tdim
3488 real(dp),
intent(out),
optional :: time_start
3489 real(dp),
intent(out),
optional :: time_end
3490 character(len=FILE_HMID),
intent(out),
optional :: time_units
3491 character(len=FILE_HSHORT),
intent(out),
optional :: calendar
3497 if (
present(single) )
then
3506 rankid=rankid, single=single_ )
3508 call file_get_datainfo_fid( fid, varname, &
3511 description, units, standard_name, &
3513 dim_rank, dim_name, dim_size, &
3514 natts, att_name, att_type, att_len, &
3516 time_start, time_end, time_units, &
3520 end subroutine file_get_datainfo_fname
3522 subroutine file_get_datainfo_fid( &
3526 description, units, standard_name, &
3528 dim_rank, dim_name, dim_size, &
3529 natts, att_name, att_type, att_len, &
3531 time_start, time_end, time_units, &
3535 integer,
intent(in) :: fid
3536 character(len=*),
intent(in) :: varname
3538 integer,
intent(in),
optional :: istep
3539 logical,
intent(out),
optional :: existed
3540 character(len=*),
intent(out),
optional :: description
3541 character(len=*),
intent(out),
optional :: units
3542 character(len=*),
intent(out),
optional :: standard_name
3543 integer,
intent(out),
optional :: datatype
3544 integer,
intent(out),
optional :: dim_rank
3545 character(len=*),
intent(out),
optional :: dim_name(:)
3546 integer,
intent(out),
optional :: dim_size(:)
3547 integer,
intent(out),
optional :: natts
3548 character(len=*),
intent(out),
optional :: att_name(:)
3549 integer,
intent(out),
optional :: att_type(:)
3550 integer,
intent(out),
optional :: att_len (:)
3551 logical,
intent(out),
optional :: has_tdim
3552 real(dp),
intent(out),
optional :: time_start
3553 real(dp),
intent(out),
optional :: time_end
3554 character(len=*),
intent(out),
optional :: time_units
3555 character(len=*),
intent(out),
optional :: calendar
3557 type(datainfo) :: dinfo
3564 logical(c_bool) :: suppress
3567 character(len=FILE_HMID) :: tu
3572 if (
present(istep) )
then
3578 if (
present(existed) )
then
3585 log_error(
"FILE_get_dataInfo_fid",*)
'File is not opened. fid = ', fid
3589 call prof_rapstart(
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
3593 file_files(fid)%fid, &
3598 call prof_rapend (
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
3601 if ( error /= file_success_code )
then
3602 if (
present( existed ) )
then
3606 log_error(
"FILE_get_dataInfo_fid",*)
'data info not found'
3611 call prof_rapstart(
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
3613 if (
present(existed) ) existed = .true.
3615 if (
present(description) )
call fstr(description, dinfo%description)
3616 if (
present(units) )
call fstr(units, dinfo%units)
3617 if (
present(standard_name) )
call fstr(standard_name, dinfo%standard_name)
3618 if (
present(datatype) ) datatype = dinfo%datatype
3619 if (
present(dim_rank) ) dim_rank = dinfo%rank
3621 if (
present(dim_name) )
then
3622 do i = 1, min( dinfo%rank,
size(dim_name) )
3623 call fstr(dim_name(
i), dinfo%dim_name(:,
i))
3627 if (
present(dim_size) )
then
3628 do i = 1, min( dinfo%rank,
size(dim_size) )
3629 dim_size(
i) = dinfo%dim_size(
i)
3633 if (
present(natts) ) natts = dinfo%natts
3634 if (
present(att_name) )
then
3635 do i = 1, min( dinfo%natts,
size(att_name) )
3636 call fstr(att_name(
i), dinfo%att_name(:,
i))
3639 if (
present(att_type) )
then
3640 do i = 1, min( dinfo%natts,
size(att_type) )
3641 att_type(
i) = dinfo%att_type(
i)
3644 if (
present(att_len) )
then
3645 do i = 1, min( dinfo%natts,
size(att_len) )
3646 att_len(
i) = dinfo%att_len(
i)
3650 call fstr(tu, dinfo%time_units)
3652 if (
present(time_units) )
then
3653 if ( tu ==
"" )
then
3654 call file_get_attribute( fid,
"global",
"time_units", time_units )
3660 if (
present(calendar) )
then
3661 if ( tu ==
"" )
then
3662 call file_get_attribute( fid,
"global",
"calendar", calendar, existed2 )
3663 if ( .not. existed2 ) calendar =
""
3665 call fstr(calendar, dinfo%calendar)
3669 if (
present(has_tdim) )
then
3670 has_tdim = dinfo%has_tdim
3673 if (
present(time_start) )
then
3674 if ( tu ==
"" )
then
3675 call file_get_attribute( fid,
"global",
"time_start", time )
3676 time_start = time(1)
3678 time_start = dinfo%time_start
3682 if (
present(time_end) )
then
3683 if ( tu ==
"" )
then
3684 call file_get_attribute( fid,
"global",
"time_start", time )
3687 time_end = dinfo%time_end
3691 call prof_rapend (
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
3694 end subroutine file_get_datainfo_fid
3699 subroutine file_get_all_datainfo_fname( &
3700 basename, varname, &
3702 description, units, standard_name, &
3704 dim_rank, dim_name, dim_size, &
3705 natts, att_name, att_type, att_len, &
3706 time_start, time_end, &
3707 time_units, calendar, &
3710 character(len=*),
intent(in) :: basename
3711 character(len=*),
intent(in) :: varname
3712 integer,
intent(out) :: step_nmax
3713 character(len=FILE_HMID),
intent(out) :: description
3714 character(len=FILE_HSHORT),
intent(out) :: units
3715 character(len=FILE_HMID),
intent(out) :: standard_name
3716 integer,
intent(out) :: datatype
3717 integer,
intent(out) :: dim_rank
3718 character(len=FILE_HSHORT),
intent(out) :: dim_name (:)
3719 integer,
intent(out) :: dim_size (:)
3720 integer,
intent(out) :: natts
3721 character(len=FILE_HSHORT),
intent(out) :: att_name (:)
3722 integer,
intent(out) :: att_type (:)
3723 integer,
intent(out) :: att_len (:)
3724 real(dp),
intent(out) :: time_start(:)
3725 real(dp),
intent(out) :: time_end (:)
3726 character(len=FILE_HMID),
intent(out) :: time_units
3727 character(len=FILE_HSHORT),
intent(out) :: calendar
3729 integer,
intent(in),
optional :: rankid
3730 logical,
intent(in),
optional :: single
3736 if (
present(single) )
then
3745 rankid=rankid, single=single_ )
3747 call file_get_all_datainfo_fid( fid, varname, &
3749 description, units, standard_name, &
3751 dim_rank, dim_name(:), dim_size(:), &
3752 natts, att_name(:), att_type(:), att_len(:), &
3753 time_start(:), time_end(:), &
3754 time_units, calendar )
3757 end subroutine file_get_all_datainfo_fname
3759 subroutine file_get_all_datainfo_fid( &
3762 description, units, standard_name, &
3764 dim_rank, dim_name, dim_size, &
3765 natts, att_name, att_type, att_len, &
3766 time_start, time_end, &
3767 time_units, calendar )
3770 integer,
intent(in) :: fid
3771 character(len=*),
intent(in) :: varname
3772 integer,
intent(out) :: step_nmax
3773 character(len=*),
intent(out) :: description
3774 character(len=*),
intent(out) :: units
3775 character(len=*),
intent(out) :: standard_name
3776 integer,
intent(out) :: datatype
3777 integer,
intent(out) :: dim_rank
3778 character(len=*),
intent(out) :: dim_name (:)
3779 integer,
intent(out) :: dim_size (:)
3780 integer,
intent(out) :: natts
3781 character(len=*),
intent(out) :: att_name (:)
3782 integer,
intent(out) :: att_type (:)
3783 integer,
intent(out) :: att_len (:)
3784 real(dp),
intent(out) :: time_start(:)
3785 real(dp),
intent(out) :: time_end (:)
3786 character(len=*),
intent(out) :: time_units
3787 character(len=*),
intent(out) :: calendar
3789 type(datainfo) :: dinfo
3797 integer :: istep_max
3799 logical(c_bool) :: suppress
3800 character(len=FILE_HMID) :: tu
3806 log_error(
"FILE_get_all_dataInfo_fid",*)
'File is not opened. fid = ', fid
3810 call prof_rapstart(
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
3820 time_start(:) = file_rmiss
3821 time_end(:) = file_rmiss
3824 istep_max = min(
size(time_start),
size(time_end) )
3825 do istep = 1, istep_max
3828 file_files(fid)%fid, &
3833 if ( error /= file_success_code )
then
3834 step_nmax = istep - 1
3838 if ( istep == 1 )
then
3839 call fstr(description, dinfo%description)
3840 call fstr(units, dinfo%units)
3841 call fstr(standard_name, dinfo%standard_name)
3842 datatype = dinfo%datatype
3843 dim_rank = dinfo%rank
3846 do i = 1, min( dinfo%rank,
size(dim_name) )
3847 call fstr(dim_name(
i), dinfo%dim_name(:,
i))
3848 dim_size(
i) = dinfo%dim_size(
i)
3851 do i = 1, min( dinfo%natts,
size(att_name) )
3852 call fstr(att_name(
i), dinfo%att_name(:,
i))
3853 att_type(
i) = dinfo%att_type(
i)
3854 att_len(
i) = dinfo%att_len (
i)
3857 call fstr(tu, dinfo%time_units)
3858 if ( tu ==
"" )
then
3859 call file_get_attribute( fid,
"global",
"time_units", time_units )
3860 call file_get_attribute( fid,
"global",
"calendar", calendar, existed )
3861 if ( .not. existed ) calendar =
""
3862 call file_get_attribute( fid,
"global",
"time_start", time )
3863 time_start(1) = time(1)
3864 time_end(1) = time(1)
3869 time_start(1) = dinfo%time_start
3870 time_end(1) = dinfo%time_end
3871 call fstr(calendar, dinfo%calendar)
3874 time_start(istep) = dinfo%time_start
3875 time_end(istep) = dinfo%time_end
3879 if ( istep == istep_max + 1 )
then
3880 if ( error /= file_success_code )
then
3881 log_error(
"FILE_get_all_dataInfo_fid",*)
'size of time is not enough: ', istep_max
3884 step_nmax = istep - 1
3888 call prof_rapend (
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
3891 end subroutine file_get_all_datainfo_fid
3896 subroutine file_read_realsp_1d( &
3897 basename, varname, &
3899 step, rankid, single, postfix, &
3900 allow_missing, missing_value )
3903 character(len=*),
intent( in) :: basename
3904 character(len=*),
intent( in) :: varname
3905 real(sp),
intent(out) :: var(:)
3906 integer,
intent( in),
optional :: step
3907 integer,
intent( in),
optional :: rankid
3908 logical,
intent( in),
optional :: single
3909 character(len=*),
intent( in),
optional :: postfix
3910 logical,
intent( in),
optional :: allow_missing
3911 real(sp),
intent( in),
optional :: missing_value
3921 rankid=rankid, single=single, &
3924 call file_read_var_realsp_1d( &
3928 allow_missing=allow_missing, missing_value=missing_value )
3931 end subroutine file_read_realsp_1d
3932 subroutine file_read_realdp_1d( &
3933 basename, varname, &
3935 step, rankid, single, postfix, &
3936 allow_missing, missing_value )
3939 character(len=*),
intent( in) :: basename
3940 character(len=*),
intent( in) :: varname
3941 real(dp),
intent(out) :: var(:)
3942 integer,
intent( in),
optional :: step
3943 integer,
intent( in),
optional :: rankid
3944 logical,
intent( in),
optional :: single
3945 character(len=*),
intent( in),
optional :: postfix
3946 logical,
intent( in),
optional :: allow_missing
3947 real(dp),
intent( in),
optional :: missing_value
3957 rankid=rankid, single=single, &
3960 call file_read_var_realdp_1d( &
3964 allow_missing=allow_missing, missing_value=missing_value )
3967 end subroutine file_read_realdp_1d
3968 subroutine file_read_realsp_2d( &
3969 basename, varname, &
3971 step, rankid, single, postfix, &
3972 allow_missing, missing_value )
3975 character(len=*),
intent( in) :: basename
3976 character(len=*),
intent( in) :: varname
3977 real(sp),
intent(out) :: var(:,:)
3978 integer,
intent( in),
optional :: step
3979 integer,
intent( in),
optional :: rankid
3980 logical,
intent( in),
optional :: single
3981 character(len=*),
intent( in),
optional :: postfix
3982 logical,
intent( in),
optional :: allow_missing
3983 real(sp),
intent( in),
optional :: missing_value
3993 rankid=rankid, single=single, &
3996 call file_read_var_realsp_2d( &
4000 allow_missing=allow_missing, missing_value=missing_value )
4003 end subroutine file_read_realsp_2d
4004 subroutine file_read_realdp_2d( &
4005 basename, varname, &
4007 step, rankid, single, postfix, &
4008 allow_missing, missing_value )
4011 character(len=*),
intent( in) :: basename
4012 character(len=*),
intent( in) :: varname
4013 real(dp),
intent(out) :: var(:,:)
4014 integer,
intent( in),
optional :: step
4015 integer,
intent( in),
optional :: rankid
4016 logical,
intent( in),
optional :: single
4017 character(len=*),
intent( in),
optional :: postfix
4018 logical,
intent( in),
optional :: allow_missing
4019 real(dp),
intent( in),
optional :: missing_value
4029 rankid=rankid, single=single, &
4032 call file_read_var_realdp_2d( &
4036 allow_missing=allow_missing, missing_value=missing_value )
4039 end subroutine file_read_realdp_2d
4040 subroutine file_read_realsp_3d( &
4041 basename, varname, &
4043 step, rankid, single, postfix, &
4044 allow_missing, missing_value )
4047 character(len=*),
intent( in) :: basename
4048 character(len=*),
intent( in) :: varname
4049 real(sp),
intent(out) :: var(:,:,:)
4050 integer,
intent( in),
optional :: step
4051 integer,
intent( in),
optional :: rankid
4052 logical,
intent( in),
optional :: single
4053 character(len=*),
intent( in),
optional :: postfix
4054 logical,
intent( in),
optional :: allow_missing
4055 real(sp),
intent( in),
optional :: missing_value
4065 rankid=rankid, single=single, &
4068 call file_read_var_realsp_3d( &
4072 allow_missing=allow_missing, missing_value=missing_value )
4075 end subroutine file_read_realsp_3d
4076 subroutine file_read_realdp_3d( &
4077 basename, varname, &
4079 step, rankid, single, postfix, &
4080 allow_missing, missing_value )
4083 character(len=*),
intent( in) :: basename
4084 character(len=*),
intent( in) :: varname
4085 real(dp),
intent(out) :: var(:,:,:)
4086 integer,
intent( in),
optional :: step
4087 integer,
intent( in),
optional :: rankid
4088 logical,
intent( in),
optional :: single
4089 character(len=*),
intent( in),
optional :: postfix
4090 logical,
intent( in),
optional :: allow_missing
4091 real(dp),
intent( in),
optional :: missing_value
4101 rankid=rankid, single=single, &
4104 call file_read_var_realdp_3d( &
4108 allow_missing=allow_missing, missing_value=missing_value )
4111 end subroutine file_read_realdp_3d
4112 subroutine file_read_realsp_4d( &
4113 basename, varname, &
4115 step, rankid, single, postfix, &
4116 allow_missing, missing_value )
4119 character(len=*),
intent( in) :: basename
4120 character(len=*),
intent( in) :: varname
4121 real(sp),
intent(out) :: var(:,:,:,:)
4122 integer,
intent( in),
optional :: step
4123 integer,
intent( in),
optional :: rankid
4124 logical,
intent( in),
optional :: single
4125 character(len=*),
intent( in),
optional :: postfix
4126 logical,
intent( in),
optional :: allow_missing
4127 real(sp),
intent( in),
optional :: missing_value
4137 rankid=rankid, single=single, &
4140 call file_read_var_realsp_4d( &
4144 allow_missing=allow_missing, missing_value=missing_value )
4147 end subroutine file_read_realsp_4d
4148 subroutine file_read_realdp_4d( &
4149 basename, varname, &
4151 step, rankid, single, postfix, &
4152 allow_missing, missing_value )
4155 character(len=*),
intent( in) :: basename
4156 character(len=*),
intent( in) :: varname
4157 real(dp),
intent(out) :: var(:,:,:,:)
4158 integer,
intent( in),
optional :: step
4159 integer,
intent( in),
optional :: rankid
4160 logical,
intent( in),
optional :: single
4161 character(len=*),
intent( in),
optional :: postfix
4162 logical,
intent( in),
optional :: allow_missing
4163 real(dp),
intent( in),
optional :: missing_value
4173 rankid=rankid, single=single, &
4176 call file_read_var_realdp_4d( &
4180 allow_missing=allow_missing, missing_value=missing_value )
4183 end subroutine file_read_realdp_4d
4185 subroutine file_read_var_realsp_1d( &
4195 integer,
intent( in) :: fid
4196 character(len=*),
intent( in) :: varname
4198 real(sp),
intent(out),
target :: var(:)
4200 real(sp),
intent(out),
target,
contiguous :: var(:)
4202 integer,
intent( in),
optional :: step
4203 logical,
intent( in),
optional :: allow_missing
4204 real(sp),
intent( in),
optional :: missing_value
4205 integer,
intent( in),
optional :: ntypes
4206 integer,
intent( in),
optional :: dtype
4207 integer,
intent( in),
optional :: start(:)
4208 integer,
intent( in),
optional :: count(:)
4211 logical(c_bool) :: allow_missing_
4212 real(sp) :: missing_value_
4214 type(datainfo) :: dinfo
4215 integer :: dim_size(1)
4220 intrinsic size, shape
4224 log_error(
"FILE_read_var_realSP_1D",*)
'File is not opened. fid = ', fid
4228 call prof_rapstart(
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
4230 if (
present(step) )
then
4236 if (
present(allow_missing) )
then
4237 allow_missing_ = allow_missing
4239 allow_missing_ = .false.
4242 if (
present(missing_value) )
then
4243 missing_value_ = missing_value
4245 missing_value_ = 0.0_sp
4250 file_files(fid)%fid, &
4252 step_, allow_missing_ )
4255 if ( error /= file_success_code )
then
4256 if ( allow_missing_ )
then
4257 log_info(
"FILE_read_var_realSP_1D",*)
'[INPUT]/[FILE] data not found! : ', &
4258 'varname= ',trim(varname),
', step=',step_
4259 log_info(
"FILE_read_var_realSP_1D",*)
'[INPUT]/[FILE] Value is set to ', missing_value_
4260 var(:) = missing_value_
4263 log_error(
"FILE_read_var_realSP_1D",*)
'failed to get data information :'//trim(varname)
4268 if ( dinfo%rank /= 1 )
then
4269 if ( (.not.
present(start)) .and. (.not.
present(count)) )
then
4270 log_error(
"FILE_read_var_realSP_1D",*)
'rank of '//trim(varname)//
' is not 1', dinfo%rank
4275 if (
present(ntypes) )
then
4276 #if defined(__GFORTRAN__) && __GNUC__ < 7
4281 dinfo, sp, ntypes, dtype, start(:), count(:) )
4282 else if (
present(start) .and.
present(count) )
then
4285 real(sp),
allocatable,
target :: work(:)
4286 allocate(work, mold=var)
4289 #if defined(__GFORTRAN__) && __GNUC__ < 7
4291 #elif defined(NVIDIA)
4296 dinfo, sp, 0, 0, start(:), count(:) )
4302 dim_size(:) = shape(var)
4304 if ( dinfo%dim_size(n) /= dim_size(n) )
then
4305 log_error(
"FILE_read_var_realSP_1D",*)
'shape is different: ', trim(varname), n, dinfo%dim_size(n), dim_size(n)
4311 real(sp),
allocatable,
target :: work(:)
4312 allocate(work, mold=var)
4315 #if defined(__GFORTRAN__) && __GNUC__ < 7
4317 #elif defined(NVIDIA)
4322 dinfo, sp, 0, 0, (/0/), (/0/) )
4328 if ( error /= file_success_code )
then
4329 log_error(
"FILE_read_var_realSP_1D",*)
'failed to get data value: ', trim(varname)
4335 call prof_rapend (
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
4338 end subroutine file_read_var_realsp_1d
4339 subroutine file_read_var_realdp_1d( &
4349 integer,
intent( in) :: fid
4350 character(len=*),
intent( in) :: varname
4352 real(dp),
intent(out),
target :: var(:)
4354 real(dp),
intent(out),
target,
contiguous :: var(:)
4356 integer,
intent( in),
optional :: step
4357 logical,
intent( in),
optional :: allow_missing
4358 real(dp),
intent( in),
optional :: missing_value
4359 integer,
intent( in),
optional :: ntypes
4360 integer,
intent( in),
optional :: dtype
4361 integer,
intent( in),
optional :: start(:)
4362 integer,
intent( in),
optional :: count(:)
4365 logical(c_bool) :: allow_missing_
4366 real(dp) :: missing_value_
4368 type(datainfo) :: dinfo
4369 integer :: dim_size(1)
4374 intrinsic size, shape
4378 log_error(
"FILE_read_var_realDP_1D",*)
'File is not opened. fid = ', fid
4382 call prof_rapstart(
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
4384 if (
present(step) )
then
4390 if (
present(allow_missing) )
then
4391 allow_missing_ = allow_missing
4393 allow_missing_ = .false.
4396 if (
present(missing_value) )
then
4397 missing_value_ = missing_value
4399 missing_value_ = 0.0_dp
4404 file_files(fid)%fid, &
4406 step_, allow_missing_ )
4409 if ( error /= file_success_code )
then
4410 if ( allow_missing_ )
then
4411 log_info(
"FILE_read_var_realDP_1D",*)
'[INPUT]/[FILE] data not found! : ', &
4412 'varname= ',trim(varname),
', step=',step_
4413 log_info(
"FILE_read_var_realDP_1D",*)
'[INPUT]/[FILE] Value is set to ', missing_value_
4414 var(:) = missing_value_
4417 log_error(
"FILE_read_var_realDP_1D",*)
'failed to get data information :'//trim(varname)
4422 if ( dinfo%rank /= 1 )
then
4423 if ( (.not.
present(start)) .and. (.not.
present(count)) )
then
4424 log_error(
"FILE_read_var_realDP_1D",*)
'rank of '//trim(varname)//
' is not 1', dinfo%rank
4429 if (
present(ntypes) )
then
4430 #if defined(__GFORTRAN__) && __GNUC__ < 7
4435 dinfo, dp, ntypes, dtype, start(:), count(:) )
4436 else if (
present(start) .and.
present(count) )
then
4439 real(dp),
allocatable,
target :: work(:)
4440 allocate(work, mold=var)
4443 #if defined(__GFORTRAN__) && __GNUC__ < 7
4445 #elif defined(NVIDIA)
4450 dinfo, dp, 0, 0, start(:), count(:) )
4456 dim_size(:) = shape(var)
4458 if ( dinfo%dim_size(n) /= dim_size(n) )
then
4459 log_error(
"FILE_read_var_realDP_1D",*)
'shape is different: ', trim(varname), n, dinfo%dim_size(n), dim_size(n)
4465 real(dp),
allocatable,
target :: work(:)
4466 allocate(work, mold=var)
4469 #if defined(__GFORTRAN__) && __GNUC__ < 7
4471 #elif defined(NVIDIA)
4476 dinfo, dp, 0, 0, (/0/), (/0/) )
4482 if ( error /= file_success_code )
then
4483 log_error(
"FILE_read_var_realDP_1D",*)
'failed to get data value: ', trim(varname)
4489 call prof_rapend (
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
4492 end subroutine file_read_var_realdp_1d
4493 subroutine file_read_var_realsp_2d( &
4503 integer,
intent( in) :: fid
4504 character(len=*),
intent( in) :: varname
4506 real(sp),
intent(out),
target :: var(:,:)
4508 real(sp),
intent(out),
target,
contiguous :: var(:,:)
4510 integer,
intent( in),
optional :: step
4511 logical,
intent( in),
optional :: allow_missing
4512 real(sp),
intent( in),
optional :: missing_value
4513 integer,
intent( in),
optional :: ntypes
4514 integer,
intent( in),
optional :: dtype
4515 integer,
intent( in),
optional :: start(:)
4516 integer,
intent( in),
optional :: count(:)
4519 logical(c_bool) :: allow_missing_
4520 real(sp) :: missing_value_
4522 type(datainfo) :: dinfo
4523 integer :: dim_size(2)
4528 intrinsic size, shape
4532 log_error(
"FILE_read_var_realSP_2D",*)
'File is not opened. fid = ', fid
4536 call prof_rapstart(
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
4538 if (
present(step) )
then
4544 if (
present(allow_missing) )
then
4545 allow_missing_ = allow_missing
4547 allow_missing_ = .false.
4550 if (
present(missing_value) )
then
4551 missing_value_ = missing_value
4553 missing_value_ = 0.0_sp
4558 file_files(fid)%fid, &
4560 step_, allow_missing_ )
4563 if ( error /= file_success_code )
then
4564 if ( allow_missing_ )
then
4565 log_info(
"FILE_read_var_realSP_2D",*)
'[INPUT]/[FILE] data not found! : ', &
4566 'varname= ',trim(varname),
', step=',step_
4567 log_info(
"FILE_read_var_realSP_2D",*)
'[INPUT]/[FILE] Value is set to ', missing_value_
4568 var(:,:) = missing_value_
4571 log_error(
"FILE_read_var_realSP_2D",*)
'failed to get data information :'//trim(varname)
4576 if ( dinfo%rank /= 2 )
then
4577 if ( (.not.
present(start)) .and. (.not.
present(count)) )
then
4578 log_error(
"FILE_read_var_realSP_2D",*)
'rank of '//trim(varname)//
' is not 2', dinfo%rank
4583 if (
present(ntypes) )
then
4584 #if defined(__GFORTRAN__) && __GNUC__ < 7
4589 dinfo, sp, ntypes, dtype, start(:), count(:) )
4590 else if (
present(start) .and.
present(count) )
then
4593 real(sp),
allocatable,
target :: work(:,:)
4594 allocate(work, mold=var)
4597 #if defined(__GFORTRAN__) && __GNUC__ < 7
4599 #elif defined(NVIDIA)
4604 dinfo, sp, 0, 0, start(:), count(:) )
4610 dim_size(:) = shape(var)
4612 if ( dinfo%dim_size(n) /= dim_size(n) )
then
4613 log_error(
"FILE_read_var_realSP_2D",*)
'shape is different: ', trim(varname), n, dinfo%dim_size(n), dim_size(n)
4619 real(sp),
allocatable,
target :: work(:,:)
4620 allocate(work, mold=var)
4623 #if defined(__GFORTRAN__) && __GNUC__ < 7
4625 #elif defined(NVIDIA)
4630 dinfo, sp, 0, 0, (/0/), (/0/) )
4636 if ( error /= file_success_code )
then
4637 log_error(
"FILE_read_var_realSP_2D",*)
'failed to get data value: ', trim(varname)
4643 call prof_rapend (
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
4646 end subroutine file_read_var_realsp_2d
4647 subroutine file_read_var_realdp_2d( &
4657 integer,
intent( in) :: fid
4658 character(len=*),
intent( in) :: varname
4660 real(dp),
intent(out),
target :: var(:,:)
4662 real(dp),
intent(out),
target,
contiguous :: var(:,:)
4664 integer,
intent( in),
optional :: step
4665 logical,
intent( in),
optional :: allow_missing
4666 real(dp),
intent( in),
optional :: missing_value
4667 integer,
intent( in),
optional :: ntypes
4668 integer,
intent( in),
optional :: dtype
4669 integer,
intent( in),
optional :: start(:)
4670 integer,
intent( in),
optional :: count(:)
4673 logical(c_bool) :: allow_missing_
4674 real(dp) :: missing_value_
4676 type(datainfo) :: dinfo
4677 integer :: dim_size(2)
4682 intrinsic size, shape
4686 log_error(
"FILE_read_var_realDP_2D",*)
'File is not opened. fid = ', fid
4690 call prof_rapstart(
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
4692 if (
present(step) )
then
4698 if (
present(allow_missing) )
then
4699 allow_missing_ = allow_missing
4701 allow_missing_ = .false.
4704 if (
present(missing_value) )
then
4705 missing_value_ = missing_value
4707 missing_value_ = 0.0_dp
4712 file_files(fid)%fid, &
4714 step_, allow_missing_ )
4717 if ( error /= file_success_code )
then
4718 if ( allow_missing_ )
then
4719 log_info(
"FILE_read_var_realDP_2D",*)
'[INPUT]/[FILE] data not found! : ', &
4720 'varname= ',trim(varname),
', step=',step_
4721 log_info(
"FILE_read_var_realDP_2D",*)
'[INPUT]/[FILE] Value is set to ', missing_value_
4722 var(:,:) = missing_value_
4725 log_error(
"FILE_read_var_realDP_2D",*)
'failed to get data information :'//trim(varname)
4730 if ( dinfo%rank /= 2 )
then
4731 if ( (.not.
present(start)) .and. (.not.
present(count)) )
then
4732 log_error(
"FILE_read_var_realDP_2D",*)
'rank of '//trim(varname)//
' is not 2', dinfo%rank
4737 if (
present(ntypes) )
then
4738 #if defined(__GFORTRAN__) && __GNUC__ < 7
4743 dinfo, dp, ntypes, dtype, start(:), count(:) )
4744 else if (
present(start) .and.
present(count) )
then
4747 real(dp),
allocatable,
target :: work(:,:)
4748 allocate(work, mold=var)
4751 #if defined(__GFORTRAN__) && __GNUC__ < 7
4753 #elif defined(NVIDIA)
4758 dinfo, dp, 0, 0, start(:), count(:) )
4764 dim_size(:) = shape(var)
4766 if ( dinfo%dim_size(n) /= dim_size(n) )
then
4767 log_error(
"FILE_read_var_realDP_2D",*)
'shape is different: ', trim(varname), n, dinfo%dim_size(n), dim_size(n)
4773 real(dp),
allocatable,
target :: work(:,:)
4774 allocate(work, mold=var)
4777 #if defined(__GFORTRAN__) && __GNUC__ < 7
4779 #elif defined(NVIDIA)
4784 dinfo, dp, 0, 0, (/0/), (/0/) )
4790 if ( error /= file_success_code )
then
4791 log_error(
"FILE_read_var_realDP_2D",*)
'failed to get data value: ', trim(varname)
4797 call prof_rapend (
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
4800 end subroutine file_read_var_realdp_2d
4801 subroutine file_read_var_realsp_3d( &
4811 integer,
intent( in) :: fid
4812 character(len=*),
intent( in) :: varname
4814 real(sp),
intent(out),
target :: var(:,:,:)
4816 real(sp),
intent(out),
target,
contiguous :: var(:,:,:)
4818 integer,
intent( in),
optional :: step
4819 logical,
intent( in),
optional :: allow_missing
4820 real(sp),
intent( in),
optional :: missing_value
4821 integer,
intent( in),
optional :: ntypes
4822 integer,
intent( in),
optional :: dtype
4823 integer,
intent( in),
optional :: start(:)
4824 integer,
intent( in),
optional :: count(:)
4827 logical(c_bool) :: allow_missing_
4828 real(sp) :: missing_value_
4830 type(datainfo) :: dinfo
4831 integer :: dim_size(3)
4836 intrinsic size, shape
4840 log_error(
"FILE_read_var_realSP_3D",*)
'File is not opened. fid = ', fid
4844 call prof_rapstart(
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
4846 if (
present(step) )
then
4852 if (
present(allow_missing) )
then
4853 allow_missing_ = allow_missing
4855 allow_missing_ = .false.
4858 if (
present(missing_value) )
then
4859 missing_value_ = missing_value
4861 missing_value_ = 0.0_sp
4866 file_files(fid)%fid, &
4868 step_, allow_missing_ )
4871 if ( error /= file_success_code )
then
4872 if ( allow_missing_ )
then
4873 log_info(
"FILE_read_var_realSP_3D",*)
'[INPUT]/[FILE] data not found! : ', &
4874 'varname= ',trim(varname),
', step=',step_
4875 log_info(
"FILE_read_var_realSP_3D",*)
'[INPUT]/[FILE] Value is set to ', missing_value_
4876 var(:,:,:) = missing_value_
4879 log_error(
"FILE_read_var_realSP_3D",*)
'failed to get data information :'//trim(varname)
4884 if ( dinfo%rank /= 3 )
then
4885 if ( (.not.
present(start)) .and. (.not.
present(count)) )
then
4886 log_error(
"FILE_read_var_realSP_3D",*)
'rank of '//trim(varname)//
' is not 3', dinfo%rank
4891 if (
present(ntypes) )
then
4892 #if defined(__GFORTRAN__) && __GNUC__ < 7
4897 dinfo, sp, ntypes, dtype, start(:), count(:) )
4898 else if (
present(start) .and.
present(count) )
then
4901 real(sp),
allocatable,
target :: work(:,:,:)
4902 allocate(work, mold=var)
4905 #if defined(__GFORTRAN__) && __GNUC__ < 7
4907 #elif defined(NVIDIA)
4912 dinfo, sp, 0, 0, start(:), count(:) )
4918 dim_size(:) = shape(var)
4920 if ( dinfo%dim_size(n) /= dim_size(n) )
then
4921 log_error(
"FILE_read_var_realSP_3D",*)
'shape is different: ', trim(varname), n, dinfo%dim_size(n), dim_size(n)
4927 real(sp),
allocatable,
target :: work(:,:,:)
4928 allocate(work, mold=var)
4931 #if defined(__GFORTRAN__) && __GNUC__ < 7
4933 #elif defined(NVIDIA)
4938 dinfo, sp, 0, 0, (/0/), (/0/) )
4944 if ( error /= file_success_code )
then
4945 log_error(
"FILE_read_var_realSP_3D",*)
'failed to get data value: ', trim(varname)
4951 call prof_rapend (
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
4954 end subroutine file_read_var_realsp_3d
4955 subroutine file_read_var_realdp_3d( &
4965 integer,
intent( in) :: fid
4966 character(len=*),
intent( in) :: varname
4968 real(dp),
intent(out),
target :: var(:,:,:)
4970 real(dp),
intent(out),
target,
contiguous :: var(:,:,:)
4972 integer,
intent( in),
optional :: step
4973 logical,
intent( in),
optional :: allow_missing
4974 real(dp),
intent( in),
optional :: missing_value
4975 integer,
intent( in),
optional :: ntypes
4976 integer,
intent( in),
optional :: dtype
4977 integer,
intent( in),
optional :: start(:)
4978 integer,
intent( in),
optional :: count(:)
4981 logical(c_bool) :: allow_missing_
4982 real(dp) :: missing_value_
4984 type(datainfo) :: dinfo
4985 integer :: dim_size(3)
4990 intrinsic size, shape
4994 log_error(
"FILE_read_var_realDP_3D",*)
'File is not opened. fid = ', fid
4998 call prof_rapstart(
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
5000 if (
present(step) )
then
5006 if (
present(allow_missing) )
then
5007 allow_missing_ = allow_missing
5009 allow_missing_ = .false.
5012 if (
present(missing_value) )
then
5013 missing_value_ = missing_value
5015 missing_value_ = 0.0_dp
5020 file_files(fid)%fid, &
5022 step_, allow_missing_ )
5025 if ( error /= file_success_code )
then
5026 if ( allow_missing_ )
then
5027 log_info(
"FILE_read_var_realDP_3D",*)
'[INPUT]/[FILE] data not found! : ', &
5028 'varname= ',trim(varname),
', step=',step_
5029 log_info(
"FILE_read_var_realDP_3D",*)
'[INPUT]/[FILE] Value is set to ', missing_value_
5030 var(:,:,:) = missing_value_
5033 log_error(
"FILE_read_var_realDP_3D",*)
'failed to get data information :'//trim(varname)
5038 if ( dinfo%rank /= 3 )
then
5039 if ( (.not.
present(start)) .and. (.not.
present(count)) )
then
5040 log_error(
"FILE_read_var_realDP_3D",*)
'rank of '//trim(varname)//
' is not 3', dinfo%rank
5045 if (
present(ntypes) )
then
5046 #if defined(__GFORTRAN__) && __GNUC__ < 7
5051 dinfo, dp, ntypes, dtype, start(:), count(:) )
5052 else if (
present(start) .and.
present(count) )
then
5055 real(dp),
allocatable,
target :: work(:,:,:)
5056 allocate(work, mold=var)
5059 #if defined(__GFORTRAN__) && __GNUC__ < 7
5061 #elif defined(NVIDIA)
5066 dinfo, dp, 0, 0, start(:), count(:) )
5072 dim_size(:) = shape(var)
5074 if ( dinfo%dim_size(n) /= dim_size(n) )
then
5075 log_error(
"FILE_read_var_realDP_3D",*)
'shape is different: ', trim(varname), n, dinfo%dim_size(n), dim_size(n)
5081 real(dp),
allocatable,
target :: work(:,:,:)
5082 allocate(work, mold=var)
5085 #if defined(__GFORTRAN__) && __GNUC__ < 7
5087 #elif defined(NVIDIA)
5092 dinfo, dp, 0, 0, (/0/), (/0/) )
5098 if ( error /= file_success_code )
then
5099 log_error(
"FILE_read_var_realDP_3D",*)
'failed to get data value: ', trim(varname)
5105 call prof_rapend (
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
5108 end subroutine file_read_var_realdp_3d
5109 subroutine file_read_var_realsp_4d( &
5119 integer,
intent( in) :: fid
5120 character(len=*),
intent( in) :: varname
5122 real(sp),
intent(out),
target :: var(:,:,:,:)
5124 real(sp),
intent(out),
target,
contiguous :: var(:,:,:,:)
5126 integer,
intent( in),
optional :: step
5127 logical,
intent( in),
optional :: allow_missing
5128 real(sp),
intent( in),
optional :: missing_value
5129 integer,
intent( in),
optional :: ntypes
5130 integer,
intent( in),
optional :: dtype
5131 integer,
intent( in),
optional :: start(:)
5132 integer,
intent( in),
optional :: count(:)
5135 logical(c_bool) :: allow_missing_
5136 real(sp) :: missing_value_
5138 type(datainfo) :: dinfo
5139 integer :: dim_size(4)
5144 intrinsic size, shape
5148 log_error(
"FILE_read_var_realSP_4D",*)
'File is not opened. fid = ', fid
5152 call prof_rapstart(
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
5154 if (
present(step) )
then
5160 if (
present(allow_missing) )
then
5161 allow_missing_ = allow_missing
5163 allow_missing_ = .false.
5166 if (
present(missing_value) )
then
5167 missing_value_ = missing_value
5169 missing_value_ = 0.0_sp
5174 file_files(fid)%fid, &
5176 step_, allow_missing_ )
5179 if ( error /= file_success_code )
then
5180 if ( allow_missing_ )
then
5181 log_info(
"FILE_read_var_realSP_4D",*)
'[INPUT]/[FILE] data not found! : ', &
5182 'varname= ',trim(varname),
', step=',step_
5183 log_info(
"FILE_read_var_realSP_4D",*)
'[INPUT]/[FILE] Value is set to ', missing_value_
5184 var(:,:,:,:) = missing_value_
5187 log_error(
"FILE_read_var_realSP_4D",*)
'failed to get data information :'//trim(varname)
5192 if ( dinfo%rank /= 4 )
then
5193 if ( (.not.
present(start)) .and. (.not.
present(count)) )
then
5194 log_error(
"FILE_read_var_realSP_4D",*)
'rank of '//trim(varname)//
' is not 4', dinfo%rank
5199 if (
present(ntypes) )
then
5200 #if defined(__GFORTRAN__) && __GNUC__ < 7
5205 dinfo, sp, ntypes, dtype, start(:), count(:) )
5206 else if (
present(start) .and.
present(count) )
then
5209 real(sp),
allocatable,
target :: work(:,:,:,:)
5210 allocate(work, mold=var)
5213 #if defined(__GFORTRAN__) && __GNUC__ < 7
5214 cloc(var(1,1,1,1)), &
5215 #elif defined(NVIDIA)
5220 dinfo, sp, 0, 0, start(:), count(:) )
5226 dim_size(:) = shape(var)
5228 if ( dinfo%dim_size(n) /= dim_size(n) )
then
5229 log_error(
"FILE_read_var_realSP_4D",*)
'shape is different: ', trim(varname), n, dinfo%dim_size(n), dim_size(n)
5235 real(sp),
allocatable,
target :: work(:,:,:,:)
5236 allocate(work, mold=var)
5239 #if defined(__GFORTRAN__) && __GNUC__ < 7
5240 cloc(var(1,1,1,1)), &
5241 #elif defined(NVIDIA)
5246 dinfo, sp, 0, 0, (/0/), (/0/) )
5252 if ( error /= file_success_code )
then
5253 log_error(
"FILE_read_var_realSP_4D",*)
'failed to get data value: ', trim(varname)
5259 call prof_rapend (
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
5262 end subroutine file_read_var_realsp_4d
5263 subroutine file_read_var_realdp_4d( &
5273 integer,
intent( in) :: fid
5274 character(len=*),
intent( in) :: varname
5276 real(dp),
intent(out),
target :: var(:,:,:,:)
5278 real(dp),
intent(out),
target,
contiguous :: var(:,:,:,:)
5280 integer,
intent( in),
optional :: step
5281 logical,
intent( in),
optional :: allow_missing
5282 real(dp),
intent( in),
optional :: missing_value
5283 integer,
intent( in),
optional :: ntypes
5284 integer,
intent( in),
optional :: dtype
5285 integer,
intent( in),
optional :: start(:)
5286 integer,
intent( in),
optional :: count(:)
5289 logical(c_bool) :: allow_missing_
5290 real(dp) :: missing_value_
5292 type(datainfo) :: dinfo
5293 integer :: dim_size(4)
5298 intrinsic size, shape
5302 log_error(
"FILE_read_var_realDP_4D",*)
'File is not opened. fid = ', fid
5306 call prof_rapstart(
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
5308 if (
present(step) )
then
5314 if (
present(allow_missing) )
then
5315 allow_missing_ = allow_missing
5317 allow_missing_ = .false.
5320 if (
present(missing_value) )
then
5321 missing_value_ = missing_value
5323 missing_value_ = 0.0_dp
5328 file_files(fid)%fid, &
5330 step_, allow_missing_ )
5333 if ( error /= file_success_code )
then
5334 if ( allow_missing_ )
then
5335 log_info(
"FILE_read_var_realDP_4D",*)
'[INPUT]/[FILE] data not found! : ', &
5336 'varname= ',trim(varname),
', step=',step_
5337 log_info(
"FILE_read_var_realDP_4D",*)
'[INPUT]/[FILE] Value is set to ', missing_value_
5338 var(:,:,:,:) = missing_value_
5341 log_error(
"FILE_read_var_realDP_4D",*)
'failed to get data information :'//trim(varname)
5346 if ( dinfo%rank /= 4 )
then
5347 if ( (.not.
present(start)) .and. (.not.
present(count)) )
then
5348 log_error(
"FILE_read_var_realDP_4D",*)
'rank of '//trim(varname)//
' is not 4', dinfo%rank
5353 if (
present(ntypes) )
then
5354 #if defined(__GFORTRAN__) && __GNUC__ < 7
5359 dinfo, dp, ntypes, dtype, start(:), count(:) )
5360 else if (
present(start) .and.
present(count) )
then
5363 real(dp),
allocatable,
target :: work(:,:,:,:)
5364 allocate(work, mold=var)
5367 #if defined(__GFORTRAN__) && __GNUC__ < 7
5368 cloc(var(1,1,1,1)), &
5369 #elif defined(NVIDIA)
5374 dinfo, dp, 0, 0, start(:), count(:) )
5380 dim_size(:) = shape(var)
5382 if ( dinfo%dim_size(n) /= dim_size(n) )
then
5383 log_error(
"FILE_read_var_realDP_4D",*)
'shape is different: ', trim(varname), n, dinfo%dim_size(n), dim_size(n)
5389 real(dp),
allocatable,
target :: work(:,:,:,:)
5390 allocate(work, mold=var)
5393 #if defined(__GFORTRAN__) && __GNUC__ < 7
5394 cloc(var(1,1,1,1)), &
5395 #elif defined(NVIDIA)
5400 dinfo, dp, 0, 0, (/0/), (/0/) )
5406 if ( error /= file_success_code )
then
5407 log_error(
"FILE_read_var_realDP_4D",*)
'failed to get data value: ', trim(varname)
5413 call prof_rapend (
'FILE_Read', 2, disable_barrier = .not. file_files(fid)%allnodes )
5416 end subroutine file_read_var_realdp_4d
5421 subroutine file_write_realsp_1d( &
5429 integer,
intent(in) :: vid
5431 real(sp),
intent(in) :: var(:)
5433 real(sp),
intent(in),
target,
contiguous :: var(:)
5435 real(dp),
intent(in) :: t_start
5436 real(dp),
intent(in) :: t_end
5437 integer,
intent(in),
optional :: ndims
5438 integer,
intent(in),
optional :: count(:)
5439 integer,
intent(in),
optional :: start(:)
5442 integer :: start_(1)
5453 fid = file_vars(vid)%fid
5456 log_error(
"FILE_write_realSP_1D",*)
'File is not opened. fid = ', fid
5460 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
5462 if (
present(ndims) )
then
5466 if ( .not.
present(start) )
then
5467 log_error(
"FILE_write_realSP_1D",*)
'start argument is neccessary when ndims is specified'
5470 if ( .not.
present(count) )
then
5471 log_error(
"FILE_write_realSP_1D",*)
'count argument is neccessary when ndims is specified'
5476 #if defined(__GFORTRAN__) && __GNUC__ < 7
5477 cloc(var(1)), ts, te, ndims, sp, &
5479 c_loc(var), ts, te, ndims, sp, &
5484 if (
present(start) )
then
5485 start_(:) = start(:)
5494 real(sp),
allocatable,
target :: work(:)
5495 allocate(work, source=var)
5498 #if defined(__GFORTRAN__) && __GNUC__ < 7
5500 #elif defined(NVIDIA)
5506 start_, shape(var) )
5511 if ( error /= file_success_code )
then
5512 log_error(
"FILE_write_realSP_1D",*)
'failed to write data: ', trim(file_vars(vid)%name)
5516 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
5519 end subroutine file_write_realsp_1d
5520 subroutine file_write_realdp_1d( &
5528 integer,
intent(in) :: vid
5530 real(dp),
intent(in) :: var(:)
5532 real(dp),
intent(in),
target,
contiguous :: var(:)
5534 real(dp),
intent(in) :: t_start
5535 real(dp),
intent(in) :: t_end
5536 integer,
intent(in),
optional :: ndims
5537 integer,
intent(in),
optional :: count(:)
5538 integer,
intent(in),
optional :: start(:)
5541 integer :: start_(1)
5552 fid = file_vars(vid)%fid
5555 log_error(
"FILE_write_realDP_1D",*)
'File is not opened. fid = ', fid
5559 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
5561 if (
present(ndims) )
then
5565 if ( .not.
present(start) )
then
5566 log_error(
"FILE_write_realDP_1D",*)
'start argument is neccessary when ndims is specified'
5569 if ( .not.
present(count) )
then
5570 log_error(
"FILE_write_realDP_1D",*)
'count argument is neccessary when ndims is specified'
5575 #if defined(__GFORTRAN__) && __GNUC__ < 7
5576 cloc(var(1)), ts, te, ndims, dp, &
5578 c_loc(var), ts, te, ndims, dp, &
5583 if (
present(start) )
then
5584 start_(:) = start(:)
5593 real(dp),
allocatable,
target :: work(:)
5594 allocate(work, source=var)
5597 #if defined(__GFORTRAN__) && __GNUC__ < 7
5599 #elif defined(NVIDIA)
5605 start_, shape(var) )
5610 if ( error /= file_success_code )
then
5611 log_error(
"FILE_write_realDP_1D",*)
'failed to write data: ', trim(file_vars(vid)%name)
5615 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
5618 end subroutine file_write_realdp_1d
5619 subroutine file_write_realsp_2d( &
5625 integer,
intent(in) :: vid
5627 real(sp),
intent(in) :: var(:,:)
5629 real(sp),
intent(in),
target,
contiguous :: var(:,:)
5631 real(dp),
intent(in) :: t_start
5632 real(dp),
intent(in) :: t_end
5633 integer,
intent(in),
optional :: start(:)
5636 integer :: start_(2)
5647 fid = file_vars(vid)%fid
5650 log_error(
"FILE_write_realSP_2D",*)
'File is not opened. fid = ', fid
5654 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
5657 if (
present(start) )
then
5658 start_(:) = start(:)
5667 real(sp),
allocatable,
target :: work(:,:)
5668 allocate(work, source=var)
5671 #if defined(__GFORTRAN__) && __GNUC__ < 7
5673 #elif defined(NVIDIA)
5679 start_, shape(var) )
5683 if ( error /= file_success_code )
then
5684 log_error(
"FILE_write_realSP_2D",*)
'failed to write data: ', trim(file_vars(vid)%name)
5688 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
5691 end subroutine file_write_realsp_2d
5692 subroutine file_write_realdp_2d( &
5698 integer,
intent(in) :: vid
5700 real(dp),
intent(in) :: var(:,:)
5702 real(dp),
intent(in),
target,
contiguous :: var(:,:)
5704 real(dp),
intent(in) :: t_start
5705 real(dp),
intent(in) :: t_end
5706 integer,
intent(in),
optional :: start(:)
5709 integer :: start_(2)
5720 fid = file_vars(vid)%fid
5723 log_error(
"FILE_write_realDP_2D",*)
'File is not opened. fid = ', fid
5727 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
5730 if (
present(start) )
then
5731 start_(:) = start(:)
5740 real(dp),
allocatable,
target :: work(:,:)
5741 allocate(work, source=var)
5744 #if defined(__GFORTRAN__) && __GNUC__ < 7
5746 #elif defined(NVIDIA)
5752 start_, shape(var) )
5756 if ( error /= file_success_code )
then
5757 log_error(
"FILE_write_realDP_2D",*)
'failed to write data: ', trim(file_vars(vid)%name)
5761 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
5764 end subroutine file_write_realdp_2d
5765 subroutine file_write_realsp_3d( &
5771 integer,
intent(in) :: vid
5773 real(sp),
intent(in) :: var(:,:,:)
5775 real(sp),
intent(in),
target,
contiguous :: var(:,:,:)
5777 real(dp),
intent(in) :: t_start
5778 real(dp),
intent(in) :: t_end
5779 integer,
intent(in),
optional :: start(:)
5782 integer :: start_(3)
5793 fid = file_vars(vid)%fid
5796 log_error(
"FILE_write_realSP_3D",*)
'File is not opened. fid = ', fid
5800 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
5803 if (
present(start) )
then
5804 start_(:) = start(:)
5813 real(sp),
allocatable,
target :: work(:,:,:)
5814 allocate(work, source=var)
5817 #if defined(__GFORTRAN__) && __GNUC__ < 7
5819 #elif defined(NVIDIA)
5825 start_, shape(var) )
5829 if ( error /= file_success_code )
then
5830 log_error(
"FILE_write_realSP_3D",*)
'failed to write data: ', trim(file_vars(vid)%name)
5834 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
5837 end subroutine file_write_realsp_3d
5838 subroutine file_write_realdp_3d( &
5844 integer,
intent(in) :: vid
5846 real(dp),
intent(in) :: var(:,:,:)
5848 real(dp),
intent(in),
target,
contiguous :: var(:,:,:)
5850 real(dp),
intent(in) :: t_start
5851 real(dp),
intent(in) :: t_end
5852 integer,
intent(in),
optional :: start(:)
5855 integer :: start_(3)
5866 fid = file_vars(vid)%fid
5869 log_error(
"FILE_write_realDP_3D",*)
'File is not opened. fid = ', fid
5873 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
5876 if (
present(start) )
then
5877 start_(:) = start(:)
5886 real(dp),
allocatable,
target :: work(:,:,:)
5887 allocate(work, source=var)
5890 #if defined(__GFORTRAN__) && __GNUC__ < 7
5892 #elif defined(NVIDIA)
5898 start_, shape(var) )
5902 if ( error /= file_success_code )
then
5903 log_error(
"FILE_write_realDP_3D",*)
'failed to write data: ', trim(file_vars(vid)%name)
5907 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
5910 end subroutine file_write_realdp_3d
5911 subroutine file_write_realsp_4d( &
5917 integer,
intent(in) :: vid
5919 real(sp),
intent(in) :: var(:,:,:,:)
5921 real(sp),
intent(in),
target,
contiguous :: var(:,:,:,:)
5923 real(dp),
intent(in) :: t_start
5924 real(dp),
intent(in) :: t_end
5925 integer,
intent(in),
optional :: start(:)
5928 integer :: start_(4)
5939 fid = file_vars(vid)%fid
5942 log_error(
"FILE_write_realSP_4D",*)
'File is not opened. fid = ', fid
5946 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
5949 if (
present(start) )
then
5950 start_(:) = start(:)
5959 real(sp),
allocatable,
target :: work(:,:,:,:)
5960 allocate(work, source=var)
5963 #if defined(__GFORTRAN__) && __GNUC__ < 7
5964 cloc(var(1,1,1,1)), &
5965 #elif defined(NVIDIA)
5971 start_, shape(var) )
5975 if ( error /= file_success_code )
then
5976 log_error(
"FILE_write_realSP_4D",*)
'failed to write data: ', trim(file_vars(vid)%name)
5980 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
5983 end subroutine file_write_realsp_4d
5984 subroutine file_write_realdp_4d( &
5990 integer,
intent(in) :: vid
5992 real(dp),
intent(in) :: var(:,:,:,:)
5994 real(dp),
intent(in),
target,
contiguous :: var(:,:,:,:)
5996 real(dp),
intent(in) :: t_start
5997 real(dp),
intent(in) :: t_end
5998 integer,
intent(in),
optional :: start(:)
6001 integer :: start_(4)
6012 fid = file_vars(vid)%fid
6015 log_error(
"FILE_write_realDP_4D",*)
'File is not opened. fid = ', fid
6019 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
6022 if (
present(start) )
then
6023 start_(:) = start(:)
6032 real(dp),
allocatable,
target :: work(:,:,:,:)
6033 allocate(work, source=var)
6036 #if defined(__GFORTRAN__) && __GNUC__ < 7
6037 cloc(var(1,1,1,1)), &
6038 #elif defined(NVIDIA)
6044 start_, shape(var) )
6048 if ( error /= file_success_code )
then
6049 log_error(
"FILE_write_realDP_4D",*)
'failed to write data: ', trim(file_vars(vid)%name)
6053 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
6056 end subroutine file_write_realdp_4d
6063 integer,
intent(in) :: fid
6070 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
6074 if ( error == file_success_code )
then
6077 log_info(
"FILE_enddef",
'(1x,A,I3.3,2A)') &
6078 'End define mode : No.', fid,
', name = ', trim(file_files(fid)%name)
6081 log_error(
"FILE_enddef",*)
'failed to exit define mode'
6085 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
6095 integer,
intent(in) :: fid
6102 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
6106 if ( error == file_success_code )
then
6109 log_info(
"FILE_redef",
'(1x,A,I3.3,2A)') &
6110 'Enter to define mode : No.', fid,
', name = ', trim(file_files(fid)%name)
6113 log_error(
"FILE_redef",*)
'failed to enter to define mode'
6117 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
6129 integer,
intent(in) :: fid
6130 integer(8),
intent(in) :: buf_amount
6137 if ( file_files(fid)%buffer_size > 0 )
then
6141 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
6145 if ( error /= file_success_code )
then
6146 log_error(
"FILE_attach_buffer",*)
'failed to attach buffer in PnetCDF'
6151 log_info(
"FILE_attach_buffer",
'(1x,A,I3.3,3A,I10)') &
6152 'Attach buffer : No.', fid,
', name = ', trim(file_files(fid)%name), &
6153 ', size = ', buf_amount
6155 file_files(fid)%buffer_size = buf_amount
6157 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
6167 integer,
intent(in) :: fid
6174 if ( file_files(fid)%fid < 0 )
return
6176 if ( file_files(fid)%buffer_size < 0 )
return
6178 call prof_rapstart(
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
6182 if ( error /= file_success_code )
then
6183 log_error(
"FILE_detach_buffer",*)
'failed to detach buffer in PnetCDF'
6188 log_info(
"FILE_detach_buffer",
'(1x,A,I3.3,2A)') &
6189 'Detach buffer : No.', fid,
', name = ', trim(file_files(fid)%name)
6191 file_files(fid)%buffer_size = -1
6193 call prof_rapend (
'FILE_Write', 2, disable_barrier = .not. file_files(fid)%allnodes )
6203 integer,
intent(in) :: fid
6210 if ( file_files(fid)%fid < 0 )
return
6212 call prof_rapstart(
'FILE', 2, disable_barrier = .not. file_files(fid)%allnodes )
6216 if ( error == file_success_code )
then
6223 log_error(
"FILE_flush",*)
'failed to flush data to netcdf file'
6227 call prof_rapend (
'FILE', 2, disable_barrier = .not. file_files(fid)%allnodes )
6235 integer,
intent(in) :: fid
6236 logical,
intent(in),
optional :: abort
6238 logical(c_bool) :: abort_
6245 if ( file_files(fid)%fid < 0 )
return
6247 call prof_rapstart(
'FILE', 2, disable_barrier = .not. file_files(fid)%allnodes )
6249 if (
present(abort) )
then
6257 if ( error == file_success_code )
then
6260 log_info(
"FILE_close",
'(1x,A,I3.3,2A)') &
6261 'Close : No.', fid,
', name = ', trim(file_files(fid)%name)
6263 elseif( error /= file_already_closed_code )
then
6264 log_error(
"FILE_close",*)
'failed to close file: ', trim(file_files(fid)%name)
6265 if ( .not. abort_ )
call prc_abort
6268 file_files(fid)%fid = -1
6269 file_files(fid)%name =
''
6270 file_files(fid)%aggregate = .false.
6271 file_files(fid)%buffer_size = -1
6273 do n = 1, file_nvars
6274 if ( file_vars(n)%fid == fid )
then
6275 file_vars(n)%vid = -1
6276 file_vars(n)%name =
''
6280 call prof_rapend (
'FILE', 2, disable_barrier = .not. file_files(fid)%allnodes )
6288 logical,
intent(in),
optional :: skip_abort
6293 do fid = 1, file_nfiles
6306 integer,
intent(in) :: date(6)
6307 character(len=*),
intent(out) :: tunits
6310 write(tunits,
'(a,i4.4,"-",i2.2,"-",i2.2," ",i2.2,":",i2.2,":",i2.2)')
'seconds since ', date
6316 integer,
intent(in) :: fid
6333 subroutine file_get_fid( &
6348 character(len=*),
intent( in) :: basename
6349 integer,
intent( in) :: mode
6350 integer,
intent( in) :: rankid
6351 logical,
intent( in) :: single
6353 integer,
intent(out) :: fid
6354 logical,
intent(out) :: existed
6356 logical,
intent( in),
optional :: allnodes
6357 logical,
intent( in),
optional :: aggregate
6358 character(len=*),
intent( in),
optional :: postfix
6360 character(len=FILE_HSHORT) :: rwname(0:2)
6361 data rwname /
'READ',
'WRITE',
'APPEND' /
6363 character(len=FILE_HLONG) :: fname
6366 logical :: allnodes_
6367 logical :: aggregate_
6375 if (
present(allnodes) )
then
6376 allnodes_ = allnodes
6382 if (
present(aggregate) )
then
6383 aggregate_ = aggregate
6388 if ( aggregate_ )
then
6394 if (
present(postfix) )
then
6395 call io_get_fname(fname, trim(basename)//trim(postfix))
6396 elseif ( aggregate_ )
then
6397 call io_get_fname(fname, basename)
6398 elseif ( single )
then
6399 call io_get_fname(fname, basename, rank=-1)
6401 call io_get_fname(fname, basename, rank=rankid)
6406 do n = 1, file_nfiles
6407 if ( fname == file_files(n)%name )
then
6418 call prof_rapstart(
'FILE', 2, disable_barrier = ( .not. allnodes_ ) .or. single )
6421 cstr(fname), mode, mpi_comm )
6423 if ( error /= file_success_code )
then
6424 log_error(
"FILE_get_fid",*)
'failed to open file :'//trim(fname)//
'.nc'
6428 file_nfiles = file_nfiles + 1
6431 file_files(fid)%name = fname
6432 file_files(fid)%fid = cfid
6433 file_files(fid)%aggregate = aggregate_
6434 file_files(fid)%single = single
6435 file_files(fid)%allnodes = allnodes_ .and. (.not. single)
6436 file_files(fid)%buffer_size = -1
6439 log_info(
"FILE_get_fid",
'(1x,A,A6,A,I3.3,2A)') &
6440 'Registration (', trim(rwname(mode)),
') : No.', fid,
', name = ', trim(fname)
6444 call prof_rapend (
'FILE', 2, disable_barrier = .not. file_files(fid)%allnodes )
6447 end subroutine file_get_fid
6449 #if defined(__GFORTRAN__) && __GNUC__ < 7
6450 function cloc_sp( x )
6453 real(sp),
target,
intent(in) :: x
6454 type(c_ptr) :: cloc_sp
6457 end function cloc_sp
6458 function cloc_dp( x )
6461 real(dp),
target,
intent(in) :: x
6462 type(c_ptr) :: cloc_dp
6465 end function cloc_dp