485
488
489 class(Dis2dType) :: this
490 integer(I4B), dimension(:), intent(in) :: icelltype
491
492 integer(I4B) :: iunit, ntxt, version
493 integer(I4B), parameter :: lentxt = 100
494 character(len=50) :: txthdr
495 character(len=lentxt) :: txt
496 character(len=LINELENGTH) :: fname
497 character(len=LENBIGLINE) :: crs
498 logical(LGP) :: found_crs
499 character(len=*), parameter :: fmtgrdsave = &
500 "(4X,'BINARY GRID INFORMATION WILL BE WRITTEN TO:', &
501 &/,6X,'UNIT NUMBER: ', I0,/,6X, 'FILE NAME: ', A)"
502
503
504 version = 1
505 ntxt = 14
506
507 call mem_set_value(crs, 'CRS', this%input_mempath, found_crs)
508
509
510 if (found_crs) then
511 ntxt = ntxt + 1
512 version = 2
513 end if
514
515
516 fname = trim(this%output_fname)
517 iunit = getunit()
518 write (this%iout, fmtgrdsave) iunit, trim(adjustl(fname))
519 call openfile(iunit, this%iout, trim(adjustl(fname)), 'DATA(BINARY)', &
521
522
523 write (txthdr, '(a)') 'GRID DIS2D'
524 txthdr(50:50) = new_line('a')
525 write (iunit) txthdr
526 write (txthdr, '(a, i0)') 'VERSION ', version
527 txthdr(50:50) = new_line('a')
528 write (iunit) txthdr
529 write (txthdr, '(a, i0)') 'NTXT ', ntxt
530 txthdr(50:50) = new_line('a')
531 write (iunit) txthdr
532 write (txthdr, '(a, i0)') 'LENTXT ', lentxt
533 txthdr(50:50) = new_line('a')
534 write (iunit) txthdr
535
536
537 write (txt, '(3a, i0)') 'NCELLS ', 'INTEGER ', 'NDIM 0 # ', this%nodesuser
538 txt(lentxt:lentxt) = new_line('a')
539 write (iunit) txt
540 write (txt, '(3a, i0)') 'NROW ', 'INTEGER ', 'NDIM 0 # ', this%nrow
541 txt(lentxt:lentxt) = new_line('a')
542 write (iunit) txt
543 write (txt, '(3a, i0)') 'NCOL ', 'INTEGER ', 'NDIM 0 # ', this%ncol
544 txt(lentxt:lentxt) = new_line('a')
545 write (iunit) txt
546 write (txt, '(3a, i0)') 'NJA ', 'INTEGER ', 'NDIM 0 # ', this%nja
547 txt(lentxt:lentxt) = new_line('a')
548 write (iunit) txt
549 write (txt, '(3a, 1pg24.15)') 'XORIGIN ', 'DOUBLE ', 'NDIM 0 # ', this%xorigin
550 txt(lentxt:lentxt) = new_line('a')
551 write (iunit) txt
552 write (txt, '(3a, 1pg24.15)') 'YORIGIN ', 'DOUBLE ', 'NDIM 0 # ', this%yorigin
553 txt(lentxt:lentxt) = new_line('a')
554 write (iunit) txt
555 write (txt, '(3a, 1pg24.15)') 'ANGROT ', 'DOUBLE ', 'NDIM 0 # ', this%angrot
556 txt(lentxt:lentxt) = new_line('a')
557 write (iunit) txt
558 write (txt, '(3a, i0)') 'DELR ', 'DOUBLE ', 'NDIM 1 ', this%ncol
559 txt(lentxt:lentxt) = new_line('a')
560 write (iunit) txt
561 write (txt, '(3a, i0)') 'DELC ', 'DOUBLE ', 'NDIM 1 ', this%nrow
562 txt(lentxt:lentxt) = new_line('a')
563 write (iunit) txt
564 write (txt, '(3a, i0)') 'BOTM ', 'DOUBLE ', 'NDIM 1 ', this%nodesuser
565 txt(lentxt:lentxt) = new_line('a')
566 write (iunit) txt
567 write (txt, '(3a, i0)') 'IA ', 'INTEGER ', 'NDIM 1 ', this%nodesuser + 1
568 txt(lentxt:lentxt) = new_line('a')
569 write (iunit) txt
570 write (txt, '(3a, i0)') 'JA ', 'INTEGER ', 'NDIM 1 ', size(this%con%jausr)
571 txt(lentxt:lentxt) = new_line('a')
572 write (iunit) txt
573 write (txt, '(3a, i0)') 'IDOMAIN ', 'INTEGER ', 'NDIM 1 ', this%nodesuser
574 txt(lentxt:lentxt) = new_line('a')
575 write (iunit) txt
576 write (txt, '(3a, i0)') 'ICELLTYPE ', 'INTEGER ', 'NDIM 1 ', this%nodesuser
577 txt(lentxt:lentxt) = new_line('a')
578 write (iunit) txt
579
580
581 if (version == 2) then
582 if (found_crs) then
583 write (txt, '(3a, i0)') 'CRS ', 'CHARACTER ', 'NDIM 1 ', &
584 len_trim(crs)
585 txt(lentxt:lentxt) = new_line('a')
586 write (iunit) txt
587 end if
588 end if
589
590
591 write (iunit) this%nodesuser
592 write (iunit) this%nrow
593 write (iunit) this%ncol
594 write (iunit) this%nja
595 write (iunit) this%xorigin
596 write (iunit) this%yorigin
597 write (iunit) this%angrot
598 write (iunit) this%delr
599 write (iunit) this%delc
600 write (iunit) this%bottom
601 write (iunit) this%con%iausr
602 write (iunit) this%con%jausr
603 write (iunit) this%idomain
604 write (iunit) icelltype
605
606
607 if (version == 2) then
608 if (found_crs) write (iunit) trim(crs)
609 end if
610
611
612 close (iunit)
613
integer(i4b), parameter lenbigline
maximum length of a big line