SUBROUTINE UA_GFLD ( report, lenr, irptr, field, lenf, iret ) C************************************************************************ C* UA_GFLD * C* * C* This subroutine returns the next field from a report starting * C* at IRPTR. The fields in REPORT normally must be separated by * C* blanks; however, if the next field contains some number of characters* C* that is a multiple of 5 and is greater than 5, then only the first 5 * C* characters of the field will be returned, leaving the remainder of * C* the field to be processed during the next call to this subroutine. * C* Any blanks at the beginning of REPORT will be skipped over. * C* The pointer IRPTR will be updated to point to the first non-blank * C* character in REPORT after the returned field. * C* * C* UA_GFLD ( REPORT, LENR, IRPTR, FIELD, LENF, IRET ) * C* * C* Input parameters: * C* REPORT CHAR* Report * C* LENR INTEGER Length of REPORT * C* * C* Input and output parameters: * C* IRPTR INTEGER Pointer within REPORT * 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 REPORT * C* -2 = next field is larger * C* than MXLENF * C** * C* Log: * C* J. Ator/NCEP 03/96 * C* J. Ator/NCEP 07/96 Add check for field larger than MXLENF * C* J. Ator/NCEP 12/97 New interface format, style changes * C* J. Ator/NCEP 10/99 Clean up function declarations * C************************************************************************ INCLUDE 'GEMPRM.PRM' INCLUDE 'uacmn.cmn' C* CHARACTER*(*) report, field C* LOGICAL start C------------------------------------------------------------------------ iret = 0 C C* Find the start of the next field. C start = .false. DO WHILE ( .not. start ) IF ( irptr .gt. lenr ) THEN iret = -1 RETURN ELSE IF ( report ( irptr : irptr ) .ne. ' ' ) THEN start = .true. ELSE irptr = irptr + 1 END IF END DO C C* Search for a blank to signal the end of this field. If no blank C* is found, then the end of the field is at the end of the report. C iend = INDEX ( report ( irptr : lenr ), ' ' ) IF ( iend .eq. 0 ) THEN iend = lenr ELSE iend = iend + irptr - 2 END IF C C* Compute the length of the field. C lnxfld = iend - irptr + 1 IF ( ( lnxfld .gt. 5 ) .and. + ( MOD ( lnxfld, 5 ) .eq. 0 ) ) THEN C C* The length of the field is greater than 5 characters C* and is a multiple of 5 characters. Return only the C* first 5 characters of the field. C iend = irptr + 4 ELSE IF ( lnxfld .gt. MXLENF ) THEN logmsg = 'group ' // report ( irptr : iend ) CALL DC_WLOG ( 2, 'UA', -1, logmsg, ierwlg ) iret = -2 RETURN END IF C C* Set the output values. C field = report ( irptr : iend ) lenf = iend - irptr + 1 irptr = iend + 1 C C* Update the pointer to point to the first non-blank character C* after the returned field. C DO WHILE ( ( report (irptr:irptr) .eq. ' ' ) .and. + ( irptr .le. lenr ) ) irptr = irptr + 1 END DO C* RETURN END