Allocate and read data for a solution.
536
541
542 class(NumericalSolutionType) :: this
543
544 class(NumericalModelType), pointer :: mp => null()
545 class(NumericalExchangeType), pointer :: cp => null()
546 character(len=linelength) :: keyword
547 character(len=linelength) :: fname
548 character(len=linelength) :: msg
549 integer(I4B) :: i
550 integer(I4B) :: ifdparam, mxvl, npp
551 integer(I4B) :: ierr
552 logical(LGP) :: isfound, endOfBlock
553 integer(I4B) :: ival
554 real(DP) :: rval
555 character(len=*), parameter :: fmtcsvout = &
556 "(4x, 'CSV OUTPUT WILL BE SAVED TO FILE: ', a, &
557 &/4x, 'OPENED ON UNIT: ', I7)"
558 character(len=*), parameter :: fmtptcout = &
559 "(4x, 'PTC OUTPUT WILL BE SAVED TO FILE: ', a, &
560 &/4x, 'OPENED ON UNIT: ', I7)"
561 character(len=*), parameter :: fmterrasym = &
562 "(a,' **',a,'** PRODUCES AN ASYMMETRIC COEFFICIENT MATRIX, BUT THE &
563 &CONJUGATE GRADIENT METHOD WAS SELECTED. USE BICGSTAB INSTEAD. ')"
564
565
566 WRITE (
iout, 1) this%iu
56700001 FORMAT(1x, /1x, 'IMS -- ITERATIVE MODEL SOLUTION PACKAGE, VERSION 6', &
568 ', 4/28/2017', /, 9x, 'INPUT READ FROM UNIT', i5)
569
570
571 i = 1
572 ifdparam = 1
573 npp = 0
574 mxvl = 0
575
576
577 call this%parser%GetBlock('OPTIONS', isfound, ierr, &
578 supportopenclose=.true., blockrequired=.false.)
579
580
581 if (isfound) then
582 write (
iout,
'(/1x,a)')
'PROCESSING IMS OPTIONS'
583 do
584 call this%parser%GetNextLine(endofblock)
585 if (endofblock) exit
586 call this%parser%GetStringCaps(keyword)
587 select case (keyword)
588 case ('PRINT_OPTION')
589 call this%parser%GetStringCaps(keyword)
590 if (keyword .eq. 'NONE') then
591 this%iprims = 0
592 else if (keyword .eq. 'SUMMARY') then
593 this%iprims = 1
594 else if (keyword .eq. 'ALL') then
595 this%iprims = 2
596 else
598 'Unknown IMS print option (', trim(keyword), ').'
600 end if
601 case ('COMPLEXITY')
602 call this%parser%GetStringCaps(keyword)
603 if (keyword .eq. 'SIMPLE') then
604 ifdparam = 1
606 else if (keyword .eq. 'MODERATE') then
607 ifdparam = 2
609 else if (keyword .eq. 'COMPLEX') then
610 ifdparam = 3
612 else
614 'Unknown IMS COMPLEXITY option (', trim(keyword), ').'
616 end if
617 case ('CSV_OUTER_OUTPUT')
618 call this%parser%GetStringCaps(keyword)
619 if (keyword == 'FILEOUT') then
620 call this%parser%GetString(fname)
623 end if
625 call openfile(this%icsvouterout,
iout, fname,
'CSV_OUTER_OUTPUT', &
626 filstat_opt='REPLACE')
627 write (
iout, fmtcsvout) trim(fname), this%icsvouterout
628 else
629 write (
errmsg,
'(a)')
'Optional CSV_OUTER_OUTPUT '// &
630 'keyword must be followed by FILEOUT'
632 end if
633 case ('CSV_INNER_OUTPUT')
634 call this%parser%GetStringCaps(keyword)
635 if (keyword == 'FILEOUT') then
636 call this%parser%GetString(fname)
639 end if
641 call openfile(this%icsvinnerout,
iout, fname,
'CSV_INNER_OUTPUT', &
642 filstat_opt='REPLACE')
643 write (
iout, fmtcsvout) trim(fname), this%icsvinnerout
644 else
645 write (
errmsg,
'(a)')
'Optional CSV_INNER_OUTPUT '// &
646 'keyword must be followed by FILEOUT'
648 end if
649 case ('NO_PTC')
650 call this%parser%GetStringCaps(keyword)
651 select case (keyword)
652 case ('ALL')
653 ival = 0
654 msg = 'ALL'
655 case ('FIRST')
656 ival = -1
657 msg = 'THE FIRST'
658 case default
659 ival = 0
660 msg = 'ALL'
661 end select
662 this%iallowptc = ival
663 write (
iout,
'(3x,A)')
'PSEUDO-TRANSIENT CONTINUATION DISABLED FOR'// &
664 ' '//trim(adjustl(msg))//' STRESS-PERIOD(S)'
665 case ('ATS_OUTER_MAXIMUM_FRACTION')
666 rval = this%parser%GetDouble()
667 if (rval < dzero .or. rval > dhalf) then
668 write (
errmsg,
'(a,G0)')
'Value for ATS_OUTER_MAXIMUM_FRAC must be &
669 &between 0 and 0.5. Found ', rval
671 end if
672 this%atsfrac = rval
673 write (
iout,
'(3x,A,G0)')
'ADAPTIVE TIME STEP SETTING FOUND. FRACTION &
674 &OF OUTER MAXIMUM USED TO INCREASE OR DECREASE TIME STEP SIZE IS ',&
675 &this%atsfrac
676
677
678
679
680
681 case ('DEV_PTC')
682 call this%parser%DevOpt()
683 this%iallowptc = 1
684 write (
iout,
'(1x,A)')
'PSEUDO-TRANSIENT CONTINUATION ENABLED'
685 case ('DEV_PTC_OUTPUT')
686 call this%parser%DevOpt()
687 this%iallowptc = 1
688 call this%parser%GetStringCaps(keyword)
689 if (keyword == 'FILEOUT') then
690 call this%parser%GetString(fname)
693 end if
696 filstat_opt='REPLACE')
697 write (
iout, fmtptcout) trim(fname), this%iptcout
698 else
700 'Optional PTC_OUTPUT keyword must be followed by FILEOUT'
702 end if
703 case ('DEV_PTC_OPTION')
704 call this%parser%DevOpt()
705 this%iallowptc = 1
706 this%iptcopt = 1
707 write (
iout,
'(1x,A)') &
708 'PSEUDO-TRANSIENT CONTINUATION USES BNORM AND L2NORM TO '// &
709 'SET INITIAL VALUE'
710 case ('DEV_PTC_EXPONENT')
711 call this%parser%DevOpt()
712 rval = this%parser%GetDouble()
713 if (rval <= dzero) then
714 write (
errmsg,
'(a)')
'PTC_EXPONENT must be > 0.'
716 else
717 this%iallowptc = 1
718 this%ptcexp = rval
719 write (
iout,
'(1x,A,1x,g15.7)') &
720 'PSEUDO-TRANSIENT CONTINUATION EXPONENT', this%ptcexp
721 end if
722 case ('DEV_PTC_DEL0')
723 call this%parser%DevOpt()
724 rval = this%parser%GetDouble()
725 if (rval <= dzero) then
726 write (
errmsg,
'(a)')
'IMS sln_ar: PTC_DEL0 must be > 0.'
728 else
729 this%iallowptc = 1
730 this%ptcdel0 = rval
731 write (
iout,
'(1x,A,1x,g15.7)') &
732 'PSEUDO-TRANSIENT CONTINUATION INITIAL TIMESTEP', this%ptcdel0
733 end if
734 case default
735 write (
errmsg,
'(a,2(1x,a))') &
736 'Unknown IMS option (', trim(keyword), ').'
738 end select
739 end do
740 write (
iout,
'(1x,a)')
'END OF IMS OPTIONS'
741 else
742 write (
iout,
'(1x,a)')
'NO IMS OPTION BLOCK DETECTED.'
743 end if
744
74500021 FORMAT(1x, 'SIMPLE OPTION:', /, &
746 1x, 'DEFAULT SOLVER INPUT VALUES FOR FAST SOLUTIONS')
74700023 FORMAT(1x, 'MODERATE OPTION:', /, 1x, 'DEFAULT SOLVER', &
748 ' INPUT VALUES REFLECT MODERATELY NONLINEAR MODEL')
74900025 FORMAT(1x, 'COMPLEX OPTION:', /, 1x, 'DEFAULT SOLVER', &
750 ' INPUT VALUES REFLECT STRONGLY NONLINEAR MODEL')
751
752
753
754 call this%sln_setouter(ifdparam)
755
756
757 call this%parser%GetBlock('NONLINEAR', isfound, ierr, &
758 supportopenclose=.true., blockrequired=.false.)
759
760
761 if (isfound) then
762 write (
iout,
'(/1x,a)')
'PROCESSING IMS NONLINEAR'
763 do
764 call this%parser%GetNextLine(endofblock)
765 if (endofblock) exit
766 call this%parser%GetStringCaps(keyword)
767
768 select case (keyword)
769 case ('OUTER_DVCLOSE')
770 this%dvclose = this%parser%GetDouble()
771 case ('OUTER_MAXIMUM')
772 this%mxiter = this%parser%GetInteger()
773 case ('UNDER_RELAXATION')
774 call this%parser%GetStringCaps(keyword)
775 ival = 0
776 if (keyword == 'NONE') then
777 ival = 0
778 else if (keyword == 'SIMPLE') then
779 ival = 1
780 else if (keyword == 'COOLEY') then
781 ival = 2
782 else if (keyword == 'DBD') then
783 ival = 3
784 else
786 'Unknown UNDER_RELAXATION specified (', trim(keyword), ').'
788 end if
789 this%nonmeth = ival
790 case ('LINEAR_SOLVER')
791 call this%parser%GetStringCaps(keyword)
792 ival = ims_solver
793 if (keyword .eq. 'DEFAULT' .or. &
794 keyword .eq. 'LINEAR') then
795 ival = ims_solver
796 else
798 'Unknown LINEAR_SOLVER specified (', trim(keyword), ').'
800 end if
801 this%linsolver = ival
802 case ('UNDER_RELAXATION_THETA')
803 this%theta = this%parser%GetDouble()
804 case ('UNDER_RELAXATION_KAPPA')
805 this%akappa = this%parser%GetDouble()
806 case ('UNDER_RELAXATION_GAMMA')
807 this%gamma = this%parser%GetDouble()
808 case ('UNDER_RELAXATION_MOMENTUM')
809 this%amomentum = this%parser%GetDouble()
810 case ('BACKTRACKING_NUMBER')
811 this%numtrack = this%parser%GetInteger()
812 IF (this%numtrack > 0) this%ibflag = 1
813 case ('BACKTRACKING_TOLERANCE')
814 this%btol = this%parser%GetDouble()
815 case ('BACKTRACKING_REDUCTION_FACTOR')
816 this%breduc = this%parser%GetDouble()
817 case ('BACKTRACKING_RESIDUAL_LIMIT')
818 this%res_lim = this%parser%GetDouble()
819 case default
821 'Unknown IMS NONLINEAR keyword (', trim(keyword), ').'
823 end select
824 end do
825 write (
iout,
'(1x,a)')
'END OF IMS NONLINEAR DATA'
826 else
827 if (ifdparam .EQ. 0) then
828 write (
errmsg,
'(a)')
'NO IMS NONLINEAR block detected.'
830 end if
831 end if
832
833 if (this%theta < dem3) then
834 this%theta = dem3
835 end if
836
837
838 if (this%nonmeth < 1) then
839 this%ibflag = 0
840 end if
841
842
843 if (this%mxiter <= 0) then
844 write (
errmsg,
'(a)')
'Outer iteration number must be > 0.'
846 END IF
847
848
849 if (this%nonmeth > 0) then
850 WRITE (
iout, *)
'**UNDER-RELAXATION WILL BE USED***'
852 elseif (this%nonmeth == 0) then
853 WRITE (
iout, *)
'***UNDER-RELAXATION WILL NOT BE USED***'
855 else
857 'Incorrect value for variable NONMETH was specified.'
859 end if
860
861
862 if (this%nonmeth == 1) then
863 if (this%gamma == 0) then
865 'GAMMA must be greater than zero if SIMPLE under-relaxation is used.'
867 end if
868 end if
869
870 if (this%solver_mode == 'PETSC') then
871 this%linsolver = petsc_solver
872 end if
873
874
875 call this%linear_settings%init(this%memory_path)
876 call this%linear_settings%preset_config(ifdparam)
877 call this%linear_settings%read_from_file(this%parser,
iout)
878 call this%linear_settings%check_settings()
879
880 if (this%linear_settings%ilinmeth == cg_method) then
881 this%isymmetric = 1
882 end if
883
884
885
886 if (this%solver_mode == "IMS") then
887 allocate (this%imslinear)
888 WRITE (
iout, *)
'***IMS LINEAR SOLVER WILL BE USED***'
889 call this%imslinear%imslinear_allocate(this%name,
iout, this%iprims, &
890 this%mxiter, this%neq, &
891 this%system_matrix, this%rhs, &
892 this%x, this%linear_settings)
893
894
895 else if (this%solver_mode == "PETSC") then
896 call this%linear_solver%initialize(this%system_matrix, &
897 this%linear_settings, &
898 this%cnvg_summary)
899
900
901 else
903 'Incorrect value for linear solution method specified.'
905 end if
906
907
908 if (this%isymmetric == 1) then
909 write (
iout,
'(1x,a,/)')
'A symmetric matrix will be solved'
910 else
911 write (
iout,
'(1x,a,/)')
'An asymmetric matrix will be solved'
912 end if
913
914
915
916 if (this%isymmetric == 1) then
917
918
919 do i = 1, this%modellist%Count()
920 mp => getnumericalmodelfromlist(this%modellist, i)
921 if (mp%get_iasym() /= 0) then
922 write (
errmsg, fmterrasym)
'MODEL', trim(adjustl(mp%name))
924 end if
925 end do
926
927
928 do i = 1, this%exchangelist%Count()
929 cp => getnumericalexchangefromlist(this%exchangelist, i)
930 if (cp%get_iasym() /= 0) then
931 write (
errmsg, fmterrasym)
'EXCHANGE', trim(adjustl(cp%name))
933 end if
934 end do
935
936 end if
937
938
939
940 this%idv_scale = this%sln_get_idvscale()
941
942 if (this%idv_scale > 0) then
943 write (
iout,
'(2(1x,a,/),1x,a,/,6x,a,/)') &
944 'X and RHS will be scaled to avoid very large positive or negative', &
945 'dependent variable values in the model IMS package.', &
946 'NOTE: Specified outer and inner DVCLOSE values in the model IMS &
947 &package', 'will be relative closure criteria.'
948 else if (this%idv_scale < 0) then
949 write (
errmsg,
'(2(a,1x))') &
950 'dependent_variable_scaling must be specified for all models in', &
951 'the solution and can only be used with GWT and GWE models. '
953 end if
954
955
956
957
958
959 WRITE (
iout, 9002) this%dvclose, this%mxiter, &
960 this%iprims, this%nonmeth, this%linsolver
961
962
9639002 FORMAT(1x, 'OUTER ITERATION CONVERGENCE CRITERION (DVCLOSE) = ', e15.6, &
964 /1x, 'MAXIMUM NUMBER OF OUTER ITERATIONS (MXITER) = ', i0, &
965 /1x, 'SOLVER PRINTOUT INDEX (IPRIMS) = ', i0, &
966 /1x, 'NONLINEAR ITERATION METHOD (NONLINMETH) = ', i0, &
967 /1x, 'LINEAR SOLUTION METHOD (LINMETH) = ', i0)
968
969 if (this%nonmeth == 1) then
970 write (
iout, 9003) this%gamma
971 else if (this%nonmeth == 2) then
972 write (
iout, 9004) this%gamma
973 else if (this%nonmeth == 3) then
974 write (
iout, 9005) this%theta, this%akappa, this%gamma, this%amomentum
975 end if
976
977
978 if (this%numtrack /= 0)
write (
iout, 9006) this%numtrack, this%btol, &
979 this%breduc, this%res_lim
980
981
9829003 FORMAT(1x, 'UNDER-RELAXATION FACTOR (GAMMA) = ', e15.6)
9839004 FORMAT(1x, 'UNDER-RELAXATION PREVIOUS HISTORY FACTOR (GAMMA) = ', e15.6)
9849005 FORMAT(1x, 'UNDER-RELAXATION WEIGHT REDUCTION FACTOR (THETA) = ', e15.6, &
985 /1x, 'UNDER-RELAXATION WEIGHT INCREASE INCREMENT (KAPPA) = ', e15.6, &
986 /1x, 'UNDER-RELAXATION PREVIOUS HISTORY FACTOR (GAMMA) = ', e15.6, &
987 /1x, 'UNDER-RELAXATION MOMENTUM TERM (AMOMENTUM) = ', e15.6)
988
989
9909006 FORMAT(1x, 'MAXIMUM NUMBER OF BACKTRACKS (NUMTRACK) = ', i0, &
991 /1x, 'BACKTRACKING TOLERANCE FACTOR (BTOL) = ', e15.6, &
992 /1x, 'BACKTRACKING REDUCTION FACTOR (BREDUC) = ', e15.6, &
993 /1x, 'BACKTRACKING RESIDUAL LIMIT (RES_LIM) = ', e15.6)
994
995
996 if (this%linsolver == ims_solver) then
997 call this%imslinear%imslinear_summary(this%mxiter)
998 else
999 call this%linear_solver%print_summary()
1000 end if
1001
1002
1004 if (ierr > 0) then
1005 call this%parser%StoreErrorUnit()
1006 end if
1007
1008
1010 call mem_reallocate(this%lrch, 3, this%mxiter,
'LRCH', this%name)
1011
1012
1013 if (this%nonmeth == 3) then
1017 do i = 1, this%neq
1018 this%wsave(i) = dzero
1019 this%hchold(i) = dzero
1020 this%deold(i) = dzero
1021 end do
1022 end if
1023 this%hncg = dzero
1024 this%lrch = 0
1025
1026
1027 if (this%iprims == 2 .or. this%icsvinnerout > 0) then
1028 this%nitermax = this%linear_settings%iter1 * this%mxiter
1029 else
1030 this%nitermax = 1
1031 end if
1032
1033 allocate (this%caccel(this%nitermax))
1034
1035
1036
1037 call this%cnvg_summary%reinit(this%nitermax)
1038
1039
1041 if (ierr > 0) then
1042 call this%parser%StoreErrorUnit()
1043 end if
1044
1045
1046 call this%parser%Clear()
This module contains simulation methods.
subroutine, public store_error(msg, terminate)
Store an error message.
integer(i4b) function, public count_errors()
Return number of errors.
subroutine, public deprecation_warning(cblock, cvar, cver, endmsg, iunit)
Store deprecation warning message.
character(len=maxcharlen) errmsg
error message string