Automate reading of files using conread

Topics about the HYSPLIT dispersion model.
Post Reply
jacobkh
Posts: 2
Joined: July 21st, 2017, 9:38 pm
Registered HYSPLIT User: No

Automate reading of files using conread

Post by jacobkh » July 21st, 2017, 10:21 pm

Thanks for all your work on HYSPLIT.

I am trying to write my own scripts (in MATLAB) to run HYSPLIT and analyze the results. However, I am having trouble reading in the binary files. I have the PC version of HYSPLIT (Windows, Feb 2016, svn:802). The executable conread would work, except it requires user inputs (filename, Extended diagnostics (0/1), Enter) after it has started, which makes it difficult to put in a script. Is there some way to use conread with just 1 command line, similar to con2asc? I would prefer not to have to convert to another format if possible.

jacobkh
Posts: 2
Joined: July 21st, 2017, 9:38 pm
Registered HYSPLIT User: No

Re: Automate reading of files using conread

Post by jacobkh » July 27th, 2017, 11:26 pm

It turns out the source code for this executable is already included in the downloadable version of HYSPLIT (data2arl/utilities/conread.f). Looking at the code, there is no option natively to include all the input arguments on one line. However, I was able to solve this myself by modifying the code to accept the filename and turn on/off "Extended diagnostics" from a single line. Now I can read the binary files into MATLAB without any direct intervention (with MATLAB's "system" command).

I compiled conread.f using gfortran after some format modifications. Also to anyone else who may attempt their own modifications, you may need to explicitly specify CONVERT='BIG_ENDIAN' as an argument when opening the file (line 87 in the original).

I've attached my version (note it's actually a fortran source code file and you may need to change the extension if you use it). After compiling you can run using the "-h" argument to see help.
Attachments
conread_f.txt
NOTE: Actually a FORTRAN source code file, change the extension as appropriate and compile.
(12.18 KiB) Downloaded 5 times

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest