24 character(len=LENBUDTXT) :: name
25 character(len=LINELENGTH) :: title
26 character(len=1),
pointer :: sep => null()
27 logical,
pointer :: write_csv => null()
28 logical,
pointer :: first_entry => null()
29 logical,
pointer :: transient => null()
30 logical,
pointer :: add_linesep => null()
31 logical,
pointer :: allow_finalization => null()
32 integer(I4B),
pointer :: iout => null()
33 integer(I4B),
pointer :: maxbound => null()
34 integer(I4B),
pointer :: nheaderlines => null()
35 integer(I4B),
pointer :: nlinewidth => null()
36 integer(I4B),
pointer :: ntableterm => null()
37 integer(I4B),
pointer :: ientry => null()
38 integer(I4B),
pointer :: iloc => null()
39 integer(I4B),
pointer :: icount => null()
40 integer(I4B),
pointer :: kstp => null()
41 integer(I4B),
pointer :: kper => null()
50 character(len=LINELENGTH),
pointer :: linesep => null()
51 character(len=LINELENGTH),
pointer :: dataline => null()
52 character(len=LINELENGTH),
dimension(:),
pointer :: header => null()
94 character(len=*),
intent(in) :: name
95 character(len=*),
intent(in) :: title
100 if (
associated(this))
then
117 subroutine table_df(this, maxbound, ntableterm, iout, transient, &
118 lineseparator, separator, finalize)
128 integer(I4B),
intent(in) :: maxbound
129 integer(I4B),
intent(in) :: ntableterm
130 integer(I4B),
intent(in) :: iout
131 logical,
intent(in),
optional :: transient
132 logical,
intent(in),
optional :: lineseparator
133 character(len=1),
intent(in),
optional :: separator
134 logical,
intent(in),
optional :: finalize
139 allocate (this%write_csv)
140 allocate (this%first_entry)
141 allocate (this%transient)
142 allocate (this%add_linesep)
143 allocate (this%allow_finalization)
145 allocate (this%maxbound)
146 allocate (this%nheaderlines)
147 allocate (this%nlinewidth)
148 allocate (this%ntableterm)
149 allocate (this%ientry)
151 allocate (this%icount)
154 allocate (this%tableterm(ntableterm))
157 if (
present(transient))
then
158 this%transient = transient
162 this%transient = .false.
164 if (
present(separator))
then
166 if (separator ==
',')
then
167 this%write_csv = .true.
169 this%write_csv = .false.
173 this%write_csv = .false.
175 if (
present(lineseparator))
then
176 this%add_linesep = lineseparator
178 this%add_linesep = .true.
180 if (
present(finalize))
then
181 this%allow_finalization = finalize
183 this%allow_finalization = .true.
187 this%first_entry = .true.
189 this%maxbound = maxbound
190 this%ntableterm = ntableterm
208 character(len=*),
intent(in) :: text
209 integer(I4B),
intent(in) :: width
210 integer(I4B),
intent(in),
optional :: alignment
213 integer(I4B) :: ialign
217 if (
present(alignment))
then
224 this%ientry = this%ientry + 1
228 if (this%ientry > this%ntableterm)
then
229 write (
errmsg,
'(a,a,a,i0,a,1x,a,1x,a,a,a,1x,i0,1x,a)') &
230 'Trying to add column "', trim(adjustl(text)),
'" (', &
231 this%ientry,
') in the', trim(adjustl(this%name)),
'table ("', &
232 trim(adjustl(this%title)),
'") that only has', this%ntableterm, &
238 call this%tableterm(idx)%initialize(text, width, alignment=ialign)
241 if (this%ientry == this%ntableterm)
then
242 call this%set_header()
263 character(len=LINELENGTH) :: cval
264 integer(I4B) :: width
265 integer(I4B) :: alignment
266 integer(I4B) :: nlines
280 do n = 1, this%ntableterm
281 width = width + this%tableterm(n)%get_width()
282 nlines = max(nlines, this%tableterm(n)%get_header_lines())
286 width = width + this%ntableterm - 1
289 call this%allocate_strings(width, nlines)
292 do n = 1, this%ntableterm
293 call this%tableterm(n)%set_header(nlines)
300 if (this%add_linesep)
then
305 do j = 1, this%ntableterm
306 width = this%tableterm(j)%get_width()
307 alignment = this%tableterm(j)%get_alignment()
308 call this%tableterm(j)%get_header(n, cval)
309 if (this%write_csv)
then
311 write (this%header(nn),
'(a)') trim(adjustl(cval))
313 write (this%header(nn),
'(a,",",G0)') &
314 trim(this%header(nn)), trim(adjustl(cval))
317 if (j == this%ntableterm)
then
319 cval(1:width), ival, rval, alignment=alignment)
322 cval(1:width), ival, rval, alignment=alignment, &
343 integer(I4B),
intent(in) :: width
344 integer(I4B),
intent(in) :: nlines
346 character(len=width) :: string
347 character(len=width) :: linesep
353 linesep = repeat(
'-', width)
356 this%nheaderlines = nlines
357 if (this%add_linesep)
then
358 this%nheaderlines = this%nheaderlines + 2
360 this%nlinewidth = width
363 allocate (this%header(this%nheaderlines))
364 allocate (this%linesep)
365 allocate (this%dataline)
368 this%linesep = linesep(1:width)
369 this%dataline = string(1:width)
370 do n = 1, this%nheaderlines
371 this%header(n) = string(1:width)
376 if (this%add_linesep)
then
377 this%header(1) = linesep(1:width)
378 this%header(nlines + 2) = linesep(1:width)
396 character(len=LINELENGTH) :: title
397 integer(I4B) :: width
402 width = this%nlinewidth
405 if (this%first_entry)
then
408 if (this%transient)
then
409 write (title,
'(a,a,i6)') trim(adjustl(title)),
' PERIOD ', this%kper
410 write (title,
'(a,a,i8)') trim(adjustl(title)),
' STEP ', this%kstp
412 if (len_trim(title) > 0)
then
413 write (this%iout,
'(/,1x,a)') trim(adjustl(title))
417 do n = 1, this%nheaderlines
418 write (this%iout,
'(1x,a)') this%header(n) (1:width)
423 this%first_entry = .false.
442 integer(I4B) :: width
446 width = this%nlinewidth
449 write (this%iout,
'(1x,a)') this%dataline(1:width)
454 this%icount = this%icount + 1
475 if (this%icount == this%maxbound)
then
476 call this%finalize_table()
497 call this%print_separator(iextralines=1)
524 do i = 1, this%ntableterm
525 call this%tableterm(i)%da()
529 deallocate (this%tableterm)
532 deallocate (this%linesep)
533 deallocate (this%dataline)
534 deallocate (this%header)
537 if (this%transient)
then
538 deallocate (this%kstp)
539 deallocate (this%kper)
541 deallocate (this%sep)
542 deallocate (this%write_csv)
543 deallocate (this%first_entry)
544 deallocate (this%transient)
545 deallocate (this%add_linesep)
546 deallocate (this%allow_finalization)
547 deallocate (this%iout)
548 deallocate (this%maxbound)
549 deallocate (this%nheaderlines)
550 deallocate (this%nlinewidth)
551 deallocate (this%ntableterm)
552 deallocate (this%ientry)
553 deallocate (this%iloc)
554 deallocate (this%icount)
570 character(len=LINELENGTH),
intent(in) :: line
572 character(len=LINELENGTH),
allocatable,
dimension(:) :: words
573 integer(I4B) :: nwords
574 integer(I4B) :: icols
579 if (this%icount == 0 .and. this%ientry == 0)
then
580 call this%write_header()
589 icols = this%ntableterm
590 icols = min(nwords, icols)
594 call this%add_term(words(i))
598 do i = icols + 1, this%ntableterm
599 call this%add_term(
' ')
623 if (this%ientry > this%ntableterm)
then
624 write (
errmsg,
'(a,1x,i0,5(1x,a),1x,i0,1x,a)') &
625 'Trying to add data to column ', this%ientry,
'in the', &
626 trim(adjustl(this%name)),
'table (', trim(adjustl(this%title)), &
627 ') that only has', this%ntableterm,
'columns.'
645 integer(I4B),
intent(in) :: ival
648 character(len=LINELENGTH) :: cval
650 integer(I4B) :: width
651 integer(I4B) :: alignment
656 if (this%icount == 0 .and. this%ientry == 0)
then
657 call this%write_header()
661 this%ientry = this%ientry + 1
664 call this%add_error()
668 width = this%tableterm(j)%get_width()
669 alignment = this%tableterm(j)%get_alignment()
671 if (j == this%ntableterm)
then
676 if (this%write_csv)
then
678 write (this%dataline,
'(G0)') ival
680 write (this%dataline,
'(a,",",G0)') trim(this%dataline), ival
683 if (j == this%ntableterm)
then
685 cval, ival, rval, alignment=alignment)
688 cval, ival, rval, alignment=alignment, sep=this%sep)
694 call this%write_line()
698 if (this%allow_finalization)
then
716 integer(I8B),
intent(in) :: long_ival
719 character(len=LINELENGTH) :: cval
722 integer(I4B) :: width
723 integer(I4B) :: alignment
728 if (this%icount == 0 .and. this%ientry == 0)
then
729 call this%write_header()
733 this%ientry = this%ientry + 1
736 call this%add_error()
740 width = this%tableterm(j)%get_width()
741 alignment = this%tableterm(j)%get_alignment()
743 if (j == this%ntableterm)
then
748 if (this%write_csv)
then
750 write (this%dataline,
'(G0)') long_ival
752 write (this%dataline,
'(a,",",G0)') trim(this%dataline), long_ival
755 write (cval,
'(i0)') long_ival
756 if (j == this%ntableterm)
then
758 trim(cval), ival, rval, alignment=alignment)
761 trim(cval), ival, rval, alignment=alignment, sep=this%sep)
767 call this%write_line()
771 if (this%allow_finalization)
then
789 real(DP),
intent(in) :: rval
792 character(len=LINELENGTH) :: cval
795 integer(I4B) :: width
796 integer(I4B) :: alignment
800 call this%add_string(
"INACTIVE")
801 else if (rval ==
dhdry)
then
802 call this%add_string(
"DRY")
806 if (this%icount == 0 .and. this%ientry == 0)
then
807 call this%write_header()
811 this%ientry = this%ientry + 1
814 call this%add_error()
818 width = this%tableterm(j)%get_width()
819 alignment = this%tableterm(j)%get_alignment()
821 if (j == this%ntableterm)
then
826 if (this%write_csv)
then
828 write (this%dataline,
'(G0)') rval
830 write (this%dataline,
'(a,",",G0)') trim(this%dataline), rval
833 if (j == this%ntableterm)
then
835 cval, ival, rval, alignment=alignment)
838 cval, ival, rval, alignment=alignment, sep=this%sep)
844 call this%write_line()
848 if (this%allow_finalization)
then
867 character(len=*) :: cval
873 integer(I4B) :: width
874 integer(I4B) :: alignment
878 if (this%icount == 0 .and. this%ientry == 0)
then
879 call this%write_header()
883 this%ientry = this%ientry + 1
886 call this%add_error()
890 width = this%tableterm(j)%get_width()
891 alignment = this%tableterm(j)%get_alignment()
893 if (j == this%ntableterm)
then
898 if (this%write_csv)
then
900 write (this%dataline,
'(a)') trim(adjustl(cval))
902 write (this%dataline,
'(a,",",a)') &
903 trim(this%dataline), trim(adjustl(cval))
906 if (j == this%ntableterm)
then
908 cval, ival, rval, alignment=alignment)
911 cval, ival, rval, alignment=alignment, sep=this%sep)
917 call this%write_line()
921 if (this%allow_finalization)
then
939 integer(I4B),
intent(in) :: maxbound
944 this%maxbound = maxbound
963 integer(I4B),
intent(in) :: kstp
964 integer(I4B),
intent(in) :: kper
986 character(len=*),
intent(in) :: title
1007 integer(I4B),
intent(in) :: iout
1028 integer(I4B),
intent(in) :: i
1029 character(len=*),
intent(in) :: nodestr
1030 real(DP),
intent(in) :: q
1031 character(len=*),
intent(in) :: bname
1036 call this%add_term(i)
1037 call this%add_term(nodestr)
1038 call this%add_term(q)
1039 if (this%ntableterm > 3)
then
1040 call this%add_term(bname)
1057 integer(I4B),
optional :: iextralines
1060 integer(I4B) :: iextra
1061 integer(I4B) :: width
1065 if (
present(iextralines))
then
1066 iextra = iextralines
1072 width = this%nlinewidth
1075 if (this%add_linesep)
then
1076 write (this%iout,
'(1x,a)') this%linesep(1:width)
1078 write (this%iout,
'(/)')
1102 this%first_entry = .true.
1106 end subroutine reset
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
real(dp), parameter dhdry
real dry cell constant
@ tabcenter
centered table column
@ tabucstring
upper case string table data
@ tabstring
string table data
@ tabinteger
integer table data
real(dp), parameter dhnoflo
real no flow constant
integer(i4b), parameter lenbudtxt
maximum length of a budget component names
This module defines variable data types.
This module contains simulation methods.
subroutine, public store_error(msg, terminate)
Store an error message.
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
subroutine set_kstpkper(this, kstp, kper)
subroutine set_header(this)
subroutine write_line(this)
subroutine table_df(this, maxbound, ntableterm, iout, transient, lineseparator, separator, finalize)
subroutine write_header(this)
subroutine finalize(this)
subroutine print_separator(this, iextralines)
subroutine set_iout(this, iout)
subroutine, public table_cr(this, name, title)
subroutine line_to_columns(this, line)
subroutine initialize_column(this, text, width, alignment)
subroutine set_maxbound(this, maxbound)
subroutine table_da(this)
subroutine add_long_integer(this, long_ival)
subroutine finalize_table(this)
subroutine set_title(this, title)
subroutine add_string(this, cval)
subroutine add_real(this, rval)
subroutine allocate_strings(this, width, nlines)
subroutine print_list_entry(this, i, nodestr, q, bname)
subroutine add_integer(this, ival)
subroutine add_error(this)