658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678 logical, intent(in) :: MyMaster
679
680 integer, intent(in) :: Ndim
681
682 real(r8), intent(out) :: Value(:)
683
684 character (len=*), intent(in) :: KeyWord
685 character (len=*), intent(in), optional :: InpName
686
687
688
689 logical :: foundit, GotFile
690
691 integer :: InpUnit, Npts, Nval, io_err, status
692
693 real(dp), dimension(nRval) :: Rval
694
695 character (len= 40) :: string
696 character (len=256) :: io_errmsg, line
697 character (len=256), dimension(nCval) :: Cval
698
699
700
701
702
703
704
705 io_err=0
706 IF (PRESENT(inpname)) THEN
707 inpunit=1
708 OPEN (inpunit, file=trim(inpname), form='formatted', &
709 & status='old', iostat=io_err, iomsg=io_errmsg)
710 IF (io_err.ne.0) THEN
711 IF (mymaster) WRITE (stdout,10) trim(inpname), &
712 & trim(io_errmsg)
713 10 FORMAT (/,' GETPAR_1D_R - Unable to open input script: ',a, &
714 & /,15x,'ERROR: ',a)
715 exit_flag=5
716 RETURN
717 ELSE
718 gotfile=.true.
719 END IF
720 ELSE
721 inpunit=stdinp_unit(mymaster, gotfile)
722 END IF
723
724
725
726 foundit=.false.
727 DO WHILE (.true.)
728 READ (inpunit,'(a)',err=20,END=40) line
729 status=decode_line(line, string, nval, cval, rval)
730 IF (status.gt.0) THEN
731 IF (trim(string).eq.trim(keyword)) THEN
732 npts=load_r(nval, rval, ndim, Value)
733 foundit=.true.
734 END IF
735 END IF
736 END DO
737 20 IF (mymaster) THEN
738 WRITE (stdout,30) line
739 30 FORMAT (/,' GETPAR_1D_R - Error while processing line: ',/,a)
740 END IF
741 exit_flag=4
742 40 CONTINUE
743 IF (.not.foundit) THEN
744 IF (mymaster) THEN
745 WRITE (stdout,50) trim(keyword)
746 50 FORMAT (/,' GETPAR_1D_R - unable to find KeyWord: ',a, &
747 & /,15x,'in ROMS standard input file.')
748 END IF
749 exit_flag=5
750 END IF
751 IF (gotfile) THEN
752 CLOSE (inpunit)
753 END IF
754
755 RETURN