CHARACTER(LEN=11) shiptempfile! rawinsonde filename. CHARACTER(LEN=11) tempdropfile! Dropwindsode filename. CHARACTER(LEN=11) tempfile

Similar documents
Getting Started with Milestone 2. From Lat Lon, to Cartesian, and back again

Computers in Engineering. Subroutines Michael A. Hawker

Dynamics of the Atmosphere GEMPAK Supplementary Handout

NoahMP namelist.hrldas: Description of Options

Syed RH Rizvi.

Combining Solr and Elasticsearch to Improve Autosuggestion on Mobile Local Search. Toan Vinh Luu, PhD Senior Search Engineer local.

TelFit Documentation. Release Kevin Gullikson

PACKAGE SPECIFICATION HSL 2013

Online Trajectory Module in COSMO - A short user guide

Fortran Coding Standards and Style

Specifications of the EMSC testimony s Service

In this exercise, you ll create a netcdf raster layer using the variable tmin. You will change the display by selecting a different time step.

GrADS for Beginners. Laura Mariotti

C interfaces to HSL routines. J. D. Hogg. Version 1.0 5th December Numerical Analysis Group Internal Report

EMEP model: SR Calculations, Sites, Sondes, and Nudging. Semeena Valiyaveetil Shamsudheen

NCL variable based on a netcdf variable model

Lesson 14 - Activity 1

Introduction to Modern Fortran

Computers in Engineering COMP 208. Subprograms. Subroutines. Subroutines Michael A. Hawker

ITACS : Interactive Tool for Analysis of the Climate System

FORTRAN 90: Functions, Modules, and Subroutines. Meteorology 227 Fall 2017

Old Questions Name: a. if b. open c. output d. write e. do f. exit

Projections for use in the Merced River basin

For more detailed instruction, see the KTA-282 user manual. This document is a condensed version; intended as a reference.

PyNGL & PyNIO Geoscience Visualization & Data IO Modules

Alexander Barth, Aida Alvera-Azcárate, Mohamed Ouberdous, Charles Troupin, Sylvain Watelet & Jean-Marie Beckers

eccodes BUFR decoding

KAshima RAy-Tracing Service (KARATS)

Watcom FORTRAN 77. Language Reference. Edition 11.0c

A hybrid object-based/pixel-based classification approach to detect geophysical phenomena

Stat Analysis Tool. Filtering Summarizing Aggregating. of Grid-Stat, Point-Stat, & Wavelet-Stat output

eccodes BUFR encoding

Day One Export Documentation

Recorded Data / Current Readings (XML Format) Specifications. Ver 1.25

Basic Tiger File System for SmartMedia. Version 1.04

ENGINEERING 1020 Introduction to Computer Programming M A Y 2 6, R E Z A S H A H I D I

Object Oriented Methods

CS 109 C/C ++ Programming for Engineers w. MatLab Summer 2012 Homework Assignment 4 Functions Involving Barycentric Coordinates and Files

Collect all of the raw.trd files into a directory such as /data/67 (67 was a deployment line). Run 125proci.sh using

190 Lecture 18 files

IPSL Boot Camp Part 5:

BDS Query. JSON Query Syntax

An Introduction to Fortran

Acquiring and Processing NREL Wind Prospector Data. Steven Wallace, Old Saw Consulting, 27 Sep 2016

NCAR/NSF GV New Automated Dropsonde System Overview

Computing Seminar Introduction Oct

MANAGEMENT OF IPY 2007/08 NATIONAL DATA

FESTIVAL_DATA OBJECT

Photoscenery for Realistic Scene Generation and Visualization in Flightgear: A Tutorial

ROTCTL(1) Rotator Control Program ROTCTL(1)

Dec 06, 10 18: f95!! To compile and run! pgf f95 o 007.exe &&./007.exe! contains. module grid

storing, retrieving and analysing marine ecosystem data of space. and Jan Erik Stiansen

SWOT LAKE PRODUCT. Claire POTTIER(CNES) and P. Callahan (JPL) SWOT ADT project team J.F. Cretaux, T. Pavelsky SWOT ST Hydro leads

Start > All Programs > OpenGrADS 2.0 > Grads Prompt

SAS/GRAPH and ANNOTATE Facility More Than Just a Bunch of Labels and Lines

7. Procedures and Structured Programming

Geopod User s Guide uideuide Table of Contents

Flytec Bluetooth Option

Lesson 14 - Activity 1

Technical English -I 5 th week SURVEYING AND MAPPING

SES 123 Global and Regional Energy Lab Procedures

3465 Diablo Avenue, Hayward, CA U.S.A Fax:

This user guide covers select features of the desktop site. These include:

AMath 483/583 Lecture 8

AN INTRODUCTION TO FORTRAN 90 LECTURE 2. Consider the following system of linear equations: a x + a x + a x = b

Functions in C C Programming and Software Tools. N.C. State Department of Computer Science

ARPS-3dvar Program. 1. Introduction

Chapter 3. Fortran Statements

The sspline Package. October 11, 2007

GeoTemporal Reasoning in a Web 3.0 World

grib_api.h File Reference

Chapter 4. Fortran Arrays

Package APSIM. July 24, 2017

FORTRAN 90: Formatted Input/Output. Meteorology 227 Fall 2018

CS 221 Lecture. Tuesday, 13 September 2011

Our Strategy for Learning Fortran 90

Computational Astrophysics AS 3013 Lecture 6:

UNIVERSITY OF OSLO Department of Geosciences. GEO4060: Intro to Fortran 2003 programming. Gunnar Wollan

Metview FLEXTRA Tutorial. Meteorological Visualisation Section Operations Department ECMWF

An interesting related problem is Buffon s Needle which was first proposed in the mid-1700 s.

Observational DataBase (ODB*) and its usage at ECMWF

Discussion 1H Notes (Week 3, April 14) TA: Brian Choi Section Webpage:

Functions. Systems Programming Concepts

WinRiver Quick Start Guide

NWSDSS. Hydrologic Engineering Center National Weather Service to Data Storage System Conversion Utility. User's Manual. Version 5.

Bits, Bytes, and Precision

write (unit=*,fmt=*) i =, i! will print: i = 3

bash Execution Control COMP2101 Winter 2019

Chapter 2 REXX STATEMENTS. SYS-ED/ Computer Education Techniques, Inc.

!=======1=========2=========3=========4=========5=========6=========7=========8=========9=========10========11

Geographic Information System and its Application in Hydro-Meteorology Exercises using SavGIS

AWA6223S Sound Level Calibrator. Instruction Manual HANGZHOU AIHUA INSTRUMENTS CO., LTD

Goals for This Lecture:

Goals for This Lecture:

FILSER ELECTRONIC GmbH LXFAI, data-fil, conv-fil, vali-fil programs for PC s, LXFAI data-fil, conv-fil, vali-fil programs for PC s VERSION 2.

SUBPROGRAMS AND MODULES

Technical specifications for accessing Water Level Web Services

GL200 GBD File Specification Sheet

Lab 2: Introduction to mydaq and LabView

Topic 6: A Quick Intro To C. Reading. "goto Considered Harmful" History

Transcription:

