SPLINE_READ

SPLINE_READ reads x, y, [and z] data from a file to a SPLINE statement. The SPLINE_READ subroutine is optional. You use it only if you do not want to use the X and Y arguments in the SPLINE statement (C++ or FORTRAN).
 
Note:  
Use mixed case names for the Adams subroutine names when using the C style interface. For the default subroutine name capitalize the first letter and have the remaining letters lower case. Doing this ensures that Adams Solver correctly distinguishes a C style subroutine from Fortran and calls with the appropriate interface.

Use

Corresponding Statement

SPLINE/id
, X=x1, x2, x3, x4 [, . . . , xn]
, Y=y1, y2, y3, y4 [, . . . , yn]
[,LINEAR_EXTRAPOLATE]
 
 
or
SPLINE/id
, X=x1, x2, x3, x4 [, . . . , xn]
, Y=z1, y11, y12, y13, y14 [, . . . ,y1n]
, Y=z2, y21, y22, y23, y24 [, . . . ,y2n]
, Y=z3, y31, y32, y33, , LINEAR_EXTRAPOLATE y34 [, . . . ,y3n]
, Y=z4, y41, y42, y43, y44 [, . . . ,y4n]
[, . . . , Y=zm, ym1, ym2, ym3, ym4,[, . . . ,ymn]]
[, LINEAR_EXTRAPOLATE]
or
SPLINE/id
, FILE=filename
[, BLOCK=blockname]
[, LINEAR_EXTRAPOLATE] SPLINE/id
[, ROUTINE=libname::subname]
[ ] Optionally select the item.
 

Calling Sequence

SUBROUTINE SPLINE_READ (id, file_name, block_name, status)

Input Arguments

 
id
An integer variable that indicates the identifier of the corresponding SPLINE statement.
file_name
A character array of dimension 132 that contains the FILE name that you specify using the FILE argument in the corresponding SPLINE statement.
block_name
A character array of dimension 132 that contains the BLOCK name (if any) that you specify using the BLOCK argument of the corresponding SPLINE statement.
LINEAR_EXTRAPOLATE
Causes Adams Solver to extrapolate a SPLINE that exceeds a defined range by applying linear function(s) tangent to the spline at the end(s) of the defined range. By default, Adams Solver extrapolates a SPLINE that exceeds a defined range by applying a cubic function over the first or last three data points.
ROUTINE=libname::subname
Specifies an alternative library and name for the user subroutine SPLINE_READ.

Learn more about the ROUTINE Argument.

Output Argument

 
status
A logical variable that indicates if SPLINE_READ successfully reads and passes the x, y, [and z] data from the file to Adams Solver. If the SPLINE data does not pass correctly, you can set the status to .TRUE. using PUT_SPLINE, which stops the appropriate operations in Adams Solver. Otherwise, set the status to .FALSE.

Extended Definition

If you are a novice Adams SOLVER user, you can use the X and Y arguments in the SPLINE statement to define the spline elements. If you are an expert user and a sizeable amount of data is required to define the spline elements, you might prefer to use the FILE argument in the SPLINE statement in conjunction with the SPLINE_READ user-written subroutine.
Adams Solver calls SPLINE_READ during the model-input phase. At this point, the model is not fully defined, and consequently, SPLINE_READ may not call most utility subroutines. SPLINE_READ must call the PUT_SPLINE utility subroutine in order to pass Adams Solver the x, y, [and z] data that it reads from the file (see PUT_SPLINE).

FORTRAN - Prototype

A sample structure for the SPLINE_READ subroutine follows next. The comments explain the activities that the subroutine performs.
SUBROUTINE SPLINE_READ (ID, FILE_NAME, BLOCK_NAME, STATUS)
C
C === Type and dimension statements ===================
C
C - External variable definitions ---------
C
    INTEGER ID
    CHARACTER*132 FILE_NAME
    CHARACTER*132 BLOCK_NAME
    LOGICAL STATUS
C
C ID Identifier of calling SPLINE statement
C FILE_NAME Name of file containing data to define spline
C BLOCK_NAME Name of named block within the file to be
C             used for this spline
C STATUS   Error status flag
C
C - Local variable definitions -----------
C
     ...
C
C === Executable code =================================
C
C open file, check validity, type... and read data into local variables
C
     ...
     CALL PUT_SPLINE(ID,NX,NZ,X,Y,Z,ERRFLG)
C
C check ERRFLG, clean-up (release memory if necessary, close file...), and set STATUS
C
     ...
C
     RETURN
     EN
D

C Style - Prototype

typedef void adams_c_SPLINE_READ(const struct sAdamsSpline* spline, int* IERR);
/*
* SPLINE -----------------------------------------------------------------
*/
struct sAdamsSpline
{
int ID;
const char* FILENAME;
const char* BLOCKNAME;
};
 
 
Caution:  
When using FORTRAN subroutines, you may need to use FORTRAN's SAVE statement if the declared arrays are large. When not using the SAVE statement, declared arrays are allocated on the operating system stack. If arrays are too large, a stack overflow may occur stopping the program execution.
When ROUTINE is specified, the CHANNEL argument (if supplied) in the SPLINE statement is ignored by Adams Solver.

Examples

For an example of this subroutine, see spline_read.f.