How to convert FORTRAN subroutine to awk function?
Hi All I am trying to convert some Fortran subroutine to awk function , those who know kindly explain how to define function in awk, and how to call function
Fortran subroutine looks somewhat like this
output should result.
I just want to understand user defined function in awk here.
Last edited by Akshay Hegde; 04-05-2013 at 12:59 AM..
Reason: to modify body according to title.
Thanks My problem is I didn't understand awk function, I am new to shell scripting, if someone explains I hope I can convert it.
You would be well advised to follow PikK45's advice to look up an algorithm that works to calculate the Gregorian date from an astronomical Julian day number. The algorithm you originally posted in this thread doesn't work.
The only tricks to converting a FORTRAN subroutine to an awk function are to realize that awk performs divisions using floating point while FORTRAN uses integer division when dividing an integer by an integer and that all variables in awk are global except those declared to be local to a function (by including them in the function declaration arg list). (I use a tab (or two) between the input arguments that are required to be passed into the function to make it work and the list of local variables used by the function. If you don't like my convention for doing this, you should pick another method and use it consistently in any awk functions you write.)
You might also note that you had some variables (L and N) in your original FORTRAN code that were not declared.
The following awk script provides two awk functions (GDATE() and GDATE2()) that are straight translations of your original FORTRAN code and the algorithm specified by the page PikK45 suggested, respectively. If feeds two known astonomical Julian day numbers and prints the MONTH, DAY, and YEAR values set by both algorithms. The script is:
The output produced by this script is:
This User Gave Thanks to Don Cragun For This Post:
Hi,
I am having script which contains many functions. Need to print each function name at the starting of the function. Like below,
functionname()
{
echo "functionname"
commands....
}
I've tried like below,
func=`grep "()" scriptname | cut -d "(" -f1`
for i in $func
do
nawk -v... (4 Replies)
I have a fortran file with code declarations such as
Subroutine str_tnum_tu &
( &
s, dl, tu, pos &
)
!
Class (*), Intent (InOut) :: tu(:)
Character (Len=*), Intent (In) :: s, dl
Character (Len=*), Intent (In), Optional :: pos
...
or
... (11 Replies)
I have the following code that counts the number
of consecuitive logicals from the first one.
Any way I can simplify this function?
Function count_present &
( &
p1, p2, p3, p4, p5, p6, p7, p8 &
) ... (4 Replies)
I've found a few posts regarding passing parameters to a function or subroutine, but for some reason when I try to run a command based on part with these parameters it's not working. If I have the function echo the parameters they show correctly so I believe they are being passed right but the... (2 Replies)
Okay I have a 1TB drive that is almost completely full with vids. I am in the process of converting them to mp4. I have two scripts right now. One is a shell script to convert them with Handbrake. The other is a script to get a sort of progress report. To make things easier to understand, I will... (0 Replies)
hi all,
i need a c++ function which converts a linear list to circular.
presently i am working with two files. i.e., one linear list file. and one circular list file to do some operations. i thought it will be helpful if there is a function that converts a linear list to circular n undo the... (1 Reply)
Actually I got a list of file end with *.txt
I want to use the same command apply to all the *.txt
Thus I try to find out the fastest way to write those same command in a script and then want to let them run automatics.
For example:
I got the file below:
file1.txt
file2.txt
file3.txt... (4 Replies)
Hi All
I am new to perl so had one question.
I have one Subroutine which works as expected and below is just an example.
where I ran a command and check the output.
so my question is if I have more than one command then how to check the results, meaning I want to add more command and check... (2 Replies)
I have issue running functions under case statement
#!/bin/bash
single() {
Commands
}
multiple() {
Commands
}
until ; do
echo -e " \t \t M A I N - M E N U Perforce delete script \n" (1 Reply)