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
e p chandler

2007-04-29, 7:04 pm

On Apr 29, 10:47 am, smurray444 <smurray...@gmail.com> 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


I imagine that you have been staring at this too long. :-).

You are reading the data into array X. You need to copy the data to
the other arrays before printing out their contents. Your data will
not produce the output table your want using the given PRINT and
FORMAT, but at least you will know where the data is going.

HTH

-- elliot


Sponsored Links







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

Copyright 2008 codecomments.com