starlite79
Technical User
Good evening.
I am trying to modify an awk program I received tremendous help with in this awk forum. I am working with a fortran file, and I want to change the value of one array element (the tolerance) to some other value. I also want the program to print to file all other lines of the file.
Here is my code:
The values for the tolerance are changed to 1D-10, but those are the only lines which are printed. Could someone help with how to get the rest of the lines to print?
Here is my input file:
SUBROUTINE T_ARG ( STATUS )
*+
* - - - - - - - - - -
* T _ A R G
* - - - - - - - - - -
*
* Test ARG subroutine.
*
* Returned:
* STATUS LOGICAL .TRUE. = success, .FALSE. = fail
*
* Called: ARG, VVD.
*
* Last revision: 7 November 2008
*
*
*-
IMPLICIT NONE
LOGICAL STATUS
DOUBLE PRECISION ANGLE(11), DAY
INTEGER IYEAR
IYEAR = 08
DAY = 311.5
CALL ARG ( IYEAR, DAY, ANGLE )
CALL VVD ( ANGLE(1), 0.5785483804494191418D0, 1D-12, 'ARG',
. 'ANGLE1', STATUS )
CALL VVD ( ANGLE(2), 6.28318080000000023D0, 1D-12, 'ARG',
. 'ANGLE2', STATUS )
CALL VVD ( ANGLE(3), 5.897950576134803669D0, 1D-12, 'ARG',
. 'ANGLE3', STATUS )
CALL VVD ( ANGLE(4), 1.615958909210931438D0, 1D-12, 'ARG',
. 'ANGLE4', STATUS )
CALL VVD ( ANGLE(5), 2.378775781400364053D0, 1D-12, 'ARG',
. 'ANGLE5', STATUS )
CALL VVD ( ANGLE(6), 4.482957906228527634D0, 1D-12, 'ARG',
. 'ANGLE6', STATUS )
CALL VVD ( ANGLE(7), 3.904405018599632626D0, 1D-12, 'ARG',
. 'ANGLE7', STATUS )
CALL VVD ( ANGLE(8), 3.519174794734325928D0, 1D-12, 'ARG',
. 'ANGLE8', STATUS )
CALL VVD ( ANGLE(9), 1.037427808761705705D0, 1D-12, 'ARG',
. 'ANGLE9', STATUS )
CALL VVD ( ANGLE(10), 0.9637917514941207742D0, 1D-12, 'ARG',
. 'ANGLE10', STATUS )
CALL VVD ( ANGLE(11), 1.615972056390525324D0, 1D-12, 'ARG',
. 'ANGLE11', STATUS )
END
Here is the output I get so far (missing most of the lines):
CALL VVD ( ANGLE(1), 0.5785483804494191418D0, 1D-10, 'ARG',
CALL VVD ( ANGLE(2), 6.28318080000000023D0, 1D-10, 'ARG',
CALL VVD ( ANGLE(3), 5.897950576134803669D0, 1D-10, 'ARG',
CALL VVD ( ANGLE(4), 1.615958909210931438D0, 1D-10, 'ARG',
CALL VVD ( ANGLE(5), 2.378775781400364053D0, 1D-10, 'ARG',
CALL VVD ( ANGLE(6), 4.482957906228527634D0, 1D-10, 'ARG',
CALL VVD ( ANGLE(7), 3.904405018599632626D0, 1D-10, 'ARG',
CALL VVD ( ANGLE(8), 3.519174794734325928D0, 1D-10, 'ARG',
CALL VVD ( ANGLE(9), 1.037427808761705705D0, 1D-10, 'ARG',
CALL VVD ( ANGLE(10), 0.9637917514941207742D0, 1D-10, 'ARG',
CALL VVD ( ANGLE(11), 1.615972056390525324D0, 1D-10, 'ARG',
Thanks for looking.
I am trying to modify an awk program I received tremendous help with in this awk forum. I am working with a fortran file, and I want to change the value of one array element (the tolerance) to some other value. I also want the program to print to file all other lines of the file.
Here is my code:
Code:
# match CALL VVD anywhere on a line
/CALL VVD/ {
# split lines up by more than one commas
split($0,a,", +")
ind=a[1]
pred[ind]=a[2]
# if precision does not have "D" in it, append "D0"
if (prec[ind] !~ "D") {
prec[ind]=prec[ind]"D0"
}
oldtol=a[3]
newtol="1D-10"
# if the tolerance was not on this line, it
# must be on the next
if (oldtol == "") {
print
getline
n=split($0,a,", +")
oldtol=a[1]
# remove line continuation and white space
sub("[[:space:]:]*","",oldtol)
}
sub(oldtol,newtol)
print
next
}
# print any other lines in the Fortran input
FNR != NR { print }
The values for the tolerance are changed to 1D-10, but those are the only lines which are printed. Could someone help with how to get the rest of the lines to print?
Here is my input file:
SUBROUTINE T_ARG ( STATUS )
*+
* - - - - - - - - - -
* T _ A R G
* - - - - - - - - - -
*
* Test ARG subroutine.
*
* Returned:
* STATUS LOGICAL .TRUE. = success, .FALSE. = fail
*
* Called: ARG, VVD.
*
* Last revision: 7 November 2008
*
*
*-
IMPLICIT NONE
LOGICAL STATUS
DOUBLE PRECISION ANGLE(11), DAY
INTEGER IYEAR
IYEAR = 08
DAY = 311.5
CALL ARG ( IYEAR, DAY, ANGLE )
CALL VVD ( ANGLE(1), 0.5785483804494191418D0, 1D-12, 'ARG',
. 'ANGLE1', STATUS )
CALL VVD ( ANGLE(2), 6.28318080000000023D0, 1D-12, 'ARG',
. 'ANGLE2', STATUS )
CALL VVD ( ANGLE(3), 5.897950576134803669D0, 1D-12, 'ARG',
. 'ANGLE3', STATUS )
CALL VVD ( ANGLE(4), 1.615958909210931438D0, 1D-12, 'ARG',
. 'ANGLE4', STATUS )
CALL VVD ( ANGLE(5), 2.378775781400364053D0, 1D-12, 'ARG',
. 'ANGLE5', STATUS )
CALL VVD ( ANGLE(6), 4.482957906228527634D0, 1D-12, 'ARG',
. 'ANGLE6', STATUS )
CALL VVD ( ANGLE(7), 3.904405018599632626D0, 1D-12, 'ARG',
. 'ANGLE7', STATUS )
CALL VVD ( ANGLE(8), 3.519174794734325928D0, 1D-12, 'ARG',
. 'ANGLE8', STATUS )
CALL VVD ( ANGLE(9), 1.037427808761705705D0, 1D-12, 'ARG',
. 'ANGLE9', STATUS )
CALL VVD ( ANGLE(10), 0.9637917514941207742D0, 1D-12, 'ARG',
. 'ANGLE10', STATUS )
CALL VVD ( ANGLE(11), 1.615972056390525324D0, 1D-12, 'ARG',
. 'ANGLE11', STATUS )
END
Here is the output I get so far (missing most of the lines):
CALL VVD ( ANGLE(1), 0.5785483804494191418D0, 1D-10, 'ARG',
CALL VVD ( ANGLE(2), 6.28318080000000023D0, 1D-10, 'ARG',
CALL VVD ( ANGLE(3), 5.897950576134803669D0, 1D-10, 'ARG',
CALL VVD ( ANGLE(4), 1.615958909210931438D0, 1D-10, 'ARG',
CALL VVD ( ANGLE(5), 2.378775781400364053D0, 1D-10, 'ARG',
CALL VVD ( ANGLE(6), 4.482957906228527634D0, 1D-10, 'ARG',
CALL VVD ( ANGLE(7), 3.904405018599632626D0, 1D-10, 'ARG',
CALL VVD ( ANGLE(8), 3.519174794734325928D0, 1D-10, 'ARG',
CALL VVD ( ANGLE(9), 1.037427808761705705D0, 1D-10, 'ARG',
CALL VVD ( ANGLE(10), 0.9637917514941207742D0, 1D-10, 'ARG',
CALL VVD ( ANGLE(11), 1.615972056390525324D0, 1D-10, 'ARG',
Thanks for looking.