The following example is coded in C/370™:
#include <stdio.h>
#include <stdlib.h>
#include "csrbpc"
#define m 200
#define n 200
#define p 200
#define kelement_size 4
int chk_code(long int ret, long int reason, int linenumber);
main()
{
long int A[m] [n];
long int B[m] [n];
long int C[m] [n];
long int i;
long int j;
long int k;
long int rc;
long int rsn;
long int arraysize;
long int direction;
long int unitsize;
long int gap;
long int units;
arraysize = m*n*kelement_size;
direction = csr_forward;
unitsize = kelement_size*n;
gap = 0;
units = 20;
csrirp(A, &arraysize, &direction,;
&unitsize,;
&gap,;
&units,;
&rc,;
&rsn);
chk_code(rc,rsn,__LINE__);
arraysize = m*p*kelement_size;
csrirp(B, &arraysize, &direction,;
&unitsize,;
&gap,;
&units,;
&rc,;
&rsn);
chk_code(rc,rsn,__LINE__);
for (i=0; i<m; i++) {
for (j=0; j<n; j++) {
A[i][j] = i + j;
}
}
for (i=0; i<n; i++) {
for (j=0; j<p; j++) {
B[i][j] = i + j;
}
}
arraysize = m*n*kelement_size;
csrrrp(A, &arraysize,;
&rc,;
&rsn);
chk_code(rc,rsn,__LINE__);
arraysize = m*p*kelement_size;
csrrrp(B, &arraysize,;
&rc,;
&rsn);
chk_code(rc,rsn,__LINE__);
arraysize = m*n*kelement_size;
units = 25;
csrirp(A, &arraysize, &direction,;
&unitsize,;
&gap,;
&units,;
&rc,;
&rsn);
chk_code(rc,rsn,__LINE__);
arraysize = n*p*kelement_size;
gap = (p-1)*kelement_size;
units = 50;
csrirp(B, &arraysize, &direction,;
&unitsize,;
&gap,;
&units,;
&rc,;
&rsn);
chk_code(rc,rsn,__LINE__);
for (i=0; i<m; i++) {
for (j=0; j<p; j++) {
C[i][j] = 0;
for (k=0; k<n; k++) {
C[i][j] = C[i][j] + A[i][k] * B[k][j];
}
}
}
arraysize = m*n*kelement_size;
csrrrp(A, &arraysize,;
&rc,;
&rsn);
chk_code(rc,rsn,__LINE__);
arraysize = n*p*kelement_size;
csrrrp(B, &arraysize,;
&rc,;
&rsn);
chk_code(rc,rsn,__LINE__);
}
/* chk_code will check return code and reason code from previous */
/* calls to HLL services. It will print a message if any of the */
int chk_code(long int ret, long int reason, int linenumber)
{
if (ret != 0)
printf("return_code = %ld instead of 0 at line %d\n",
ret, linenumber);
if (reason != 0)
printf("reason_code = %ld instead of 0 at line %d\n",
reason, linenumber);
}
//*--------------------------------------------------------------------
//* JCL USED TO COMPILE, LINK, THE C/370 PROGRAM
//*--------------------------------------------------------------------
//CJOB JOB
//CCSTEP EXEC EDCCO,
// CPARM='LIST,XREF,OPTIMIZE,RENT,SOURCE',
// INFILE='REFPAT.SAMPLE.PROG(C),DISP=SHR'
//COMPILE.SYSLIN DD DSN='TEST.MPS.OBJ(C),DISP=SHR'
//COMPILE.USERLIB DD DSN=REFPAT.DECLARE.SET,DISP=SHR
//LKSTEP EXEC EDCPLO,
// LPARM='AMOD=31,LIST,REFR,RENT,RMOD=ANY,XREF' 00022007
//PLKED.SYSIN DD DSN='TEST.MPS.OBJ(C),DISP=SHR'
//LKED.SYSLMOD DD DSN=REFPAT.USER.LOAD,DISP=SHR,
// UNIT=3380,VOL=SER=RSMPAK
//LKED.SYSIN DD *
LIBRARY IN(CSRIRP,CSRRRP)
NAME BPGC(R)
//LKED.IN DD DSN=SYS1.CSSLIB,DISP=SHR
//*--------------------------------------------------------------------
//* JCL USED TO EXECUTE THE C/370 PROGRAM
//*--------------------------------------------------------------------
//CGO JOB TIME=1440,MSGLEVEL=(1,1),MSGCLASS=A
//RUN EXEC PGM=BPGC,TIME=1440 00110804
//STEPLIB DD DSN=REFPAT.USER.LOAD,DISP=SHR, 00111002
// UNIT=3380,VOL=SER=VM2TSO 00111101
// DD DSN=CEE.SCEERUN,DISP=SHR 0111002
//SYSPRINT DD SYSOUT=*
//PLIDUMP DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*