40 public :: fileputassociatedcoordinates
41 public :: fileaddvariable
48 public :: filegetglobalattribute
49 public :: filesetglobalattribute
55 module procedure fileputaxisrealsp
56 module procedure fileputaxisrealdp
57 end interface fileputaxis
58 interface fileputassociatedcoordinates
59 module procedure fileput1dassociatedcoordinatesrealsp
60 module procedure fileput1dassociatedcoordinatesrealdp
61 module procedure fileput2dassociatedcoordinatesrealsp
62 module procedure fileput2dassociatedcoordinatesrealdp
63 module procedure fileput3dassociatedcoordinatesrealsp
64 module procedure fileput3dassociatedcoordinatesrealdp
65 module procedure fileput4dassociatedcoordinatesrealsp
66 module procedure fileput4dassociatedcoordinatesrealdp
67 end interface fileputassociatedcoordinates
68 interface fileaddvariable
69 module procedure fileaddvariablenot
70 module procedure fileaddvariablerealsp
71 module procedure fileaddvariablerealdp
72 end interface fileaddvariable
74 module procedure fileread1drealsp
75 module procedure fileread1drealdp
76 module procedure fileread2drealsp
77 module procedure fileread2drealdp
78 module procedure fileread3drealsp
79 module procedure fileread3drealdp
80 module procedure fileread4drealsp
81 module procedure fileread4drealdp
82 end interface fileread
84 module procedure filewrite1drealsp
85 module procedure filewrite1drealdp
86 module procedure filewrite2drealsp
87 module procedure filewrite2drealdp
88 module procedure filewrite3drealsp
89 module procedure filewrite3drealdp
90 module procedure filewrite4drealsp
91 module procedure filewrite4drealdp
92 end interface filewrite
93 interface filegetglobalattribute
94 module procedure filegetglobalattributetext
95 module procedure filegetglobalattributeint
96 module procedure filegetglobalattributefloat
97 module procedure filegetglobalattributedouble
98 end interface filegetglobalattribute
99 interface filesetglobalattribute
100 module procedure filesetglobalattributetext
101 module procedure filesetglobalattributeint
102 module procedure filesetglobalattributefloat
103 module procedure filesetglobalattributedouble
104 end interface filesetglobalattribute
110 real(DP),
parameter,
public ::
rmiss = -9.9999e+30
119 integer,
private,
parameter :: file_nfile_max = 512
121 integer,
private,
parameter :: file_nvar_max = 40960
124 character(LEN=File_HLONG),
private,
save :: file_fname_list(file_nfile_max)
125 integer,
private,
save :: file_fid_list (file_nfile_max)
126 integer,
private,
save :: file_fid_count = 1
127 character(LEN=File_HLONG),
private,
save :: file_vname_list (file_nvar_max)
128 integer,
private,
save :: file_vid_fid_list(file_nvar_max)
129 integer,
private,
save :: file_vid_list (file_nvar_max)
130 integer,
private,
save :: file_vid_count = 1
131 integer,
private,
save :: mpi_myrank
133 character(LEN=LOG_LMSG),
private :: message
152 integer,
intent(out) :: fid
153 logical,
intent(out) :: existed
154 character(LEN=*),
intent( in) :: basename
155 character(LEN=*),
intent( in) :: title
156 character(LEN=*),
intent( in) :: source
157 character(LEN=*),
intent( in) :: institution
158 integer,
intent( in) :: master
159 integer,
intent( in) :: myrank
160 integer,
intent( in) :: rankidx(:)
161 character(LEN=*),
intent( in),
optional :: time_units
162 logical,
intent( in),
optional :: single
163 logical,
intent( in),
optional :: append
165 character(len=File_HMID) :: time_units_
172 if (
present(time_units) )
then 173 time_units_ = time_units
175 time_units_ =
'seconds' 180 if (
present(single) )
then 181 if ( single .and. (myrank .ne. master) )
return 188 if (
present(append) )
then 200 if ( existed )
return 203 call filesetglobalattribute( fid, &
205 call filesetglobalattribute( fid, &
207 call filesetglobalattribute( fid, &
208 "institution", institution )
209 call filesetglobalattribute( fid, &
210 "myrank", (/myrank/) )
211 call filesetglobalattribute( fid, &
218 call log(
'E',
'xxx failed to set time units')
225 subroutine filegetglobalattributetext( &
230 integer,
intent(in) :: fid
231 character(LEN=*),
intent(in) :: key
232 character(LEN=*),
intent(out) :: val
242 call log(
'E',
'xxx failed to get text global attribute: '//trim(key))
246 end subroutine filegetglobalattributetext
249 subroutine filegetglobalattributeint( &
254 integer,
intent(in) :: fid
255 character(LEN=*),
intent(in) :: key
256 integer,
intent(out) :: val(:)
263 fid, key,
size(val), &
266 call log(
'E',
'xxx failed to get integer global attribute: '//trim(key))
270 end subroutine filegetglobalattributeint
273 subroutine filegetglobalattributefloat( &
278 integer,
intent(in) :: fid
279 character(LEN=*),
intent(in) :: key
280 real(SP),
intent(out) :: val(:)
287 fid, key,
size(val), &
290 call log(
'E',
'xxx failed to get float global attribute: '//trim(key))
294 end subroutine filegetglobalattributefloat
297 subroutine filegetglobalattributedouble( &
302 integer,
intent(in) :: fid
303 character(LEN=*),
intent(in) :: key
304 real(DP),
intent(out) :: val(:)
311 fid, key,
size(val), &
314 call log(
'E',
'xxx failed to get double global attribute: '//trim(key))
318 end subroutine filegetglobalattributedouble
322 subroutine filesetglobalattributetext( &
327 integer,
intent(in) :: fid
328 character(LEN=*),
intent(in) :: key
329 character(LEN=*),
intent(in) :: val
337 call log(
'E',
'xxx failed to set text global attribute: '//trim(key))
341 end subroutine filesetglobalattributetext
344 subroutine filesetglobalattributeint( &
349 integer,
intent(in) :: fid
350 character(LEN=*),
intent(in) :: key
351 integer,
intent(in) :: val(:)
358 key, val,
size(val), &
361 call log(
'E',
'xxx failed to set integer global attribute: '//trim(key))
365 end subroutine filesetglobalattributeint
368 subroutine filesetglobalattributefloat( &
373 integer,
intent(in) :: fid
374 character(LEN=*),
intent(in) :: key
375 real(SP),
intent(in) :: val(:)
382 key, val,
size(val), &
385 call log(
'E',
'xxx failed to set float global attribute: '//trim(key))
389 end subroutine filesetglobalattributefloat
392 subroutine filesetglobalattributedouble( &
397 integer,
intent(in) :: fid
398 character(LEN=*),
intent(in) :: key
399 real(DP),
intent(in) :: val(:)
406 key, val,
size(val), &
409 call log(
'E',
'xxx failed to set double global attribute: '//trim(key))
413 end subroutine filesetglobalattributedouble
422 integer,
intent(in) :: fid
423 character(LEN=*),
intent(in) :: filetype
424 character(LEN=*),
intent(in) :: key
425 character(LEN=*),
intent(in) :: val
430 filetype, key, val, &
433 call log(
'E',
'xxx failed to set option')
448 integer,
intent(out) :: fid
449 character(LEN=*),
intent( in) :: basename
450 integer,
intent( in) :: mode
451 logical,
intent( in),
optional :: single
454 logical :: single_ = .false.
456 if (
present(single) ) single_ = single
458 call filegetfid( fid, &
460 basename, mode, single_ )
468 subroutine fileputaxisrealsp( &
476 integer,
intent(in) :: fid
477 character(len=*),
intent(in) :: name
478 character(len=*),
intent(in) :: desc
479 character(len=*),
intent(in) :: units
480 character(len=*),
intent(in) :: dim_name
481 integer,
intent(in) :: dtype
482 real(SP),
intent(in) :: val(:)
488 name, desc, units, dim_name, dtype, val,
size(val),
sp, &
491 call log(
'E',
'xxx failed to put axis')
495 end subroutine fileputaxisrealsp
496 subroutine fileputaxisrealdp( &
504 integer,
intent(in) :: fid
505 character(len=*),
intent(in) :: name
506 character(len=*),
intent(in) :: desc
507 character(len=*),
intent(in) :: units
508 character(len=*),
intent(in) :: dim_name
509 integer,
intent(in) :: dtype
510 real(DP),
intent(in) :: val(:)
516 name, desc, units, dim_name, dtype, val,
size(val),
dp, &
519 call log(
'E',
'xxx failed to put axis')
523 end subroutine fileputaxisrealdp
528 subroutine fileput1dassociatedcoordinatesrealsp( &
536 integer,
intent(in) :: fid
537 character(len=*),
intent(in) :: name
538 character(len=*),
intent(in) :: desc
539 character(len=*),
intent(in) :: units
540 character(len=*),
intent(in) :: dim_names(:)
541 integer,
intent(in) :: dtype
542 real(SP),
intent(in) :: val(:)
548 name, desc, units, dim_names,
size(dim_names), dtype, &
552 call log(
'E',
'xxx failed to put associated coordinates')
556 end subroutine fileput1dassociatedcoordinatesrealsp
557 subroutine fileput1dassociatedcoordinatesrealdp( &
565 integer,
intent(in) :: fid
566 character(len=*),
intent(in) :: name
567 character(len=*),
intent(in) :: desc
568 character(len=*),
intent(in) :: units
569 character(len=*),
intent(in) :: dim_names(:)
570 integer,
intent(in) :: dtype
571 real(DP),
intent(in) :: val(:)
577 name, desc, units, dim_names,
size(dim_names), dtype, &
581 call log(
'E',
'xxx failed to put associated coordinates')
585 end subroutine fileput1dassociatedcoordinatesrealdp
586 subroutine fileput2dassociatedcoordinatesrealsp( &
594 integer,
intent(in) :: fid
595 character(len=*),
intent(in) :: name
596 character(len=*),
intent(in) :: desc
597 character(len=*),
intent(in) :: units
598 character(len=*),
intent(in) :: dim_names(:)
599 integer,
intent(in) :: dtype
600 real(SP),
intent(in) :: val(:,:)
606 name, desc, units, dim_names,
size(dim_names), dtype, &
610 call log(
'E',
'xxx failed to put associated coordinates')
614 end subroutine fileput2dassociatedcoordinatesrealsp
615 subroutine fileput2dassociatedcoordinatesrealdp( &
623 integer,
intent(in) :: fid
624 character(len=*),
intent(in) :: name
625 character(len=*),
intent(in) :: desc
626 character(len=*),
intent(in) :: units
627 character(len=*),
intent(in) :: dim_names(:)
628 integer,
intent(in) :: dtype
629 real(DP),
intent(in) :: val(:,:)
635 name, desc, units, dim_names,
size(dim_names), dtype, &
639 call log(
'E',
'xxx failed to put associated coordinates')
643 end subroutine fileput2dassociatedcoordinatesrealdp
644 subroutine fileput3dassociatedcoordinatesrealsp( &
652 integer,
intent(in) :: fid
653 character(len=*),
intent(in) :: name
654 character(len=*),
intent(in) :: desc
655 character(len=*),
intent(in) :: units
656 character(len=*),
intent(in) :: dim_names(:)
657 integer,
intent(in) :: dtype
658 real(SP),
intent(in) :: val(:,:,:)
664 name, desc, units, dim_names,
size(dim_names), dtype, &
668 call log(
'E',
'xxx failed to put associated coordinates')
672 end subroutine fileput3dassociatedcoordinatesrealsp
673 subroutine fileput3dassociatedcoordinatesrealdp( &
681 integer,
intent(in) :: fid
682 character(len=*),
intent(in) :: name
683 character(len=*),
intent(in) :: desc
684 character(len=*),
intent(in) :: units
685 character(len=*),
intent(in) :: dim_names(:)
686 integer,
intent(in) :: dtype
687 real(DP),
intent(in) :: val(:,:,:)
693 name, desc, units, dim_names,
size(dim_names), dtype, &
697 call log(
'E',
'xxx failed to put associated coordinates')
701 end subroutine fileput3dassociatedcoordinatesrealdp
702 subroutine fileput4dassociatedcoordinatesrealsp( &
710 integer,
intent(in) :: fid
711 character(len=*),
intent(in) :: name
712 character(len=*),
intent(in) :: desc
713 character(len=*),
intent(in) :: units
714 character(len=*),
intent(in) :: dim_names(:)
715 integer,
intent(in) :: dtype
716 real(SP),
intent(in) :: val(:,:,:,:)
722 name, desc, units, dim_names,
size(dim_names), dtype, &
726 call log(
'E',
'xxx failed to put associated coordinates')
730 end subroutine fileput4dassociatedcoordinatesrealsp
731 subroutine fileput4dassociatedcoordinatesrealdp( &
739 integer,
intent(in) :: fid
740 character(len=*),
intent(in) :: name
741 character(len=*),
intent(in) :: desc
742 character(len=*),
intent(in) :: units
743 character(len=*),
intent(in) :: dim_names(:)
744 integer,
intent(in) :: dtype
745 real(DP),
intent(in) :: val(:,:,:,:)
751 name, desc, units, dim_names,
size(dim_names), dtype, &
755 call log(
'E',
'xxx failed to put associated coordinates')
759 end subroutine fileput4dassociatedcoordinatesrealdp
764 subroutine fileaddvariablenot( &
774 integer,
intent(out) :: vid
775 integer,
intent( in) :: fid
776 character(len=*),
intent( in) :: varname
777 character(len=*),
intent( in) :: desc
778 character(len=*),
intent( in) :: units
779 character(len=*),
intent( in) :: dims(:)
780 integer,
intent( in) :: dtype
781 logical,
intent( in),
optional :: tavg
783 call fileaddvariablerealdp(vid, fid, varname, desc, units, dims, dtype, &
787 end subroutine fileaddvariablenot
788 subroutine fileaddvariablerealsp( &
799 integer,
intent(out) :: vid
800 integer,
intent( in) :: fid
801 character(len=*),
intent( in) :: varname
802 character(len=*),
intent( in) :: desc
803 character(len=*),
intent( in) :: units
804 character(len=*),
intent( in) :: dims(:)
805 integer,
intent( in) :: dtype
806 real(SP),
intent( in) :: tint
807 logical,
intent( in),
optional :: tavg
818 do n = 1, file_vid_count
819 if ( file_vid_fid_list(n) == fid .and. &
820 varname == file_vname_list(n) )
then 821 vid = file_vid_list(n)
827 write(message,*)
'*** [File] Var registration' 828 call log(
"I", message)
829 write(message,*)
'*** variable name: ', trim(varname)
830 call log(
"I", message)
832 tint8 =
real(tint,
dp)
834 if (
present(tavg) )
then 845 fid, varname, desc, units, dims,
size(dims), dtype, &
849 call log(
'E',
'xxx failed to add variable: '//trim(varname))
852 file_vname_list(file_vid_count) = trim(varname)
853 file_vid_list(file_vid_count) = vid
854 file_vid_fid_list(file_vid_count) = fid
855 file_vid_count = file_vid_count + 1
859 end subroutine fileaddvariablerealsp
860 subroutine fileaddvariablerealdp( &
871 integer,
intent(out) :: vid
872 integer,
intent( in) :: fid
873 character(len=*),
intent( in) :: varname
874 character(len=*),
intent( in) :: desc
875 character(len=*),
intent( in) :: units
876 character(len=*),
intent( in) :: dims(:)
877 integer,
intent( in) :: dtype
878 real(DP),
intent( in) :: tint
879 logical,
intent( in),
optional :: tavg
890 do n = 1, file_vid_count
891 if ( file_vid_fid_list(n) == fid .and. &
892 varname == file_vname_list(n) )
then 893 vid = file_vid_list(n)
899 write(message,*)
'*** [File] Var registration' 900 call log(
"I", message)
901 write(message,*)
'*** variable name: ', trim(varname)
902 call log(
"I", message)
904 tint8 =
real(tint,
dp)
906 if (
present(tavg) )
then 917 fid, varname, desc, units, dims,
size(dims), dtype, &
921 call log(
'E',
'xxx failed to add variable: '//trim(varname))
924 file_vname_list(file_vid_count) = trim(varname)
925 file_vid_list(file_vid_count) = vid
926 file_vid_fid_list(file_vid_count) = fid
927 file_vid_count = file_vid_count + 1
931 end subroutine fileaddvariablerealdp
942 integer,
intent(in) :: fid
943 character(len=*),
intent(in) :: vname
944 character(len=*),
intent(in) :: key
945 character(len=*),
intent(in) :: val
954 call log(
'E',
'xxx failed to put axis')
972 integer,
intent(out) :: dims(:)
973 character(LEN=*),
intent( in) :: basename
974 character(LEN=*),
intent( in) :: varname
975 integer,
intent( in) :: myrank
976 logical,
intent( in),
optional :: single
983 logical :: single_ = .false.
991 if (
present(single) ) single_ = single
999 fid, varname, 1, .false., &
1004 call log(
'E',
'xxx failed to get data information :'//trim(varname))
1007 if ( dinfo%rank /=
size(dims) )
then 1008 write(message,*)
'xxx rank is different, ',
size(dims), dinfo%rank
1009 call log(
'E', message)
1011 do n = 1,
size(dims)
1012 dims(n) = dinfo%dim_size(n)
1037 character(len=*),
intent(in) :: basename
1038 character(len=*),
intent(in) :: varname
1039 integer,
intent(in) :: myrank
1040 integer,
intent(in) :: istep
1041 logical,
intent(in),
optional :: single
1043 character(len=File_HMID),
intent(out),
optional :: description
1044 character(len=File_HSHORT),
intent(out),
optional :: units
1045 integer,
intent(out),
optional :: datatype
1046 integer,
intent(out),
optional :: dim_rank
1047 character(len=File_HSHORT),
intent(out),
optional :: dim_name(:)
1048 integer,
intent(out),
optional :: dim_size(:)
1049 real(DP),
intent(out),
optional :: time_start
1050 real(DP),
intent(out),
optional :: time_end
1051 character(len=File_HMID),
intent(out),
optional :: time_units
1056 integer :: ndim, idim
1060 logical :: single_ = .false.
1067 if (
present(single) ) single_ = single
1085 call log(
'E',
'xxx data info not found in '//trim(basename))
1088 if (
present(description) ) description = dinfo%description
1089 if (
present(units) ) units = dinfo%units
1090 if (
present(datatype) ) datatype = dinfo%datatype
1091 if (
present(dim_rank) ) dim_rank = dinfo%rank
1093 if (
present(dim_name) )
then 1094 ndim = min( dinfo%rank,
size(dim_name) )
1096 dim_name(idim) = dinfo%dim_name(idim)
1099 if (
present(dim_size) )
then 1100 ndim = min( dinfo%rank,
size(dim_size) )
1102 dim_size(idim) = dinfo%dim_size(idim)
1106 if (
present(time_units) )
then 1107 if ( dinfo%time_units ==
"" )
then 1108 call filegetglobalattribute( fid,
"time_units", time_units )
1110 time_units = dinfo%time_units
1113 if (
present(time_start) )
then 1114 if ( dinfo%time_units ==
"" )
then 1115 call filegetglobalattribute( fid,
"time", time )
1116 time_start = time(1)
1118 time_start = dinfo%time_start
1121 if (
present(time_end) )
then 1122 if ( dinfo%time_units ==
"" )
then 1123 call filegetglobalattribute( fid,
"time", time )
1126 time_end = dinfo%time_end
1155 integer,
intent(in) :: step_limit
1156 integer,
intent(in) :: dim_limit
1157 character(len=*),
intent(in) :: basename
1158 character(len=*),
intent(in) :: varname
1159 integer,
intent(in) :: myrank
1160 integer,
intent(out) :: step_nmax
1161 character(len=File_HMID),
intent(out) :: description
1162 character(len=File_HSHORT),
intent(out) :: units
1163 integer,
intent(out) :: datatype
1164 integer,
intent(out) :: dim_rank
1165 character(len=File_HSHORT),
intent(out) :: dim_name (dim_limit)
1166 integer,
intent(out) :: dim_size (dim_limit)
1167 real(DP),
intent(out) :: time_start(step_limit)
1168 real(DP),
intent(out) :: time_end (step_limit)
1169 character(len=File_HMID),
intent(out) :: time_units
1171 logical,
intent(in),
optional :: single
1177 integer :: istep, idim
1178 logical :: flag_first = .true.
1181 logical :: single_ = .false.
1186 if (
present(single) ) single_ = single
1201 time_start(:) =
rmiss 1204 do istep = 1, step_limit
1215 step_nmax = istep - 1
1219 if ( flag_first )
then 1220 flag_first = .false.
1222 description = dinfo%description
1224 datatype = dinfo%datatype
1225 dim_rank = dinfo%rank
1227 ndim = min( dinfo%rank, dim_limit )
1229 dim_name(idim) = dinfo%dim_name(idim)
1230 dim_size(idim) = dinfo%dim_size(idim)
1233 time_units = dinfo%time_units
1236 time_start(istep) = dinfo%time_start
1237 time_end(istep) = dinfo%time_end
1246 subroutine fileread1drealsp( &
1257 real(SP),
intent(out) :: var(:)
1258 character(LEN=*),
intent( in) :: basename
1259 character(LEN=*),
intent( in) :: varname
1260 integer,
intent( in) :: step
1261 integer,
intent( in) :: myrank
1262 logical,
intent( in),
optional :: allow_missing
1263 logical,
intent( in),
optional :: single
1267 integer :: dim_size(1)
1271 logical :: single_ = .false.
1278 if (
present(single) ) single_ = single
1286 fid, varname, step, .false., &
1291 if (
present(allow_missing) )
then 1292 if ( allow_missing )
then 1293 write(message,*)
'xxx [INPUT]/[File] data not found! : ', &
1294 'varname= ',trim(varname),
', step=',step
1295 call log(
'I', message)
1296 call log(
'I',
'xxx [INPUT]/[File] Value is set to 0.')
1299 call log(
'E',
'xxx failed to get data information :'//trim(varname))
1302 call log(
'E',
'xxx failed to get data information :'//trim(varname))
1306 if ( dinfo%rank /= 1 )
then 1307 write(message,*)
'xxx rank is not 1', dinfo%rank
1308 call log(
'E', message)
1310 dim_size(:) = shape(var)
1312 if ( dinfo%dim_size(n) /= dim_size(n) )
then 1313 write(message,*)
'xxx shape is different: ', varname, n, dinfo%dim_size(n), dim_size(n)
1314 call log(
'E', message)
1322 call log(
'E',
'xxx failed to get data value')
1326 end subroutine fileread1drealsp
1327 subroutine fileread1drealdp( &
1338 real(DP),
intent(out) :: var(:)
1339 character(LEN=*),
intent( in) :: basename
1340 character(LEN=*),
intent( in) :: varname
1341 integer,
intent( in) :: step
1342 integer,
intent( in) :: myrank
1343 logical,
intent( in),
optional :: allow_missing
1344 logical,
intent( in),
optional :: single
1348 integer :: dim_size(1)
1352 logical :: single_ = .false.
1359 if (
present(single) ) single_ = single
1367 fid, varname, step, .false., &
1372 if (
present(allow_missing) )
then 1373 if ( allow_missing )
then 1374 write(message,*)
'xxx [INPUT]/[File] data not found! : ', &
1375 'varname= ',trim(varname),
', step=',step
1376 call log(
'I', message)
1377 call log(
'I',
'xxx [INPUT]/[File] Value is set to 0.')
1380 call log(
'E',
'xxx failed to get data information :'//trim(varname))
1383 call log(
'E',
'xxx failed to get data information :'//trim(varname))
1387 if ( dinfo%rank /= 1 )
then 1388 write(message,*)
'xxx rank is not 1', dinfo%rank
1389 call log(
'E', message)
1391 dim_size(:) = shape(var)
1393 if ( dinfo%dim_size(n) /= dim_size(n) )
then 1394 write(message,*)
'xxx shape is different: ', varname, n, dinfo%dim_size(n), dim_size(n)
1395 call log(
'E', message)
1403 call log(
'E',
'xxx failed to get data value')
1407 end subroutine fileread1drealdp
1408 subroutine fileread2drealsp( &
1419 real(SP),
intent(out) :: var(:,:)
1420 character(LEN=*),
intent( in) :: basename
1421 character(LEN=*),
intent( in) :: varname
1422 integer,
intent( in) :: step
1423 integer,
intent( in) :: myrank
1424 logical,
intent( in),
optional :: allow_missing
1425 logical,
intent( in),
optional :: single
1429 integer :: dim_size(2)
1433 logical :: single_ = .false.
1440 if (
present(single) ) single_ = single
1448 fid, varname, step, .false., &
1453 if (
present(allow_missing) )
then 1454 if ( allow_missing )
then 1455 write(message,*)
'xxx [INPUT]/[File] data not found! : ', &
1456 'varname= ',trim(varname),
', step=',step
1457 call log(
'I', message)
1458 call log(
'I',
'xxx [INPUT]/[File] Value is set to 0.')
1461 call log(
'E',
'xxx failed to get data information :'//trim(varname))
1464 call log(
'E',
'xxx failed to get data information :'//trim(varname))
1468 if ( dinfo%rank /= 2 )
then 1469 write(message,*)
'xxx rank is not 2', dinfo%rank
1470 call log(
'E', message)
1472 dim_size(:) = shape(var)
1474 if ( dinfo%dim_size(n) /= dim_size(n) )
then 1475 write(message,*)
'xxx shape is different: ', varname, n, dinfo%dim_size(n), dim_size(n)
1476 call log(
'E', message)
1484 call log(
'E',
'xxx failed to get data value')
1488 end subroutine fileread2drealsp
1489 subroutine fileread2drealdp( &
1500 real(DP),
intent(out) :: var(:,:)
1501 character(LEN=*),
intent( in) :: basename
1502 character(LEN=*),
intent( in) :: varname
1503 integer,
intent( in) :: step
1504 integer,
intent( in) :: myrank
1505 logical,
intent( in),
optional :: allow_missing
1506 logical,
intent( in),
optional :: single
1510 integer :: dim_size(2)
1514 logical :: single_ = .false.
1521 if (
present(single) ) single_ = single
1529 fid, varname, step, .false., &
1534 if (
present(allow_missing) )
then 1535 if ( allow_missing )
then 1536 write(message,*)
'xxx [INPUT]/[File] data not found! : ', &
1537 'varname= ',trim(varname),
', step=',step
1538 call log(
'I', message)
1539 call log(
'I',
'xxx [INPUT]/[File] Value is set to 0.')
1542 call log(
'E',
'xxx failed to get data information :'//trim(varname))
1545 call log(
'E',
'xxx failed to get data information :'//trim(varname))
1549 if ( dinfo%rank /= 2 )
then 1550 write(message,*)
'xxx rank is not 2', dinfo%rank
1551 call log(
'E', message)
1553 dim_size(:) = shape(var)
1555 if ( dinfo%dim_size(n) /= dim_size(n) )
then 1556 write(message,*)
'xxx shape is different: ', varname, n, dinfo%dim_size(n), dim_size(n)
1557 call log(
'E', message)
1565 call log(
'E',
'xxx failed to get data value')
1569 end subroutine fileread2drealdp
1570 subroutine fileread3drealsp( &
1581 real(SP),
intent(out) :: var(:,:,:)
1582 character(LEN=*),
intent( in) :: basename
1583 character(LEN=*),
intent( in) :: varname
1584 integer,
intent( in) :: step
1585 integer,
intent( in) :: myrank
1586 logical,
intent( in),
optional :: allow_missing
1587 logical,
intent( in),
optional :: single
1591 integer :: dim_size(3)
1595 logical :: single_ = .false.
1602 if (
present(single) ) single_ = single
1610 fid, varname, step, .false., &
1615 if (
present(allow_missing) )
then 1616 if ( allow_missing )
then 1617 write(message,*)
'xxx [INPUT]/[File] data not found! : ', &
1618 'varname= ',trim(varname),
', step=',step
1619 call log(
'I', message)
1620 call log(
'I',
'xxx [INPUT]/[File] Value is set to 0.')
1623 call log(
'E',
'xxx failed to get data information :'//trim(varname))
1626 call log(
'E',
'xxx failed to get data information :'//trim(varname))
1630 if ( dinfo%rank /= 3 )
then 1631 write(message,*)
'xxx rank is not 3', dinfo%rank
1632 call log(
'E', message)
1634 dim_size(:) = shape(var)
1636 if ( dinfo%dim_size(n) /= dim_size(n) )
then 1637 write(message,*)
'xxx shape is different: ', varname, n, dinfo%dim_size(n), dim_size(n)
1638 call log(
'E', message)
1646 call log(
'E',
'xxx failed to get data value')
1650 end subroutine fileread3drealsp
1651 subroutine fileread3drealdp( &
1662 real(DP),
intent(out) :: var(:,:,:)
1663 character(LEN=*),
intent( in) :: basename
1664 character(LEN=*),
intent( in) :: varname
1665 integer,
intent( in) :: step
1666 integer,
intent( in) :: myrank
1667 logical,
intent( in),
optional :: allow_missing
1668 logical,
intent( in),
optional :: single
1672 integer :: dim_size(3)
1676 logical :: single_ = .false.
1683 if (
present(single) ) single_ = single
1691 fid, varname, step, .false., &
1696 if (
present(allow_missing) )
then 1697 if ( allow_missing )
then 1698 write(message,*)
'xxx [INPUT]/[File] data not found! : ', &
1699 'varname= ',trim(varname),
', step=',step
1700 call log(
'I', message)
1701 call log(
'I',
'xxx [INPUT]/[File] Value is set to 0.')
1704 call log(
'E',
'xxx failed to get data information :'//trim(varname))
1707 call log(
'E',
'xxx failed to get data information :'//trim(varname))
1711 if ( dinfo%rank /= 3 )
then 1712 write(message,*)
'xxx rank is not 3', dinfo%rank
1713 call log(
'E', message)
1715 dim_size(:) = shape(var)
1717 if ( dinfo%dim_size(n) /= dim_size(n) )
then 1718 write(message,*)
'xxx shape is different: ', varname, n, dinfo%dim_size(n), dim_size(n)
1719 call log(
'E', message)
1727 call log(
'E',
'xxx failed to get data value')
1731 end subroutine fileread3drealdp
1732 subroutine fileread4drealsp( &
1743 real(SP),
intent(out) :: var(:,:,:,:)
1744 character(LEN=*),
intent( in) :: basename
1745 character(LEN=*),
intent( in) :: varname
1746 integer,
intent( in) :: step
1747 integer,
intent( in) :: myrank
1748 logical,
intent( in),
optional :: allow_missing
1749 logical,
intent( in),
optional :: single
1753 integer :: dim_size(4)
1757 logical :: single_ = .false.
1764 if (
present(single) ) single_ = single
1772 fid, varname, step, .false., &
1777 if (
present(allow_missing) )
then 1778 if ( allow_missing )
then 1779 write(message,*)
'xxx [INPUT]/[File] data not found! : ', &
1780 'varname= ',trim(varname),
', step=',step
1781 call log(
'I', message)
1782 call log(
'I',
'xxx [INPUT]/[File] Value is set to 0.')
1783 var(:,:,:,:) = 0.0_sp
1785 call log(
'E',
'xxx failed to get data information :'//trim(varname))
1788 call log(
'E',
'xxx failed to get data information :'//trim(varname))
1792 if ( dinfo%rank /= 4 )
then 1793 write(message,*)
'xxx rank is not 4', dinfo%rank
1794 call log(
'E', message)
1796 dim_size(:) = shape(var)
1798 if ( dinfo%dim_size(n) /= dim_size(n) )
then 1799 write(message,*)
'xxx shape is different: ', varname, n, dinfo%dim_size(n), dim_size(n)
1800 call log(
'E', message)
1808 call log(
'E',
'xxx failed to get data value')
1812 end subroutine fileread4drealsp
1813 subroutine fileread4drealdp( &
1824 real(DP),
intent(out) :: var(:,:,:,:)
1825 character(LEN=*),
intent( in) :: basename
1826 character(LEN=*),
intent( in) :: varname
1827 integer,
intent( in) :: step
1828 integer,
intent( in) :: myrank
1829 logical,
intent( in),
optional :: allow_missing
1830 logical,
intent( in),
optional :: single
1834 integer :: dim_size(4)
1838 logical :: single_ = .false.
1845 if (
present(single) ) single_ = single
1853 fid, varname, step, .false., &
1858 if (
present(allow_missing) )
then 1859 if ( allow_missing )
then 1860 write(message,*)
'xxx [INPUT]/[File] data not found! : ', &
1861 'varname= ',trim(varname),
', step=',step
1862 call log(
'I', message)
1863 call log(
'I',
'xxx [INPUT]/[File] Value is set to 0.')
1864 var(:,:,:,:) = 0.0_dp
1866 call log(
'E',
'xxx failed to get data information :'//trim(varname))
1869 call log(
'E',
'xxx failed to get data information :'//trim(varname))
1873 if ( dinfo%rank /= 4 )
then 1874 write(message,*)
'xxx rank is not 4', dinfo%rank
1875 call log(
'E', message)
1877 dim_size(:) = shape(var)
1879 if ( dinfo%dim_size(n) /= dim_size(n) )
then 1880 write(message,*)
'xxx shape is different: ', varname, n, dinfo%dim_size(n), dim_size(n)
1881 call log(
'E', message)
1889 call log(
'E',
'xxx failed to get data value')
1893 end subroutine fileread4drealdp
1898 subroutine filewrite1drealsp( &
1907 real(SP),
intent(in) :: var(:)
1908 integer,
intent(in) :: fid
1909 integer,
intent(in) :: vid
1910 real(DP),
intent(in) :: t_start
1911 real(DP),
intent(in) :: t_end
1916 character(len=100) :: str
1924 do n = 1, file_vid_count
1925 if ( file_vid_list(n) == vid )
then 1926 write(str,*)
'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
1930 call log(
'E', trim(str))
1934 end subroutine filewrite1drealsp
1935 subroutine filewrite1drealdp( &
1944 real(DP),
intent(in) :: var(:)
1945 integer,
intent(in) :: fid
1946 integer,
intent(in) :: vid
1947 real(DP),
intent(in) :: t_start
1948 real(DP),
intent(in) :: t_end
1953 character(len=100) :: str
1961 do n = 1, file_vid_count
1962 if ( file_vid_list(n) == vid )
then 1963 write(str,*)
'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
1967 call log(
'E', trim(str))
1971 end subroutine filewrite1drealdp
1972 subroutine filewrite2drealsp( &
1981 real(SP),
intent(in) :: var(:,:)
1982 integer,
intent(in) :: fid
1983 integer,
intent(in) :: vid
1984 real(DP),
intent(in) :: t_start
1985 real(DP),
intent(in) :: t_end
1990 character(len=100) :: str
1998 do n = 1, file_vid_count
1999 if ( file_vid_list(n) == vid )
then 2000 write(str,*)
'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
2004 call log(
'E', trim(str))
2008 end subroutine filewrite2drealsp
2009 subroutine filewrite2drealdp( &
2018 real(DP),
intent(in) :: var(:,:)
2019 integer,
intent(in) :: fid
2020 integer,
intent(in) :: vid
2021 real(DP),
intent(in) :: t_start
2022 real(DP),
intent(in) :: t_end
2027 character(len=100) :: str
2035 do n = 1, file_vid_count
2036 if ( file_vid_list(n) == vid )
then 2037 write(str,*)
'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
2041 call log(
'E', trim(str))
2045 end subroutine filewrite2drealdp
2046 subroutine filewrite3drealsp( &
2055 real(SP),
intent(in) :: var(:,:,:)
2056 integer,
intent(in) :: fid
2057 integer,
intent(in) :: vid
2058 real(DP),
intent(in) :: t_start
2059 real(DP),
intent(in) :: t_end
2064 character(len=100) :: str
2072 do n = 1, file_vid_count
2073 if ( file_vid_list(n) == vid )
then 2074 write(str,*)
'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
2078 call log(
'E', trim(str))
2082 end subroutine filewrite3drealsp
2083 subroutine filewrite3drealdp( &
2092 real(DP),
intent(in) :: var(:,:,:)
2093 integer,
intent(in) :: fid
2094 integer,
intent(in) :: vid
2095 real(DP),
intent(in) :: t_start
2096 real(DP),
intent(in) :: t_end
2101 character(len=100) :: str
2109 do n = 1, file_vid_count
2110 if ( file_vid_list(n) == vid )
then 2111 write(str,*)
'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
2115 call log(
'E', trim(str))
2119 end subroutine filewrite3drealdp
2120 subroutine filewrite4drealsp( &
2129 real(SP),
intent(in) :: var(:,:,:,:)
2130 integer,
intent(in) :: fid
2131 integer,
intent(in) :: vid
2132 real(DP),
intent(in) :: t_start
2133 real(DP),
intent(in) :: t_end
2138 character(len=100) :: str
2146 do n = 1, file_vid_count
2147 if ( file_vid_list(n) == vid )
then 2148 write(str,*)
'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
2152 call log(
'E', trim(str))
2156 end subroutine filewrite4drealsp
2157 subroutine filewrite4drealdp( &
2166 real(DP),
intent(in) :: var(:,:,:,:)
2167 integer,
intent(in) :: fid
2168 integer,
intent(in) :: vid
2169 real(DP),
intent(in) :: t_start
2170 real(DP),
intent(in) :: t_end
2175 character(len=100) :: str
2183 do n = 1, file_vid_count
2184 if ( file_vid_list(n) == vid )
then 2185 write(str,*)
'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
2189 call log(
'E', trim(str))
2193 end subroutine filewrite4drealdp
2201 integer,
intent(in) :: fid
2203 character(LEN=File_HLONG) :: fname
2208 if ( fid < 0 )
return 2210 do n = 1, file_fid_count-1
2211 if ( file_fid_list(n) == fid )
exit 2213 if ( fid /= file_fid_list(n) )
then 2214 write(message,*)
'xxx invalid fid' , fid
2215 call log(
'E', message)
2220 write(message,
'(1x,A,i3)')
'*** [File] File Close : NO.', n
2221 call log(
'I', message)
2222 call log(
'I',
'*** closed filename: ' // trim(file_fname_list(n)))
2224 call log(
'E',
'xxx failed to close file')
2227 do n = 1, file_fid_count-1
2228 if ( file_fid_list(n) == fid )
then 2229 file_fid_list(n) = -1
2230 file_fname_list(n) =
'' 2243 do n = 1, file_fid_count-1
2259 character(len=*),
intent(out) :: fname
2260 character(len=*),
intent( in) :: basename
2261 character(len=*),
intent( in) :: prefix
2262 integer,
intent( in) :: myrank
2263 integer,
intent( in) :: len
2266 character(len=17) :: fmt =
"(A, '.', A, I*.*)" 2269 if ( len < 1 .or. len > 9 )
then 2270 call log(
'E',
'xxx len is invalid')
2273 write(fmt(14:14),
'(I1)') len
2274 write(fmt(16:16),
'(I1)') len
2275 write(fname, fmt) trim(basename), trim(prefix), myrank
2280 subroutine filegetfid( &
2288 integer,
intent(out) :: fid
2289 logical,
intent(out) :: existed
2290 character(LEN=*),
intent( in) :: basename
2291 integer,
intent( in) :: mode
2292 logical,
intent( in) :: single
2295 character(LEN=File_HSHORT) :: rwname(0:2)
2296 data rwname /
'READ',
'WRITE',
'APPEND' /
2298 character(LEN=File_HLONG) :: fname
2306 fname = trim(basename)//
'.peall' 2313 do n = 1, file_fid_count-1
2314 if ( fname==file_fname_list(n) ) fid = file_fid_list(n)
2317 if ( fid >= 0 )
then 2326 call log(
'E',
'xxx failed to open file :'//trim(fname)//
'.nc')
2329 write(message,*)
'*** [File] File registration : ',trim(rwname(mode)),
' -', fid
2330 call log(
"I", message)
2331 write(message,*)
'*** filename: ', trim(fname)
2332 call log(
"I", message)
2334 file_fname_list(file_fid_count) = trim(fname)
2335 file_fid_list(file_fid_count) = fid
2336 file_fid_count = file_fid_count + 1
2341 end subroutine filegetfid
integer, parameter, public log_lmsg
integer, parameter, public dp
subroutine, public log(type, message)
integer, parameter, public sp