For Programmers: Free Programming Magazines  


Home > Archive > Fortran > April 2007 > Re: Fortran: creating a table and interpolating values









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Fortran: creating a table and interpolating values
smurray444

2007-04-26, 7:05 pm

Hi again - thanks for your efforts. Maybe the 6509 is a fault on my
part - I got this figure by looking at the data in Excel and seeing
that there were 6059 rows with latitude and longitude values in.
Regarding the 18 new values in each direction for each pair of values,
again this may be a calculation error on my part... I'm looking to
perform an interpolation so that the current data (at 1.5-degrees) is
reformatted to 5-minutes, so thought that in order to achieve this, 18
new values would need to be created in between a given existing pair.

I'm not aware of a way of uploading the input data file, if there is
then please let me know, as it would probably make things clearer if
you could see the whole dataset (although it's a continuation of that
listed above).

Please don't be afraid to continue asking for any further
clarification.

Thanks again,
smurray444


Louis Krupp

2007-04-30, 4:09 am

smurray444 wrote:
> Dear all,
>
> Many thanks for your help. I've attempted to construct a program based
> on my interpretations of your advice, but have come up against a
> series of errors upon compilation. These are mostly 'invalid first
> character at ^' errors, which appear for example under the the first
> letter of the commands 'PROGRAM', 'IMPLICIT', 'OPEN', 'READ', 'PRINT'
> and 'END'... so I'm not sure what I've done wrong there...
> The program to 'reformat' the data is as follows (obviously I can't
> move onto the interpolation stage before achieveing this):
>
> PROGRAM table
> IMPLICIT none
> DIMENSION DATA(73,83,102)
> DIMENSION TEMP(102)
> OPEN (4,file=transts.arunoff.out',status='old')
> READ (4,*)TEMP
> DATA (TEMP(I),I=4,102)
> PRINT*,TEMP
> END PROGRAM table
>
> Before initially messaging the group, I'd had a few other attempts at
> getting this to work, with one program successfully compiling without
> doing as I'd hoped it would! This is shown below:
>
> PROGRAM readone
> IMPLICIT none
> INTEGER numdata, I
> PARAMETER (numdata=6059)
> REAL table(6059,6059)
> REAL*8 x(105,numdata)
> REAL*8 lat(numdata), long(numdata), runoff(numdata,102)
> OPEN (4,file='transts.arunoff.out',status='old')
> READ (4,*) x
> DO I = 1,6059,1
> PRINT*,100,table,long,lat,runoff
> 100 FORMAT (F7.2,I4,F6.2,I4,F9.4)
> END DO
> END PROGRAM readone
>
> This program merely produces a seemingly endless series of zeros (0.)
> in 19 columns (even though I don't want 19 columns!). I can't seem to
> read the data in, in the correct format as hoped. I don't know if you
> think I'm anywhere close though, and if a combined approach of the two
> programs might be useful? As I said, I'm a complete beginner, picking
> up bits and pieces from textbooks and the internet and not really
> understanding some of the things I input (e.g. the '*8' in the command
> REAL*8 in the previous program!), so you know much better than me...!
>
> I hope by providing these details you will be able to help get this
> working for me, with any luck...
>
> Thanks again, and have a good w,
> smurray444
>


You might consider learning to walk before you try to run. Pick a book,
and read it from the beginning. Try doing something really simple in
Fortran, get that to work, and then move on to your real problem. In
the end, you'll save yourself time and stress.

Make sure you're using the compiler option that specifies free-form
source. The "invalid first character" messages sound like the compiler
is expecting fixed-form, with only statement numbers or comments allowed
in columns 1 through 5.

Also, as a matter of style (and maintainability), you might want to use
parameters for all of your constants.

Louis
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com