################################################################## ################################################################## ###### ###### ###### ingest_upperair.f09 ###### ###### ###### ###### Developed by ###### ###### Center for Analysis and Prediction of Storms ###### ###### University of Oklahoma ###### ###### ###### ################################################################## ################################################################## How to run this code: ingest_upperair.exe [-t YYMMDDHH] [-latmin min_lat] [-latmax max_lat] [-lonmin min_lon] [-lonmax max_lon] [-dt delta_mins] [+dt delta_mins] [-o output_file] ----------------------------------------------------------------------- PURPOSE: The airep file provided by the Central Weather Bureau is the data output from an airplane flight, which are not fixed in location and sample the atmosphere every hour. The airplane measures: Pressure [mb*10] Height [gpm] Temperature [deg Celsius*10] Wind Speed [m/s] Wind Direction [deg] The pilot file provided by the Central Weather Bureau is the data output that is fixed in location and sample the atmosphere every twelve hours. The instrument measures: Pressure [mb*10] Height [gpm] Wind Speed [m/s] Wind Direction [deg] The shiptemp file provided by the Central Weather Bureau is the data output from a rawinsonde that was launched from a ship, which are not-fixed in location and sample the atmosphere every twelve hours. The rawinsonde measures: Pressure [mb*10] Height [gpm] Temperature [deg Celsius*10] Wind Speed [m/s] Dewpoint Depression [deg Celsius*10] Wind Direction [deg] The tempdrop file provided by the Central Weather Bureau is the data output from a dropwindsonde, which are not fixed in location and are irregular temporally. The dropwindsonde measures: Pressure [mb*10] Height [gpm] Temperature [deg Celsius*10] Wind Speed [m/s] Dewpoint Depression [deg Celsius*10] Wind Direction [deg] According to the National Hurricane Center typical measurement errors for a GPS dropwindsonde are: pressure ~ 1mb temperature ~ 0.2K relative humidity ~ 5-10% wind < 1m/s The temp file provided by the Central Weather Bureau is the data output from a rawinsonde, which are fixed in location and sample the atmosphere every twelve hours. The rawinsonde measures: Pressure [mb*10] Height [gpm] -1-

Temperature [deg Celsius*10] Wind Speed [m/s] Dewpoint Depression [deg Celsius*10] Wind Direction [deg] This code: 1. Reads in the data measured from the each of the aforementioned intruments. 2. Coverts the data into the units needed for assimulation into the ARPS model: Pressure [mb] Height [gpm] Temperature [deg Celsius] Wind Speed [m/s] Dewpoint Temperature [deg Celsius] Wind Direction [deg] 3. Outputs the data into an *.snd file ----------------------------------------------------------------------- AUTHOR: Michael Kevin Hernandez, email: michael.hernandez@ou.edu (11/08/2011) ----------------------------------------------------------------------- PROGRAM ingest_upperair IMPLICIT NONE CHARACTER(LEN=11) airepfile Airep filename CHARACTER(LEN=11) pilotfile Pilot filename CHARACTER(LEN=11) shiptempfile rawinsonde filename CHARACTER(LEN=11) tempfile rawinsonde filename CHARACTER(LEN=11) tempdropfile Dropwindsode filename CHARACTER(LEN=3) airepprefix CHARACTER(LEN=3) pilotprefix CHARACTER(LEN=3) shiptempprefix CHARACTER(LEN=3) tempprefix CHARACTER(LEN=3) tempdropprefix CHARACTER(LEN=3) instrument three letter identifier Command line arguement variables: INTEGER*4 IARGC Intrinsic subroutine INTEGER*4 nargs # of command line args INTEGER*4 iargs, jargs index for command line args CHARACTER(LEN=7) cargs var for command line options CHARACTER(LEN=8) date Input date (MUST BE INCLUDED) REAL*4 min_lat, max_lat User specified lat BC REAL*4 min_lon, max_lon User specified lon BC INTEGER*4 delta_mins_minus, delta_mins_add User specified time BC CHARACTER(LEN=20) output_filename User specified output filename Command line indicators LOGICAL min_lat_ind, max_lat_ind LOGICAL min_lon_ind, max_lon_ind LOGICAL delta_mins_minus_ind, delta_mins_add_ind LOGICAL output_filename_ind Debug level: if debug = 0 the basic information is printed out to the screen if debug = 1 the basic info plus user settings are printed out if debug = 9 the data gets outputted into the screen INTEGER*4, PARAMETER :: debug = 0 Each data file has a prefix. airepprefix = "tua" pilotprefix = "tup" shiptempprefix = "tus" tempprefix = "tus" tempdropprefix = "tux" Grab the command line arguement: -2-

Process command line: [-t YYMMDDHH] [-latmin min_lat] [-latmax max_lat] [-lonmin min_lon] [-lonmax max_lon] [-dt delta_mins] [+dt delta_mins] [-o output_file] nargs = IARGC() iargs = 1 DO jargs = 1, nargs, 2 CALL GETARG(iargs,cargs) IF (cargs(1:2) /= '-t') THEN WRITE(*,*) 'ERROR: Please enter a date \"-t YYMMDDHH\"' STOP ENDDO IF (debug == 1) THEN WRITE(*,*) 'Number of command line arguments: ', nargs Setting the indicators to zero, if there is a command line arguement other than date (which is required) then the index gets set to one. min_lat_ind =.FALSE. max_lat_ind =.FALSE. min_lon_ind =.FALSE. max_lon_ind =.FALSE. delta_mins_minus_ind =.FALSE. delta_mins_add_ind =.FALSE. output_filename_ind =.FALSE. iargs = 1 DO jargs = 1, nargs, 2 CALL GETARG(iargs,cargs) iargs = iargs + 1 IF (cargs(1:2) == '-t') THEN CALL GETARG(iargs,date) IF (debug == 1) THEN WRITE(*,*) 'User Specified date: ', date IF (cargs(1:7) == '-latmin') THEN CALL GETARG(iargs,cargs) READ(cargs,*) min_lat min_lat_ind =.TRUE. IF (debug == 1) THEN WRITE(*,'(A25,F5.2)') 'User Specified min lat: ', min_lat Error Check IF (ABS(min_lat).GT. 90.00) THEN WRITE(*,'(A35)') 'ERROR: The minimum latitude is < -90' STOP IF (cargs(1:7) == '-latmax') THEN CALL GETARG(iargs,cargs) READ(cargs,*) max_lat max_lat_ind =.TRUE. IF (debug == 1) THEN WRITE(*,'(A25,F5.2)') 'User Specified max lat: ', max_lat Error Check IF (ABS(max_lat).GT. 90.00) THEN WRITE(*,'(A35)') 'ERROR: The maximum latitude is > 90' STOP -3-

IF (cargs(1:7) == '-lonmin') THEN CALL GETARG(iargs,cargs) READ(cargs,*) min_lon min_lon_ind =.TRUE. IF (debug == 1) THEN WRITE(*,'(A25,F5.2)') 'User Specified min lon: ', min_lon Error Check IF (ABS(min_lon).GT. 180.00) THEN WRITE(*,'(A39)') 'ERROR: The minimum longitude is < -180' STOP IF (cargs(1:7) == '-lonmax') THEN CALL GETARG(iargs,cargs) READ(cargs,*) max_lon max_lon_ind =.TRUE. IF (debug == 1) THEN WRITE(*,'(A25,F5.2)') 'User Specified max lon: ', max_lon Error Check IF (ABS(max_lon).GT. 90.00) THEN WRITE(*,'(A39)') 'ERROR: The maximum longitude is > 180' STOP IF (cargs(1:3) == '-dt') THEN CALL GETARG(iargs,cargs) READ(cargs,*) delta_mins_minus delta_mins_minus_ind =.TRUE. IF (debug == 1) THEN WRITE(*,'(A29,I5)') 'User Specified -delta time: ', delta_mins_minus IF (cargs(1:3) == '+dt') THEN CALL GETARG(iargs,cargs) READ(cargs,*) delta_mins_add delta_mins_add_ind =.TRUE. IF (debug == 1) THEN WRITE(*,'(A29,I5)') 'User Specified +delta time: ', delta_mins_add IF (cargs(1:2) == '-o') THEN CALL GETARG(iargs,cargs) READ(cargs,*) output_filename output_filename_ind =.TRUE. IF (debug == 1) THEN WRITE(*,*) 'User Specified output file name: ', output_filename iargs = iargs + 1 END DO WRITE(*,*) 'User Specified data vector: ' WRITE(*,*) min_lat_ind, max_lat_ind, min_lon_ind, max_lon_ind, delta_mins_minus_ind, delta_mins_add_ind, output_filename_ind Create the file names -4-

