721
724
725 class(DisvType) :: this
726 integer(I4B), dimension(:), intent(in) :: icelltype
727
728 integer(I4B) :: iunit, i, ntxt, version
729 integer(I4B), parameter :: lentxt = 100
730 character(len=50) :: txthdr
731 character(len=lentxt) :: txt
732 character(len=LINELENGTH) :: fname
733 character(len=LENBIGLINE) :: crs
734 logical(LGP) :: found_crs
735
736 character(len=*), parameter :: fmtgrdsave = &
737 "(4X,'BINARY GRID INFORMATION WILL BE WRITTEN TO:', &
738 &/,6X,'UNIT NUMBER: ', I0,/,6X, 'FILE NAME: ', A)"
739
740
741 version = 1
742 ntxt = 20
743
744 call mem_set_value(crs, 'CRS', this%input_mempath, found_crs)
745
746
747 if (found_crs) then
748 ntxt = ntxt + 1
749 version = 2
750 end if
751
752
753 fname = trim(this%output_fname)
754 iunit = getunit()
755 write (this%iout, fmtgrdsave) iunit, trim(adjustl(fname))
756 call openfile(iunit, this%iout, trim(adjustl(fname)), 'DATA(BINARY)', &
758
759
760 write (txthdr, '(a)') 'GRID DISV'
761 txthdr(50:50) = new_line('a')
762 write (iunit) txthdr
763 write (txthdr, '(a, i0)') 'VERSION ', version
764 txthdr(50:50) = new_line('a')
765 write (iunit) txthdr
766 write (txthdr, '(a, i0)') 'NTXT ', ntxt
767 txthdr(50:50) = new_line('a')
768 write (iunit) txthdr
769 write (txthdr, '(a, i0)') 'LENTXT ', lentxt
770 txthdr(50:50) = new_line('a')
771 write (iunit) txthdr
772
773
774 write (txt, '(3a, i0)') 'NCELLS ', 'INTEGER ', 'NDIM 0 # ', this%nodesuser
775 txt(lentxt:lentxt) = new_line('a')
776 write (iunit) txt
777 write (txt, '(3a, i0)') 'NLAY ', 'INTEGER ', 'NDIM 0 # ', this%nlay
778 txt(lentxt:lentxt) = new_line('a')
779 write (iunit) txt
780 write (txt, '(3a, i0)') 'NCPL ', 'INTEGER ', 'NDIM 0 # ', this%ncpl
781 txt(lentxt:lentxt) = new_line('a')
782 write (iunit) txt
783 write (txt, '(3a, i0)') 'NVERT ', 'INTEGER ', 'NDIM 0 # ', this%nvert
784 txt(lentxt:lentxt) = new_line('a')
785 write (iunit) txt
786 write (txt, '(3a, i0)') 'NJAVERT ', 'INTEGER ', 'NDIM 0 # ', size(this%javert)
787 txt(lentxt:lentxt) = new_line('a')
788 write (iunit) txt
789 write (txt, '(3a, i0)') 'NJA ', 'INTEGER ', 'NDIM 0 # ', this%con%nja
790 txt(lentxt:lentxt) = new_line('a')
791 write (iunit) txt
792 write (txt, '(3a, 1pg25.15e3)') &
793 'XORIGIN ', 'DOUBLE ', 'NDIM 0 # ', this%xorigin
794 txt(lentxt:lentxt) = new_line('a')
795 write (iunit) txt
796 write (txt, '(3a, 1pg25.15e3)') &
797 'YORIGIN ', 'DOUBLE ', 'NDIM 0 # ', this%yorigin
798 txt(lentxt:lentxt) = new_line('a')
799 write (iunit) txt
800 write (txt, '(3a, 1pg25.15e3)') 'ANGROT ', 'DOUBLE ', 'NDIM 0 # ', this%angrot
801 txt(lentxt:lentxt) = new_line('a')
802 write (iunit) txt
803 write (txt, '(3a, i0)') 'TOP ', 'DOUBLE ', 'NDIM 1 ', this%ncpl
804 txt(lentxt:lentxt) = new_line('a')
805 write (iunit) txt
806 write (txt, '(3a, i0)') 'BOTM ', 'DOUBLE ', 'NDIM 1 ', this%nodesuser
807 txt(lentxt:lentxt) = new_line('a')
808 write (iunit) txt
809 write (txt, '(3a, i0)') 'VERTICES ', 'DOUBLE ', 'NDIM 2 2 ', this%nvert
810 txt(lentxt:lentxt) = new_line('a')
811 write (iunit) txt
812 write (txt, '(3a, i0)') 'CELLX ', 'DOUBLE ', 'NDIM 1 ', this%ncpl
813 txt(lentxt:lentxt) = new_line('a')
814 write (iunit) txt
815 write (txt, '(3a, i0)') 'CELLY ', 'DOUBLE ', 'NDIM 1 ', this%ncpl
816 txt(lentxt:lentxt) = new_line('a')
817 write (iunit) txt
818 write (txt, '(3a, i0)') 'IAVERT ', 'INTEGER ', 'NDIM 1 ', this%ncpl + 1
819 txt(lentxt:lentxt) = new_line('a')
820 write (iunit) txt
821 write (txt, '(3a, i0)') 'JAVERT ', 'INTEGER ', 'NDIM 1 ', size(this%javert)
822 txt(lentxt:lentxt) = new_line('a')
823 write (iunit) txt
824 write (txt, '(3a, i0)') 'IA ', 'INTEGER ', 'NDIM 1 ', this%nodesuser + 1
825 txt(lentxt:lentxt) = new_line('a')
826 write (iunit) txt
827 write (txt, '(3a, i0)') 'JA ', 'INTEGER ', 'NDIM 1 ', size(this%con%jausr)
828 txt(lentxt:lentxt) = new_line('a')
829 write (iunit) txt
830 write (txt, '(3a, i0)') 'IDOMAIN ', 'INTEGER ', 'NDIM 1 ', this%nodesuser
831 txt(lentxt:lentxt) = new_line('a')
832 write (iunit) txt
833 write (txt, '(3a, i0)') 'ICELLTYPE ', 'INTEGER ', 'NDIM 1 ', this%nodesuser
834 txt(lentxt:lentxt) = new_line('a')
835 write (iunit) txt
836
837
838 if (version == 2) then
839 if (found_crs) then
840 write (txt, '(3a, i0)') 'CRS ', 'CHARACTER ', 'NDIM 1 ', &
841 len_trim(crs)
842 txt(lentxt:lentxt) = new_line('a')
843 write (iunit) txt
844 end if
845 end if
846
847
848 write (iunit) this%nodesuser
849 write (iunit) this%nlay
850 write (iunit) this%ncpl
851 write (iunit) this%nvert
852 write (iunit) size(this%javert)
853 write (iunit) this%nja
854 write (iunit) this%xorigin
855 write (iunit) this%yorigin
856 write (iunit) this%angrot
857 write (iunit) this%top1d
858 write (iunit) this%bot2d
859 write (iunit) this%vertices
860 write (iunit) (this%cellxy(1, i), i=1, this%ncpl)
861 write (iunit) (this%cellxy(2, i), i=1, this%ncpl)
862 write (iunit) this%iavert
863 write (iunit) this%javert
864 write (iunit) this%con%iausr
865 write (iunit) this%con%jausr
866 write (iunit) this%idomain
867 write (iunit) icelltype
868
869
870 if (version == 2) then
871 if (found_crs) write (iunit) trim(crs)
872 end if
873
874
875 close (iunit)
876
integer(i4b), parameter lenbigline
maximum length of a big line