C$$$   SUBPROGRAM DOCUMENTATION BLOCK
C
C SUBPROGRAM:    M_MKWFNM    CONVERTS YYDDDHHMM FILENAME TO WFOA
C   PRGMMR:  HARTSOUGH, C.   ORG: ERL/PROFS  DATE: 97-07-16
C
C ABSTRACT: THIS ROUTINE CONVERTS A STANDARD PROFS FILE NAME, I.E.
C   YYDDDHHMM, INTO THE CORRESPONDING WFOA FILENAME, I.E. YYYYMMDD_HHMM
C
C PROGRAM HISTORY LOG:
C   97-07-16  HARTSOUGH,  USED M_MKI4TM AS STARTING POINT
C   98-07-10  M. BARTH    HANDLE 1980 THROUGH 2179.
C   99-09-21  M. BARTH    COPIED FROM MSAS & MODIFIED FOR MADIS.
C   08-06-13  L. BENJAMIN CHANGED "MADISCON" INCLUDE TO 
C                         "INTQC1CON1".  
C
C USAGE:    CALL M_MKWFNM(FILENAME, FILENEW, ISTATUS)
C   INPUT ARGUMENT LIST:
C     FILENAME   - PROFS STYLE FILE NAME IN 'YYDDDHHMM' - CHARACTER
C
C   OUTPUT ARGUMENT LIST:
C     FILENEW  - THE CORRESPONDING WFOA FILENAME - YYYYMMDD_HHMM (CHAR)
C     ISTATUS   - RETURNED PROGRAM STATUS - INTEGER
C
C REMARKS: NONE
C
C ATTRIBUTES:
C   LANGUAGE: FORTRAN + EXTENSIONS
C   MACHINE: UNIX
C
C$$$
      SUBROUTINE M_MKWFNM (FILENAME, FILENEW, ISTATUS)

C
C       THIS ROUTINE CONVERTS A STANDARD PROFS FILE NAME, I.E. YYDDDHHM
C       INTO THE CORRESPONDING WFOA FILENAME, YYYYMMDD_HHMM.
C
C       ON INPUT
C          FILENAME - THE PROFS STYLE FILE NAME.
C
C       ON OUTPUT
C          FILENEW - THE CORRESPONDING WFOA STYLE FILENAME.
C          ISTATUS -  THE RETURN STATUS.
C
C       HARTSOUGH, C.   16-JUL-19897     ORIGINAL USED M_MKI4TM AS START

      INCLUDE 'IMPLICIT'
      INCLUDE 'INTQC1CON1'

      CHARACTER*(*) FILENAME
      CHARACTER*(*) FILENEW
      INTEGER IFILE(9),I,ISTATUS,
     +        NYEAR,MONTH,JDAY,NDAY,NHOUR,MIN
      INTEGER ICHAR0
C
C       CHECK THE LENGTH OF FILENAME TO BE SURE THAT IT IS VALID.
C
      IF (LEN(FILENAME).NE.9) THEN
         GO TO 1000
      END IF
C
C     ASCII CHARACTER SET '0'=30X=48
C
      ICHAR0=48
C
C       SPLIT THE FILE NAME INTO INDIVIDUAL INTEGERS, CHECKING FOR
C       INVALID CHARACTERS IN THE FILE NAME.
C
      DO 10 I = 1,9
         IFILE(I) = ICHAR(FILENAME(I:I))-ICHAR0
         IF (IFILE(I) .LT. 0 .OR. IFILE(I) .GT.9) THEN
            GO TO 1000
         END IF
10    CONTINUE
C
C       CONVERT THESE NUMBERS IN YEAR, JULIAN DAY, HOURS, AND MINUTES.
C
      NYEAR = 10*IFILE(1) + IFILE(2)
      JDAY = 100*IFILE(3) + 10*IFILE(4) + IFILE(5)
      NHOUR = 10*IFILE(6) + IFILE(7)
      MIN = 10*IFILE(8) + IFILE(9)
C
C       CONVERT THE JULIAN DAY INTO MONTH AND DAY.
C
      CALL M_CVJLMD (JDAY, NYEAR, MONTH, NDAY, ISTATUS)
      IF (ISTATUS.NE.SUCCESS_P)
     1   GO TO 2000