airepfile = airepprefix // date pilotfile = pilotprefix // date shiptempfile = shiptempprefix // date tempfile = tempprefix // date tempdropfile = tempdropprefix // date instrument = "ARP" CALL readairepfile(debug,airepfile, instrument, min_lat, max_lat, min_lon, max_lon, delta_mins_minus, delta_mins_add, output_filename, min_lat_ind, max_lat_ind, min_lon_ind, max_lon_ind, delta_mins_minus_ind, delta_mins_add_ind, output_filename_ind) WRITE(*,*) "Completed: ", airepfile instrument = "TMP" CALL readtempfile(debug, tempfile, instrument, min_lat, max_lat, min_lon, max_lon, delta_mins_minus, delta_mins_add, output_filename, min_lat_ind, max_lat_ind, min_lon_ind, max_lon_ind, delta_mins_minus_ind, delta_mins_add_ind, output_filename_ind) WRITE(*,*) "Completed: ", tempfile instrument = "DRP" CALL readdroptempfile(debug, tempdropfile, instrument, min_lat, max_lat, min_lon, max_lon, delta_mins_minus, delta_mins_add, output_filename, min_lat_ind, max_lat_ind, min_lon_ind, max_lon_ind, delta_mins_minus_ind, delta_mins_add_ind, output_filename_ind) WRITE(*,*) "Completed: ", tempdropfile instrument = "stp" CALL readshiptempfile(debug,tempfile, instrument, min_lat, max_lat, min_lon, max_lon, delta_mins_minus, delta_mins_add, output_filename, min_lat_ind, max_lat_ind, min_lon_ind, max_lon_ind, delta_mins_minus_ind, delta_mins_add_ind, output_filename_ind) WRITE(*,*) "Completed: ", shiptempfile instrument = "PLT" CALL readpilotfile(debug, pilotfile, instrument, min_lat, max_lat, min_lon, max_lon, delta_mins_minus, delta_mins_add, output_filename, min_lat_ind, max_lat_ind, min_lon_ind, max_lon_ind, delta_mins_minus_ind, delta_mins_add_ind, output_filename_ind) WRITE(*,*) "Completed: ", pilotfile END PROGRAM ---------------------------------------------------------------------- SUBROUTINE readairepfile ---------------------------------------------------------------------- PURPOSE: This subroutine will Read in the data measured from the airep. ---------------------------------------------------------------------- -5-

SUBROUTINE readairepfile(debug, airepfile, instrument, min_lat, max_lat, min_lon, max_lon, delta_mins_minus, delta_mins_add, output_filename, min_lat_ind, max_lat_ind, min_lon_ind, max_lon_ind, delta_mins_minus_ind, delta_mins_add_ind, output_filename_ind) IMPLICIT NONE INTEGER*4 FileHandle INTEGER*4 stat file stat CHARACTER(LEN=11) airepfile airep filename CHARACTER(LEN=3) instrument instrument indentifier INTEGER*4 i Counter in the z-direction INTEGER*4 station_no Station Number INTEGER*4 station_hgt Station Hieght INTEGER*4 read_lat Latitude [degree*100] INTEGER*4 read_lon Longitude [degree*100] INTEGER*4 read_year Year INTEGER*4 read_month Month INTEGER*4 read_day Day INTEGER*4 past_hour Concatination by the hour var INTEGER*4 read_hour Hour INTEGER*4 past_minute Concatinate variable INTEGER*4 read_minute Minute INTEGER*4 redovar Var to read catted files INTEGER*4 read_record Total number of logical record INTEGER*4 NumberOfLines Actual number of data lines INTEGER*4, DIMENSION(1) :: read_pres Pressure INTEGER*4, DIMENSION(1) :: read_hght Height INTEGER*4, DIMENSION(1) :: read_temp Temperature INTEGER*4, DIMENSION(1) :: read_dewp Dewpoint INTEGER*4, DIMENSION(1) :: read_wdir Wind Dir INTEGER*4, DIMENSION(1) :: read_wspd Wind speed INTEGER*4, DIMENSION(1) :: remark1 pres flag INTEGER*4, DIMENSION(1) :: remark2 hieght flag INTEGER*4, DIMENSION(1) :: remark3 temp flag INTEGER*4, DIMENSION(1) :: remark4 Wspd flag Command line variables REAL*4 min_lat, max_lat User specified lat BC REAL*4 min_lon, max_lon User specified lon BC INTEGER*4 delta_mins_minus, delta_mins_add User specified time BC CHARACTER(LEN=20) output_filename User specified output filename Command line indicators LOGICAL min_lat_ind, max_lat_ind LOGICAL min_lon_ind, max_lon_ind LOGICAL delta_mins_minus_ind, delta_mins_add_ind LOGICAL output_filename_ind INTEGER*4 debug Debug level Formating statements 1000 FORMAT (12x, 2I5, 2x, 5I2, I3) 2000 FORMAT ( I4, I1, I5, I1, I4, I1, 21X) 3000 FORMAT (10x, 2I3, I1, 37x) Start of the subroutine: opening and reading in the data into their respective variables and arrays. NumberOfLines = 1 FileHandle = 11 redovar = 0 past_hour = 0 past_minute = 0-6-

OPEN(UNIT=FileHandle,FILE=airepFile,ACTION='READ',IOSTAT=stat) IF (stat==0) THEN DO This line in the code will read in the header, and it sets up the the rest of the code. READ(FileHandle, 1000,END =10) read_lat, read_lon, read_year, read_month, read_day, read_hour, read_minute, read_record This loop will ensure to keep reading a concatinated file and packages the *.snd files per hour. 10 IF (read_hour.ne. past_hour) THEN past_hour = read_hour read_minute = past_minute This is the part of the code that does the actual reading in of the data (useful and useless). READ(FileHandle,2000,END = 20) read_pres, remark1, read_hght, remark2, read_temp, remark3 20 READ(FileHandle,3000,IOSTAT = redovar) read_wdir, read_wspd, remark4 This is a set of conditions for the code to exit if it has reached the end of the file or something is wrong with the input data, if not, continue running within the do loop. IF (redovar > 0) THEN... something wrong... WRITE(*,*) "... Something is wrong with the data file..." IF (redovar < 0) THEN... end of file reached... EXIT... do normal stuff... Call on the subroutine to convet the units from what was read in to what the model requires. CALL UnitConverter(debug,station_no,station_hgt,read_pres, read_hght, read_temp, read_dewp, read_wdir, read_wspd, NumberOfLines, read_lat, read_lon, read_year, read_month, read_day, read_hour, read_minute, instrument, min_lat, max_lat, min_lon, max_lon, delta_mins_minus, delta_mins_add, output_filename, min_lat_ind, max_lat_ind, min_lon_ind, max_lon_ind, delta_mins_minus_ind, delta_mins_add_ind, output_filename_ind) END DO CLOSE(FileHandle) END SUBROUTINE ---------------------------------------------------------------------- SUBROUTINE readpilotfile ---------------------------------------------------------------------- -7-

PURPOSE: This subroutine will Read in the data measured from the pilot data. ---------------------------------------------------------------------- SUBROUTINE readpilotfile(debug, pilotfile, instrument, min_lat, max_lat, min_lon, max_lon, delta_mins_minus, delta_mins_add, output_filename, min_lat_ind, max_lat_ind, min_lon_ind, max_lon_ind, delta_mins_minus_ind, delta_mins_add_ind, output_filename_ind) IMPLICIT NONE INTEGER*4 FileHandle INTEGER*4 stat file status CHARACTER(LEN=11) pilotfile pilot data filename CHARACTER(LEN=3) instrument instrument indentifier INTEGER*4 i Counter in the z-direction INTEGER*4 station_no Station Number INTEGER*4 station_hgt Station Hieght INTEGER*4 read_lat Latitude [degree*100] INTEGER*4 read_lon Longitude [degree*100] INTEGER*4 read_year Year INTEGER*4 read_month Month INTEGER*4 read_day Day INTEGER*4 past_hour Concatination by the hour var INTEGER*4 read_hour Hour INTEGER*4 past_minute Concatinate variable INTEGER*4 read_minute Minute INTEGER*4 redovar Var to read catted files INTEGER*4 read_record Total number of logical record INTEGER*4 NumberOfLines Actual number of data lines INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_pres Pressure INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_hght Height INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_temp Temperature INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_dewp Dewpoint INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_wdir Wind Dir INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_wspd Wind speed INTEGER*4, ALLOCATABLE, DIMENSION(:) :: remark1 pres flag INTEGER*4, ALLOCATABLE, DIMENSION(:) :: remark2 var flag INTEGER*4, ALLOCATABLE, DIMENSION(:) :: remark3 Wspd flag Command line variables REAL*4 min_lat, max_lat User specified lat BC REAL*4 min_lon, max_lon User specified lon BC INTEGER*4 delta_mins_minus, delta_mins_add User specified time BC CHARACTER(LEN=20) output_filename User specified output filename Command line indicators LOGICAL min_lat_ind, max_lat_ind LOGICAL min_lon_ind, max_lon_ind LOGICAL delta_mins_minus_ind, delta_mins_add_ind LOGICAL output_filename_ind INTEGER*4 debug Debug level Formating statements 1000 FORMAT (3x, I5, I4, 2I5, 2x, 5I2, I3) 2000 FORMAT (2x, 2I5, 1x, I1, 12x, 2I3, 2I1, 3x) Start of the subroutine: opening and reading in the data into their respective variables and arrays. FileHandle = 11 redovar = 0-8-

