AWK processing of a three-column file

I have a 3-column data file, for which I wish to print certain parts of $3

PHI         PSI       A(x)
-177.5 -177.5 1.0625
-177.5 -172.5 0.55
-177.5  -167.5 0.0478125
-177.5 -162.5 0
-177.5 -157.5 0.284375
-177.5  -152.5 0.187188
-177.5 -147.5 0.236875
-177.5 -142.5 0.383438
-177.5  -137.5 0.720938
-177.5 -132.5 1.11906
-177.5 -127.5 1.47406
-177.5  -122.5 1.61094
-177.5 -117.5 1.81344
-177.5 -112.5 1.96156
-177.5  -107.5 2.11969
-177.5 -102.5 2.23438
-177.5 -97.5 2.38438
-177.5  -92.5 2.53969
-177.5 -87.5 2.46938
-177.5 -82.5 2.64406
-177.5  -77.5 2.84781
-177.5 -72.5 2.79375
-177.5 -67.5 3.25781
-177.5  -62.5 3.48031
-177.5 -57.5 3.975
-177.5 -52.5 4.30406
-177.5  -47.5 4.79688
-177.5 -42.5 5.21844
-177.5 -37.5 5.88375
-177.5  -32.5 6.56906
-177.5 -27.5 7.15531
-177.5 -22.5 7.75125
-177.5  -17.5 8.38563
-177.5 -12.5 8.92563
-177.5 -7.5 9.37313
-177.5  -2.5 9.9325
-177.5 2.5 10.6044
-177.5 7.5 10.6159

...
until +180

I want to access a certain range of the data, e.g. print $3 when the following conditions are met:
PHI 50 to 100 and PSI -70 to -90

which would give the following data:

52.5 -87.5  4.61531
52.5 -82.5 4.59969
52.5 -77.5 4.45344
52.5 -72.5 4.245

57.5  -87.5 4.24344
57.5 -82.5 4.0775
57.5 -77.5 3.90438
57.5 -72.5  3.86375

62.5 -87.5 3.84125
62.5 -82.5 3.76875
62.5 -77.5  3.63406
62.5 -72.5 3.39844

67.5 -87.5 3.73563
67.5 -82.5  3.65938
67.5 -77.5 3.60906
67.5 -72.5 3.31

72.5 -87.5  3.73688
72.5 -82.5 3.61813
72.5 -77.5 3.45938
72.5 -72.5  3.27969

77.5 -87.5 4.01219
77.5 -82.5 3.61063
77.5 -77.5  3.555
77.5 -72.5 3.43531

82.5 -87.5 4.32906
82.5 -82.5  4.00188
82.5 -77.5 3.83781
82.5 -72.5 4.08438

87.5 -87.5  4.89344
87.5 -82.5 4.60594
87.5 -77.5 4.6525
87.5 -72.5 4.54781

92.5  -87.5 5.455
92.5 -82.5 5.32375
92.5 -77.5 5.18188
92.5 -72.5  5.35219

97.5 -87.5 6.19656
97.5 -82.5 6.05938
97.5 -77.5  6.01063
97.5 -72.5 6.30094

Then I want to post-process this data
Any help here?

Try:

awk '$1>=50&&$1<=100&&$2>=-90&&$2<=-70' file

Ok, thanks, now my output data is of the form:

4.61531
4.59969
4.45344
4.245
4.24344
4.0775
3.90438
3.86375
3.84125
3.76875
3.63406
3.39844
3.73563
3.65938
3.60906
3.31
3.73688
3.61813
3.45938
....etc...

and I have called the two data files I have c7eq.dat (dimension 25:1) and c7ax.dat (dimension 41:1)

In my Fortran program I wish to process this data:

Program average_2
      implicit none
      double precision, dimension (25:1) :: H
      double precision, dimension (41:1) :: G

      open (unit=2, file="c7eq.dat", form="unformatted")
      read (2) G
      open (unit=3, file="c7ax.dat", form="unformatted")
      read (3) H

However I get the error:
forrtl: severe (24): end-of-file during read, unit 2, file /home/guest/c7eq.dat

Anyone can help me here?

---------- Post updated at 10:31 AM ---------- Previous update was at 09:06 AM ----------

The error further says

Image PC Routine Line Source
Exercise8.exe 08088DE2 Unknown Unknown Unknown
Exercise8.exe 08087D59 Unknown Unknown Unknown
Exercise8.exe 08087CD5 Unknown Unknown Unknown
Exercise8.exe 0805FB82 Unknown Unknown Unknown
Exercise8.exe 0805F8B2 Unknown Unknown Unknown
Exercise8.exe 0805568F Unknown Unknown Unknown
Exercise8.exe 08049DCC Unknown Unknown Unknown
Exercise8.exe 08049BE9 Unknown Unknown Unknown
libc.so.6 F7C1C390 Unknown Unknown Unknown
Exercise8.exe 08049B11 Unknown Unknown Unknown

Hi.

Are you sure that you have unformatted data? What do you think that means? ... cheers, drl

1 Like