Please bear with me on this because I'm really not a programmer at all but I need some help with modifying a code in fortran. This program is supposed to extract data for a single month of data at a time from the file highlighted in red below which contains 108 years of data. First of all, I would like to be able to call forth that file automatically without having to type it in everytime. I tried to put in a 'write' line to do that but when it came up in the program run, it didn't have the backslashes.
Second, rather than getting one month at a time, I would like to get all the months from a given year in each output file.
Lastly, the part at the bottom highlighted in green is dealing with latitudes. I only want to get latitudes within a certain range, which I've already plugged in. however, for the values i.gt.8.5, I don't want them to be included, so what do I have to put on the right side of that part to make that happen. Thanks in advance for any help anyone can offer!
C INITIALIZE VARIABLES
datachk = 0
openfile = 0
loopcnt = 0
C ASK USER FOR INPUT GRID SET
write(*,*) 'Enter gridded dataset filename. '
C [color=Red] write(*,*) 'C:Program FilesForce 2.0grid_prcp_1900-2008.dat'[/color]
C OPEN INPUT FILE
openfile = 1
C GRIDDED FILENAME NOT VALID
500 do while(openfile .eq. 0)
write(*,*) 'Cannot open ',infile
write(*,*) 'Reenter gridded dataset filename.'
openfile = 1
C ASK USER FOR OUTPUT FILENAME
write(*,*) 'Enter output filename for gridded subset. '
C OPEN OUTPUT FILE
C ASK USER FOR MONTH AND YEAR TO EXTRACT
write(*,*) 'Enter month to extract',
*'- integer format (1=>Jan, 2=>Feb, etc.)'
write(*,*) 'Enter year to extract'
FMT100 = '(2i5)'
write(*,*) 'Enter type of data, 1==>temp, 2==>prcp'
FMT20 = '(12i5)'
FMT20 = '(12i7)'
C LOOP OVER ALL MONTHS AND YEARS UNTIL FIND REQUESTED DATA
do while(datachk .ne. 1)
read(10,FMT100,end=900) jmonth, jyear
loopcnt = loopcnt + 1
C IF FOUND, THEN READ IN GRIDDED DATA
if(imonth .eq. jmonth .and. iyear .eq. jyear) then
write(*,50) imonth, iyear
50 format(' Reading gridded data for month ', i2.2,
*' and year ',i4)
do i = 1,36
do j = 1,6
C SET BOOLEAN TO TRUE
datachk = 1
C NOT CORRECT MONTH AND YEAR, SO SKIP GRIDDED DATA FIELDS
110 format(' Searching for month ', i2.2, ' and year ',i4)
do i = 1,216
C WRITE DATA TO OUTPUT FILE
write(*,*)'Writing output data to file'
do i = 1,36
[color=Green] if(i.le.8.5) lat = 92.5 - i * 5.0
elseif(i.gt.8.5) lat = ((i-18) * (-5.0)) + 2.5[/color]
do j = 1,72
if(valu(i,j) .ne. -9999) then
if(j.le.36) lon = (182.5 - (j * 5.0)) * (-1)
if(j.gt.36) lon = ((j-36) * 5.0) - 2.5
C CLOSE INPUT AND OUTPUT FILES
GO TO 999
540 write(*,*) 'Cannot close ',infile
560 write(*,*) 'Cannot close output file'
900 write(*,*) 'Requested Data Not Available!!!!'
write(*,*) 'Sorry - Try Again. Exiting Program!!!!'