past_hour = 0 past_minute = 0 OPEN(UNIT=FileHandle,FILE=pilotFile,ACTION='READ',IOSTAT=stat) IF (stat==0) THEN DO This line in the code will read in the header, and it sets up the the rest of the code. READ(FileHandle, 1000, END =10) station_no, station_hgt, read_lat, read_lon, read_year, read_month, read_day, read_hour, read_minute, read_record This loop will ensure to keep reading a concatinated file and packages the *.snd files per hour. 10 IF (read_hour.ne. past_hour) THEN past_hour = read_hour read_minute = past_minute There is data from the instrument that cannot be injested into the model, however the read_record includes those lines as well. Thus the NumberOfLines variable sets the number of lines to read that contains data useful to the model. NumberOfLines = read_record - 1 Allocate the arrays by the length of the data that is useful for the model. Since the remark2 variable is used for two different variables it gets allocated accordingly. ALLOCATE(remark1(NumberOfLines)) ALLOCATE(remark2(2*NumberOfLines)) ALLOCATE(remark3(NumberOfLines)) ALLOCATE(read_pres(NumberOfLines)) ALLOCATE(read_hght(NumberOfLines)) ALLOCATE(read_temp(NumberOfLines)) ALLOCATE(read_dewp(NumberOfLines)) ALLOCATE(read_Wdir(NumberOfLines)) ALLOCATE(read_Wspd(NumberOfLines)) This is the part of the code that does the actual reading in of the data (useful and useless). DO i = 1, NumberOfLines, 1 READ(FileHandle,2000,IOSTAT = redovar) read_pres(i), read_hght(i), remark1(i), read_wdir(i), read_wspd(i), remark2(i), remark3(i) 20 END DO This is a set of conditions for the code to exit if it has reached the end of the file or something is wrong with the input data, if not, continue running within the do loop. IF (redovar > 0) THEN... something wrong... WRITE(*,*) "... Something is wrong with the data file..." EXIT IF (redovar < 0) THEN... end of file reached... EXIT... do normal stuff... -9-

Call on the subroutine to convet the units from what was read in to what the model requires. CALL UnitConverter(debug,station_no,station_hgt,read_pres, read_hght, read_temp, read_dewp, read_wdir, read_wspd, NumberOfLines, read_lat, read_lon, read_year, read_month, read_day, read_hour, read_minute, instrument, min_lat, max_lat, min_lon, max_lon, delta_mins_minus, delta_mins_add, output_filename, min_lat_ind, max_lat_ind, min_lon_ind, max_lon_ind, delta_mins_minus_ind, delta_mins_add_ind, output_filename_ind) DEALLOCATE(remark2) DEALLOCATE(remark3) DEALLOCATE(read_pres) DEALLOCATE(read_hght) DEALLOCATE(read_temp) DEALLOCATE(read_dewp) DEALLOCATE(read_Wdir) DEALLOCATE(read_Wspd) END DO CLOSE(FileHandle) END SUBROUTINE ---------------------------------------------------------------------- SUBROUTINE readshiptempfile ---------------------------------------------------------------------- PURPOSE: This subroutine will Read in the data measured from the rawinsonde. ---------------------------------------------------------------------- SUBROUTINE readshiptempfile(debug, shiptempfile, instrument, min_lat, max_lat, min_lon, max_lon, delta_mins_minus, delta_mins_add, output_filename, min_lat_ind, max_lat_ind, min_lon_ind, max_lon_ind, delta_mins_minus_ind, delta_mins_add_ind, output_filename_ind) IMPLICIT NONE INTEGER*4 FileHandle INTEGER*4 stat file status CHARACTER(LEN=11) shiptempfile ship rawinsonde filename CHARACTER(LEN=3) instrument instrument indentifier INTEGER*4 i Counter in the z-direction INTEGER*4 station_no Station Number INTEGER*4 station_hgt Station Hieght INTEGER*4 read_lat Latitude [degree*100] INTEGER*4 read_lon Longitude [degree*100] INTEGER*4 read_year Year INTEGER*4 read_month Month INTEGER*4 read_day Day INTEGER*4 past_hour Concatination by the hour var INTEGER*4 read_hour Hour INTEGER*4 past_minute Concatinate variable INTEGER*4 read_minute Minute -10-

INTEGER*4 redovar Var to read catted files INTEGER*4 read_record Total number of logical record INTEGER*4 NumberOfLines Actual number of data lines INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_pres Pressure INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_hght Height INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_temp Temperature INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_dewp Dewpoint INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_wdir Wind Dir INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_wspd Wind speed CHARACTER(LEN=3), ALLOCATABLE, DIMENSION(:) :: remark1 pres flag INTEGER*4, ALLOCATABLE, DIMENSION(:) :: remark2 var flag INTEGER*4, ALLOCATABLE, DIMENSION(:) :: remark3 Wspd flag Command line variables REAL*4 min_lat, max_lat User specified lat BC REAL*4 min_lon, max_lon User specified lon BC INTEGER*4 delta_mins_minus, delta_mins_add User specified time BC CHARACTER(LEN=20) output_filename User specified output filename Command line indicators LOGICAL min_lat_ind, max_lat_ind LOGICAL min_lon_ind, max_lon_ind LOGICAL delta_mins_minus_ind, delta_mins_add_ind LOGICAL output_filename_ind INTEGER*4 debug Debug level Formating statements 1000 FORMAT (3x, I5, 4x, 2I5, 2x, 5I2, I3) 2000 FORMAT (A2, 2I5, I2, I4, I2, I4, I2, 2I3, I2, 3x) 3000 FORMAT (37x) Start of the subroutine: opening and reading in the data into their respective variables and arrays. FileHandle = 11 redovar = 0 past_hour = 0 past_minute = 0 OPEN(UNIT=FileHandle,FILE=shiptempFile,ACTION='READ', IOSTAT=stat) IF (stat==0) THEN DO This line in the code will read in the header, and it sets up the the rest of the code. READ(FileHandle, 1000, END = 10) station_no, read_lat, read_lon, read_year, read_month, read_day, read_hour, read_minute, read_record This loop will ensure to keep reading a concatinated file and packages the *.snd files per hour. 10 IF (read_hour.ne. past_hour) THEN past_hour = read_hour read_minute = past_minute There is data from the instrument that cannot be injested into the model, however the read_record includes those lines as well. Thus the NumberOfLines variable sets the number of lines to read that contains data useful to the model. NumberOfLines = read_record - 2-11-

