Chapter Contents

Previous

Next
Executing C Programs

Executing C Programs under OS/390 Batch

The following sections discuss the cataloged procedures provided to execute C programs immediately after the link-edit step.


Using Cataloged Procedures to Execute C Programs

You can use one of the cataloged procedures LC370CLG or LC370LG to execute a C program immediately after it is link-edited. Neither of these procedures runs COOL. If you need to run COOL before link-editing and executing a program, because it is reentrant or uses extended names, use the LC370LRG cataloged procedure.

Sample JCL for Linking and Executing a C Program Using the Cataloged Procedure LC370LG shows how to link-edit and execute a C program. Expanded JCL for the LC370LG Procedure and Expanded JCL for the LC370CLG Procedure show the expanded JCL for the cataloged procedures that execute non-reentrant C programs LC370LG and LC370CLG, respectively.


Sample JCL for Linking and Executing a C Program Using the Cataloged Procedure LC370LG
//JOBNAME JOB job card information //*------------------------------------------------------------ //* LINK AND RUN A C PROGRAM //*------------------------------------------------------------ //STEP1 EXEC LC370LG //LKED.SYSLMOD DD DISP=SHR,DSN=your.load.library(member) //LKED.SYSIN DD DISP=SHR,DSN=your.object.library(member) /*


The LC370LG Cataloged Procedure

Expanded JCL for the LC370LG procedure is illustrated in Expanded JCL for the LC370LG Procedure. This JCL is correct as of the publication of this guide. However, it may be subject to change.


Expanded JCL for the LC370LG Procedure
//LC370LG PROC ENTRY=MAIN,ENV=STD, // CALLLIB='SASC.BASELIB', // SYSLIB='SASC.BASELIB' //**************************************************************** //* PRODUCT: SAS/C *** //* PROCEDURE: LINKAGE AND EXECUTION *** //* DOCUMENTATION: SAS/C COMPILER AND LIBRARY USER'S GUIDE *** //* FROM: SAS INSTITUTE INC., SAS CAMPUS DRIVE, CARY, NC *** //**************************************************************** //* //* ****************************************************************** //* ENV=STD: MODULE RUNS IN THE NORMAL C ENVIRONMENT //* ENV=SPE: MODULE USES THE SYSTEMS PROGRAMMING ENVIRONMENT //* ENTRY=MAIN: MODULE IS A NORMAL C MAIN PROGRAM //* ENTRY=OS: MODULE IS AN OS SPE APPLICATION //* ENTRY=NONE: ENTRY POINT TO BE ASSIGNED BY USER //* ****************************************************************** //LKED EXEC PGM=LINKEDIT,PARM='LIST,MAP',REGION=1536K //SYSPRINT DD SYSOUT=A,DCB=(RECFM=FBA,LRECL=121,BLKSIZE=1210) //SYSTERM DD SYSOUT=A //SYSLIN DD DSN=SASC.BASEOBJ(EP@&ENTRY), // DISP=SHR // DD DDNAME=SYSIN //SYSLIB DD DSN=SASC.&ENV.LIB, // DISP=SHR STDLIB OR SPELIB // DD DSN=&SYSLIB,DISP=SHR COMMON RESIDENT LIBRARY // DD DSN=&CALLLIB,DISP=SHR //SYSUT1 DD DSN=&&SYSUT1,UNIT=SYSDA,DCB=BLKSIZE=1024, // SPACE=(1024,(200,50)) //SYSLMOD DD DSN=&&LOADMOD(MAIN),DISP=(,PASS),UNIT=SYSDA, // SPACE=(1024,(50,20,1)) //GO EXEC PGM=*.LKED.SYSLMOD,COND=(4,LT,LKED) //STEPLIB DD DSN=SASC.LINKLIB, // DISP=SHR C TRANSIENT LIBRARY //SYSPRINT DD SYSOUT=A //SYSTERM DD SYSOUT=A //DBGLOG DD SYSOUT=A //SYSTMPDB DD UNIT=SYSDA,SPACE=(TRK,25) VS1 ONLY

Note:    The symbolic parameter SYSLIB refers to the autocall library at your installation.  [cautionend]


The LC370CLG Cataloged Procedure

Expanded JCL for the LC370CLG procedure is illustrated in Expanded JCL for the LC370CLG Procedure. This JCL is correct as of the publication of this guide. However, it may be subject to change.


