cdfjday - calculate julian date given year, month, and day in the Gregorian calendar.
cdfjday year-fld month-fld day-fld jday-fld [ref-year] [ref-month] [ref-day]
Cdfjday expects a candis file on the standard input. It writes a modified candis file to the standard output. Cdfjday calculates the julian date from information contained in the fields year-fld, month-fld, day-fld and puts the result in a new field called jday-fld. Jday-fld will have the same dimension names and dimension sizes as year-fld.
A few requirements are made of the date fields to keep the program simple and robust. Year-fld, month-fld, and day-fld must all have the same dimension names and sizes. Cdfjday will read data from either the static or variable slices, however, all date fields must be in the same slice. Jday-fld will be written to the same slice containing the other date fields. Cdfjday will not read from both static and variable slices. If the date fields are located in the static slice, Cdfjday modifies the static slice and passes all variable slices to the standard output unchanged, and vice versa.
Cdfjday provides three optional arguments. Ref-year, ref-month, ref-day constitute a reference date from which to calculate the julian date. This is done by calculating the julian date of the reference and subtracting it from a julian date calculated from data. This effectively calculates the number of days between the given date and the reference. In general it is a good idea to provide a reference. The julian date otherwise calculated is a rather large and cumbersome number of often small practical value. The reference must be provided in numerical format and the day value is one less than would be intuitively expected. (i.e. Jan. 1, 1992 becomes 1992 1 0, not 1992 1 1.)
Cdfjday attempts to handle errors gracefully. Cdfjday chokes on any violation of the above requirements or other foreseeable hardware and software errors such as, not-enough-memory, misnamed variables, and badly misshapen data. Cdfjday terminates upon such errors, and should not produce cores or other nasty side effects.
swallow:~/$ cdfjday year month day jday 1991 1 0 < infile > outfile