Allocate the arrays by the length of the data that is useful for the model. Since the remark2 variable is used for three different variables it gets allocated accordingly. ALLOCATE(remark1(NumberOfLines)) ALLOCATE(remark2(3*NumberOfLines)) ALLOCATE(remark3(NumberOfLines)) ALLOCATE(read_pres(NumberOfLines)) ALLOCATE(read_hght(NumberOfLines)) ALLOCATE(read_temp(NumberOfLines)) ALLOCATE(read_dewp(NumberOfLines)) ALLOCATE(read_Wdir(NumberOfLines)) ALLOCATE(read_Wspd(NumberOfLines)) This is the part of the code that does the actual reading in of the data (useful and useless). DO i = 1, NumberOfLines, 1 READ(FileHandle,2000, END = 20) remark1(i), read_pres(i), read_hght(i), remark2(3*i-2), read_temp(i), remark2(3*i-1), read_dewp(i), remark2(3*i), read_wdir(i), read_wspd(i), remark3(i) 20 CONTINUE END DO READ(FileHandle,3000, IOSTAT = redovar) This is a set of conditions for the code to exit if it has reached the end of the file or something is wrong with the input data, if not, continue running within the do loop. IF (redovar > 0) THEN... something wrong... WRITE(*,*) "ERROR: Something is wrong with the data file." EXIT IF (redovar < 0) THEN... end of file reached... EXIT... do normal stuff... Call on the subroutine to convet the units from what was read in to what the model requires. CALL UnitConverter(debug,station_no,station_hgt,read_pres, read_hght, read_temp, read_dewp, read_wdir, read_wspd, NumberOfLines, read_lat, read_lon, read_year, read_month, read_day, read_hour, read_minute, instrument, min_lat, max_lat, min_lon, max_lon, delta_mins_minus, delta_mins_add, output_filename, min_lat_ind, max_lat_ind, min_lon_ind, max_lon_ind, delta_mins_minus_ind, delta_mins_add_ind, output_filename_ind) DEALLOCATE(remark1) DEALLOCATE(remark2) DEALLOCATE(remark3) DEALLOCATE(read_pres) DEALLOCATE(read_hght) DEALLOCATE(read_temp) DEALLOCATE(read_dewp) DEALLOCATE(read_Wdir) DEALLOCATE(read_Wspd) END DO -12-

CLOSE(FileHandle) END SUBROUTINE ---------------------------------------------------------------------- SUBROUTINE readdroptempfile ---------------------------------------------------------------------- PURPOSE: This subroutine will Read in the data measured from the dropsonde. ---------------------------------------------------------------------- SUBROUTINE readdroptempfile(debug, tempdropfile, instrument, min_lat, max_lat, min_lon, max_lon, delta_mins_minus, delta_mins_add, output_filename, min_lat_ind, max_lat_ind, min_lon_ind, max_lon_ind, delta_mins_minus_ind, delta_mins_add_ind, output_filename_ind) IMPLICIT NONE INTEGER*4 FileHandle INTEGER*4 stat file status CHARACTER(LEN=11) tempdropfile dropsonde filename CHARACTER(LEN=3) instrument instrument indentifier INTEGER*4 i Counter in the z-direction INTEGER*4 station_no Station Number INTEGER*4 station_hgt Station Hieght INTEGER*4 read_lat Latitude [degree*100] INTEGER*4 read_lon Longitude [degree*100] INTEGER*4 read_year Year INTEGER*4 read_month Month INTEGER*4 read_day Day INTEGER*4 past_hour Concatination by the hour var INTEGER*4 read_hour Hour INTEGER*4 past_minute Concatinate variable INTEGER*4 read_minute Minute INTEGER*4 redovar Var to read catted files INTEGER*4 read_record Total number of logical record INTEGER*4 NumberOfLines Actual number of data lines INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_pres Pressure INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_hght Height INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_temp Temperature INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_dewp Dewpoint INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_wdir Wind Dir INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_wspd Wind speed CHARACTER(LEN=3) EndOfFileChecker Checks for the end of file CHARACTER(LEN=3), ALLOCATABLE, DIMENSION(:) :: remark1 pres flag INTEGER*4, ALLOCATABLE, DIMENSION(:) :: remark2 var flag INTEGER*4, ALLOCATABLE, DIMENSION(:) :: remark3 Wspd flag INTEGER*4, ALLOCATABLE, DIMENSION(:) :: remark4 Wsfc flag Command line variables REAL*4 min_lat, max_lat User specified lat BC REAL*4 min_lon, max_lon User specified lon BC INTEGER*4 delta_mins_minus, delta_mins_add User specified time BC CHARACTER(LEN=20) output_filename User specified output filename Command line indicators LOGICAL min_lat_ind, max_lat_ind LOGICAL min_lon_ind, max_lon_ind LOGICAL delta_mins_minus_ind, delta_mins_add_ind LOGICAL output_filename_ind INTEGER*4 debug Formating statements Debug level -13-

1000 FORMAT (A3, 9x, 2I5, 2x, 5I2, I3) 2000 FORMAT (A2, 2I5, I2, I4, I2, I4, I2, 2I3, I2, I3) 3000 FORMAT (37x) Start of the subroutine: opening and reading in the data into their respective variables and arrays. FileHandle = 11 redovar = 0 past_hour = 0 past_minute = 0 OPEN(UNIT=FileHandle,FILE=tempdropFile,ACTION='READ', IOSTAT=stat) IF (stat==0) THEN DO This line in the code will read in the header, and it sets up the the rest of the code. READ(FileHandle, 1000, END =10) EndOfFileChecker, read_lat, read_lon, read_year, read_month, read_day, read_hour, read_minute, read_record This loop will ensure to keep reading a concatinated file and packages the *.snd files per hour. 10 IF (read_hour.ne. past_hour) THEN past_hour = read_hour read_minute = past_minute There is data from the instrument that cannot be injested into the model, however the read_record includes those lines as well. Thus the NumberOfLines variable sets the number of lines to read that contains data useful to the model. NumberOfLines = read_record - 5 Allocate the arrays by the length of the data that is useful for the model. Since the remark2 variable is used for three different variables it gets allocated accordingly. ALLOCATE(remark1(NumberOfLines)) ALLOCATE(remark2(3*NumberOfLines)) ALLOCATE(remark3(NumberOfLines)) ALLOCATE(remark4(NumberOfLines)) ALLOCATE(read_pres(NumberOfLines)) ALLOCATE(read_hght(NumberOfLines)) ALLOCATE(read_temp(NumberOfLines)) ALLOCATE(read_dewp(NumberOfLines)) ALLOCATE(read_Wdir(NumberOfLines)) ALLOCATE(read_Wspd(NumberOfLines)) This is the part of the code that does the actual reading in of the data (useful and useless). DO i = 1, NumberOfLines, 1 READ(FileHandle,2000, END = 20) remark1(i), read_pres(i), read_hght(i), remark2(3*i-2), read_temp(i), remark2(3*i-1), read_dewp(i), remark2(3*i), read_wdir(i), read_wspd(i), remark4(i), remark3(i) 20 END DO READ(FileHandle,3000, END = 30) -14-

30 READ(FileHandle,3000, END = 40) 40 READ(FileHandle,3000, END = 50) 50 READ(FileHandle,3000, IOSTAT = redovar) This is a set of conditions for the code to exit if it has reached the end of the file or something is wrong with the input data, if not, continue running within the do loop. IF (redovar > 0) THEN... something wrong... WRITE(*,*) "... Something is wrong with the data file..." EXIT IF (redovar < 0) THEN... end of file reached... EXIT... do normal stuff... Call on the subroutine to convet the units from what was read in to what the model requires. CALL UnitConverter(debug,station_no,station_hgt,read_pres, read_hght, read_temp, read_dewp, read_wdir, read_wspd, NumberOfLines, read_lat, read_lon, read_year, read_month, read_day, read_hour, read_minute, instrument, min_lat, max_lat, min_lon, max_lon, delta_mins_minus, delta_mins_add, output_filename, min_lat_ind, max_lat_ind, min_lon_ind, max_lon_ind, delta_mins_minus_ind, delta_mins_add_ind, output_filename_ind) DEALLOCATE(remark1) DEALLOCATE(remark2) DEALLOCATE(remark3) DEALLOCATE(remark4) DEALLOCATE(read_pres) DEALLOCATE(read_hght) DEALLOCATE(read_temp) DEALLOCATE(read_dewp) DEALLOCATE(read_Wdir) DEALLOCATE(read_Wspd) END DO CLOSE(FileHandle) END SUBROUTINE ---------------------------------------------------------------------- SUBROUTINE readtempfile ---------------------------------------------------------------------- PURPOSE: This subroutine will Read in the data measured from the rawinsonde. ---------------------------------------------------------------------- SUBROUTINE readtempfile(debug, tempfile, instrument, min_lat, max_lat, min_lon, max_lon, delta_mins_minus, delta_mins_add, output_filename, min_lat_ind, max_lat_ind, min_lon_ind, max_lon_ind, delta_mins_minus_ind, delta_mins_add_ind, output_filename_ind) -15-

