24 #if defined(__pgi) || defined(__es2)
44 public :: historyputaxis
45 public :: historyputassociatedcoordinates
55 interface historyputaxis
58 end interface historyputaxis
60 interface historyputassociatedcoordinates
69 end interface historyputassociatedcoordinates
72 module procedure historyput0dnamesp
73 module procedure historyput0didsp
74 module procedure historyput0dnamedp
75 module procedure historyput0diddp
76 module procedure historyput1dnamesp
77 module procedure historyput1didsp
78 module procedure historyput1dnamedp
79 module procedure historyput1diddp
80 module procedure historyput2dnamesp
81 module procedure historyput2didsp
82 module procedure historyput2dnamedp
83 module procedure historyput2diddp
84 module procedure historyput3dnamesp
85 module procedure historyput3didsp
86 module procedure historyput3dnamedp
87 module procedure historyput3diddp
88 end interface historyput
92 module procedure historyget1ddp
97 end interface historyget
100 character(len=File_HSHORT) :: name
101 character(len=File_HLONG) :: desc
102 character(len=File_HSHORT) :: units
103 character(len=File_HSHORT) :: dim
105 real(DP),
pointer :: var(:)
109 character(len=File_HSHORT) :: name
110 character(len=File_HLONG) :: desc
111 character(len=File_HSHORT) :: units
112 character(len=File_HSHORT) :: dims(4)
115 real(DP),
pointer :: var(:)
134 character(len=File_HMID) :: history_title
135 character(len=File_HMID) :: history_source
136 character(len=File_HMID) :: history_institution
137 character(len=File_HMID) :: history_time_units
138 character(len=File_HMID) :: history_time_since
139 real(DP) :: history_dtsec
140 real(DP) :: history_startdaysec
142 logical :: history_output_step0 = .false.
143 real(DP) :: history_output_start = 0.0_dp
144 logical :: history_error_putmiss = .false.
146 integer,
parameter :: history_req_limit = 1000
147 character(len=File_HLONG) :: history_req_basename(history_req_limit)
148 character(len=File_HSHORT) :: history_req_item (history_req_limit)
149 real(DP) :: history_req_tintsec (history_req_limit)
150 integer :: history_req_tintstep(history_req_limit)
151 logical :: history_req_tavg (history_req_limit)
152 logical :: history_req_zinterp (history_req_limit)
153 integer :: history_req_dtype (history_req_limit)
155 integer :: history_req_nmax = 0
156 integer :: history_id_count = 0
157 character(len=File_HSHORT),
allocatable :: history_item (:)
158 integer,
allocatable :: history_fid (:)
159 integer,
allocatable :: history_vid (:)
160 real(DP),
allocatable :: history_tintsec (:)
161 integer,
allocatable :: history_tintstep(:)
162 logical,
allocatable :: history_tavg (:)
163 logical,
allocatable :: history_zinterp (:)
164 real(DP),
allocatable :: history_varsum (:,:)
165 integer,
allocatable :: history_size (:)
166 real(DP),
allocatable :: history_tstart (:)
167 integer,
allocatable :: history_tstrstep(:)
168 integer,
allocatable :: history_tlststep(:)
169 real(DP),
allocatable :: history_tsumsec (:)
172 real(DP),
parameter :: eps = 1.d-10
173 integer :: history_master
174 integer :: history_myrank
175 integer,
allocatable :: history_rankidx(:)
177 integer,
parameter :: history_axis_limit = 100
178 integer :: history_axis_count = 0;
179 type(axis) :: history_axis(history_axis_limit)
181 integer,
parameter :: history_assoc_limit = 20
182 integer :: history_assoc_count = 0;
183 type(assoc) :: history_assoc(history_assoc_limit)
185 character(LEN=LOG_LMSG),
private :: message
190 title, source, institution, & ! (in)
192 master, myrank, rankidx, &
193 time_start, time_interval, &
194 time_units, time_since, &
196 default_tinterval, default_tunit, default_taverage, &
199 namelist_filename, namelist_fid &
209 character(len=*),
intent(in) :: title
210 character(len=*),
intent(in) :: source
211 character(len=*),
intent(in) :: institution
212 integer,
intent(in) :: array_size
213 integer,
intent(in) :: master
214 integer,
intent(in) :: myrank
215 integer,
intent(in) :: rankidx(:)
216 real(DP),
intent(in) :: time_start
217 real(DP),
intent(in) :: time_interval
218 character(len=*),
intent(in),
optional :: time_units
219 character(len=*),
intent(in),
optional :: time_since
220 character(len=*),
intent(in),
optional :: default_basename
221 real(DP),
intent(in),
optional :: default_tinterval
222 character(len=*),
intent(in),
optional :: default_tunit
223 logical,
intent(in),
optional :: default_taverage
224 logical,
intent(in),
optional :: default_zinterp
225 character(len=*),
intent(in),
optional :: default_datatype
226 character(len=*),
intent(in),
optional :: namelist_filename
227 integer ,
intent(in),
optional :: namelist_fid
229 character(len=File_HLONG) :: HISTORY_DEFAULT_BASENAME =
'' 230 real(DP) :: HISTORY_DEFAULT_TINTERVAL = 1.0_dp
231 character(len=File_HSHORT) :: HISTORY_DEFAULT_TUNIT =
'sec' 232 logical :: HISTORY_DEFAULT_TAVERAGE = .false.
233 logical :: HISTORY_DEFAULT_ZINTERP = .false.
234 character(len=File_HSHORT) :: HISTORY_DEFAULT_DATATYPE =
'REAL4' 236 namelist / param_history / &
239 history_institution, &
240 history_time_units, &
241 history_default_basename, &
242 history_default_tinterval, &
243 history_default_tunit, &
244 history_default_taverage, &
245 history_default_zinterp, &
246 history_default_datatype, &
247 history_output_step0, &
248 history_output_start, &
249 history_error_putmiss
251 character(len=File_HLONG) :: BASENAME
252 character(len=File_HSHORT) :: ITEM
253 real(DP) :: TINTERVAL
254 character(len=File_HSHORT) :: TUNIT
257 character(len=File_HSHORT) :: DATATYPE
259 namelist / histitem / &
277 call log(
'I',
'+++ Module[HISTORY]/Categ[IO]')
280 history_title = title
281 history_source = source
282 history_institution = institution
283 history_startdaysec = time_start
284 history_dtsec = time_interval
285 if (
present(time_units) )
then 286 history_time_units = time_units
288 history_time_units =
'seconds' 290 if (
present(time_since) )
then 291 history_time_since = time_since
293 history_time_since =
'' 295 if (
present(default_basename) )
then 296 history_default_basename = default_basename
298 if (
present(default_tinterval) )
then 299 history_default_tinterval = default_tinterval
300 if (
present(default_tunit) )
then 301 history_default_tunit = default_tunit
304 if (
present(default_taverage) )
then 305 history_default_taverage = default_taverage
307 if (
present(default_zinterp) )
then 308 history_default_zinterp = default_zinterp
310 if (
present(default_datatype) )
then 311 history_default_datatype = default_datatype
314 if (
present(namelist_fid) )
then 315 fid_conf = namelist_fid
317 else if (
present(namelist_filename) )
then 318 if ( namelist_filename /=
'' )
then 319 open( fid_conf, file = trim(namelist_filename), &
320 form =
'formatted', status =
'old', iostat = ierr)
322 call log(
'I',
'*** Brank namelist file was specified. Default used. ***')
326 call log(
'I',
'*** No namelist was specified. Default used. ***')
330 if ( fid_conf > 0 )
then 331 read(fid_conf, nml=param_history, iostat=ierr)
334 call log(
'I',
'*** Not found namelist. Default used.')
335 elseif( ierr > 0 )
then 336 call log(
'E',
'xxx Not appropriate names in namelist PARAM_HISTORY. Check!')
338 #if defined(__PGI) || defined(__ES2) 339 write(log_fid,nml=param_history)
341 write(message,nml=param_history)
342 call log(
'I', message)
348 if ( fid_conf > 0 )
then 350 do n = 1, history_req_limit
351 basename = history_default_basename
352 read(fid_conf, nml=histitem, iostat=ierr)
354 if ( basename /=
"" ) history_req_nmax = history_req_nmax + 1
358 if ( history_req_nmax > history_req_limit )
then 359 write(message,*)
'*** request of history file is exceed! n >', history_req_limit
360 call log(
'I', message)
361 elseif( history_req_nmax == 0 )
then 362 call log(
'I',
'*** No history file specified.')
366 allocate( history_item(history_req_nmax) ); history_item(:) =
'' 367 allocate( history_fid(history_req_nmax) )
368 allocate( history_vid(history_req_nmax) )
369 allocate( history_tintsec(history_req_nmax) )
370 allocate( history_tintstep(history_req_nmax) )
371 allocate( history_tavg(history_req_nmax) )
372 allocate( history_zinterp(history_req_nmax) )
374 allocate( history_varsum(array_size,history_req_nmax) )
375 allocate( history_size(history_req_nmax) )
376 allocate( history_tstart(history_req_nmax) )
377 allocate( history_tstrstep(history_req_nmax) )
378 allocate( history_tlststep(history_req_nmax) )
379 allocate( history_tsumsec(history_req_nmax) )
381 if ( fid_conf > 0 ) rewind(fid_conf)
384 do n = 1, history_req_limit
386 basename = history_default_basename
388 tinterval = history_default_tinterval
389 tunit = history_default_tunit
390 taverage = history_default_taverage
391 zinterp = history_default_zinterp
392 datatype = history_default_datatype
394 if ( fid_conf > 0 )
then 395 read(fid_conf, nml=histitem,iostat=ierr)
399 if ( basename ==
"" ) cycle
402 history_req_item(ni) = item
403 history_req_basename(ni) = basename
404 call calendarymdhms2sec( history_req_tintsec(ni), tinterval, tunit )
405 history_req_tintstep(ni) = int( history_req_tintsec(ni) / history_dtsec )
407 history_req_tavg(ni) = taverage
408 history_req_zinterp(ni) = zinterp
410 if ( history_req_tintsec(ni) <= 0.d0 )
then 411 write(message,*)
'xxx Not appropriate time interval. Check!', item, tinterval
412 call log(
'E', message)
415 if ( abs(history_req_tintsec(ni)-
real(History_req_tintstep(ni),kind=
dp)*history_dtsec) > eps )
then 416 write(message,*)
'xxx time interval must be a multiple of delta t ', &
417 history_req_tintsec(ni),
real(History_req_tintstep(ni),kind=
dp)*history_dtsec
418 call log(
'E', message)
421 if ( datatype ==
'REAL4' )
then 423 elseif( datatype ==
'REAL8' )
then 426 write(message,*)
'xxx Not appropriate DATATYPE. Check!', datatype
427 call log(
'E', message)
430 memsize = memsize + array_size *
file_preclist(history_req_dtype(ni))
433 write(message,*)
'*** Number of requested history item : ', history_req_nmax
434 call log(
'I', message)
435 write(message,*)
'*** Output default data type : ', history_default_datatype
436 call log(
'I', message)
437 write(message,*)
'*** Memory usage for history data buffer [Mbyte] : ', memsize/1024/1024
438 call log(
'I', message)
440 if ( (.not.
present(namelist_fid)) )
then 441 if ( fid_conf > 0 )
close(fid_conf)
444 history_master = master
445 history_myrank = myrank
446 allocate( history_rankidx(
size(rankidx)) )
447 history_rankidx(:) = rankidx(:)
469 fileputassociatedcoordinates
472 character(len=*),
intent(in) :: varname
473 character(len=*),
intent(in) :: dims(:)
474 character(len=*),
intent(in) :: desc
475 character(len=*),
intent(in) :: units
476 integer,
intent(in) :: now_step
477 integer,
intent(out) :: id
478 logical,
intent(out) :: zinterp
479 logical,
intent(out) :: existed
480 character(len=*),
intent(in),
optional :: options
482 character(len=File_HMID) :: tunits
484 logical :: fileexisted
485 integer :: nmax, reqid
487 integer :: ic, ie, is, lo
496 nmax = min( history_id_count, history_req_nmax )
498 if ( varname == history_item(n) )
then 500 zinterp = history_zinterp(n)
509 if ( history_time_since ==
'' )
then 510 tunits = history_time_units
512 tunits = trim(history_time_units)//
' since '//trim(history_time_since)
515 do n = 1, history_req_nmax
516 if ( varname == history_req_item(n) )
then 518 if( history_req_basename(reqid) ==
'' )
exit 519 history_id_count = history_id_count + 1
520 id = history_id_count
524 trim(history_req_basename(reqid)), &
527 history_institution, &
531 time_units = tunits )
533 if ( .not. fileexisted )
then 535 if (
present(options) )
then 539 lo = len_trim(options)
541 if ( m == lo+1 .or. options(m:m) ==
'&' )
then 542 if ( ic == -1 .or. ie == -1 )
then 543 call log(
'E',
'xxx option is invalid: ' // trim(options))
547 options(ic+1:ie-1), options(ie+1:m-1) )
551 else if ( options(m:m) ==
':' )
then 553 else if ( options(m:m) ==
'=' )
then 559 do m = 1, history_axis_count
560 call fileputaxis( history_fid(id), &
561 history_axis(m)%name, history_axis(m)%desc, &
562 history_axis(m)%units, history_axis(m)%dim, &
563 history_axis(m)%type, history_axis(m)%var )
566 do m = 1, history_assoc_count
567 call fileputassociatedcoordinates( history_fid(id), &
568 history_assoc(m)%name, history_assoc(m)%desc, &
569 history_assoc(m)%units, &
570 history_assoc(m)%dims(1:history_assoc(m)%ndims), &
571 history_assoc(m)%type, history_assoc(m)%var )
576 history_item(id) = varname
577 history_tintsec(id) = history_req_tintsec(reqid)
578 history_tintstep(id) = history_req_tintstep(reqid)
579 history_tavg(id) = history_req_tavg(reqid)
580 history_zinterp(id) = history_req_zinterp(reqid)
582 history_varsum(:,id) = 0.d0
584 if ( history_output_step0 .and. now_step==1 )
then 585 history_tstrstep(id) = 1 - history_tintstep(id)
587 history_tstrstep(id) = 1
589 if ( history_output_start > 0.0_dp )
then 590 history_tstart(id) = history_startdaysec + history_output_start
592 history_tstart(id) = history_startdaysec
594 history_tlststep(id) = history_tstrstep(id)
595 history_tsumsec(id) = 0.d0
597 call fileaddvariable( history_vid(id), &
599 varname, desc, units, dims, &
600 history_req_dtype(reqid), &
601 history_tintsec(id), &
604 if ( .not. fileexisted )
then 605 do m = 1, history_axis_count
606 if ( history_axis(m)%down )
then 607 call filesettattr( history_fid(id), history_axis(m)%name,
"positive",
"down" )
612 write(message,*)
'*** [HIST] Item registration No.= ', id
613 call log(
'I', message)
614 write(message,*)
'] Name : ', trim(history_item(id))
615 call log(
'I', message)
616 write(message,*)
'] Description : ', trim(desc)
617 call log(
'I', message)
618 write(message,*)
'] Unit : ', trim(units)
619 call log(
'I', message)
620 write(message,*)
'] Interval [sec] : ', history_tintsec(id)
621 call log(
'I', message)
622 write(message,*)
'] Interval [step] : ', history_tintstep(id)
623 call log(
'I', message)
624 write(message,*)
'] Time Average? : ', history_tavg(id)
625 call log(
'I', message)
626 write(message,*)
'] z* -> z conversion? : ', history_zinterp(id)
627 call log(
'I', message)
630 zinterp = history_zinterp(id)
658 character(len=*),
intent(in) :: name
659 character(len=*),
intent(in) :: desc
660 character(len=*),
intent(in) :: units
661 character(len=*),
intent(in) :: dim
662 real(SP),
intent(in) :: var(:)
663 character(len=*),
intent(in),
optional :: dtype
664 logical,
intent(in),
optional :: down
669 if (
present(dtype) )
then 670 if ( dtype ==
'REAL4' )
then 672 else if ( dtype ==
'REAL8' )
then 675 write(message,*)
'xxx Not appropriate dtype. Check!', dtype
676 call log(
'E', message)
682 if ( history_axis_count < history_axis_limit )
then 683 history_axis_count = history_axis_count + 1
684 history_axis(history_axis_count)%name = name
685 history_axis(history_axis_count)%desc = desc
686 history_axis(history_axis_count)%units = units
687 history_axis(history_axis_count)%dim = dim
688 history_axis(history_axis_count)%type =
type 689 allocate(history_axis(history_axis_count)%var(
size(var)))
690 history_axis(history_axis_count)%var = var
691 if (
present(down) )
then 692 history_axis(history_axis_count)%down = down
694 history_axis(history_axis_count)%down = .false.
697 write(message,*)
'xxx Number of axis exceeds the limit.' 698 call log(
'E', message)
717 character(len=*),
intent(in) :: name
718 character(len=*),
intent(in) :: desc
719 character(len=*),
intent(in) :: units
720 character(len=*),
intent(in) :: dim
721 real(DP),
intent(in) :: var(:)
722 character(len=*),
intent(in),
optional :: dtype
723 logical,
intent(in),
optional :: down
728 if (
present(dtype) )
then 729 if ( dtype ==
'REAL4' )
then 731 else if ( dtype ==
'REAL8' )
then 734 write(message,*)
'xxx Not appropriate dtype. Check!', dtype
735 call log(
'E', message)
741 if ( history_axis_count < history_axis_limit )
then 742 history_axis_count = history_axis_count + 1
743 history_axis(history_axis_count)%name = name
744 history_axis(history_axis_count)%desc = desc
745 history_axis(history_axis_count)%units = units
746 history_axis(history_axis_count)%dim = dim
747 history_axis(history_axis_count)%type =
type 748 allocate(history_axis(history_axis_count)%var(
size(var)))
749 history_axis(history_axis_count)%var = var
750 if (
present(down) )
then 751 history_axis(history_axis_count)%down = down
753 history_axis(history_axis_count)%down = .false.
756 write(message,*)
'xxx Number of axis exceeds the limit.' 757 call log(
'E', message)
779 character(len=*),
intent(in) :: name
780 character(len=*),
intent(in) :: desc
781 character(len=*),
intent(in) :: units
782 character(len=*),
intent(in) :: dims(:)
783 real(SP),
intent(in) :: var(:)
784 character(len=*),
intent(in),
optional :: dtype
789 if (
present(dtype) )
then 790 if ( dtype ==
'REAL4' )
then 792 else if ( dtype ==
'REAL8' )
then 795 write(message,*)
'xxx Not appropriate dtype. Check!', dtype
796 call log(
'E', message)
802 if ( history_assoc_count < history_assoc_limit )
then 803 history_assoc_count = history_assoc_count + 1
804 history_assoc(history_assoc_count)%name = name
805 history_assoc(history_assoc_count)%desc = desc
806 history_assoc(history_assoc_count)%units = units
807 history_assoc(history_assoc_count)%dims(1:1) = dims
808 history_assoc(history_assoc_count)%ndims = 1
809 history_assoc(history_assoc_count)%type =
type 810 allocate(history_assoc(history_assoc_count)%var(
size(var)))
811 history_assoc(history_assoc_count)%var = reshape(var, (/
size(var)/))
813 write(message,*)
'xxx Number of associate coordinates exceeds the limit.' 814 call log(
'E', message)
832 character(len=*),
intent(in) :: name
833 character(len=*),
intent(in) :: desc
834 character(len=*),
intent(in) :: units
835 character(len=*),
intent(in) :: dims(:)
836 real(DP),
intent(in) :: var(:)
837 character(len=*),
intent(in),
optional :: dtype
842 if (
present(dtype) )
then 843 if ( dtype ==
'REAL4' )
then 845 else if ( dtype ==
'REAL8' )
then 848 write(message,*)
'xxx Not appropriate dtype. Check!', dtype
849 call log(
'E', message)
855 if ( history_assoc_count < history_assoc_limit )
then 856 history_assoc_count = history_assoc_count + 1
857 history_assoc(history_assoc_count)%name = name
858 history_assoc(history_assoc_count)%desc = desc
859 history_assoc(history_assoc_count)%units = units
860 history_assoc(history_assoc_count)%dims(1:1) = dims
861 history_assoc(history_assoc_count)%ndims = 1
862 history_assoc(history_assoc_count)%type =
type 863 allocate(history_assoc(history_assoc_count)%var(
size(var)))
864 history_assoc(history_assoc_count)%var = reshape(var, (/
size(var)/))
866 write(message,*)
'xxx Number of associate coordinates exceeds the limit.' 867 call log(
'E', message)
885 character(len=*),
intent(in) :: name
886 character(len=*),
intent(in) :: desc
887 character(len=*),
intent(in) :: units
888 character(len=*),
intent(in) :: dims(:)
889 real(SP),
intent(in) :: var(:,:)
890 character(len=*),
intent(in),
optional :: dtype
895 if (
present(dtype) )
then 896 if ( dtype ==
'REAL4' )
then 898 else if ( dtype ==
'REAL8' )
then 901 write(message,*)
'xxx Not appropriate dtype. Check!', dtype
902 call log(
'E', message)
908 if ( history_assoc_count < history_assoc_limit )
then 909 history_assoc_count = history_assoc_count + 1
910 history_assoc(history_assoc_count)%name = name
911 history_assoc(history_assoc_count)%desc = desc
912 history_assoc(history_assoc_count)%units = units
913 history_assoc(history_assoc_count)%dims(1:2) = dims
914 history_assoc(history_assoc_count)%ndims = 2
915 history_assoc(history_assoc_count)%type =
type 916 allocate(history_assoc(history_assoc_count)%var(
size(var)))
917 history_assoc(history_assoc_count)%var = reshape(var, (/
size(var)/))
919 write(message,*)
'xxx Number of associate coordinates exceeds the limit.' 920 call log(
'E', message)
938 character(len=*),
intent(in) :: name
939 character(len=*),
intent(in) :: desc
940 character(len=*),
intent(in) :: units
941 character(len=*),
intent(in) :: dims(:)
942 real(DP),
intent(in) :: var(:,:)
943 character(len=*),
intent(in),
optional :: dtype
948 if (
present(dtype) )
then 949 if ( dtype ==
'REAL4' )
then 951 else if ( dtype ==
'REAL8' )
then 954 write(message,*)
'xxx Not appropriate dtype. Check!', dtype
955 call log(
'E', message)
961 if ( history_assoc_count < history_assoc_limit )
then 962 history_assoc_count = history_assoc_count + 1
963 history_assoc(history_assoc_count)%name = name
964 history_assoc(history_assoc_count)%desc = desc
965 history_assoc(history_assoc_count)%units = units
966 history_assoc(history_assoc_count)%dims(1:2) = dims
967 history_assoc(history_assoc_count)%ndims = 2
968 history_assoc(history_assoc_count)%type =
type 969 allocate(history_assoc(history_assoc_count)%var(
size(var)))
970 history_assoc(history_assoc_count)%var = reshape(var, (/
size(var)/))
972 write(message,*)
'xxx Number of associate coordinates exceeds the limit.' 973 call log(
'E', message)
991 character(len=*),
intent(in) :: name
992 character(len=*),
intent(in) :: desc
993 character(len=*),
intent(in) :: units
994 character(len=*),
intent(in) :: dims(:)
995 real(SP),
intent(in) :: var(:,:,:)
996 character(len=*),
intent(in),
optional :: dtype
1001 if (
present(dtype) )
then 1002 if ( dtype ==
'REAL4' )
then 1004 else if ( dtype ==
'REAL8' )
then 1007 write(message,*)
'xxx Not appropriate dtype. Check!', dtype
1008 call log(
'E', message)
1014 if ( history_assoc_count < history_assoc_limit )
then 1015 history_assoc_count = history_assoc_count + 1
1016 history_assoc(history_assoc_count)%name = name
1017 history_assoc(history_assoc_count)%desc = desc
1018 history_assoc(history_assoc_count)%units = units
1019 history_assoc(history_assoc_count)%dims(1:3) = dims
1020 history_assoc(history_assoc_count)%ndims = 3
1021 history_assoc(history_assoc_count)%type =
type 1022 allocate(history_assoc(history_assoc_count)%var(
size(var)))
1023 history_assoc(history_assoc_count)%var = reshape(var, (/
size(var)/))
1025 write(message,*)
'xxx Number of associate coordinates exceeds the limit.' 1026 call log(
'E', message)
1044 character(len=*),
intent(in) :: name
1045 character(len=*),
intent(in) :: desc
1046 character(len=*),
intent(in) :: units
1047 character(len=*),
intent(in) :: dims(:)
1048 real(DP),
intent(in) :: var(:,:,:)
1049 character(len=*),
intent(in),
optional :: dtype
1054 if (
present(dtype) )
then 1055 if ( dtype ==
'REAL4' )
then 1057 else if ( dtype ==
'REAL8' )
then 1060 write(message,*)
'xxx Not appropriate dtype. Check!', dtype
1061 call log(
'E', message)
1067 if ( history_assoc_count < history_assoc_limit )
then 1068 history_assoc_count = history_assoc_count + 1
1069 history_assoc(history_assoc_count)%name = name
1070 history_assoc(history_assoc_count)%desc = desc
1071 history_assoc(history_assoc_count)%units = units
1072 history_assoc(history_assoc_count)%dims(1:3) = dims
1073 history_assoc(history_assoc_count)%ndims = 3
1074 history_assoc(history_assoc_count)%type =
type 1075 allocate(history_assoc(history_assoc_count)%var(
size(var)))
1076 history_assoc(history_assoc_count)%var = reshape(var, (/
size(var)/))
1078 write(message,*)
'xxx Number of associate coordinates exceeds the limit.' 1079 call log(
'E', message)
1097 character(len=*),
intent(in) :: name
1098 character(len=*),
intent(in) :: desc
1099 character(len=*),
intent(in) :: units
1100 character(len=*),
intent(in) :: dims(:)
1101 real(SP),
intent(in) :: var(:,:,:,:)
1102 character(len=*),
intent(in),
optional :: dtype
1107 if (
present(dtype) )
then 1108 if ( dtype ==
'REAL4' )
then 1110 else if ( dtype ==
'REAL8' )
then 1113 write(message,*)
'xxx Not appropriate dtype. Check!', dtype
1114 call log(
'E', message)
1120 if ( history_assoc_count < history_assoc_limit )
then 1121 history_assoc_count = history_assoc_count + 1
1122 history_assoc(history_assoc_count)%name = name
1123 history_assoc(history_assoc_count)%desc = desc
1124 history_assoc(history_assoc_count)%units = units
1125 history_assoc(history_assoc_count)%dims(1:4) = dims
1126 history_assoc(history_assoc_count)%ndims = 4
1127 history_assoc(history_assoc_count)%type =
type 1128 allocate(history_assoc(history_assoc_count)%var(
size(var)))
1129 history_assoc(history_assoc_count)%var = reshape(var, (/
size(var)/))
1131 write(message,*)
'xxx Number of associate coordinates exceeds the limit.' 1132 call log(
'E', message)
1150 character(len=*),
intent(in) :: name
1151 character(len=*),
intent(in) :: desc
1152 character(len=*),
intent(in) :: units
1153 character(len=*),
intent(in) :: dims(:)
1154 real(DP),
intent(in) :: var(:,:,:,:)
1155 character(len=*),
intent(in),
optional :: dtype
1160 if (
present(dtype) )
then 1161 if ( dtype ==
'REAL4' )
then 1163 else if ( dtype ==
'REAL8' )
then 1166 write(message,*)
'xxx Not appropriate dtype. Check!', dtype
1167 call log(
'E', message)
1173 if ( history_assoc_count < history_assoc_limit )
then 1174 history_assoc_count = history_assoc_count + 1
1175 history_assoc(history_assoc_count)%name = name
1176 history_assoc(history_assoc_count)%desc = desc
1177 history_assoc(history_assoc_count)%units = units
1178 history_assoc(history_assoc_count)%dims(1:4) = dims
1179 history_assoc(history_assoc_count)%ndims = 4
1180 history_assoc(history_assoc_count)%type =
type 1181 allocate(history_assoc(history_assoc_count)%var(
size(var)))
1182 history_assoc(history_assoc_count)%var = reshape(var, (/
size(var)/))
1184 write(message,*)
'xxx Number of associate coordinates exceeds the limit.' 1185 call log(
'E', message)
1201 character(len=*),
intent(in) :: varname
1202 character(len=*),
intent(in) :: key
1203 character(len=*),
intent(in) :: val
1208 do n = 1, history_id_count
1225 integer,
intent(in) :: itemid
1226 integer,
intent(in) :: step_next
1227 logical,
intent(out) :: answer
1232 if ( history_tavg(itemid) )
then 1234 elseif( step_next == history_tstrstep(itemid) + history_tintstep(itemid) )
then 1243 subroutine historyput0dnamesp( &
1249 character(len=*),
intent(in) :: varname
1250 integer,
intent(in) :: step_next
1251 real(SP),
intent(in) :: var
1253 integer :: itemid, n
1258 do n = 1, history_id_count
1259 if ( varname == history_item(n) )
then 1265 call historyput0didsp(itemid, step_next, var)
1268 end subroutine historyput0dnamesp
1272 subroutine historyput0didsp( &
1278 integer,
intent(in) :: itemid
1279 integer,
intent(in) :: step_next
1280 real(SP),
intent(in) :: var
1287 if ( itemid < 0 )
return 1289 dt = ( step_next - history_tlststep(itemid) ) * history_dtsec
1291 if ( dt < eps .AND. ( .NOT. history_tavg(itemid) ) )
then 1292 write(message,*)
'xxx History variable was put two times before output!: ', &
1293 trim(history_item(itemid)), &
1294 step_next, history_tlststep(itemid)
1295 call log(
'E', message)
1298 if ( history_tavg(itemid) )
then 1300 history_varsum(idx,itemid) = history_varsum(idx,itemid) + var * dt
1303 history_varsum(idx,itemid) = var
1306 history_size(itemid) = idx
1307 history_tlststep(itemid) = step_next
1308 history_tsumsec(itemid) = history_tsumsec(itemid) + dt
1311 end subroutine historyput0didsp
1312 subroutine historyput0dnamedp( &
1318 character(len=*),
intent(in) :: varname
1319 integer,
intent(in) :: step_next
1320 real(DP),
intent(in) :: var
1322 integer :: itemid, n
1327 do n = 1, history_id_count
1328 if ( varname == history_item(n) )
then 1334 call historyput0diddp(itemid, step_next, var)
1337 end subroutine historyput0dnamedp
1341 subroutine historyput0diddp( &
1347 integer,
intent(in) :: itemid
1348 integer,
intent(in) :: step_next
1349 real(DP),
intent(in) :: var
1356 if ( itemid < 0 )
return 1358 dt = ( step_next - history_tlststep(itemid) ) * history_dtsec
1360 if ( dt < eps .AND. ( .NOT. history_tavg(itemid) ) )
then 1361 write(message,*)
'xxx History variable was put two times before output!: ', &
1362 trim(history_item(itemid)), &
1363 step_next, history_tlststep(itemid)
1364 call log(
'E', message)
1367 if ( history_tavg(itemid) )
then 1369 history_varsum(idx,itemid) = history_varsum(idx,itemid) + var * dt
1372 history_varsum(idx,itemid) = var
1375 history_size(itemid) = idx
1376 history_tlststep(itemid) = step_next
1377 history_tsumsec(itemid) = history_tsumsec(itemid) + dt
1380 end subroutine historyput0diddp
1381 subroutine historyput1dnamesp( &
1387 character(len=*),
intent(in) :: varname
1388 integer,
intent(in) :: step_next
1389 real(SP),
intent(in) :: var(:)
1391 integer :: itemid, n
1396 do n = 1, history_id_count
1397 if ( varname == history_item(n) )
then 1403 call historyput1didsp(itemid, step_next, var)
1406 end subroutine historyput1dnamesp
1410 subroutine historyput1didsp( &
1416 integer,
intent(in) :: itemid
1417 integer,
intent(in) :: step_next
1418 real(SP),
intent(in) :: var(:)
1427 if ( itemid < 0 )
return 1430 dt = ( step_next - history_tlststep(itemid) ) * history_dtsec
1432 if ( dt < eps .AND. ( .NOT. history_tavg(itemid) ) )
then 1433 write(message,*)
'xxx History variable was put two times before output!: ', &
1434 trim(history_item(itemid)), &
1435 step_next, history_tlststep(itemid)
1436 call log(
'E', message)
1439 if ( history_tavg(itemid) )
then 1442 history_varsum(idx,itemid) = history_varsum(idx,itemid) + var(i) * dt
1447 history_varsum(idx,itemid) = var(i)
1451 history_size(itemid) = idx
1452 history_tlststep(itemid) = step_next
1453 history_tsumsec(itemid) = history_tsumsec(itemid) + dt
1456 end subroutine historyput1didsp
1457 subroutine historyput1dnamedp( &
1463 character(len=*),
intent(in) :: varname
1464 integer,
intent(in) :: step_next
1465 real(DP),
intent(in) :: var(:)
1467 integer :: itemid, n
1472 do n = 1, history_id_count
1473 if ( varname == history_item(n) )
then 1479 call historyput1diddp(itemid, step_next, var)
1482 end subroutine historyput1dnamedp
1486 subroutine historyput1diddp( &
1492 integer,
intent(in) :: itemid
1493 integer,
intent(in) :: step_next
1494 real(DP),
intent(in) :: var(:)
1503 if ( itemid < 0 )
return 1506 dt = ( step_next - history_tlststep(itemid) ) * history_dtsec
1508 if ( dt < eps .AND. ( .NOT. history_tavg(itemid) ) )
then 1509 write(message,*)
'xxx History variable was put two times before output!: ', &
1510 trim(history_item(itemid)), &
1511 step_next, history_tlststep(itemid)
1512 call log(
'E', message)
1515 if ( history_tavg(itemid) )
then 1518 history_varsum(idx,itemid) = history_varsum(idx,itemid) + var(i) * dt
1523 history_varsum(idx,itemid) = var(i)
1527 history_size(itemid) = idx
1528 history_tlststep(itemid) = step_next
1529 history_tsumsec(itemid) = history_tsumsec(itemid) + dt
1532 end subroutine historyput1diddp
1533 subroutine historyput2dnamesp( &
1539 character(len=*),
intent(in) :: varname
1540 integer,
intent(in) :: step_next
1541 real(SP),
intent(in) :: var(:,:)
1543 integer :: itemid, n
1548 do n = 1, history_id_count
1549 if ( varname == history_item(n) )
then 1555 call historyput2didsp(itemid, step_next, var)
1558 end subroutine historyput2dnamesp
1562 subroutine historyput2didsp( &
1568 integer,
intent(in) :: itemid
1569 integer,
intent(in) :: step_next
1570 real(SP),
intent(in) :: var(:,:)
1579 if ( itemid < 0 )
return 1582 dt = ( step_next - history_tlststep(itemid) ) * history_dtsec
1584 if ( dt < eps .AND. ( .NOT. history_tavg(itemid) ) )
then 1585 write(message,*)
'xxx History variable was put two times before output!: ', &
1586 trim(history_item(itemid)), &
1587 step_next, history_tlststep(itemid)
1588 call log(
'E', message)
1591 if ( history_tavg(itemid) )
then 1595 history_varsum(idx,itemid) = history_varsum(idx,itemid) + var(i,j) * dt
1602 history_varsum(idx,itemid) = var(i,j)
1607 history_size(itemid) = idx
1608 history_tlststep(itemid) = step_next
1609 history_tsumsec(itemid) = history_tsumsec(itemid) + dt
1612 end subroutine historyput2didsp
1613 subroutine historyput2dnamedp( &
1619 character(len=*),
intent(in) :: varname
1620 integer,
intent(in) :: step_next
1621 real(DP),
intent(in) :: var(:,:)
1623 integer :: itemid, n
1628 do n = 1, history_id_count
1629 if ( varname == history_item(n) )
then 1635 call historyput2diddp(itemid, step_next, var)
1638 end subroutine historyput2dnamedp
1642 subroutine historyput2diddp( &
1648 integer,
intent(in) :: itemid
1649 integer,
intent(in) :: step_next
1650 real(DP),
intent(in) :: var(:,:)
1659 if ( itemid < 0 )
return 1662 dt = ( step_next - history_tlststep(itemid) ) * history_dtsec
1664 if ( dt < eps .AND. ( .NOT. history_tavg(itemid) ) )
then 1665 write(message,*)
'xxx History variable was put two times before output!: ', &
1666 trim(history_item(itemid)), &
1667 step_next, history_tlststep(itemid)
1668 call log(
'E', message)
1671 if ( history_tavg(itemid) )
then 1675 history_varsum(idx,itemid) = history_varsum(idx,itemid) + var(i,j) * dt
1682 history_varsum(idx,itemid) = var(i,j)
1687 history_size(itemid) = idx
1688 history_tlststep(itemid) = step_next
1689 history_tsumsec(itemid) = history_tsumsec(itemid) + dt
1692 end subroutine historyput2diddp
1693 subroutine historyput3dnamesp( &
1699 character(len=*),
intent(in) :: varname
1700 integer,
intent(in) :: step_next
1701 real(SP),
intent(in) :: var(:,:,:)
1703 integer :: itemid, n
1708 do n = 1, history_id_count
1709 if ( varname == history_item(n) )
then 1715 call historyput3didsp(itemid, step_next, var)
1718 end subroutine historyput3dnamesp
1722 subroutine historyput3didsp( &
1728 integer,
intent(in) :: itemid
1729 integer,
intent(in) :: step_next
1730 real(SP),
intent(in) :: var(:,:,:)
1739 if ( itemid < 0 )
return 1742 dt = ( step_next - history_tlststep(itemid) ) * history_dtsec
1744 if ( dt < eps .AND. ( .NOT. history_tavg(itemid) ) )
then 1745 write(message,*)
'xxx History variable was put two times before output!: ', &
1746 trim(history_item(itemid)), &
1747 step_next, history_tlststep(itemid)
1748 call log(
'E', message)
1751 if ( history_tavg(itemid) )
then 1755 idx = (k*ijk(2)+j)*ijk(1)+i
1756 history_varsum(idx,itemid) = history_varsum(idx,itemid) + var(i,j,k) * dt
1764 idx = (k*ijk(2)+j)*ijk(1)+i
1765 history_varsum(idx,itemid) = var(i,j,k)
1771 history_size(itemid) = idx
1772 history_tlststep(itemid) = step_next
1773 history_tsumsec(itemid) = history_tsumsec(itemid) + dt
1776 end subroutine historyput3didsp
1777 subroutine historyput3dnamedp( &
1783 character(len=*),
intent(in) :: varname
1784 integer,
intent(in) :: step_next
1785 real(DP),
intent(in) :: var(:,:,:)
1787 integer :: itemid, n
1792 do n = 1, history_id_count
1793 if ( varname == history_item(n) )
then 1799 call historyput3diddp(itemid, step_next, var)
1802 end subroutine historyput3dnamedp
1806 subroutine historyput3diddp( &
1812 integer,
intent(in) :: itemid
1813 integer,
intent(in) :: step_next
1814 real(DP),
intent(in) :: var(:,:,:)
1823 if ( itemid < 0 )
return 1826 dt = ( step_next - history_tlststep(itemid) ) * history_dtsec
1828 if ( dt < eps .AND. ( .NOT. history_tavg(itemid) ) )
then 1829 write(message,*)
'xxx History variable was put two times before output!: ', &
1830 trim(history_item(itemid)), &
1831 step_next, history_tlststep(itemid)
1832 call log(
'E', message)
1835 if ( history_tavg(itemid) )
then 1839 idx = (k*ijk(2)+j)*ijk(1)+i
1840 history_varsum(idx,itemid) = history_varsum(idx,itemid) + var(i,j,k) * dt
1848 idx = (k*ijk(2)+j)*ijk(1)+i
1849 history_varsum(idx,itemid) = var(i,j,k)
1855 history_size(itemid) = idx
1856 history_tlststep(itemid) = step_next
1857 history_tsumsec(itemid) = history_tsumsec(itemid) + dt
1860 end subroutine historyput3diddp
1873 integer,
intent(in) :: itemid
1874 integer,
intent(in) :: step_now
1877 real(DP) :: time_str, time_end
1878 real(DP) :: sec_str, sec_end
1880 real(DP),
save :: sec_end_last = -1.0_dp
1881 logical,
save :: firsttime = .true.
1884 if( history_id_count == 0 )
return 1886 if ( step_now < history_tstrstep(itemid) + history_tintstep(itemid) )
then 1890 if ( history_tlststep(itemid) == history_tstrstep(itemid) )
then 1891 write(message,*)
'xxx History variable was never put after the last output!: ', &
1892 trim(history_item(itemid))
1893 if ( history_error_putmiss )
then 1894 call log(
'E', message)
1896 call log(
'I', message)
1900 isize = history_size(itemid)
1902 if ( history_tavg(itemid) )
then 1903 history_varsum(1:isize,itemid) = history_varsum(1:isize,itemid) / history_tsumsec(itemid)
1906 if ( firsttime )
then 1911 sec_str = history_startdaysec +
real(History_tstrstep(itemid)-1,kind=DP) * HISTORY_DTSEC
1912 sec_end = history_startdaysec +
real(step_now-1 ,kind=DP) * HISTORY_DTSEC
1915 call calendarsec2ymdhms( time_str, sec_str, history_time_units )
1916 call calendarsec2ymdhms( time_end, sec_end, history_time_units )
1918 if ( sec_end .ge. history_tstart(itemid) )
then 1919 if ( sec_end_last < sec_end )
then 1920 write(message,
'(A)')
'*** Output History' 1921 call log(
'I', message)
1924 call filewrite( history_fid(itemid), &
1925 history_vid(itemid), &
1926 history_varsum(1:isize,itemid), &
1930 if ( sec_end_last < sec_end )
then 1931 write(message,
'(A,2F15.3)')
'*** Output History: Suppressed ', sec_end, history_tstart(itemid)
1932 call log(
'I', message)
1936 history_varsum(:,itemid) = 0.0_dp
1937 history_tstrstep(itemid) = step_now
1938 history_tlststep(itemid) = step_now
1939 history_tsumsec(itemid) = 0.0_dp
1941 sec_end_last = sec_end
1952 integer,
intent(in) :: step_now
1957 do n = 1, history_id_count
1966 subroutine historyget1ddp( &
1977 real(DP),
intent(out) :: var(:)
1978 character(len=*),
intent(in) :: basename
1979 character(len=*),
intent(in) :: varname
1980 integer,
intent(in) :: step
1981 logical,
intent(in),
optional :: allow_missing
1982 logical,
intent(in),
optional :: single
1985 call fileread( var, &
1994 end subroutine historyget1ddp
2006 real(SP),
intent(out) :: var(:)
2007 character(len=*),
intent(in) :: basename
2008 character(len=*),
intent(in) :: varname
2009 integer,
intent(in) :: step
2010 logical,
intent(in),
optional :: allow_missing
2011 logical,
intent(in),
optional :: single
2014 call fileread( var, &
2035 real(DP),
intent(out) :: var(:,:)
2036 character(len=*),
intent(in) :: basename
2037 character(len=*),
intent(in) :: varname
2038 integer,
intent(in) :: step
2039 logical,
intent(in),
optional :: allow_missing
2040 logical,
intent(in),
optional :: single
2043 call fileread( var, &
2064 real(SP),
intent(out) :: var(:,:)
2065 character(len=*),
intent(in) :: basename
2066 character(len=*),
intent(in) :: varname
2067 integer,
intent(in) :: step
2068 logical,
intent(in),
optional :: allow_missing
2069 logical,
intent(in),
optional :: single
2072 call fileread( var, &
2093 real(DP),
intent(out) :: var(:,:,:)
2094 character(len=*),
intent(in) :: basename
2095 character(len=*),
intent(in) :: varname
2096 integer,
intent(in) :: step
2097 logical,
intent(in),
optional :: allow_missing
2098 logical,
intent(in),
optional :: single
2101 call fileread( var, &
2122 real(SP),
intent(out) :: var(:,:,:)
2123 character(len=*),
intent(in) :: basename
2124 character(len=*),
intent(in) :: varname
2125 integer,
intent(in) :: step
2126 logical,
intent(in),
optional :: allow_missing
2127 logical,
intent(in),
optional :: single
2130 call fileread( var, &
2149 write(message,*)
'*** [HIST] Output item list ' 2150 call log(
'I', message)
2151 write(message,*)
'*** Number of history item :', history_req_nmax
2152 call log(
'I', message)
2153 write(message,*)
'NAME :size :interval[sec]: [step]:timeavg?:zinterp?' 2154 call log(
'I', message)
2155 write(message,*)
'============================================================================' 2156 call log(
'I', message)
2158 do n = 1, history_id_count
2159 write(message,
'(1x,A,1x,I8,1x,f13.3,1x,I8,1x,L8,1x,L8)') &
2160 history_item(n), history_size(n), history_tintsec(n), history_tintstep(n), history_tavg(n), history_zinterp(n)
2161 call log(
'I', message)
2164 write(message,*)
'============================================================================' 2165 call log(
'I', message)
2180 do n = 1, history_id_count
subroutine historyput2dassociatedcoordinatesdp(name, desc, units, dims, var, dtype)
subroutine historyget3ddp(var, basename, varname, step, allow_missing, single)
subroutine historyput1dassociatedcoordinatesdp(name, desc, units, dims, var, dtype)
subroutine historyput2dassociatedcoordinatessp(name, desc, units, dims, var, dtype)
subroutine historyput3dassociatedcoordinatessp(name, desc, units, dims, var, dtype)
subroutine historyget3dsp(var, basename, varname, step, allow_missing, single)
subroutine, public historywrite(itemid, step_now)
subroutine historyget1dsp(var, basename, varname, step, allow_missing, single)
subroutine historyput4dassociatedcoordinatessp(name, desc, units, dims, var, dtype)
integer, parameter, public dp
subroutine historyput1dassociatedcoordinatessp(name, desc, units, dims, var, dtype)
subroutine, public historyfinalize
subroutine, public historyaddvariable(varname, dims, desc, units, now_step, id, zinterp, existed, options)
subroutine, public historyinit(title, source, institution, array_size, master, myrank, rankidx, time_start, time_interval, time_units, time_since, default_basename, default_tinterval, default_tunit, default_taverage, default_zinterp, default_datatype, namelist_filename, namelist_fid)
subroutine, public log(type, message)
subroutine historyget2ddp(var, basename, varname, step, allow_missing, single)
subroutine, public historyoutputlist
subroutine historyput3dassociatedcoordinatesdp(name, desc, units, dims, var, dtype)
integer, parameter, public sp
subroutine historyput4dassociatedcoordinatesdp(name, desc, units, dims, var, dtype)
subroutine, public historywriteall(step_now)
subroutine historyputaxisdp(name, desc, units, dim, var, dtype, down)
subroutine historyget2dsp(var, basename, varname, step, allow_missing, single)
subroutine, public historyquery(itemid, step_next, answer)
subroutine, public historysettattr(varname, key, val)
subroutine historyputaxissp(name, desc, units, dim, var, dtype, down)