Expanded JCL for the LC370CLG Procedure
//LC370CLG PROC ENTRY=MAIN,ENV=STD, // CALLLIB='SASC.BASELIB', // MACLIB='SASC.MACLIBH', // SYSLIB='SASC.BASELIB' //**************************************************************** //* PRODUCT: SAS/C *** //* PROCEDURE: COMPILATION, LINKAGE, AND EXECUTION *** //* DOCUMENTATION: SAS/C COMPILER AND LIBRARY USER'S GUIDE *** //* FROM: SAS INSTITUTE INC., SAS CAMPUS DRIVE, CARY, NC *** //**************************************************************** //* //* ****************************************************************** //* ENV=STD: MODULE RUNS IN THE NORMAL C ENVIRONMENT //* ENV=SPE: MODULE USES THE SYSTEMS PROGRAMMING ENVIRONMENT //* ENTRY=MAIN: MODULE IS A NORMAL C MAIN PROGRAM //* ENTRY=OS: MODULE IS AN OS SPE APPLICATION //* ENTRY=NONE: ENTRY POINT TO BE ASSIGNED BY USER //* ****************************************************************** //C EXEC PGM=LC370B //STEPLIB DD DSN=SASC.LOAD, // DISP=SHR COMPILER LIBRARY // DD DSN=SASC.LINKLIB, // DISP=SHR RUNTIME LIBRARY //SYSTERM DD SYSOUT=A //SYSPRINT DD SYSOUT=A //SYSUT1 DD UNIT=SYSDA,SPACE=(TRK,(10,10)) //SYSUT2 DD UNIT=SYSDA,SPACE=(TRK,(10,10)) //SYSUT3 DD UNIT=SYSDA,SPACE=(TRK,(10,10)) //SYSLIN DD DSN=&&OBJECT,SPACE=(3200,(10,10)),DISP=(MOD,PASS), // UNIT=SYSDA //SYSLIB DD DSN=&MACLIB,DISP=SHR STANDARD MACRO LIBRARY //SYSDBLIB DD DSN=&&DBGLIB,SPACE=(4080,(20,20,1)),DISP=(,PASS), // UNIT=SYSDA,DCB=(RECFM=U,BLKSIZE=4080) //SYSTMP01 DD UNIT=SYSDA,SPACE=(TRK,25) VS1 ONLY //SYSTMP02 DD UNIT=SYSDA,SPACE=(TRK,25) VS1 ONLY //LKED EXEC PGM=LINKEDIT,PARM='LIST,MAP',COND=(8,LT,C) //SYSPRINT DD SYSOUT=A,DCB=(RECFM=FBA,LRECL=121,BLKSIZE=1210) //SYSTERM DD SYSOUT=A //SYSLIN DD DSN=*.C.SYSLIN,DISP=(OLD,PASS),VOL=REF=*.C.SYSLIN // DD DSN=SASC.BASEOBJ(EP@&ENTRY), // DISP=SHR // DD DDNAME=SYSIN //SYSLIB DD DSN=SASC.&ENV.LIB, // DISP=SHR STDLIB OR SPELIB // DD DSN=&SYSLIB,DISP=SHR COMMON RESIDENT LIBRARY // DD DSN=&CALLLIB,DISP=SHR //SYSUT1 DD DSN=&&SYSUT1,UNIT=SYSDA,DCB=BLKSIZE=1024, // SPACE=(1024,(200,50)) //SYSLMOD DD DSN=&&LOADMOD(MAIN),DISP=(,PASS),UNIT=SYSDA, // SPACE=(1024,(50,20,1)) //GO EXEC PGM=*.LKED.SYSLMOD,COND=((8,LT,C),(4,LT,LKED)) //STEPLIB DD DSN=SASC.LINKLIB, // DISP=SHR C TRANSIENT LIBRARY //SYSPRINT DD SYSOUT=A //SYSTERM DD SYSOUT=A //DBGLOG DD SYSOUT=A //DBGLIB DD DSN=*.C.SYSDBLIB,DISP=(OLD,PASS),VOL=REF=*.C.SYSDBLIB //SYSTMPDB DD UNIT=SYSDA.,SPACE=(TRK,25) VS1 ONLY

Note the following about this example:


The LC370LRG Cataloged Procedure

The LC370LRG cataloged procedure is similar to LC370LR, with the addition of a GO step. Expanded JCL for the LC370LRG procedure is illustrated in Expanded JCL for the LC370LRG Procedure. This JCL is correct as of the publication of this guide. However, it may be subject to change.


