c$Header: /weru/cvs/weps/weps.src/manage/old.src/getr.for.keep,v 1.1.1.1 1999-03-12 17:05:28 wagner Exp $NH c c integer function getr m (ivar, rvar, cvar, i need, type) c c + + + PURPOSE + + + c Getr is called from dooper and doproc. "Need" number of "type" c data is read in from the management file and placed into the c corresponding variable. It is normal to call getr with the first c 3 variables as the same name. (fortran uses call-by-variable.) c After the required input has been read in, getr moves to the next c available value in the file (stopping at non-continuation lines). c c Getr returns the last (next non-white space char) position within c the line it is reading after obtaining the desired number of c values (specified by need). c c + + + KEYWORDS + + + c tillage, file, read, input, management c c + + + PARAMETERS AND COMMON BLOCKS + + + *$noereference include 'p1werm.inc' include 'manage/man.inc' *$reference c c + + + ARGUMENT DECLARATIONS + + + integer ivar(*) integer jchar real rvar(*) character*(*) cvar(*) integer need character type c c + + + ARGUMENT DEFINITIONS + + + c ivar - integer variable or array c rvar - real variable or array c cvar - character string or string array c need - the size of the array, or the number of items to be read in c type - a character representing the type of input requested c 'i' integer | 'r' real | 'c' character c c + + + LOCAL VARIABLES + + + character*80 dumchar integer last, index c integer width c c + + + DATA INITIALIZATIONS + + + index=0 c c + + + END SPECIFICATIONS + + + c c are we placing on a new line? 5 if (mlpos.eq.0) then c ---------------- new line c better get it then 10 recnum=recnum+1 read (10, rec=recnum) mline(:rcl) if (mline (1:1).eq.'#') go to 10 if (mline (1:1).eq.'+') then mlpos=2 else c we have hit an error at this point if (index.lt.need) then print*,'ERROR-Expecting a continuation line, and got this:' print*,mline getr=-1 else getr=0 endif go to 50 endif endif c c we now have a mlpos to start parsing c c look for a "non-space" 20 if (mline(mlpos:mlpos).ne.' ') then c found the starting position of a value else mlpos=mlpos+1 if (mlpos.eq.72) then mlpos = 0 go to 5 endif go to 20 endif c if (index.lt.need) then c look for a space last=mlpos 30 if (mline(last:last).eq.' ') then c we have a value to pull off now index=index+1 c write(*,*) mlpos,(last-1),' mline',mline(:rcl) if (type.eq.'i') then read (mline(mlpos:last-1) ,*) ivar(index) else if (type.eq.'r') then read (mline(mlpos:last-1) ,*) rvar(index) else if (type.eq.'c') then c ANH 08/11/95 c fix for reading character variables. jchar=1 do mlpos=mlpos,(last-1) dumchar(jchar:jchar)=mline(mlpos:mlpos) jchar=jchar+1 enddo cvar(index)=dumchar(1:jchar-1) c read (mline(mlpos:last-1), '(a)') cvar(index) else print*,'Error in Getr: Invalid type' endif endif endif mlpos=last go to 20 else last=last+1 if (last.eq.72) then c we have a value to pull off now index=index+1 if (type.eq.'i') then read (mline(mlpos:last-1), '(i8)') ivar(index) else if (type.eq.'r') then read (mline(mlpos:last-1), '(g8.4)') rvar(index) else if (type.eq.'c') then c ANH 08/11/95 c fix for reading character variables. jchar=1 do mlpos=mlpos,(last-1) dumchar(jchar:jchar)=mline(mlpos:mlpos) jchar=jchar+1 enddo cvar(index)=dumchar(1:jchar-1) c read (mline(mlpos:last-1), '(a)') cvar(index) else print*,'Error in Getr: Invalid type' endif endif endif mlpos=0 go to 5 endif endif go to 30 else c found all we need getr=mlpos go to 50 endif c print*,'should not have reached this point' 50 return end c c$Log: not supported by cvs2svn $ c Revision 1.4 1995/11/28 20:29:16 hawkins c changed the way character strings are read to avoid errors. c c Revision 1.3 1995/11/07 16:00:18 jt c Changed how the management file in as free format. c There is still a problem reading character variables free format c (eg. at line 103). c c Revision 1.2 1995/09/13 15:54:41 wagner c Necessary changes made to allow FORTRAN src files (*.for) to use the c extended FORTRAN include statement rather than the MICROSOFT $INCLUDE c directive as previously used. This is required to allow use of other c FORTRAN compilers. c c Changes have been made to the prologue.mk, epilogue.mk, and the Unix c master startup.mk files as well as the src files. c c Revision 1.1.1.1 1995/01/18 04:19:54 wagner c Initial checkin c c Revision 1.4 1992/10/13 08:31:05 wagner c Major changes involving reading management file. c c Revision 1.3 1992/10/13 03:07:06 wagner c fixed a couple of Microsoft warnings. c Still have a problem with free format specifier "*" c Microsoft FORTRAN doesn't accept that in "internal" c files such as read statements using a char string c as the input file. c It requires a format specifier with a number such c as i8, g8.4, etc. c We need to determine what will be acceptable and what c won't. Also, we need to check if we can make them c parameter variables. c c Revision 1.2 1992/10/10 21:15:07 wagner c Converted TILLAGE submodel to MANAGEMENT submodel. c c Revision 1.1 1992/06/29 22:10:35 dudley c Initial revision c