Privacy and Security Notice

Common problems when porting to HP-UX

Common problems when porting to HP-UX

K.Beard, CASA, TJNAF


The computer center is as of now no longer supporting scientific computing under HP-UX. They have indicated that they will not fix the problems with jlabh1.

Often,, when moving code between UNIX platforms, the biggest obstacles are a few, commonly used, system dependent operations. Among the most common are the call to get the current time and date, the call to get a random number, call to the system, and IO.

My KBB libraries solve many common problems, including the first. On all UNIX platforms in common use at TJNAF, my libraries provide a platform independent call by using the system C routines. Refer to the main KBB page for linking instructions, the "FORTRAN calls to KBB C library" page for examples, and the FTP site for binaries and source.


time

For the current date and time, the routine kbb_time_now will return a string of the format

"Day Mon dd hh:mm:ss yyyy"
for example
"Mon Jul 22 18:51:18 2002" 

Other string formats can be had using the now_format_date and now_time_and_date routines.


system call

To send a message to the system, use the SEND_TO_SYSTEM routine.


random numbers

C has intrinsic random number generators used by the UNIX operating system; I've written FORTRAN callable routines (KBB_SEED_I4, KBB_SEED_I8, KBB_RANDOM_R4, KBB_RANDOM_R8) to allow one to set the seed and to get a random number between 0. and 1.:


HP-UX F77 intrinsic calls

These are typical intrinsics; the compiler automatically will adapt to give same kind of output as the input unless otherwise listed:

functionreal*Nx
complex*2N z
if not automatic
for
N=8
maximum: max(x,y)MAX(x,y)
sine of radians: sin(xradians)SIN(x)
sine of degrees: sin(xdegrees)SIND(x)
arcsine in radians: asin(x)ASIN(x)
arcsine in degrees: asin(x)ASIND(x)
hyperbolic sine: sinh(x)SINH(x)
complex: z(a,b)CMPLX(a,b)DCMPLX(a,b)
imaginary component: Im(z)IMAG(z)DIMAG(z)
real component: Re(z)REAL(z)DREAL(z)
natural log: ln(x)LOG(x)
base10 log: log10(x)LOG10(x)


IO

The NEW_FILE, OLD_FILE, and APPEND_FILE routines have the correct OPEN specifiers for each platform supported by KBB/F77; the HP-UX OPEN statment has the following commonly used specifiers:

specifierexamplenotes
UNIT=iochannelUNIT=7
FILE=filenameFILE="input.dat"
ERR=statement_numberERR=999
FORM=formattypeFORM="formatted""formatted" or "unformatted"
STATUS=newORoldSTATUS="new""old", "new", "scratch", or "unknown"
IOSTAT=ioflagIOSTAT=ioproblemok if ioproblem.EQ.0


K.B.Beard, 23 Jan 2003, updated 25 Aug 2003