Expanded JCL for the LC370LRG Procedure
//LC370LRG PROC ENV=STD,ALLRES=NO, // CALLLIB='SASC.BASEOBJ', // SYSLIB='SASC.BASEOBJ' //**************************************************************** //* PRODUCT: SAS/C *** //* PROCEDURE: COOL LINKAGE EDITOR PREPROCESSOR, LINK EDIT *** //* AND EXECUTE *** //* DOCUMENTATION: SAS/C COMPILER AND LIBRARY USER'S GUIDE *** //* FROM: SAS INSTITUTE INC., SAS CAMPUS DRIVE, CARY, NC *** //**************************************************************** //* ENV=STD: MODULE RUNS IN THE NORMAL C ENVIRONMENT //* ENV=SPE: MODULE USES THE SYSTEMS PROGRAMMING ENVIRONMENT //* ****************************************************************** //LKED EXEC PGM=COOLB,PARM='LIST,MAP',REGION=1536K //STEPLIB DD DSN=SASC.LOAD, // DISP=SHR C COMPILER LIBRARY // DD DSN=SASC.LINKLIB, // DISP=SHR C RUNTIME LIBRARY //SYSPRINT DD SYSOUT=A,DCB=(RECFM=FBA,LRECL=121,BLKSIZE=1210) //SYSTERM DD SYSOUT=A //SYSLIN DD UNIT=SYSDA,DSN=&&LKEDIN,SPACE=(3200,(20,20)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=3200) //SYSLIB DD DDNAME=AR#&ALLRES ARESOBJ OR STDOBJ OR SPEOBJ // DD DSN=SASC.&ENV.OBJ, // DISP=SHR STDOBJ OR SPEOBJ // DD DSN=&SYSLIB,DISP=SHR COMMON RESIDENT LIBRARY // DD DSN=&CALLLIB,DISP=SHR //SYSUT1 DD DSN=&&SYSUT1,UNIT=SYSDA,DCB=BLKSIZE=1024, // SPACE=(1024,(200,50)) //SYSLMOD DD DSN=&&LOADMOD(MAIN),DISP=(,PASS),UNIT=SYSDA, // SPACE=(1024,(50,20,1)) //AR#NO DD DSN=SASC.&ENV.OBJ, // DISP=SHR //AR#YES DD DSN=SASC.ARESOBJ, // DISP=SHR //GO EXEC PGM=*.LKED.SYSLMOD,COND=(4,LT,LKED) //STEPLIB DD DSN=SASC.LINKLIB, // DISP=SHR C TRANSIENT LIBRARY //SYSPRINT DD SYSOUT=A //SYSTERM DD SYSOUT=A //DBGLOG DD SYSOUT=A //SYSTMPDB DD UNIT=SYSDA,SPACE=(TRK,25) VS1 ONLY

Note the following about this example:


The LC370CRG Cataloged Procedure

The LC370CRG cataloged procedure is similar to LC370CLR, with the addition of a GO step. Expanded JCL for the LC370CRG procedure is illustrated in Expanded JCL for the LC370CRG Procedure. This JCL is correct as of publication of this guide. However, it may be subject to change.


