The complete linked module has a size limit of 256,000 bytes. A subroutine can have up to 15 arguments, which can be a mixture of constants, scalars, vectors, matrices, character strings, and text variables. A function can have up to 20 arguments, which must all be REAL*8 constants or scalars. The appropriate arguments, which may be constants, scalars, vectors, matrices, character strings, or text variables, must be used. The arguments must agree in variable type and number.
PHYSICA expects to find a user written subroutine of the form: SUBROUTINE subname(IATYPE,ICODE,IUPDATE,IER,ARG1,ARG2,...,ARGM) INTEGER*4 IATYPE(15),ICODE(3,15),IUPDATE(15),IER If the subroutine is to loaded via the sharable image, its name must be one of SUB1, SUB2, ..., SUB8. If the subroutine is to be loaded at run- time via the LOAD command, its name is irrelevant and when the subroutine is used in the CALL command, the name is not entered. All of the numeric arguments, except for the integer arguments IATYPE, ICODE, IUPDATE, and IER, must be REAL*8. A character argument is passed as a LOGICAL*1 array.
Additional Information on:
The user written function should have the following form: REAL*8 FUNCTION funcname(ARG1,ARG2,...,ARGM) REAL*8 ARG2,ARG2,...,ARGM The name of the function, funcname, is irrelevant. When the function is used in an expression, the name that is used must be USERN. All arguments must be REAL*8 variables. When the function is used in an expression, you can use vectors or matrices as arguments, since the expression evaluator will process the function one element at a time. Arithmetic errors, such as division by zero, over/underflow, will be asynchronously trapped.
Suppose FUNC.OBJ is some compiled function which requires two arguments and DISK:[DIR]LIBRARY.OLB is an object module library that is needed by the routine FUNC. To compile and load this routine and then use it in an expression: $FORTRAN FUNC LOAD FUNC,DISK:[DIR]LIBRARY/LIB Z=USERN(B*X,Y-C)+COS(X)
Suppose you want to load and use a function, FUNC, which has 3 arguments: x1, x2, and x3, and returns the sum of x1 and x2 when x3 is within 0.5 of sqrt(x1^2+x2^2), else it returns 0. To compile, load and test this function: $FORTRAN FUNC LOAD FUNC X1=RAN([1:100]) X2=RAN([1:100]) X3=RAN([1:100]) Y=USERN(X1,X2,X3) Y2=(X1+X2)*(ABS(SQRT(X1^2+X2^2)-X3)<0.5) and then compare Y with Y2.
Additional Information on: