!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! Copyright (C) 2007 UNESCO-IHE, WL|Delft Hydraulics and Delft University ! ! Dano Roelvink, Ap van Dongeren, Ad Reniers, Jamie Lescinski, ! ! Jaap van Thiel de Vries, Robert McCall ! ! ! ! d.roelvink@unesco-ihe.org ! ! UNESCO-IHE Institute for Water Education ! ! P.O. Box 3015 ! ! 2601 DA Delft ! ! The Netherlands ! ! ! ! This library is free software; you can redistribute it and/or ! ! modify it under the terms of the GNU Lesser General Public ! ! License as published by the Free Software Foundation; either ! ! version 2.1 of the License, or (at your option) any later version. ! ! ! ! This library is distributed in the hope that it will be useful, ! ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! ! Lesser General Public License for more details. ! ! ! ! You should have received a copy of the GNU Lesser General Public ! ! License along with this library; if not, write to the Free Software ! ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 ! ! USA ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! module readkey_module use typesandkinds, only: slen implicit none save private public readkey_int, readkey_name, readkey_dbl, isSetParameter, parmapply, readkey_dblvec, readkey_inio, strippedline public count_lines, readkey_intvec, lowercase, setallowednames, setoldnames, readkey, read_v ! before using any of the routines here, set readkey_inio ! .true. : value read will be broadcasted to all processes, including the ! output process. ! otherwise: the value will be broadcasted to the computational processes only ! logical :: readkey_inio = .false. integer, parameter, private :: maxnames = 20 character(slen), dimension(maxnames), private :: allowednames character(slen), dimension(maxnames), private :: oldnames character(slen), private :: varname integer, dimension(maxnames), private :: intvalues integer, private :: numallowednames integer, private :: numoldnames interface read_v module procedure read_v_array module procedure read_v_9 end interface read_v contains real*8 function readkey_dbl(fname,key,defval,mnval,mxval,bcast,required,silent,strict) ! if USEMPI then the master process will read the parameter, ! this value is subsequently broadcasted to the other processes use xmpi_module use logging_module, only: writelog, report_file_read_error implicit none character(len=*) :: fname,key character(slen) :: printkey real*8 :: defval,mnval,mxval logical, intent(in), optional :: bcast,required,silent,strict character(slen) :: value,tempout real*8 :: value_dbl logical :: lbcast,lrequired,lsilent,lstrict character(slen) :: fmt integer :: ier fmt = '(a,a,a,f0.4,a,f0.4)' if (present(bcast)) then lbcast = bcast else lbcast = .true. endif if (present(required)) then lrequired = required else lrequired = .false. endif if (present(silent)) then lsilent = silent else lsilent = .false. endif if (present(strict)) then lstrict = strict else lstrict = .false. endif !printkey=key printkey = ' ' printkey(2:24)=trim(key) printkey(1:1)=' ' if (xmaster) then call readkey(fname,key,value) if (value/=' ') then read(value,'(f10.0)',iostat=ier)value_dbl if (ier .ne. 0) then tempout = trim(fname)//' (value of '''//trim(printkey)//''' cannot be interpreted)' call report_file_read_error(tempout) endif if(lstrict .and. (value_dbl>mxval .or. value_dblmxval) then call writelog('lw','(a24,a,f0.4,a,f0.4)',(printkey),' = ',value_dbl,' Warning: value > recommended value of ',mxval) call writelog('s','(a24,a,a,f0.4)','Warning: ',trim(printkey),' > recommended value of ',mxval) elseif (value_dblmxval .or. value_intmxval) then call writelog('lw',fmt,'Warning: variable ',(printkey),' ',value_int,' > recommended value of ',mxval) call writelog('s','(a24,a,a,i0)','Warning: ',trim(printkey),' > recommended value of ',mxval) elseif (value_intmxval) then call writelog('lw','(a24,a,f0.4,a,f0.4)',(printkey),' = ',value_vec(i), & ' Warning: value > recommended value of ',mxval) call writelog('s','(a24,a,a,f0.4)','Warning: ',trim(printkey),' > recommended value of ',mxval) elseif (value_vec(i)mxval) then call writelog('lw','(a24,a,i0,a,i0)',(printkey),' = ',value_vec(i), & ' Warning: value > recommended value of ',mxval) call writelog('s','(a24,a,a,i0)','Warning: ',trim(printkey),' > recommended value of ',mxval) elseif (value_vec(i)126) then ! this is anything not in standard ! alphanumeric strippedline(itab:itab) = ' ' else strippedline(itab:itab) = line(itab:itab) endif enddo end function end module readkey_module