IMPLICIT NONE INTEGER*4 FileHandle INTEGER*4 stat file status CHARACTER(LEN=11) tempfile rawinsonde filename CHARACTER(LEN=3) instrument instrument indentifier INTEGER*4 i Counter in the z-direction INTEGER*4 station_no Station Number INTEGER*4 station_hgt Station Hieght INTEGER*4 read_lat Latitude [degree*100] INTEGER*4 read_lon Longitude [degree*100] INTEGER*4 read_year Year INTEGER*4 read_month Month INTEGER*4 read_day Day INTEGER*4 past_hour Concatination by the hour var INTEGER*4 read_hour Hour INTEGER*4 past_minute Concatinate variable INTEGER*4 read_minute Minute INTEGER*4 redovar Var to read catted files INTEGER*4 read_record Total number of logical record INTEGER*4 NumberOfLines Actual number of data lines INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_pres Pressure INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_hght Height INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_temp Temperature INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_dewp Dewpoint INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_wdir Wind Dir INTEGER*4, ALLOCATABLE, DIMENSION(:) :: read_wspd Wind speed CHARACTER(LEN=3), ALLOCATABLE, DIMENSION(:) :: remark1 pres flag INTEGER*4, ALLOCATABLE, DIMENSION(:) :: remark2 var flag INTEGER*4, ALLOCATABLE, DIMENSION(:) :: remark3 Wspd flag Command line variables REAL*4 min_lat, max_lat User specified lat BC REAL*4 min_lon, max_lon User specified lon BC INTEGER*4 delta_mins_minus, delta_mins_add User specified time BC CHARACTER(LEN=20) output_filename User specified output filename Command line indicators LOGICAL min_lat_ind, max_lat_ind LOGICAL min_lon_ind, max_lon_ind LOGICAL delta_mins_minus_ind, delta_mins_add_ind LOGICAL output_filename_ind INTEGER*4 debug Debug level Formating statements 1000 FORMAT (3x, I5, I4, 2I5, 2x, 5I2, I3) 2000 FORMAT (A2, 2I5, I2, I4, I2, I4, I2, 2I3, I2, 3x) 3000 FORMAT (37x) Start of the subroutine: opening and reading in the data into their respective variables and arrays. FileHandle = 11 redovar = 0 past_hour = 0 past_minute = 0 OPEN(UNIT=FileHandle,FILE=tempFile,ACTION='READ',IOSTAT=stat) IF (stat==0) THEN DO This line in the code will read in the header, and it sets up the the rest of the code. READ(FileHandle, 1000, END = 10) station_no, station_hgt, read_lat, read_lon, read_year, read_month, read_day, read_hour, read_minute, read_record -16-

This loop will ensure to keep reading a concatinated file and packages the *.snd files per hour. 10 IF (read_hour.ne. past_hour) THEN past_hour = read_hour read_minute = past_minute There is data from the instrument that cannot be injested into the model, however the read_record includes those lines as well. Thus the NumberOfLines variable sets the number of lines to read that contains data useful to the model. NumberOfLines = read_record - 2 Allocate the arrays by the length of the data that is useful for the model. Since the remark2 variable is used for three different variables it gets allocated accordingly. ALLOCATE(remark1(NumberOfLines)) ALLOCATE(remark2(3*NumberOfLines)) ALLOCATE(remark3(NumberOfLines)) ALLOCATE(read_pres(NumberOfLines)) ALLOCATE(read_hght(NumberOfLines)) ALLOCATE(read_temp(NumberOfLines)) ALLOCATE(read_dewp(NumberOfLines)) ALLOCATE(read_Wdir(NumberOfLines)) ALLOCATE(read_Wspd(NumberOfLines)) This is the part of the code that does the actual reading in of the data (useful and useless). DO i = 1, NumberOfLines, 1 READ(FileHandle,2000, END = 20) remark1(i), read_pres(i), read_hght(i), remark2(3*i-2), read_temp(i), remark2(3*i-1), read_dewp(i), remark2(3*i), read_wdir(i), read_wspd(i), remark3(i) 20 CONTINUE END DO READ(FileHandle,3000, IOSTAT = redovar) This is a set of conditions for the code to exit if it has reached the end of the file or something is wrong with the input data, if not, continue running within the do loop. IF (redovar > 0) THEN... something wrong... WRITE(*,*) "ERROR: Something is wrong with the data file." EXIT IF (redovar < 0) THEN... end of file reached... EXIT... do normal stuff... Call on the subroutine to convet the units from what was read in to what the model requires. CALL UnitConverter(debug,station_no,station_hgt,read_pres, read_hght, read_temp, read_dewp, read_wdir, read_wspd, NumberOfLines, read_lat, read_lon, read_year, read_month, read_day, read_hour, read_minute, instrument, min_lat, max_lat, min_lon, max_lon, delta_mins_minus, -17-

delta_mins_add, output_filename, min_lat_ind, max_lat_ind, min_lon_ind, max_lon_ind, delta_mins_minus_ind, delta_mins_add_ind, output_filename_ind) DEALLOCATE(remark1) DEALLOCATE(remark2) DEALLOCATE(remark3) DEALLOCATE(read_pres) DEALLOCATE(read_hght) DEALLOCATE(read_temp) DEALLOCATE(read_dewp) DEALLOCATE(read_Wdir) DEALLOCATE(read_Wspd) END DO CLOSE(FileHandle) END SUBROUTINE ---------------------------------------------------------------------- SUBROUTINE UnitConverter ---------------------------------------------------------------------- PURPOSE: This subroutine coverts the data into the units needed for assimulation into the ARPS model. The variables with the prefix read_ contained the original data provided by the temp file in their original units. Whereas, the variables with the prefix output_ contain the data modified from the temp file into the units needed for ARPS5.3.0 3dvar. ---------------------------------------------------------------------- SUBROUTINE UnitConverter(debug,station_no,station_hgt,read_pres, read_hght, read_temp, read_dewp, read_wdir, read_wspd, NumberOfLines, read_lat, read_lon, read_year, read_month, read_day, read_hour, read_minute, instrument, min_lat, max_lat, min_lon, max_lon, delta_mins_minus,delta_mins_add, output_filename, min_lat_ind, max_lat_ind, min_lon_ind, max_lon_ind, delta_mins_minus_ind, delta_mins_add_ind, output_filename_ind) IMPLICIT NONE CHARACTER(LEN=20) OutName *.snd filename variable CHARACTER(LEN=3) instrument instrument indentifier INTEGER*4 i Counter in the z-direction INTEGER*4 station_no station number INTEGER*4 station_hgt input station hieght REAL*4 output_station_hgt output station hieght INTEGER*4 NumberOfLines number of data in the vertical INTEGER*4 ActualLines actual number of data INTEGER*4 read_lat Latitude [degree*100] INTEGER*4 read_lon Longitude [degree*100] INTEGER*4 read_year year INTEGER*4 read_month month INTEGER*4 read_day day INTEGER*4 read_hour hour INTEGER*4 read_minute minute -18-

