1 2 SUBROUTINE MEOPEN 3 !*********************************************************************** 4 ! MEOPEN Module of the AERMOD Model 5 ! 6 ! PURPOSE: Open The Input file for Hourly Meteorological Data, 7 ! And Check Header Record 8 ! 9 ! PROGRAMMER: Roger Brode 10 ! 11 ! DATE: March 2, 1992 12 ! 13 ! INPUTS: Meteorology File Specifications 14 ! 15 ! OUTPUTS: File OPEN Error Status 16 ! 17 ! CALLED FROM: SETUP 18 ! 19 ! REVISION HISTORY: 20 ! -- Modified check of version date in header record of surface 21 ! file. Fatal error occurs if version date is greater than 22 ! 90000 OR less than current release date. 23 ! R. Brode, PES, 09/10/02 24 ! -- Modified comparisons of met station IDs between SURFFILE 25 ! header record and ME pathway. IDs are initially read as 26 ! integers, and then as characters if an error occurs. Also 27 ! changed from fatal error to a warning message if a mismatch 28 ! occurs, and included SITEDATA ID in the comparison. 29 ! R. Brode, PES, 11/10/98 30 ! -- Modified to check for version date associated with of AERMET 31 ! surface file, and compare to two reference dates. Versions 32 ! prior to first date cause fatal error, while version prior to 33 ! second date cause warning. R. Brode, PES, 11/21/97 34 ! -- Removed the comparison of the years defined in the input 35 ! data file with the years declared in the control file 36 ! -- Added OPEN for the profile file 37 ! -- Read and interpreted the latitude and longitude in the 38 ! first record of the SURFFILE 39 ! 40 !*********************************************************************** 41 42 ! Variable Declarations 43 USE MAIN1 44 IMPLICIT NONE 45 CHARACTER MODNAM*12 46 INTEGER :: METVER , IOSI , ISSI , IUSI 47 48 SAVE 49 50 ! Set Parameters for AERMET Version Dates. 51 ! Using data > MDATE1 or < MDATE2 causes a fatal error message. 52 INTEGER , PARAMETER :: MDATE1 = 90000 , MDATE2 = 04300 53 54 CHARACTER(LEN=8) :: CUSI , CSSI , COSI 55 CHARACTER(LEN=6) :: SPEC1 , SPEC2 , SPEC3 56 57 ! Variable Initializations 58 MODNAM = 'MEOPEN' ! 3 59 60 ! File Unit Initialized in BLOCK DATA INIT 61 ! File Format Set By Keyword "SURFFILE" on "ME" pathway 62 ! OPEN Surface Met Data File --- Formatted is the only option 63 ! READ In the Station Numbers for Comparison to SETUP File 64 65 OPEN (UNIT=MFUNIT,ERR=998,FILE=METINP,FORM='FORMATTED', & 66 & IOSTAT=IOERRN,STATUS='OLD') 67 68 GOTO 1000 ! 2 69 70 ! Write Out Error Message for File OPEN Error 71 998 CALL ERRHDL(PATH,MODNAM,'E','500','SURFFILE') ! 1 72 ! Skip READ if there is an error opening file 73 GOTO 1001 74 75 1000 CONTINUE ! 2 76 77 READ (MFUNIT,1900,ERR=90,IOSTAT=IOERRN) ALAT , ALON , SPEC1 , & 78 & IUSI , SPEC2 , ISSI , SPEC3 , IOSI , METVER 79 1900 FORMAT (2A10,T31,A6,T38,I8,T48,A6,T55,I8,T65,A6,T72,I8,T94,I5) 80 81 GOTO 800 ! 2 82 83 90 CONTINUE ! 0 84 85 ! Error reading the header record. Now we'll try using character 86 ! instead of integer reads for the station IDs. 87 88 REWIND MFUNIT 89 READ (MFUNIT,1901,ERR=99,IOSTAT=IOERRN) ALAT , ALON , SPEC1 , & 90 & CUSI , SPEC2 , CSSI , SPEC3 , COSI , METVER 91 1901 FORMAT (2A10,T31,A6,T38,A8,T48,A6,T55,A8,T65,A6,T72,A8,T94,I5) 92 93 ! Convert character IDs to integers 94 CALL STONUM(CUSI,8,FNUM,IMIT) ! 0 95 IF ( IMIT.EQ.1 ) THEN 96 IUSI = NINT(FNUM) ! 0 97 ELSE 98 IUSI = 0 ! 0 99 ENDIF 100 CALL STONUM(CSSI,8,FNUM,IMIT) ! 0 101 IF ( IMIT.EQ.1 ) THEN 102 ISSI = NINT(FNUM) ! 0 103 ELSE 104 ISSI = 0 ! 0 105 ENDIF 106 CALL STONUM(COSI,8,FNUM,IMIT) ! 0 107 IF ( IMIT.EQ.1 ) THEN 108 IOSI = NINT(FNUM) ! 0 109 ELSE 110 IOSI = 0 ! 0 111 ENDIF 112 113 800 CONTINUE ! 2 114 115 ! Check for valid version of meteorological data 116 IF ( METVER.GT.MDATE1 .OR. METVER.LT.MDATE2 ) THEN 117 WRITE (DUMMY,'(2X,I5.5)') METVER ! 0 118 CALL ERRHDL(PATH,MODNAM,'E','395',DUMMY) 119 ENDIF 120 121 ! Check Station IDs in SURFFILE for agreement with ME pathway 122 ! Write Warning Message: SURFDATA id mismatch 123 IF ( ISSI.NE.IDSURF ) CALL ERRHDL(PATH,MODNAM,'W','530','SURFDATA'& 124 & ) 125 ! Write Warning Message: UAIRDATA id mismatch 126 IF ( IUSI.NE.IDUAIR ) CALL ERRHDL(PATH,MODNAM,'W','530','UAIRDATA'& 127 & ) 128 IF ( IMSTAT(9).EQ.1 ) THEN 129 ! Write Warning Message: SITEDATA id mismatch 130 IF ( IOSI.NE.IDSITE ) & 131 & CALL ERRHDL(PATH,MODNAM,'W','530','SITEDATA') 132 ENDIF 133 134 ! Get the hemisphere and latitude (from the first record of the 135 ! scalar file 136 CALL DCDLAT() ! 2 137 138 GOTO 1001 139 140 ! Write Out Error Message for File READ Error 141 99 CALL ERRHDL(PATH,MODNAM,'E','510','SURFFILE') ! 0 142 143 1001 CONTINUE ! 3 144 145 ! File Format Set By Keyword "PROFFILE" on "ME" pathway 146 ! OPEN Profile Met Data File --- Formatted is the only option 147 148 OPEN (UNIT=MPUNIT,ERR=999,FILE=PROINP,FORM='FORMATTED', & 149 & IOSTAT=IOERRN,STATUS='OLD') 150 151 GOTO 1002 ! 2 152 153 ! Write Out Error Message for File OPEN Error 154 999 CALL ERRHDL(PATH,MODNAM,'E','500','PROFFILE') ! 1 155 GOTO 1002 156 157 1002 CONTINUE ! 3 158 159 END
HyperKWIC - Version 1.00DD executed at 20:00 on 1 Mar 2018 | Personal or Academic or Evaluation User | Free for Non-Commercial, Non-Government Use