C Program: sndmak C C Introduction: C Fortran program to convert ASCII output files from McMurdo upper C air flights to an ASCII file that lists the levels in ascending C height and removes any duplicate levels. C C The following are the column headers for the output: C PRES - pressure (millibars) C HGHT - geopotential height (meters) C TMPC - temperature (deg C) C DPDC - dew point temperature (deg C) C RELH - relative humidity (percent) C DRCT - wind direction C SKNT - wind speed (knots) C C The file names are inputed by the user, and then the output file C is automatically created by sorting all the levels by height. C C Mark Seefeldt C Antarctic Automatic Weather Stations C Space Science and Engineering Center C University of Wisconsin - Madsion C C Version: 1.00 C Date: May 28, 1996 C PROGRAM mcmsnd C C declare real variables REAL HGHT,PRES,SKNT,TMPC,DPDC,RELH,H,P,S,T,R C HGHT - height in meters C PRES - station pressure in millibars C SKNT - wind speed in knots C TMPC - temperature in Celsius C DPDC - dewpoint depression Celsius C RELH - relative humidity in percent C H,P,S,T,R - same as above, used in the sorting technique C C declare integer variables INTEGER DRCT,NLEV,WD,NLEVN,D C DRCT - wind direction in degrees C NLEV - number of levels C WD - C NLEVN- number of sorted levels C D - wind direction, used in the sorting technique C C declare character variables CHARACTER FNAMIN*20,FNAMOUT*20,CHECK*9 C FNAMIN - input file name C FNAMOUT - ouput file name C CHECK - check for '1000 FOOT PILOT LEVEL' C C declare array segments DIMENSION HGHT(300),PRES(300),SKNT(300),DRCT(300),TMPC(300), *DPDC(300),RELH(300) C C C INTRO C print opening statements WRITE (*,2000) WRITE (*,2002) WRITE (*,2004) 2000 FORMAT (//10X 'McMurdo Upper Air - Data File Conversion') 2002 FORMAT (/'Fortran program to convert McMurdo upper air report ', *'output file,') 2004 FORMAT ('to an ASCII format with the level in ascending order.') C C enter input file information WRITE (*,2010) 2010 FORMAT (/'Please enter the name of the upper air file.') READ (*,1010) FNAMIN 1010 FORMAT (A20) C C open the input file OPEN (10, FILE=FNAMIN) C C loop through all of the lines in the upper air file DO 150 I=1,300 C read in the data C check to see if you are at the '1000 FOOT PILOT LEVELS' part C when the file reaches this point, the .rpt is complete 110 READ (10, 1015) CHECK 1015 FORMAT (A9) IF (CHECK.EQ.'1000 FOOT') THEN GOTO 160 ELSE BACKSPACE 10 ENDIF C read in the line of text 112 READ (10,1020, ERR=130, END=160) HGHT(I),DRCT(I),SKNT(I), * TMPC(I),DPDC(I),PRES(I),RELH(I) 1020 FORMAT (1X,F7.1,4X,I3,2X,F5.1,4X,F5.1,2X,F5.1,3X,F6.1,2X,F5.1) C determine if the line that was read in, is a valid data line IF (HGHT(I).EQ.0.OR.HGHT(I).GT.70000.OR.HGHT(I).EQ.9999.9.OR. * PRES(I).EQ.0) GOTO 110 GOTO 150 130 GOTO 110 150 CONTINUE C determine the number of valid levels 160 NLEV=I-1 C C sort the data by ascending height DO 250 J=2,NLEV H=HGHT(J) WD=DRCT(J) S=SKNT(J) T=TMPC(J) D=DPDC(J) P=PRES(J) R=RELH(J) DO 230 I=J-1,1,-1 IF (HGHT(I).LE.H) GOTO 240 HGHT(I+1)=HGHT(I) DRCT(I+1)=DRCT(I) SKNT(I+1)=SKNT(I) TMPC(I+1)=TMPC(I) DPDC(I+1)=DPDC(I) PRES(I+1)=PRES(I) RELH(I+1)=RELH(I) 230 CONTINUE I=0 240 HGHT(I+1)=H DRCT(I+1)=WD SKNT(I+1)=S TMPC(I+1)=T DPDC(I+1)=D PRES(I+1)=P RELH(I+1)=R 250 CONTINUE C C C remove duplicate levels NLEVN=NLEV DO 270 I=1,NLEV 255 IF (I.GT.NLEVN) GOTO 270 IF (PRES(I).EQ.PRES(I+1)) THEN NLEVN=NLEVN-1 DO 260 J=I+1,NLEVN HGHT(J)=HGHT(J+1) DRCT(J)=DRCT(J+1) SKNT(J)=SKNT(J+1) TMPC(J)=TMPC(J+1) DPDC(J)=DPDC(J+1) PRES(J)=PRES(J+1) RELH(J)=RELH(J+1) 260 CONTINUE GOTO 255 ELSE GOTO 270 ENDIF 270 CONTINUE C C output the file information WRITE (*,2300) 2300 FORMAT ('Please enter the name of the output file.') READ (*,1300) FNAMOUT 1300 FORMAT (A20) C C open the output file OPEN (20,FILE=FNAMOUT) C C write out the column headers WRITE (20,2310) 2310 FORMAT (/,4X,'PRES',4X,'HGHT',4X,'TMPC',4X,'DPDC',4X,'RELH', *4X,'DRCT',4X,'SKNT') C loop through each valid level, and write out the data DO 330 J=1,NLEVN WRITE (20,2320) PRES(J),HGHT(J),TMPC(J),DPDC(J),RELH(J), * DRCT(J),SKNT(J) 2320 FORMAT (2X,F6.1,1X,F7.1,3X,F5.1,3X,F5.1,4X,F4.1,5X,I3,3X,F5.1) 330 CONTINUE C C 999 STOP END