759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778 logical, intent(in) :: MyMaster
779
780 character (len=*), intent( in) :: KeyWord
781 character (len=*), intent(out) :: Value
782 character (len=*), intent( in), optional :: InpName
783
784
785
786 logical :: foundit, GotFile
787
788 integer :: InpUnit, Npts, Nval, i, io_err, status
789
790 real(dp), dimension(nRval) :: Rval
791
792 character (len=1 ), parameter :: blank = ' '
793 character (len= 40) :: string
794 character (len=256) :: io_errmsg, line
795 character (len=256), dimension(nCval) :: Cval
796
797
798
799
800
801
802
803 io_err=0
804 IF (PRESENT(inpname)) THEN
805 inpunit=1
806 OPEN (inpunit, file=trim(inpname), form='formatted', &
807 & status='old', iostat=io_err, iomsg=io_errmsg)
808 IF (io_err.ne.0) THEN
809 IF (mymaster) WRITE (stdout,10) trim(inpname), &
810 & trim(io_errmsg)
811 10 FORMAT (/,' GETPAR_0D_S - Unable to open input script: ',a, &
812 & /,15x,'ERROR: ',a)
813 exit_flag=5
814 RETURN
815 ELSE
816 gotfile=.true.
817 END IF
818 ELSE
819 inpunit=stdinp_unit(mymaster, gotfile)
820 END IF
821
822
823
824 foundit=.false.
825 DO WHILE (.true.)
826 READ (inpunit,'(a)',err=20,END=40) line
827 status=decode_line(line, string, nval, cval, rval)
828 IF (status.gt.0) THEN
829 IF (trim(string).eq.trim(keyword)) THEN
830 DO i=1,len(Value)
831 value(i:i)=blank
832 END DO
833 Value=trim(adjustl(cval(nval)))
834 foundit=.true.
835 END IF
836 END IF
837 END DO
838 20 IF (mymaster) THEN
839 WRITE (stdout,30) line
840 30 FORMAT (/,' GETPAR_0D_S - Error while processing line: ',/,a)
841 END IF
842 exit_flag=4
843 40 CONTINUE
844 IF (.not.foundit) THEN
845 IF (mymaster) THEN
846 WRITE (stdout,50) trim(keyword)
847 50 FORMAT (/,' GETPAR_0D_S - unable to find KeyWord: ',a, &
848 & /,15x,'in ROMS standard input file.')
849 END IF
850 exit_flag=5
851 END IF
852 IF (gotfile) THEN
853 CLOSE (inpunit)
854 END IF
855
856 RETURN