INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Fortran/NOAA data

Fortran/NOAA data

(OP)
Hi,

I'm trying to access public data from NOAA (precipitation data for Africa). They provided sample code to read the data (.bin) and transform it to usable .txt data. However, for some reason, I have not been able to get the code to work. The input data is from:
ftp://ftp.cpc.ncep.noaa.gov/fews/fewsdata/africa/r...

Just have to unzip it.

PROGRAM convert_rfe_bin2asc

c cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c Program: convert_rfe2.f
c
c Description: This program reads in a daily RFE (rainfall estimate) file
c (version 2) in .bin format and creates an ascii integer
c file. Each file contains rfe coordinate data ordered by rows.
c Rainfall resolution is 0.1 degree with a domain of
c 20W-55E, 40S-40N.
c
c Inputs: 'input_file' = the binary precip file to be converted
c
c Output: 'output.txt' = the output ascii converted text file
c
c
c cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

REAL*4 rfe(751,801),arr(3,601551)
real*4 lat,lon
INTEGER:: i,j,ind
character*30:: input_file

c ##### CHANGE FILE NAME BELOW TO INPUT FILE #####

input_file="all_products.bin.20100621"

c ##################################################

c ##### Initialize the arrays #####
do i = 1,751
do j = 1,801
rfe (i,j) = -999
end do
end do

c ##### Read in the input rainfall data #####
open (unit=22,file=input_file,access="direct",
1 convert='big_endian',status="old",recl=751*801*4)
read (22, rec=1) rfe

c ##### Open the output file #####
open (88,file="output.txt",access='sequential',
1 status='unknown',form='formatted')

c ##### The next code converts the input rainfall data. Each row is then written
c to the output file.

ind=1
lat= -40.0
lon= -20.0
do j=1,801
do i=1,751
arr(1,ind)=lat
arr(2,ind)=lon
arr(3,ind)=rfe(i,j)

write (88,499) arr(1,ind), arr(2,ind), arr(3,ind)
499 format(1X,f6.2,1X,f6.2,1X,f8.2)

ind=ind+1
lon=lon+0.1
end do
lat=lat+0.1
lon=-20.0
end do

END PROGRAM

RE: Fortran/NOAA data

"not been able to get it to work" is not enough at all, please explain in detail what exactly you are doing and what exactly is happening that you don't like, etc.

By the way, I compiled your program, run it and seemed to worked just fine...here are the first few lines of the output file generated:

CODE

-40.00 -20.00     6.61
-40.00 -19.90     5.99
-40.00 -19.80     6.61
-40.00 -19.70     7.24
-40.00 -19.60     8.11
-40.00 -19.50     8.98
-40.00 -19.40     6.11
-40.00 -19.30     5.86
-40.00 -19.20     4.87 

RE: Fortran/NOAA data

(OP)
Thank you; I got it to work as well. It was actually due to windows not recognizing the unzipped files as .bin, so something completely unrelated. Thanks

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close