REAL*4 output_lat Latitude [degree] REAL*4 output_lon Longitude [degree] INTEGER*4, DIMENSION(NumberOfLines) :: read_pres Pressure INTEGER*4, DIMENSION(NumberOfLines) :: read_hght Hieght INTEGER*4, DIMENSION(NumberOfLines) :: read_temp Temperature INTEGER*4, DIMENSION(NumberOfLines) :: read_dewp Dewpoint INTEGER*4, DIMENSION(NumberOfLines) :: read_wdir Wind dir INTEGER*4, DIMENSION(NumberOfLines) :: read_wspd Wind spd REAL*4, DIMENSION(NumberOfLines) :: output_pres Pressure REAL*4, DIMENSION(NumberOfLines) :: output_temp Temperature REAL*4, DIMENSION(NumberOfLines) :: output_dewp Dewpoint REAL*4, DIMENSION(NumberOfLines) :: output_wdir Wind Dir REAL*4, DIMENSION(NumberOfLines) :: output_wspd Wind Speed REAL*4, DIMENSION(NumberOfLines) :: output_hght Hieght Command line variables REAL*4 min_lat, max_lat User specified lat BC REAL*4 min_lon, max_lon User specified lon BC INTEGER*4 delta_mins_minus, delta_mins_add User specified time BC CHARACTER(LEN=20) output_filename User specified output filename Command line indicators LOGICAL min_lat_ind, max_lat_ind LOGICAL min_lon_ind, max_lon_ind LOGICAL delta_mins_minus_ind, delta_mins_add_ind LOGICAL output_filename_ind LOGICAL datum Data does(n't) fit the date range INTEGER*4 debug Debug level Simple unit and variable types conversions. output_lat = read_lat/100. output_lon = read_lon/100. output_station_hgt = station_hgt*1. output_hght = read_hght output_pres = read_pres/10. output_temp = read_temp/10. DO i = 1, NumberofLines, 1 IF (read_dewp(i) == -999) THEN output_dewp(i) = -999. else output_dewp(i) = (read_temp(i) - ABS(read_dewp(i)))/10. END DO output_wdir = read_wdir output_wspd = read_wspd Change missing data which is represented one way in the temp file into the -999., which is required for the model. ActualLines = 0 DO i = 1, NumberofLines, 1 IF (output_pres(i) == -999.9) THEN output_pres(i) = -999. ENDDO DO i = 1, NumberofLines, 1 IF (output_hght(i) == -9999.) THEN output_hght(i) = -999. ActualLines = ActualLines + 1 ENDDO -19-

DO i = 1, NumberofLines, 1 IF (output_temp(i) == -99.9) THEN output_temp(i) = -999. output_dewp(i) = -999. ENDDO DO i = 1, NumberofLines, 1 IF (output_wspd(i) == -99.) THEN output_wspd(i) = -999. ENDDO DO i = 1, NumberofLines, 1 IF (output_wdir(i) == -99.) THEN output_wdir(i) = -999. ENDDO This calls a subroutine that creates the name of the *.snd file and stores it in the OutName variable. CALL createoutname(read_year, read_month, read_day, read_hour, read_minute, delta_mins_minus, delta_mins_add, delta_mins_minus_ind, delta_mins_add_ind, OutName, datum) This calls a subroutine that creates the *.snd file and inputs all the data necessary for data assimulation. CALL outputintoascii(debug, station_no, output_station_hgt, NumberOfLines, ActualLines,output_lat, output_lon, output_pres, output_hght, output_temp, output_dewp,output_wdir, output_wspd, OutName, instrument, min_lat, max_lat, min_lon, max_lon, output_filename, min_lat_ind, max_lat_ind, min_lon_ind, max_lon_ind, output_filename_ind, datum) RETURN ENDSUBROUTINE ----------------------------------------------------------------------- SUBROUTINE createoutname ----------------------------------------------------------------------- PURPOSE: Creates the name of the *.snd file and returns the name back in the OutName variable. ----------------------------------------------------------------------- SUBROUTINE createoutname(year, month, day, hour, minute, mins_minus, mins_add, mins_minus_ind, mins_add_ind, OutName, datum) IMPLICIT NONE CHARACTER(LEN=20) OutName *.snd filename variable CHARACTER(LEN=2) centurychar 19/20 century INTEGER*4 filehandle -20-

INTEGER*4 startyear, year INTEGER*4 startmonth, month INTEGER*4 startday, day INTEGER*4 starthour, hour INTEGER*4 startminute, minute Command line variables INTEGER*4 mins_minus, mins_add User specified time BC Command line indicators LOGICAL mins_minus_ind, mins_add_ind, datum delta dates INTEGER*4 yearminusone, yearplusone INTEGER*4 monthminusone, monthplusone INTEGER*4 dayminusone, dayplusone INTEGER*4 hourminusone, hourplusone INTEGER*4 minuteminusone, minuteplusone OutName variable format 200 FORMAT(A21,2(I2.2,A),I4,A,2I2) 880 FORMAT(A4,I4.4,4(I2.2),A4) Calculates what century the data is from. IF(year >= 50) THEN centurychar = "19" centurychar = "20" filehandle = 12 OPEN(UNIT=fileHandle, FILE='yearfile') WRITE(fileHandle,'(A2,I2.2)') centurychar, year CLOSE(fileHandle) filehandle = 13 OPEN(UNIT=fileHandle, FILE='yearfile') READ(UNIT=fileHandle,"(I4)") year CLOSE(UNIT=fileHandle, DISP='DELETE') Check to see if the data fits the specified time window, if not then data will not be plotted in the end as datum will equal.false.. startyear = year startmonth = month startday = day starthour = hour startminute = minute datum =.FALSE. CALL timeminusone(year, month, day, hour, minute, mins_minus, mins_minus_ind, yearminusone, monthminusone, dayminusone, hourminusone, minuteminusone) CALL timeplusone(year, month, day, hour, minute, mins_add, mins_add_ind, yearplusone, monthplusone, dayplusone, hourplusone, minuteplusone) IF (startyear.le. yearplusone.and. startyear.ge. yearminusone) THEN IF (startmonth.le. monthplusone.and. startmonth.ge. monthminusone) THEN IF (startmonth == 1) THEN CONTINUE Error Check datum=.false. -21-

WRITE (*,200) ' DATA OMITTED on ',startmonth,'/', startday,'/',startyear,'/',starthour, startminute WRITE(*,*) " becuase t < +/- 1 month" IF (startday.le. dayplusone.and. startday.ge. dayminusone)then IF (startday == 1) THEN CONTINUE Error Check datum=.false. WRITE (*,200) ' DATA OMITTED on ',startmonth,'/', startday,'/',startyear,'/',starthour, startminute WRITE(*,*) " becuase t < +/- 1 day" IF (starthour.le. hourplusone.and. starthour.ge. hourminusone) THEN IF (starthour == 0) THEN CONTINUE datum=.false. WRITE (*,200) ' DATA OMITTED on ',startmonth, '/', startday,'/',startyear,'/', starthour,startminute WRITE(*,*) " becuase t < +/-1 hour" IF ((startminute.le. minuteplusone.and. abs(startminute).le. 60-minuteminusone).OR. (starthour.eq. hourminusone.and. startminute.ge. minuteplusone)) THEN datum=.true. IF (startminute == 0) THEN continue Error Check datum=.false. WRITE (*,200) ' DATA OMITTED on ',startmonth,'/', startday,'/',startyear,'/',starthour, startminute WRITE(*,*) " becuase t < +/-60 minutes" Error Check datum=.false. WRITE (*,200) ' DATA OMITTED on ',startmonth,'/', startday,'/',startyear,'/',starthour, startminute WRITE(*,*) " becuase t < +/- 1 year" Data are placed by the hour, thus if we want all the data to be in one file per hour we must set the minutes to a set time. minute=0 Opens up a dummy file, which writes out the OutName variable, which is later on read into the variable. Once its done, this dummy file gets deleted. filehandle = 12 OPEN(UNIT=fileHandle, FILE='namefile') WRITE(fileHandle,880) "uair", year, month, day, hour, minute, ".snd" -22-

CLOSE(fileHandle) filehandle = 13 OPEN(UNIT=fileHandle, FILE='namefile') READ(fileHandle,"A20") OutName CLOSE(UNIT=fileHandle, DISP='DELETE') RETURN ENDSUBROUTINE ----------------------------------------------------------------------- SUBROUTINE timeminusone ----------------------------------------------------------------------- PURPOSE: This subroutine will calcuate the correct time given the user specified time interval. Default is set to plus or minus one hour. ----------------------------------------------------------------------- SUBROUTINE timeminusone(startyear, startmonth, startday, starthour, startminute, mins_minus, mins_minus_ind, yearminusone, monthminusone, dayminusone, hourminusone, minuteminusone) IMPLICIT NONE INTEGER*4 startyear, year, yearminusone INTEGER*4 startmonth, month, monthminusone INTEGER*4 startday, day, dayminusone INTEGER*4 starthour, hour, hourminusone INTEGER*4 startminute, minute, minuteminusone Command line variables INTEGER*4 mins_minus User specified time BC Command line indicators LOGICAL mins_minus_ind User specified time BC indicator year = startyear month = startmonth day = startday hour = starthour minute = startminute IF (mins_minus_ind.eq..false.) THEN IF (hour == 0) THEN hour = 23 day = day - 1 hour = hour - 1 minute = 00 IF (hour == 0) THEN hour = 23 day = day - 1 hour = hour - 1 minute = 60 - mins_minus -23-

If we were to subtract 1 hour it could easily change the day, month, or year. The code below will allow us to subtract one hour properly. IF (day == 0.AND. hour == 23) THEN IF (month == 1) THEN month = 12 day = 31 year = year - 1 IF (month == 3) THEN month = 2 IF(MOD(year,4) == 0.OR. MOD(year,100) == 0.OR. (MOD(year,400) == 0.OR. MOD(year,100) == 0)) THEN Leap Year day = 29 day = 28 IF (month == 5.OR. month == 7.OR. month == 8.OR. month == 10.OR. month == 12) THEN month = month - 1 day = 30 IF (month == 2.OR. month == 4.OR. month == 6.OR. month == 9.OR. month == 11) THEN month = month - 1 day = 31 yearminusone = year monthminusone = month dayminusone = day hourminusone = hour minuteminusone = minute RETURN ENDSUBROUTINE ----------------------------------------------------------------------- SUBROUTINE timeplusone ----------------------------------------------------------------------- PURPOSE: This subroutine will calcuate the correct time given the user specified time interval. Default is set to plus or minus one hour. ----------------------------------------------------------------------- SUBROUTINE timeplusone(startyear, startmonth, startday, starthour, startminute, mins_plus, mins_plus_ind, yearplusone, monthplusone, dayplusone, hourplusone, minuteplusone) IMPLICIT NONE INTEGER*4 startyear, year, yearplusone INTEGER*4 startmonth, month, monthplusone INTEGER*4 startday, day, dayplusone INTEGER*4 starthour, hour, hourplusone INTEGER*4 startminute, minute, minuteplusone Command line variables INTEGER*4 mins_plus User specified time BC Command line indicators LOGICAL mins_plus_ind User specified time BC indicator -24-

year = startyear month = startmonth day = startday hour = starthour minute = startminute IF (mins_plus_ind.eq..false.) THEN IF (hour.eq. 23) THEN hour = 00 day = day + 1 hour = hour + 1 minute = 00 IF (hour.eq. 23) THEN hour = 00 day = day + 1 hour = hour + 1 minute = mins_plus If we were to add 1 hour it could easily change the day, month, or year. The code below will allow us to add one hour properly. IF (day == 31.AND. hour == 00) THEN IF (month == 12) THEN month = 1 day = 1 year = year + 1 IF (month == 2) THEN month = 2 IF(MOD(year,4).EQ. 0.OR. MOD(year,100).NE. 0.OR. (MOD(year,400).EQ. 0.OR. MOD(year,100).EQ. 0)) THEN Leap Year day = 29 month = 3 day = 1 IF (month == 1.OR. month == 3.OR. month == 5.OR. month == 7.OR. month == 8.OR. month == 10) THEN month = month + 1 day = 1 IF (month == 4.OR. month == 6.OR. month == 9.OR. month == 11) THEN month = month + 1 day = 1 yearplusone = year monthplusone = month dayplusone = day hourplusone = hour minuteplusone = minute RETURN ENDSUBROUTINE ----------------------------------------------------------------------- -25-

SUBROUTINE outputintoascii ----------------------------------------------------------------------- PURPOSE: This subroutine outputs the data into an *.snd file. ----------------------------------------------------------------------- SUBROUTINE outputintoascii(debug, station_no, station_hgt, NumberOfLines, Actual,lat,lon,pres,hgt, temp, dewp, Wdir, Wspd, OutName, instrument, min_lat, max_lat, min_lon, max_lon, output_filename, min_lat_ind, max_lat_ind, min_lon_ind, max_lon_ind, output_filename_ind, datum) IMPLICIT NONE INTEGER*4 i Counter in the z-direction INTEGER*4 filehandle INTEGER*4 station_no station number REAL*4 station_hgt station height INTEGER*4 NumberOfLines number of line of useful data INTEGER*4 Actual actual number of lines in data CHARACTER(LEN=20) OutName *.snd filename variable CHARACTER(LEN=3) instrument REAL*4 lat Latitude [degree] REAL*4 lon Longitude [degree] REAL*4, DIMENSION(NumberOfLines) :: pres Pressure [mb] REAL*4, DIMENSION(NumberOfLines) :: hgt Height [gpm] REAL*4, DIMENSION(NumberOfLines) :: temp Temperature [C] REAL*4, DIMENSION(NumberOfLines) :: dewp Dewpoint [C] REAL*4, DIMENSION(NumberOfLines) :: Wdir Wind Dir [deg] REAL*4, DIMENSION(NumberOfLines) :: Wspd Wind Speed [m/s] Command line variables REAL*4 min_lat, max_lat User specified lat BC REAL*4 min_lon, max_lon User specified lon BC INTEGER*4 delta_mins_minus, delta_mins_add User specified time BC CHARACTER(LEN=20) output_filename User specified output filename Command line indicators LOGICAL min_lat_ind, max_lat_ind LOGICAL min_lon_ind, max_lon_ind LOGICAL output_filename_ind LOGICAL datum Data does(n't) fit the date range INTEGER*4 debug Debug level Formating statements for the *.snd file. FORMAT 860 is for the header, while FORMAT 870 is for the body of data. 200 FORMAT(A18,F6.2,A2,F6.2,A) 860 FORMAT(2I12,f11.4,f15.4,F15.0,5x,A5,1x,A8) 870 FORMAT(6F10.2) Setting boundaries specified by the user if any. IF (min_lat_ind.eq..false.) THEN min_lat = -90.00 IF (max_lat_ind.eq..false.) THEN max_lat = 90.00 IF (min_lon_ind.eq..false.) THEN min_lon = -180.00 IF (max_lon_ind.eq..false.) THEN max_lon = 180.00-26-

IF (output_filename_ind.eq..true.) THEN OutName = output_filename Opening and writing into the file the header and body of data, and append data (only if it fits within an one hour time window). IF (datum.eq..true.) THEN IF (lat.gt. min_lat.and. lat.lt. max_lat.and. lon.gt. min_lon.and. lon.lt. max_lon ) THEN filehandle = 13 OPEN(UNIT=fileHandle,FILE=OutName,POSITION='APPEND') IF (instrument == "TMP") THEN WRITE(fileHandle,860) station_no, Actual, lat, lon,station_hgt, "intmp", "CWBRAWIN" DO i = 1, NumberOfLines, 1 IF (hgt(i) == -999.) THEN WRITE(fileHandle,870) hgt(i), pres(i), temp(i), dewp(i), Wdir(i), Wspd(i) ENDDO IF (debug == 9) THEN DO i = 1, NumberOfLines, 1 WRITE(*,860) station_no, NumberOfLines, lat, lon, station_hgt WRITE(*,870) hgt(i), pres(i), temp(i), dewp(i), END DO Wdir(i), Wspd(i) IF (instrument == "DRP") THEN station_no = 37678367 station_hgt = 0. WRITE(fileHandle,860) station_no, Actual, lat, lon,station_hgt, "indrp", "DROPWIND" DO i = 1, NumberOfLines, 1 IF (hgt(i) == -999.) THEN WRITE(fileHandle,870) hgt(i), pres(i), temp(i), dewp(i), Wdir(i), Wspd(i) ENDDO IF (debug == 9) THEN DO i = 1, NumberOfLines, 1 WRITE(*,860) station_no, NumberOfLines, lat, lon, station_hgt WRITE(*,870) hgt(i), pres(i), temp(i), dewp(i), END DO Wdir(i), Wspd(i) IF (instrument == "STP") THEN station_hgt = 0. WRITE(fileHandle,860) station_no, Actual, lat, lon,station_hgt, "instp", "SHIPDATA" DO i = 1, NumberOfLines, 1 IF (hgt(i) == -999.) THEN WRITE(fileHandle,870) hgt(i), pres(i), temp(i), dewp(i), Wdir(i), Wspd(i) -27-