Expanded JCL for the LC370CRG Procedure
//LC370CRG PROC ENV=STD,ALLRES=NO, // CALLLIB='SASC.BASEOBJ', // MACLIB='SASC.MACLIBC', // SYSLIB='SASC.BASEOBJ' //**************************************************************** //* NAME: LC370CRG (LC370CRG) *** //* PRODUCT: SAS/C *** //* PROCEDURE: COMPILATION, PRE-LINK, LINKAGE, AND EXECUTION *** //* DOCUMENTATION: SAS/C COMPILER AND LIBRARY USER'S GUIDE *** //* FROM: SAS INSTITUTE INC., SAS CAMPUS DRIVE, CARY, NC *** //**************************************************************** //* //* ****************************************************************** //* ENV=STD: MODULE RUNS IN THE NORMAL C ENVIRONMENT //* ENV=SPE: MODULE USES THE SYSTEMS PROGRAMMING ENVIRONMENT //* ****************************************************************** //C EXEC PGM=LC370B //STEPLIB DD DSN=SASC.LOAD, // DISP=SHR COMPILER LIBRARY // DD DSN=SASC.LINKLIB, // DISP=SHR RUNTIME LIBRARY //SYSTERM DD SYSOUT=* //SYSPRINT DD SYSOUT=* //SYSUT1 DD UNIT=SYSDA,SPACE=(TRK,(10,10)) //SYSUT2 DD UNIT=SYSDA,SPACE=(TRK,(10,10)) //SYSUT3 DD UNIT=SYSDA,SPACE=(TRK,(10,10)) //SYSLIN DD DSN=&&OBJECT,SPACE=(3200,(10,10)),DISP=(MOD,PASS), // UNIT=SYSDA,DCB=(RECFM=FB,LRECL=80) //SYSLIB DD DSN=&MACLIB,DISP=SHR STANDARD MACRO LIBRARY //SYSDBLIB DD DSN=&&DBGLIB,SPACE=(4080,(20,20,1)),DISP=(,PASS), // UNIT=SYSDA,DCB=(RECFM=U,BLKSIZE=4080) //SYSTMP01 DD UNIT=SYSDA,SPACE=(TRK,25) VS1 ONLY //SYSTMP02 DD UNIT=SYSDA,SPACE=(TRK,25) VS1 ONLY //LKED EXEC PGM=COOLB,PARM='LIST,MAP',COND=(8,LT,C),REGION=1536K //STEPLIB DD DSN=SASC.LOAD, // DISP=SHR COMPILER LIBRARY // DD DSN=SASC.LINKLIB, // DISP=SHR RUNTIME LIBRARY //SYSPRINT DD SYSOUT=*,DCB=(RECFM=FBA,LRECL=121,BLKSIZE=1210) //SYSTERM DD SYSOUT=* //SYSLIN DD UNIT=SYSDA,DSN=&&LKEDIN,SPACE=(3200,(20,20)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=3200) //SYSLIB DD DDNAME=AR#&ALLRES ARESOBJ OR STDOBJ OR SPEOBJ // DD DSN=SASC.&ENV.OBJ, // DISP=SHR STDOBJ OR SPEOBJ // DD DSN=&SYSLIB,DISP=SHR COMMON RESIDENT LIBRARY // DD DSN=&CALLLIB,DISP=SHR //SYSUT1 DD DSN=&&SYSUT1,UNIT=SYSDA,DCB=BLKSIZE=1024, // SPACE=(1024,(200,50)) //SYSLMOD DD DSN=&&LOADMOD(MAIN),DISP=(,PASS),UNIT=SYSDA, // SPACE=(1024,(50,20,1)) //SYSIN DD DSN=*.C.SYSLIN,DISP=(OLD,PASS),VOL=REF=*.C.SYSLIN //AR#NO DD DSN=SASC.&ENV.OBJ, // DISP=SHR //AR#YES DD DSN=SASC.ARESOBJ, // DISP=SHR //GO EXEC PGM=*.LKED.SYSLMOD,COND=((8,LT,C),(4,LT,LKED)) //STEPLIB DD DSN=SASC.LINKLIB, // DISP=SHR C TRANSIENT LIBRARY //SYSPRINT DD SYSOUT=* //SYSTERM DD SYSOUT=* //DBGTERM DD SYSOUT=* //DBGLOG DD SYSOUT=* //DBGLIB DD DSN=*.C.SYSDBLIB,DISP=(OLD,PASS),VOL=REF=*.C.SYSDBLIB //SYSTMPDB DD UNIT=SYSDA,SPACE=(TRK,25) VS1 ONLY

Note the following about this example:


Run-Time JCL Requirements

To run a C program, some or all of the DD statements summarized in Data Definition Statements for Program Execution under OS/390 may be required.

Data Definition Statements for Program Execution under OS/390
DDname
STEPLIB or JOBLIB
CTRANS
SYSTERM
SYSPRINT
SYSIN
DGBLIB
DBGSRC
DBGLOG
DBGIN

CTRANS may be used to define the run-time library if not defined in JOBLIB or STEPLIB or in your system libraries.

The PARM keyword of the EXEC statement can be used to specify program arguments, which are passed by the argc/argv interface to the main program. The PARM string can also contain library arguments, standard file redirections, and environment variables.

A SYSUDUMP card should be included if a dump is desired.

The DBGLIB, DBGSRC, DBGLOG, and DBGIN DDnames are explained in detail in the SAS/C Debugger User's Guide and Reference.

Sample JCL for Program Execution illustrates how to execute a C program that writes to standard output.


Sample JCL for Program Execution
//JOBNAME JOB job card information //*------------------------------------------------------------ //* RUN A C PROGRAM //*------------------------------------------------------------ //JOBLIB DD DISP=SHR,DSN=your.load.library // DD DISP=SHR,DSN=runtime.transient.library //STEP1 EXEC PGM=MVSEXAM,PARM='=W <INPUT -z' //SYSPRINT DD SYSOUT=class //SYSTERM DD SYSOUT=class //INPUT DD DSN=your.input.data,DISP=SHR /*


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.