C
C       CONVERT THESE INTEGERS INTO WFOA FILENAME.
C
      IF(NYEAR.GE.80)THEN
         WRITE(FILENEW, 6000) NYEAR,MONTH,NDAY,NHOUR,MIN
 6000    FORMAT('19',3I2,'_',2I2)
      ELSE
         WRITE(FILENEW, 6001) NYEAR,MONTH,NDAY,NHOUR,MIN
 6001    FORMAT('20',3I2,'_',2I2)
      ENDIF
      DO 1500 I=1,13
       IF(FILENEW(I:I) .EQ. ' ') FILENEW(I:I)='0'
 1500 CONTINUE
      IF (ISTATUS.NE.SUCCESS_P)
     1   GO TO 2000
C
C       SUCCESSFUL RETURN
C
      ISTATUS = SUCCESS_P
      RETURN
C
C       ERROR DETECTED IN THIS ROUTINE.
C
 1000 CONTINUE
      ISTATUS = INV_TIME_P
      RETURN
C
C       ERROR DETECTED IN CALLED ROUTINE
C
 2000 CONTINUE
      ISTATUS = INV_TIME_P
      RETURN
      END
C**---------------------------------------------------------------------
C**REQUIRED STANDARD FSL DISCLAIMER (NOVEMBER 2000)
C**---------------------------------------------------------------------
C**  OPEN SOURCE LICENSE/DISCLAIMER,  FORECAST SYSTEMS LABORATORY
C**  NOAA/OAR/FSL, 325 BROADWAY BOULDER, CO 80305
C**
C**  THIS SOFTWARE IS DISTRIBUTED UNDER THE OPEN SOURCE DEFINITION, 
C**  WHICH MAY BE FOUND AT http://www.opensource.org/osd.html.
C**
C**  IN PARTICULAR, REDISTRIBUTION AND USE IN SOURCE AND BINARY FORMS,
C**  WITH OR WITHOUT MODIFICATION, ARE PERMITTED PROVIDED THAT THE 
C**  FOLLOWING CONDITIONS ARE MET:
C**
C**  - REDISTRIBUTIONS OF SOURCE CODE MUST RETAIN THIS NOTICE, THIS LIST
C**    OF CONDITIONS AND THE FOLLOWING DISCLAIMER.
C**
C**  - REDISTRIBUTIONS IN BINARY FORM MUST PROVIDE ACCESS TO THIS 
C**    NOTICE, THIS LIST OF CONDITIONS AND THE FOLLOWING DISCLAIMER, AND
C**    THE UNDERLYING SOURCE CODE.
C**
C**  - ALL MODIFICATIONS TO THIS SOFTWARE MUST BE CLEARLY DOCUMENTED, 
C**    AND ARE SOLELY THE RESPONSIBILITY OF THE AGENT MAKING THE 
C**    MODIFICATIONS.
C**
C**  - IF SIGNIFICANT MODIFICATIONS OR ENHANCEMENTS ARE MADE TO THIS
C**    SOFTWARE, THE FSL SOFTWARE POLICY MANAGER 
C**    (softwaremgr.fsl@noaa.gov) BE NOTIFIED.
C**
C**  THIS SOFTWARE AND ITS DOCUMENTATION ARE IN THE PUBLIC DOMAIN AND 
C**  ARE FURNISHED "AS IS."  THE AUTHORS, THE UNITED STATES GOVERNMENT,
C**  ITS INSTRUMENTALITIES, OFFICERS, EMPLOYEES, AND AGENTS MAKE NO 
C**  WARRANTY, EXPRESS OR IMPLIED, AS TO THE USEFULNESS OF THE SOFTWARE
C**  AND DOCUMENTATION FOR ANY PURPOSE.  THEY ASSUME NO RESPONSIBILITY 
C**  (1) FOR THE USE OF THE SOFTWARE AND DOCUMENTATION; OR (2) TO 
C**  PROVIDE TECHNICAL SUPPORT TO USERS.
C**---------------------------------------------------------------------
