SUBROUTINE NX_GFLD ( string, lens, isptr, field, lenf, iret ) C************************************************************************ C* NX_GFLD * C* * C* This subroutine returns the next field from STRING that begins at or * C* after pointer ISPTR. The fields in STRING must be separated by at * C* least one "separator character" (currently defined as a blank or a * C* comma). Any separator characters between ISPTR and the start of * C* the next field will not be returned. * C* * C* NX_GFLD ( STRING, LENS, ISPTR, FIELD, LENF, IRET ) * C* * C* Input parameters: * C* STRING CHAR* String of characters * C* LENS INTEGER Length of STRING * C* * C* Input and output parameters: * C* ISPTR INTEGER Pointer within STRING * C* * C* Output parameters: * C* FIELD CHAR* Next field * C* LENF INTEGER Length of FIELD * C* IRET INTEGER Return code * C* 0 = normal return * C* -1 = no more fields in STRING * C* -2 = LENF for next field is * C* larger than MXLENF * C** * C* Log: * C* J. Ator/NCEP 04/98 * C* R. Hollern/NCEP 01/99 Initialize seps,lseps in DATA stmts * C* J. Ator/NCEP 01/02 Declare field locally * C* C. Caruso Magee/NCEP 02/02 Fixed bug in definition scope of MXLENF * C************************************************************************ INCLUDE 'GEMPRM.PRM' INCLUDE 'nxcmn.cmn' C* CHARACTER*(*) string, field C* LOGICAL start C* PARAMETER ( NSEPS = 2 ) C* INTEGER lseps ( NSEPS ) C* CHARACTER*1 seps ( NSEPS ) C* DATA (seps(i), i = 1,NSEPS) / ' ', ',' / C* DATA (lseps(i), i = 1,NSEPS) / 1, 1 / C------------------------------------------------------------------------ iret = 0 C C* Find the start of the next field. C start = .false. DO WHILE ( .not. start ) IF ( isptr .gt. lens ) THEN iret = -1 RETURN ELSE IF ( ( string ( isptr : isptr ) .ne. seps (1) ) .and. + ( string ( isptr : isptr ) .ne. seps (2) ) ) THEN start = .true. ELSE isptr = isptr + 1 END IF END DO C C* Search for a separator character to signal the end of this C* field. If no such character is found, then the end of the C* field is at the end of STRING. C CALL ST_NXTS ( string, isptr, lens, seps, lseps, NSEPS, + ipt1, iseps, iernxt ) IF ( iernxt .ne. 0 ) THEN iend = lens ELSE iend = ipt1 - 1 END IF C C* Check that the length of the field is less than or equal to C* MXLENF characters. C lnxfld = iend - isptr + 1 IF ( lnxfld .gt. MXLENF ) THEN logmsg = 'Field ' // string ( isptr : iend ) // + ' is too big' CALL DC_WLOG ( 2, 'NX', -1, logmsg, ierwlg ) iret = -2 RETURN END IF C C* Set output values. C field = string ( isptr : iend ) lenf = iend - isptr + 1 isptr = iend + 1 C* RETURN END