module readkey_module contains real*8 function readkey_dbl(fname,key,defval,mnval,mxval,bcast,required) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! 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 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! 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 implicit none character(len=*) :: fname,key character(24) :: printkey real*8 :: defval,mnval,mxval logical, intent(in), optional :: bcast,required character*80 :: value real*8 :: value_dbl logical :: lbcast,lrequired character(24) :: fmt 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 !printkey=key printkey(2:24)=key printkey(1:1)=' ' if (xmaster) then call readkey(fname,key,value) if (value/=' ') then read(value,'(f10.0)')value_dbl if (value_dbl>mxval) then call writelog('l','(a,a,f0.4,a,f0.4)',(printkey),' = ',value_dbl,' Warning: value > recommended value of ',mxval) call writelog('s','(a,a,a,f0.4)','Warning: ',trim(printkey),' > recommended value of ',mxval) elseif (value_dblmxval) then call writelog('l',fmt,'Warning: variable ',(printkey),' ',value_int,' > recommended value of ',mxval) call writelog('s','(a,a,a,i0)','Warning: ',trim(printkey),' > recommended value of ',mxval) elseif (value_int0) then ikey=ikey+1 keyword(ikey)=adjustl(line(1:ic-1)) values(ikey)=adjustl(line(ic+1:80)) endif enddo nkeys=ikey close(lun) allocate(readindex(nkeys)) readindex=0 endif value=' ' do ikey=1,nkeys if (key.eq.keyword(ikey)) then value=values(ikey) readindex(ikey)=1 endif enddo ! If required, do a check whether params are not used or unknown if (key .eq. 'checkparams') then do ikey=1,nkeys if (readindex(ikey)==0) then call writelog('sl','','Unknown, unused or multiple statements of parameter ',trim(keyword(ikey)),& ' in ',trim(fname)) endif enddo endif end subroutine readkey ! The following code is taken from program "CHCASE" @ http://www.davidgsimpson.com/software/chcase_f90.txt: ! Programmer: Dr. David G. Simpson ! NASA Goddard Space Flight Center ! Greenbelt, Maryland 20771 ! ! Date: January 24, 2003 ! ! Language: Fortran-90 ! ! Version: 1.00a ! SUBROUTINE UPPERCASE(STR) IMPLICIT NONE CHARACTER(LEN=*), INTENT(IN OUT) :: STR INTEGER :: I, DEL DEL = IACHAR('a') - IACHAR('A') DO I = 1, LEN_TRIM(STR) IF (LGE(STR(I:I),'a') .AND. LLE(STR(I:I),'z')) THEN STR(I:I) = ACHAR(IACHAR(STR(I:I)) - DEL) END IF END DO RETURN END SUBROUTINE UPPERCASE ! ! LOWERCASE ! SUBROUTINE LOWERCASE(STR) IMPLICIT NONE CHARACTER(LEN=*), INTENT(IN OUT) :: STR INTEGER :: I, DEL DEL = IACHAR('a') - IACHAR('A') DO I = 1, LEN_TRIM(STR) IF (LGE(STR(I:I),'A') .AND. LLE(STR(I:I),'Z')) THEN STR(I:I) = ACHAR(IACHAR(STR(I:I)) + DEL) END IF END DO RETURN END SUBROUTINE LOWERCASE ! End of code taken from CHCASE end module readkey_module