1basl2c(1B)                            PBS                           basl2c(1B)
2
3
4

NAME

6       basl2c  -  converts  a  BASL  (BAtch Scheduling Language) code into a C
7       scheduler code.
8

SYNOPSIS

10       basl2c [-d] [-l lexerDebugFile] [-p parserDebugFile]  [-y  symtabDebug‐
11       File] [-s semanticDebugFile] [-g codegenDebugFile] [-c cFile] baslFile
12

DESCRIPTION

14       basl2c  is  the  BASL  to C compiler that produces an intermediate code
15       that can be fed into a regular C compiler,  and  linked  with  the  PBS
16       libraries to produce the scheduler executable.  Basl2c takes as input a
17       baslFile, which is a program written in the BAtch Scheduling  Language,
18       containing  the  main  scheduling  code.  Basl2c then converts the BASL
19       constructs in the file into C statements, and it  also  attaches  addi‐
20       tional  code to produce the PBS scheduler source code.  By default, the
21       resulting C code is written into the file pbs_sched.c.
22
23       The full pathname to the resulting C file is what needs to be specified
24       in  the SCHD_CODE variable in local.mk before compiling the BASL sched‐
25       uler to produce the pbs_sched executable.
26

OPTIONS

28       -d   Prints additional debugging messages to the lexer (see -l option),
29            parser  (see  -p  option),  symbol table (see -y option), semantic
30            analyzer (see -s option), and code generator (see -g option).
31
32       -l lexerDebugFile
33            lexerDebugFile is the name of a file to write into  the  debugging
34            messages generated while scanning for tokens.
35
36       -p parserDebugFile
37            parserDebugFile  is the name of a file to write into the debugging
38            messages generated while putting together tokens in a usable way.
39
40       -y symtabDebugFile
41            symtabDebugFile is the name of a file to write into the  debugging
42            messages related to the symbol table.
43
44       -s semanticDebugFile
45            semanticDebugFile  is  the name of a file to write into the debug‐
46            ging messages generated while checking to make sure variables  and
47            operators are used in a consistent way.
48
49       -g codegenDebugFile
50            codegenDebugFile is the name of a file to write into the debugging
51            messages generated while converting BASL statements  to  C  state‐
52            ments.
53
54       -c cFile
55            cFile  is the name of a file where the generated C code is written
56            into.
57

MAIN STRUCTURE

59       The basic structure of a scheduler code written in BASL is as follows:
60               zero or more FUNCTIONS definitions
61               zero or more global VARIABLE DECLARATIONS
62               zero or more assignment statements (to initialize global variables)
63               sched_main()
64               {
65                       one or more VARIABLE DECLARATIONS
66
67                       zero or more STATEMENTS
68               }
69
70
71       For example,
72               % cat sched.basl
73               Int sum(Int a, Int b)
74               {
75                       Int s;
76                       s = a + b;
77                       return(s);
78               }
79            Int glob;
80               sched_main()
81               {
82                       Int c;
83
84                       a = 3;
85                       b = 4;
86                       c = sum(a, b);
87                       print(c);
88                 glob = 5;
89                 print(glob);
90               }
91
92       sched_main() is the function that gets called at every scheduling iter‐
93       ation.
94

FUNCTIONS

96       To  define  a  function that can be called in subsequent functions, the
97       syntax is:
98
99           ReturnType function-name ( DATATYPE1 IDENTIFIER1,
100                                      DATATYPE2 IDENTIFIER2, ... )
101               {
102                       one or more VARIABLE DECLARATIONS
103
104                       zero or more STATEMENTS
105               }
106
107       For example,
108           Void printStuff(Dayofweek dow, DateTime t, String str,
109                                                Size sz, CNode cn)
110           {
111               print(dow);
112               print(t);
113               print(str);
114               print(sz);
115               print(cn);
116           }
117
118       Valid function ReturnType are: Void, Int, Float,  Dayofweek,  DateTime,
119       String,  Size,  Server,  Que, Job, CNode, Set Server, Set Que, Set Job,
120       Set CNode.
121
122       Valid data types ( DATATYPE1, DATATYPE2, ...  ) for the parameter iden‐
123       tifiers  are:  Int,  Float,  Dayofweek, DateTime, String, Size, Server,
124       Que, Job, CNode, Set Server, Set Que, Set Job, Set  CNode,  Range  Int,
125       Range  Float, Range Dayofweek, Range DateTime, Range Size, Fun Int, Fun
126       Float, Fun Void, Fun Dayofweek, Fun DateTime, Fun String, Fun Size, Fun
127       Server,  Fun  Que, Fun Job, Fun CNode, Fun Set Server, Fun Set Que, Fun
128       Set Job, Fun Set CNode.  These data types will be discussed in the next
129       topic.
130
131       Functions are invoked by their name and their arguments as in:
132
133               printStuff( MON, (5|1|1997@14:32:00), "sched begins",
134                                                        30gb, node );
135
136       basl2c will actually add a "basl_" prefix to the function name given by
137       the scheduler writer to minimize chance of name  collision,  which  can
138       result  when  the  resulting  C  code  is  linked  with  the  PBS, BASL
139       libraries.  For example, if you  look  at  the  generated  C  code  for
140       printStuff, you would see,
141
142               basl_printStuff( MON, (5|1|1997@14:32:00),
143                                        "sched begins", 30gb, node );
144
145       As in C, all function calls must have been previously defined. The BASL
146       compiler will check to make sure that arguments in  the  function  call
147       match  up  exactly (in terms of types) with the parameters in the func‐
148       tion definition.
149
150       Two kinds of functions exist in BASL: user-defined functions and prede‐
151       fined  functions.  User-defined  functions are those that the scheduler
152       writer provided a definition for, while predefined functions are  those
153       that  can  immediately  be called without a need for defining it. For a
154       list of predefined functions, see section on PREDEFINED FUNCTIONS .
155

VARIABLE DECLARATIONS

157       Like in C, all variables in a BASL code  must  be  explicitly  declared
158       before  use.   Those  variables  declared  outside  of any function are
159       referred to as global variables,  while  variables  that  are  declared
160       within  a  function  body are called local variables.  Global variables
161       are usable anywhere within the BASL code,  while  local  variables  are
162       readable only within the function from which they were declared.
163
164       The syntax of a variable declaration is:
165
166               DATATYPE IDENTIFIER ;
167
168       where  DATATYPE  can be: Int, Float, Dayofweek, DateTime, String, Size,
169       Server, Que, Job, CNode, Set Server, Set Que, Set Job, Set CNode, Range
170       Int, Range Float, Range Dayofweek, Range DateTime, Range Size.
171
172

DATA TYPE

174       Void    used for functions that don't return a value.
175
176       Int     signed, whole numbers given in base 10.
177
178               Sample constants:
179                      5,  +1,  -3,  SUCCESS  (=1), FAIL (=0), TRUE (=1), FALSE
180                      (=0)
181
182       Float   real numbers which are represented as doubles in the translated
183               C code.
184               Sample constants: 4.3, +1.2, -2.6
185
186       Dayofweek
187               constant  values: SUN, MON, TUE, WED, THU, FRI, SAT, internally
188               represented as integer valued constants with SUN=0, MON=1,  and
189               so on.
190
191       DateTime
192               specify in one of 3 formats:
193
194
195               [1]    (m|d|y)  where  1  <= m <= 12, 1 <= d <= 31, 0 <= y, ex.
196                      (4|4|1997);
197
198               [2]    (hh:mm:ss) where 0 <= hh <= 23, 0 <= mm <= 59, 0  <=  ss
199                      <= 61, ex. (12:01:00);
200
201               [3]    (m|d|y@hh:mm:ss), ex. (4|4|1997@12:01:00)
202                      During dates/times comparison, "now" time is substituted
203                      if the time portion is not given (format [1]); the "now"
204                      date  is  substituted  if  the date portion is not given
205                      (format [2]).  Also, the full year portion must be given
206                      (i.e.  1997 instead of 97) in dates to avoid ambiguity.
207
208       String  A  string is enclosed in quotes (") and it can contain anything
209               except another quote, a newline, and left and  right  parenthe‐
210               ses.
211               Sample constants: "a sample string", NULLSTR
212
213       Size    format:  <integer><suffix>  where suffix is a multiplier of the
214               form: <multiplier><unit>:
215
216                  multiplier              unit (bytes or words)
217                  ===================     =====================
218                  k,m,g,t,p,K,M,G,T,P     b,B,w,W
219
220               where     k=K=1024,      m=M=1,048,576,      g=G=1,073,741,824,
221               t=T=1,099,511,627,776,  p=P=1,125,899,906,842,624,  b=B=1,  and
222               word size w=W is locally defined  (i.e.  4 bytes  in  a  32-bit
223               machine).
224
225               When  operating  on  2 size operands that are of different suf‐
226               fixes, the suffix of the "lower" of the two will be the  resul‐
227               tant suffix. For example,
228                    10mb + 10gb =  10250mb
229               Sample constants: -1b, 2w, 1kb, 2mw, +3gb, 4tw, 6Pb
230
231       Range Int
232
233               format: (low Int value, high Int value)
234                       where  low  Int  value  <= high Int value.  Sample con‐
235                       stant: (1,3)
236
237       Range Float
238
239               format: (low Float value, high Float value)
240                       where low value <= high value.  Sample constant:  (2.3,
241                       4.6)
242
243       Range Dayofweek
244
245               format: (earlier day, later day)
246                       where  earlier  day  <=   later  day.  Sample constant:
247                       (WED, FRI)
248
249       Range DateTime
250
251               format: (earlier date/time, later date/time)
252                       where earlier date/time <= later date/time.
253                       NOTE: if range contains only time portions, and earlier
254                       time  "appears"  to  be  > later time as in "((18:0:0),
255                       (6:0:0))",  then  during  date/time  comparisons,   the
256                       "later"  time  will  be  adjusted by one day so that it
257                       will look  like:  "(  (<now  date>@18:0:0),  (<tomorrow
258                       date>@6:0:0) )"
259
260               Sample constants:
261                      ((4|4|1997),   (4|10|1997)),  ((12:01:00),  (12:30:00)),
262                      ((4|4|1997@12:01:00), (4|10|1997@12:30:00))
263
264       Range Size
265
266               format: (low size, high size)
267                       where low size <= high size.  Sample constants:  (23gb,
268                       50gb)
269
270       Server  Maps directly to the PBS server object. A Server manages one or
271               more Que objects.
272               Sample constant: NOSERVER
273
274       CNode   for computational node consisting  of  a  single  OS  image,  a
275               shared memory, and a set of cpus. CNode runs 1 PBS MOM.
276               Sample constant: NOCNODE
277
278       Que     Maps  directly to the PBS queue object. A Que object spools one
279               or more Job objects.
280               Sample constant: NOQUE
281
282       Job     Maps directly to the PBS job object. A Job object carries  some
283               attributes and resource requirements.
284               Sample constant: NOJOB
285
286       Set Server
287               list of Server objects.
288               Sample constant: EMPTYSETSERVER
289
290       Set CNode
291               list of CNode objects.
292               Sample constant: EMPTYSETCNODE
293
294       Set Que list of Que objects.
295               Sample constant: EMPTYSETQUE
296
297       Set Job list of Job objects.
298               Sample constant: EMPTYSETJOB
299
300

BASL-DEFINED CONSTANTS

302       These  are  constants that cannot be used for naming an identifier (see
303       next topic). These are always in uppercase.
304
305          DATA TYPE               BASL-DEFINED CONSTANT
306          ===================     =============================================
307          Dayofweek               SUN, MON, TUE, WED, THU, FRI, SAT
308
309          Int                     SUCCESS, FAIL, FALSE, TRUE, SYNCRUN, ASYNCRUN,
310                                  DELETE, RERUN, HOLD, RELEASE, SIGNAL,
311                                  MODIFYATTR, MODIFYRES, SERVER_ACTIVE,
312                                  SERVER_IDLE, SERVER_SCHED, SERVER_TERM,
313                                  SERVER_TERMDELAY, QTYPE_E, QTYPE_R,
314                                  SCHED_DISABLED, SCHED_ENABLED, TRANSIT,
315                                  QUEUED, HELD, WAITING, RUNNING, EXITING,
316                                  CNODE_OFFLINE, CNODE_DOWN, CNODE_FREE,
317                                  CNODE_RESERVE, CNODE_INUSE_EXCLUSIVE,
318                                  CNODE_INUSE_SHARED, CNODE_TIMESHARED,
319                                  CNODE_CLUSTER, CNODE_UNKNOWN, OP_EQ, OP_NEQ,
320                                  OP_LE, OP_LT, OP_GE, OP_GT, OP_MAX, OP_MIN,
321                                  ASC, DESC
322
323          Server                  NOSERVER
324          Set Server              EMPTYSETSERVER
325
326          CNode                   NOCNODE
327          Set CNode               EMPTYSETCNODE
328
329          Que                     NOQUE
330          Set Que                 EMPTYSETQUE
331
332          Job                     NOJOB
333          Set Job                 EMPTYSETJOB
334
335          String                  NULLSTR
336
337

IDENTIFIER

339       Identifiers (used  for  variable  names  and  function  names)  are  in
340       alphanumeric   format,  with  the  special  underscore  (_)   character
341       allowed. Currently, BASL can only handle identifiers with length of  up
342       to  80  chars. Also, you cannot use the BASL-defined constant names for
343       naming an identifier.
344

STATEMENTS

346       In BASL(2), you can have a single statement terminated by a semi-colon,
347       or a group of statements (called compound statement or block) delimited
348       by '{' and '}'. The different kinds of statements that can appear in  a
349       BASL code are:
350
351              1. expression statement
352                     Expression statements are anything of the form:
353
354                             expr ;
355
356                     where expr can be:
357
358                     a)     Arithmetic expressions
359
360                                    lexpr + rexpr   (add)
361                                    lexpr - rexpr   (subtract)
362                                    lexpr * rexpr   (multiply)
363                                    lexpr / rexpr   (divide)
364                                    lexpr % rexpr   (modulus or remainder)
365
366                            NOTE:  Adding, subtracting, multiplying, dividing,
367                            and remaindering will only be allowed  for  proper
368                            types and if the left and right expressions are of
369                            consistent types. The table below illustrates what
370                            types are consistent among the various operators:
371
372                            For +:
373
374                                    lexpr          rexpr
375                                    ============   ============
376                                    Int or Float   Int or Float
377                                    Size           Size
378                                    String         String
379
380                            For -, *, /:
381
382                                    lexpr          rexpr
383                                    ============   ============
384                                    Int or Float   Int or Float
385                                    Size           Size
386
387                            For %:
388
389                                    lexpr          rexpr
390                                    ============   ============
391                                    Int or Float   Int or Float
392
393                            Here are some sample arithmetic expressions state‐
394                            ments:
395                                    Int     i1;
396                                    Int     i2;
397                                    Float   f1;
398                                    Float   f2;
399                                    Size    sz1;
400                                    Size    sz2;
401                                    String  str1;
402                                    String  str2;
403
404                                    i1 + i2;
405                                    f1 - i2;
406                                    sz1 * sz2 * 2b;
407                                    sz1 / 1024b;
408
409                                    str1 = "basl";
410                                    str2 = " cool";
411
412                                    // the following is a string concatenation
413                                    // operation resulting in the string:
414                                    //      "basl cool"
415                                    str1 + str2;
416
417                                    i1 % 10;
418
419                     b)     Unary expressions
420
421                                    +expr     // positive - multiplies by 1 an
422                                                  //        expression that is
423                                                  //        of Int, Float, or
424                                                  //        Size type
425
426                                    -expr     // negative - multiplies by -1 an
427                                                  //        expression that is
428                                                  //        of Int, Float, or
429                                                  //        Size type
430
431                                    !expr     // not - converts a non-zero expr
432                                                  //       value into 0, and a
433                                                  //       zero expr value into 1
434                                                  //       where expr type must be
435                                                  //       of type Int or Float
436
437                            Some sample unary expressions:
438                                    Int i;
439
440                                    +3;
441                                    -(i + 4);
442                                    !i;
443
444                     c)     Logical expressions
445
446                                    lexpr EQ  rexpr
447                                    lexpr NEQ rexpr
448                                    lexpr LT  rexpr
449                                    lexpr LE  rexpr
450                                    lexpr GT  rexpr
451                                    lexpr GE  rexpr
452                                    lexpr AND rexpr
453                                    lexpr OR  rexpr
454
455                            lexpr and rexpr must have types that are  mutually
456                            consistent as shown in the following table:
457
458                                    lterminal-expr   rterminal-expr
459                                    ==============   ==============
460                                    Int or Float     Int or Float
461                                    Dayofweek        Dayofweek
462                                    DateTime         DateTime
463                                    String           String
464                                    Size             Size
465                                    Server           Server
466                                    Que              Que
467                                    Job              Job
468                                    CNode            CNode
469                                    Set Server       Set Server
470                                    Set Que          Set Que
471                                    Set Job          Set Job
472                                    Set CNode        Set CNode
473
474                            For AND, OR operators, the lexpr, rexpr consistent
475                            types are Int or Float.
476
477                            Some sample logical expressions:
478
479                                    i1 EQ  i2;
480                                    i1 NEQ f2;
481                                    dow1 LE dow2;
482                                    d1 LT d2;
483                                    str1 GT str2;
484                                    sz1 GE sz2;
485
486                     d)     Post-operator expressions
487                            These are expressions that are merely shortcut  to
488                            assignment statements.
489
490                                    IDENTIFIER++;    // identifier=identifier+1
491                                    IDENTIFIER--;     // identifier=identifier-1
492
493                            IDENTIFIER must be of Int or Float type.
494
495                            Example:
496                                     Int i;
497                                     Float f;
498
499                                     i++;
500                                     f--;
501
502                     e)     Function call
503
504                                    function-name ( arg1 ,arg2 ... , argN )
505
506                            where arg1, ..., argN can be any constant or vari‐
507                            able. You can't have another function call  as  an
508                            argument.
509                            Example:
510                                    Void pr(Int a) {
511                                            print(a);
512                                    }
513
514                                    pr(5);
515
516                            There  are  certain  predefined  functions  that a
517                            scheduler writer can automatically call in his/her
518                            BASL code without a need to define it. These func‐
519                            tions are referred  to  as  assist  functions  (or
520                            helper  functions)  and  they  are discussed under
521                            PREDEFINED FUNCTIONS topic.
522
523                     f)     Constants
524                            Some valid constant expressions are given  in  the
525                            following:
526                                    5;
527                                    +1.2;
528                                    SUN;
529                                    MON;
530                                    TUE;
531                                    WED;
532                                    THU;
533                                    FRI;
534                                    SAT;
535                                    (4|4|1997);
536                                    (12:01:00);
537                                    (4|4|1997@12:01:00);
538                                    "wonderful";
539                                    -1b;
540                                    SYNCRUN;
541                                    ASYNCRUN;
542                                    DELETE;
543                                    RERUN;
544                                    HOLD;
545                                    RELEASE;
546                                    SIGNAL;
547                                    MODIFYATTR;
548                                    MODIFYRES;
549                                    (1, 3);
550                                    (2.3, 4.6);
551                                    (WED, FRI);
552                                    ((4|4|1997), (4|10|1997));
553                                    ((12:01:00), (12:30:00));
554                                    ((4|4|1997@12:01:00), (4|10|1997@12:30:00));
555                                    (23gb, 50gb);
556                                    NOSERVER;
557                                    NOCNODE;
558                                    NOQUE;
559                                    NOJOB;
560                                    EMPTYSETSERVER;
561                                    EMPTYSETCNODE;
562                                    EMPTYSETQUE;
563                                    EMPTYSETJOB;
564                                    NULLSTR;
565                                    SUCCESS;
566                                    FAIL;
567                                    SERVER_ACTIVE;
568                                    SERVER_IDLE;
569                                    SERVER_SCHED;
570                                    SERVER_TERM;
571                                    SERVER_TERMDELAY;
572                                    QTYPE_E;
573                                    QTYPE_R;
574                                    SCHED_DISABLED;
575                                    SCHED_ENABLED;
576                                    FALSE;
577                                    TRUE;
578                                    TRANSIT;
579                                    QUEUED;
580                                    HELD;
581                                    WAITING;
582                                    RUNNING;
583                                    EXITING;
584                                    CNODE_OFFLINE;
585                                    CNODE_DOWN;
586                                    CNODE_FREE;
587                                    CNODE_RESERVE;
588                                    CNODE_INUSE_EXCLUSIVE;
589                                    CNODE_INUSE_SHARED;
590                                    CNODE_TIMESHARED;
591                                    CNODE_CLUSTER;
592                                    CNODE_UNKNOWN;
593                                    OP_EQ;
594                                    OP_NEQ;
595                                    OP_LE;
596                                    OP_LT;
597                                    OP_GE;
598                                    OP_GT;
599                                    OP_MAX;
600                                    OP_MIN;
601
602                     g)     Identifier
603
604                            Example:
605                                    Int i;
606
607                                    i;
608
609              2. Assignment statement
610
611                             IDENTIFIER = expr ;
612
613                     IDENTIFIER  and  expr  must  have types that are mutually
614                     consistent as illustrated in the following table:
615
616                             identifier        expr
617                             ===============   ===============
618                             Int               Int, Float
619                             Float             Int, Float
620                             Dayofweek         Dayofweek
621                             DateTime          DateTime
622                             String            String
623                             Size              Size
624                             Que               Que
625                             Job               Job
626                             CNode             CNode
627                             Server            Server
628                             Dayofweek         Dayofweek
629                             DateTime          DateTime
630                             Set Server        Set Server
631                             Set Que           Set Que
632                             Set Job           Set Job
633                             Set CNode         Set CNode
634                             Range Int         Range Int
635                             Range Float       Range Float
636                             Range Dayofweek   Range Dayofweek
637                             Range DateTime    Range DateTime
638                             Range Size        Range Size
639
640              3. if...else statement
641                     The format of an if statement is similar  to  that  in  C
642                     with the delimiting "{" and "}" always present:
643
644                             if( expr ) {
645                                     zero or more (true) STATEMENTS
646                             }
647
648                             if( expr ) {
649                                     zero or more (true) STATEMENTS
650                             } else {
651                                     zero or more (false) STATEMENTS
652                             }
653
654                     The  expr  's type must be either Int or Float, and after
655                     evaluation if its value is non-zero, then the true state‐
656                     ments are executed. On the second form, if the expr eval‐
657                     uates to zero, then the false statements are executed.
658
659                     Some sample if statements are given below:
660
661                             if (2 * x )
662                             {
663                                     y = y + 3;
664                                     print(y);
665                             }
666
667                             if (2 * x ) {
668                                     y = y + 3;
669                             } else {
670                                     if( 3 * x ) {
671                                             y = 4;
672                                     } else {
673                                             y = 5;
674                                     }
675                             }
676
677              4. for loop statement
678                     The format of a for statement is as follows:
679
680                             for( start; test; action ) {
681                                     zero or more STATEMENTS
682                             }
683
684                     Just like in C, for first executes start , then evaluates
685                     the test condition to see if it returns a non-zero value.
686                     If it does, the for statements are  executed.  After  the
687                     for  statements  are  executed, then action is evaluated,
688                     and then it checks the test condition again in  the  same
689                     manner  as  before.   start  and  action  can be a simple
690                     assignment  expression  or  a  post-operator  expression.
691                     test is a logical/relational expression.  Some sample for
692                     statements are given in the following:
693
694                             for (i = 0; i LT 3 ; i = i + 1)
695                             {
696                                     print(i);
697                             }
698
699
700                             for (i = 0; i LT 2 * x; i++)
701                             {
702                                     if (x GT 3)
703                                    {
704                                             y = 99;
705                                     } else
706                                     {
707                                             x = 73;
708                                     }
709                             }
710
711              5. foreach loop statement
712                     This  statement  is  primarily  used   for   successively
713                     retrieving  each  element of a Set data type: Set Server,
714                     Set CNode, Set Job, Set Que.  The syntax is:
715
716
717                             foreach ( IDENTIFIER1 in IDENTIFIER2 ) {
718                                     zero or more STATEMENTS
719                             }
720
721                     where the following pairing of types for the  identifiers
722                     are allowed:
723
724                             IDENTIFIER1   IDENTIFIER2
725                             ===========   ===========
726                             Server        Set Server
727                             Que           Set Que
728                             Job           Set Job
729                             CNode         Set CNode
730
731                     Example:
732                             Server  s;
733                             Que     q;
734                             Job     j;
735                             CNode   c;
736
737                             Set Server ss;
738                             Set Que    sq;
739                             Set Job    sj;
740                             Set CNode  sc;
741
742
743                             foreach(s in ss){
744                                     print(s);
745                             }
746                             foreach(q in sq){
747                                     print(q);
748                             }
749                             foreach(j in sj){
750                                     print(j);
751                             }
752                             foreach(c in sc){
753                                     print(c);
754                             }
755
756              6. while loop statement
757                     The syntax of a while loop is:
758
759                             while ( expr ) {
760                                     zero or more STATEMENTS
761                             }
762
763                     where  expr must be of Int or Float type. If expr is non-
764                     zero, then the zero or more STATEMENTS are  executed  and
765                     expr is re-evaluated.
766
767                     Example:
768                             Int i;
769                             i = 3;
770                             while(i) {
771                                     if( i EQ 0 ) {
772                                             print("break on i = 1");
773                                             break;
774                                     }
775                                     i--;
776                             }
777
778              7. switch statement
779                     The  switch  statement  is a mult-way decision that tests
780                     whether an identifier's value matches one of a number  of
781                     values,  and  branches  to  a group of statements accord‐
782                     ingly.
783                     The syntax for a switch statement is:
784
785                             switch( IDENTIFIER )  {
786                                     case constant-expr :
787                                             {
788                                                     zero or more STATEMENTS
789                                             }
790                                     case constant-expr :
791                                             {
792                                                     zero or more STATEMENTS
793                                             }
794                                       ...
795                                     case in constant-rangeOrSet-expr :
796                                             {
797                                                     zero or more STATEMENTS
798                                             }
799                                     case in IDENTIFIER-rangeOrSettype :
800                                             {
801                                                     zero or more STATEMENTS
802                                             }
803                                     default :
804                                             {
805                                                     zero or more STATEMENTS
806                                             }
807                             }
808
809                     where constant-expr is an expr of type Int,  Float,  Day‐
810                     ofweek,  DateTime,  Size,  String,  Server,  Que, Job, or
811                     CNode.   constant-rangeOrSet-expr  and  IDENTIFIER-range‐
812                     OrSettype  can be of type Set Server, Set CNode, Set Que,
813                     Set Job, Range Int, Range Float, Range  Dayofweek,  Range
814                     DateTime, or Range Size.
815
816                     IDENTIFIER  cannot  be  of type Void.  IDENTIFIER 's type
817                     must be consistent with constant-expr 's, constant-range‐
818                     OrSet-expr  's,  and IDENTIFIER-rangeOrSettype 's type as
819                     illustrated in the following table:
820                        IDENTIFIER  constant-range-expr, IDENTIFIER-rangetype
821                        =========== =========================================
822                        Server      Set Server
823                        Que         Set Que
824                        Job         Set Job
825                        CNode       Set CNode
826                        Int         Range Int
827                        Float       Range Float
828                        Dayofweek   Range Dayofweek
829                        DateTime    Range DateTime
830                        Size        Range Size
831
832                     If a case expression matches  the  IDENTIFIER  's  value,
833                     then  the corresponding block of statements are executed.
834                     Unlike in C, execution does NOT fall through to the  next
835                     case  statement.  The reason for this is that basl2c will
836                     translate this switch statement into if-elseif-else  con‐
837                     struct.  The  case labeled default is executed if none of
838                     the other cases are satisfied.  The default is  optional;
839                     if  it  isn't  there,  and if none of the cases match, no
840                     action takes place.
841
842                     Example:
843                             Dayofweek dow;
844
845                             switch(dow)
846                             {
847                                     case MON:
848                                     {
849                                             print("case MON");
850                                     }
851                                     case TUE:
852                                     {
853                                             print("case TUE");
854                                     }
855                                     case WED:
856                                     {
857                                             print("case WED");
858                                     }
859                                     case THU:
860                                     {
861                                             print("case THU");
862                                     }
863                                     case FRI:
864                                     {
865                                             print("case FRI");
866                                     }
867                                     case SAT:
868                                     {
869                                             print("case SAT");
870                                     }
871                                     case SUN:
872                                     {
873                                             print("case SUN");
874                                     }
875                                     default:
876                                     {
877                                             print("case defaulted");
878                                     }
879                             }
880
881                             Int a;
882                             Range Int ri;
883                             ri = (10, 12);
884                             switch(a)
885                             {
886                                     case in (1,5):
887                                     {
888                                             print("case 1,5");
889                                     }
890                                     case in (6,9):
891                                     {
892                                             print("case 6,9");
893                                     }
894                                     case in ri:
895                                     {
896                                             print("case ri");
897                                     }
898                             }
899
900              8. print statement
901                     Print statement is capable  of  printing  to  stdout  the
902                     value  of  any identifier or constant of type Int, Float,
903                     Dayofweek,  DateTime,  String,  Size,  Que,  Job,  CNode,
904                     Server,  Range  Int,  Range Float, Range Dayofweek, Range
905                     DateTime, Range Size.
906                     The syntax is as follows:
907
908                             print ( IDENTIFIER );
909                             print ( constant );
910
911                     Example:
912                             DateTime dt;
913                             CNode cn;
914
915                             dt = (4|4|1997@12:13:36);
916                             cn = AllNodesLocalHostGet();
917
918                             print(dt);
919                             print(cn);
920
921                     For Set types, use foreach to go through each element and
922                     print as in:
923
924                             Server s;
925                             Set Server ss;
926
927                             ss = AllServersGet();
928
929                             foreach(s in ss) {
930                                     print(s);
931                             }
932
933
934              9. continue statement
935
936                             continue ;
937
938                     The  continue  statement  must have been invoked within a
939                     for, foreach, and while loop. It causes the  next  itera‐
940                     tion of the enclosing loop to begin.
941
942
943
944              10. break statement
945
946                             break ;
947
948                     The  break statement must have been invoked within a for,
949                     foreach, and while loop. It provides an early  exit  from
950                     the enclosing loop.
951
952
953              11. return statement
954
955                             return(IDENTIFIER) ;
956                             return(constant) ;
957                             return() ;
958
959                     The  return  statement  provides the value (if any) to be
960                     returned by a function.  The type returned by  IDENTIFIER
961                     and  constant  must  match  the calling function's return
962                     type.  constant types allowed are anything except Set and
963                     Range types.  The last format, return() is usually called
964                     within a function that doesn't return any  value  (  like
965                     sched_main() ).
966
967              12. exit statement
968
969                             exit(constant);
970
971                     where  constant  is of type Int. Calling this will termi‐
972                     nate the scheduler.
973
974              13. Comment statement
975                     These are  statements  prefixed  by  "//"  and  they  are
976                     ignored by the BASL compiler.
977
978                            // this line is ignored
979                            Int i;  // string following the slashes is ignored
980
981

OPERATOR PRECEDENCE AND ASSOCIATIVITY

983       The  following  table  shows the various operator precedence levels and
984       associativity defined in the BASL language.  The operators  are  listed
985       in  the order of decreasing precedence. The higher the precedence of an
986       operator, the earlier it gets executed. The order in which  the  opera‐
987       tors  on the same level are executed depends on the associativity: left
988       means the operators are seen from left to right, while right means they
989       are seen from right to left.
990
991           Operator                                     Associativity
992           =======================================      =============
993           ! ++ -- + (unary plus) - (unary minus)       right
994           * / %                                        left
995           + -                                          left
996           LT LE GT GE                                  left
997           EQ NEQ                                       left
998           AND                                          left
999           OR                                           left
1000           =                                            right
1001

PREDEFINED FUNCTIONS

1003       In  BASL(2), a Server data type maps directly to a batch server object.
1004       Similarly, CNode is to mom/resmom, Job is to batch job, and Que  is  to
1005       batch  queue.  However,  not  all  attributes to the PBS objects can be
1006       accessed from BASL.  Only a subset of attributes, those that seemed  to
1007       make  sense in the context of a scheduler, are made available, and val‐
1008       ues to these attributes can be accessed by calling the following prede‐
1009       fined functions, known also as assist/helper functions.
1010
1011              (1) Server-related functions
1012
1013                     Set Server AllServersGet(void)
1014                            Returns  the list of servers specified in the con‐
1015                            figuration file for  which  the  scheduler  writer
1016                            wants the system to periodically check for status,
1017                            queues and jobs  info.   See  pbs__sched__basl(8B)
1018                            for  a  discussion on the format of the configura‐
1019                            tion file.
1020                            CAUTION: This function must be called from  inside
1021                            sched_main()  so  that  at every scheduling itera‐
1022                            tion, the most up to date Set Server structure  is
1023                            returned.
1024
1025                     Server AllServersLocalHostGet(void)
1026                        Returns  the  Server  object that represents the local
1027                        host.  unset value: NOSERVER.  This is a simple  func‐
1028                        tion  to  call for non-cluster environments where only
1029                        one server host exists.
1030                        CAUTION: This function  must  be  called  from  inside
1031                        sched_main()   (or  from  within  function  called  by
1032                        sched_main) so that at every scheduling iteration, the
1033                        most up to date Server structure is returned.
1034
1035                     String ServerInetAddrGet(Server s)
1036                        Returns name for Server s. unset value: NULLSTR
1037
1038                     String ServerDefQueGet(Server s)
1039                        Returns the default_queue attribute of Server s. unset
1040                        value: NULLSTR
1041
1042                     Int ServerStateGet(Server s)
1043                        Returns server_state attribute of Server s.
1044
1045                        Return value:
1046                               SERVER_ACTIVE,    SERVER_IDLE,    SERVER_SCHED,
1047                               SERVER_TERM, SERVER_TERMDELAY, -1 (unset value)
1048
1049                     Int ServerMaxRunJobsGet(Server s)
1050                        Returns  max_running  attribute  of  Server  s.  unset
1051                        value:  0
1052
1053                     Int ServerMaxRunJobsPerUserGet(Server s)
1054                        Returns max_user_run  attribute  of  Server  s.  unset
1055                        value:  0
1056
1057                     Int ServerMaxRunJobsPerGroupGet(Server s)
1058                        Returns  max_group_run  attribute  of  Server s. unset
1059                        value:  0
1060
1061                     Set Que ServerQueuesGet(Server s)
1062                        Returns list of queues managed by Server s.
1063
1064                     Set Job ServerJobsGet(Server s)
1065                        Returns list of jobs managed by Server s. For  obtain‐
1066                        ing a subset of this list, see QueJobsGet().
1067
1068                     Int ServerIntResAvailGet(Server s, String name)
1069                        Returns  the  value to resource specified in name that
1070                        is available  to  jobs  run  by  this  server  (Server
1071                        resources_available.name  attribute).  Call this func‐
1072                        tion for resources with values that are of  Int  type.
1073                        Sample  resource  names  are:  cput,  pcput, walltime,
1074                        mppt, pmppt, nice, procs, mppe, ncpus, pncpus, nodect,
1075                        srfs_assist,  mta,..., mth. For a description of these
1076                        resource    names,    see     pbs_resources_irix5(7B),
1077                        pbs_resources_sp2(7B),       pbs_resources_sunos4(7B),
1078                        pbs_resources_unicos8(7B),  pbs_server_attributes(7B),
1079                        pbs_resources_irix6(7B), pbs_resources_linux(7B).
1080
1081                        Example:
1082                           Int cpuAvail;
1083                           // return the # of cpus currently available in
1084                           // the server
1085                           cpuAvail = ServerIntResAvailGet(server, "ncpus");
1086
1087                     Size ServerSizeResAvailGet(Server s, String name)
1088                        Returns  the  value to resource specified in name that
1089                        is available  to  jobs  run  by  this  server  (Server
1090                        resources_available.name  attribute).  Call this func‐
1091                        tion for resources with values that are of Size  type.
1092                        Sample  resource  names  are:  file,  mem, pmem, work‐
1093                        ingset,  pf,  ppf,   srfs_tmp,   srfs_wrk,   srfs_big,
1094                        srfs_fast,  sds,  psds.  For  a  description  of these
1095                        resource    names,    see     pbs_resources_irix5(7B),
1096                        pbs_resources_sp2(7B),       pbs_resources_sunos4(7B),
1097                        pbs_resources_unicos8(7B),  pbs_server_attributes(7B),
1098                        pbs_resources_irix6(7B), pbs_resources_linux(7B).
1099
1100                        Example:
1101                           Size memAvail;
1102                           // return the amount of available memory in
1103                           // the server
1104                           memAvail = ServerSizeResAvailGet(server, "mem");
1105
1106                     String ServerStringResAvailGet(Server s, String name)
1107                        Returns  the  value to resource specified in name that
1108                        is available  to  jobs  run  by  this  server  (Server
1109                        resources_available.name  attribute).  Call this func‐
1110                        tion for resources with  values  that  are  of  String
1111                        type.   Sample   resource   names  are:  nodes,  arch,
1112                        neednodes. For a description of these resource  names,
1113                        see   pbs_resources_irix5(7B),  pbs_resources_sp2(7B),
1114                        pbs_resources_sunos4(7B),   pbs_resources_unicos8(7B),
1115                        pbs_server_attributes(7B),    pbs_resources_irix6(7B),
1116                        pbs_resources_linux(7B).
1117
1118                        Example:
1119                           String type;
1120                           // return the architecture (or os type) of
1121                           // the server
1122                           type = ServerStringResAvailGet(server, "arch");
1123
1124                     Int ServerIntResAssignGet(Server s, String name)
1125                        Returns the value to resource specified in  name  that
1126                        is     allocated     to     running    jobs    (Server
1127                        resources_assigned.name attribute). Call this function
1128                        for resources with values that are of Int type. Sample
1129                        resource  names  are:  cput,  pcput,  walltime,  mppt,
1130                        pmppt,  nice,  procs,  mppe,  ncpus,  pncpus,  nodect,
1131                        srfs_assist, mta,..., mth. For a description of  these
1132                        resource     names,    see    pbs_resources_irix5(7B),
1133                        pbs_resources_sp2(7B),       pbs_resources_sunos4(7B),
1134                        pbs_resources_unicos8(7B),  pbs_server_attributes(7B),
1135                        pbs_resources_irix6(7B), pbs_resources_linux(7B).
1136
1137                        Example:
1138                           Int cpuAssn;
1139                           // return the # of cpus currently assigned in
1140                           // the server
1141                           cpuAssn = ServerIntResAssignGet(server, "ncpus");
1142
1143                     Size ServerSizeResAssignGet(Server s, String name)
1144                        Returns the value to resource specified in  name  that
1145                        is     allocated     to     running    jobs    (Server
1146                        resources_assigned.name attribute). Call this function
1147                        for  resources with values that are of Size type. Sam‐
1148                        ple resource names are: file, mem,  pmem,  workingset,
1149                        pf, ppf, srfs_tmp, srfs_wrk, srfs_big, srfs_fast, sds,
1150                        psds. For a description of these resource  names,  see
1151                        pbs_resources_irix5(7B),        pbs_resources_sp2(7B),
1152                        pbs_resources_sunos4(7B),   pbs_resources_unicos8(7B),
1153                        pbs_server_attributes(7B),    pbs_resources_irix6(7B),
1154                        pbs_resources_linux(7B).
1155
1156                        Example:
1157                           Size sdsAssn;
1158                           // return the amount of sds space currently assigned
1159                           // in the server
1160                           sdsAssn = ServerSizeResAssignGet(server, "sds");
1161
1162                     String ServerStringResAssignGet(Server s, String name)
1163                        Returns the value to resource specified in  name  that
1164                        is     allocated     to     running    jobs    (Server
1165                        resources_assigned.name attribute). Call this function
1166                        for  resources  with  values  that are of String type.
1167                        Sample resource names are: nodes, arch, neednodes. For
1168                        a   description   of   these   resource   names,   see
1169                        pbs_resources_irix5(7B),        pbs_resources_sp2(7B),
1170                        pbs_resources_sunos4(7B),   pbs_resources_unicos8(7B),
1171                        pbs_server_attributes(7B),    pbs_resources_irix6(7B),
1172                        pbs_resources_linux(7B).
1173
1174                     Set CNode ServerNodesGet(Server s)
1175                        Returns  the  set  of nodes managed by server s. unset
1176                        value: EMPTYSETCNODE.
1177                        NOTE: You can usually call the following functions for
1178                        the  nodes  returned  by  this  call: CNodeStateGet(),
1179                        CNodePropertiesGet(), and CNodeTypeGet().
1180
1181                     Int ServerNodesQuery(Server s, String spec)
1182                        Issues a request to the specified server to query  the
1183                        availability  of  resources specified in spec.  At the
1184                        present time, the only resource specification  allowed
1185                        is one that involves "nodes" and it can be of the for‐
1186                        mat "nodes", "nodes=", or  "nodes=<type>".  The  query
1187                        results can be accessed by calling the following func‐
1188                        tions:   ServerNodesNumAvailGet(),   ServerNodesNumAl‐
1189                        locGet(),   ServerNodesNumRsvdGet(),   ServerNodesNum‐
1190                        DownGet().
1191                        NOTE: This  is  a  wrapper  to  the  pbs_rescquery(3B)
1192                        server function.
1193
1194                        Return value:
1195                               SUCCESS, FAIL
1196
1197                     Int ServerNodesNumAvailGet(Server s)
1198                        Returns  the  number of nodes available for those man‐
1199                        aged by the specified server, or as reflected  by  the
1200                        most  recent query specified by ServerNodesQuery(). If
1201                        the return value is zero, then this  means  that  some
1202                        number of nodes currently needed to satisfy the speci‐
1203                        fication of ServerNodesQuery() are currently  unavail‐
1204                        able.  The request maybe satisfied at some later time.
1205                        If the result is negative,  no  combination  of  known
1206                        nodes can satisfy the specification.
1207
1208                     Int ServerNodesNumAllocGet(Server s)
1209                        Returns  the  number of nodes allocated for those man‐
1210                        aged by the specified server, or as reflected  by  the
1211                        most recent query specified by ServerNodesQuery().
1212
1213                     Int ServerNodesNumRsvdGet(Server s)
1214                        Returns the number of nodes reserved for those managed
1215                        by the specified server, or as reflected by  the  most
1216                        recent query specified by ServerNodesQuery().
1217
1218                     Int ServerNodesNumDownGet(Server s)
1219                        Returns  the number of nodes down for those managed by
1220                        the specified server, or  as  reflected  by  the  most
1221                        recent query specified by ServerNodesQuery().
1222
1223                     Int ServerNodesReserve(Server s,String spec,Int resId)
1224                        Issues  a  request  to the specified server to reserve
1225                        the resources specified in spec.  A  value  of  0  for
1226                        resId  means that this is for doing a new reservation.
1227                        Otherwise, the number will represent an existing (par‐
1228                        tial)  reservation. Resources  currently  reserved for
1229                        this resId will be released and the  full  reservation
1230                        will  be  attempted  again.   At  the present time the
1231                        only   resources   which   may   be   specified    are
1232                        "nodes".    It  should  be  specified  as nodes=speci‐
1233                        fication where specification is what  a   user  speci‐
1234                        fies  in  the  -l  option argument list for nodes, see
1235                        qsub (1B).
1236                        NOTE: This is a  wrapper  to  the  pbs_rescreserve(3B)
1237                        server function.
1238
1239                        Return value:
1240                               a  reference  number  to  a  successful or par‐
1241                               tially-successful reservation, or FAIL
1242
1243                     Int ServerNodesRelease(Server s, Int resId)
1244                        This releases or frees  resources  reserved  with  the
1245                        reference number specified in resId.
1246                        NOTE:  This  is  a  wrapper to the pbs_rescrelease(3B)
1247                        server function.
1248
1249                        Return value:
1250                               SUCCESS, or FAIL
1251
1252              (2) Que-related functions:
1253
1254                     String QueNameGet( Que que )
1255                            Returns name of Que que. unset value: NULLSTR
1256
1257                     Int QueTypeGet( Que que )
1258                            Returns queue_type attribute of Que que.
1259                            Return value: QTYPE_E (Execution), QTYPE_R  (Rout‐
1260                            ing), -1 (unset value)
1261
1262                     Int QueNumJobsGet( Que que )
1263                            Returns  number of jobs residing in Que que. unset
1264                            value:  0
1265
1266                     Int QueMaxRunJobsGet( Que que )
1267                            Returns max_running attribute of  Que  que.  unset
1268                            value:  0
1269
1270                     Int QueMaxRunJobsPerUserGet( Que que )
1271                            Returns  max_user_run  attribute of Que que. unset
1272                            value:  0
1273
1274                     Int QueMaxRunJobsPerGroupGet( Que que )
1275                            Returns max_group_run attribute of Que que.  unset
1276                            value:  0
1277
1278                     Int QuePriorityGet( Que que )
1279                            Returns  Priority  attribute  of  Que  que.  unset
1280                            value: 0
1281
1282                     Int QueStateGet( Que que )
1283                            Returns started attribute of Que  que  -  the  job
1284                            execution  selection  state of the que: SCHED_DIS‐
1285                            ABLED, SCHED_ENABLED. unset value: SCHED_DISABLED
1286
1287                     Set Job QueJobsGet( Que que )
1288                            Returns the list of  jobs  currently  residing  in
1289                            que.
1290
1291                     Int QueIntResAvailGet(Que q, String name)
1292                            Returns  the  value  to resource specified in name
1293                            that is available to jobs running from this q (Que
1294                            resources_available.name   attribute).  Call  this
1295                            function for resources with values that are of Int
1296                            type.  Sample  resource  names  are:  cput, pcput,
1297                            walltime, mppt, pmppt, nice, procs,  mppe,  ncpus,
1298                            pncpus,  nodect,  srfs_assist, mta,..., mth. For a
1299                            description   of   these   resource   names,   see
1300                            pbs_resources_irix5(7B),    pbs_resources_sp2(7B),
1301                            pbs_resources_sunos4(7B),       pbs_resources_uni‐
1302                            cos8(7B),               pbs_server_attributes(7B),
1303                            pbs_resources_irix6(7B), pbs_resources_linux(7B).
1304
1305                     Size QueSizeResAvailGet(Que q, String name)
1306                            Returns the value to resource  specified  in  name
1307                            that is available to jobs running from this q (Que
1308                            resources_available.name  attribute).  Call   this
1309                            function  for  resources  with  values that are of
1310                            Size type. Sample resource names are:  file,  mem,
1311                            pmem,  workingset,  pf,  ppf,  srfs_tmp, srfs_wrk,
1312                            srfs_big, srfs_fast, sds, psds. For a  description
1313                            of       these       resource      names,      see
1314                            pbs_resources_irix5(7B),    pbs_resources_sp2(7B),
1315                            pbs_resources_sunos4(7B),       pbs_resources_uni‐
1316                            cos8(7B),               pbs_server_attributes(7B),
1317                            pbs_resources_irix6(7B), pbs_resources_linux(7B).
1318
1319                     String QueStringResAvailGet(Que q, String name)
1320                            Returns  the  value  to resource specified in name
1321                            that is available to jobs running from this q (Que
1322                            resources_available.name   attribute).  Call  this
1323                            function for resources with  values  that  are  of
1324                            String  type.  Sample  resource  names are: nodes,
1325                            arch,  neednodes.  For  a  description  of   these
1326                            resource   names,   see   pbs_resources_irix5(7B),
1327                            pbs_resources_sp2(7B),   pbs_resources_sunos4(7B),
1328                            pbs_resources_unicos8(7B),
1329                            pbs_server_attributes(7B),
1330                            pbs_resources_irix6(7B), pbs_resources_linux(7B).
1331
1332                     Int QueIntResAssignGet(Que q, String name)
1333                            Returns  the  value  to resource specified in name
1334                            that is allocated to jobs running from this  queue
1335                            (Que resources_assigned.name attribute). Call this
1336                            function for resources with values that are of Int
1337                            type.  Sample  resource  names  are:  cput, pcput,
1338                            walltime, mppt, pmppt, nice, procs,  mppe,  ncpus,
1339                            pncpus,  nodect,  srfs_assist, mta,..., mth. For a
1340                            description   of   these   resource   names,   see
1341                            pbs_resources_irix5(7B),    pbs_resources_sp2(7B),
1342                            pbs_resources_sunos4(7B),       pbs_resources_uni‐
1343                            cos8(7B),               pbs_server_attributes(7B),
1344                            pbs_resources_irix6(7B), pbs_resources_linux(7B).
1345
1346                     Size QueSizeResAssignGet(Que q, String name)
1347                            Returns the value to resource  specified  in  name
1348                            that is allocated to jobs running from this q (Que
1349                            resources_assigned.name  attribute).   Call   this
1350                            function  for  resources  with  values that are of
1351                            Size type. Sample resource names are:  file,  mem,
1352                            pmem,  workingset,  pf,  ppf,  srfs_tmp, srfs_wrk,
1353                            srfs_big, srfs_fast, sds, psds. For a  description
1354                            of       these       resource      names,      see
1355                            pbs_resources_irix5(7B),    pbs_resources_sp2(7B),
1356                            pbs_resources_sunos4(7B),       pbs_resources_uni‐
1357                            cos8(7B),               pbs_server_attributes(7B),
1358                            pbs_resources_irix6(7B), pbs_resources_linux(7B).
1359
1360                     String QueStringResAssignGet(Que q, String name)
1361                            Returns  the  value  to resource specified in name
1362                            that is allocated to jobs running from this q (Que
1363                            resources_assigned.name   attribute).   Call  this
1364                            function for resources with  values  that  are  of
1365                            String  type.  Sample  resource  names are: nodes,
1366                            arch,  neednodes.  For  a  description  of   these
1367                            resource   names,   see   pbs_resources_irix5(7B),
1368                            pbs_resources_sp2(7B),   pbs_resources_sunos4(7B),
1369                            pbs_resources_unicos8(7B),
1370                            pbs_server_attributes(7B),
1371                            pbs_resources_irix6(7B), pbs_resources_linux(7B).
1372
1373              (3) Job-related functions
1374
1375                     String JobIdGet( Job job )
1376                            Returns  job  identifier  of Job job. unset value:
1377                            NULLSTR
1378
1379                     String JobNameGet( Job job )
1380                            Returns  Job_Name  attribute  of  Job  job.  unset
1381                            value: NULLSTR
1382
1383                     String JobOwnerNameGet( Job job )
1384                            Returns  Job_Owner  attribute  of  Job  job. unset
1385                            value: NULLSTR
1386
1387                     String JobEffectiveUserNameGet( Job job)
1388                            Returns euser attribute of Job job.
1389
1390                     String JobEffectiveGroupNameGet(Job job)
1391                            Returns egroup attribute of Job job. unset  value:
1392                            NULLSTR
1393
1394                     Int JobStateGet ( Job job )
1395                            Returns job_state attribute of Job job.
1396
1397                            Return value:
1398                                   TRANSIT,  QUEUED,  HELD,  WAITING, RUNNING,
1399                                   EXITING, -1 (unset value)
1400
1401                     Int JobPriorityGet( Job job )
1402                            Returns  Priority  attribute  of  Job  job.  unset
1403                            value: 0
1404
1405                     Int JobRerunFlagGet( Job job )
1406                            Returns Rerunable attribute of Job job.
1407                            Return value: FALSE, TRUE, -1 (unset value)
1408
1409                     Int JobInteractiveFlagGet( Job job )
1410                            Returns interactive attribute of Job job.
1411                            Return value: FALSE, TRUE. unset value: FALSE
1412
1413                     DateTime JobDateTimeCreatedGet(Job job)
1414                            Returns  the  ctime  attribute  of Job job.  unset
1415                            value: (0|0|0@-1:-1:-1)
1416
1417                     String JobEmailAddrGet( Job job )
1418                            Returns the Mail_Users attribute of Job job. unset
1419                            value: NULLSTR
1420
1421                     String JobStageinFilesGet( Job job )
1422                            Returns  the  stagein attribute of Job job.  unset
1423                            value: NULLSTR
1424
1425                     String JobStageoutFilesGet( Job job )
1426                            Returns stageout  attribute  of  Job  job.   unset
1427                            value: NULLSTR
1428
1429                     Int JobIntResReqGet(Job job, String name)
1430                            Returns the value to resource specified in name as
1431                            required  by  the  job   (Job   Resource_List.name
1432                            attribute).  Call this function for resources with
1433                            values that are of Int type. Sample resource names
1434                            are:  cput,  pcput,  walltime,  mppt, pmppt, nice,
1435                            procs, mppe, ncpus, pncpus,  nodect,  srfs_assist,
1436                            mta,...,  mth. For a description of these resource
1437                            names,        see         pbs_resources_irix5(7B),
1438                            pbs_resources_sp2(7B),   pbs_resources_sunos4(7B),
1439                            pbs_resources_unicos8(7B),
1440                            pbs_server_attributes(7B),
1441                            pbs_resources_irix6(7B), pbs_resources_linux(7B).
1442
1443                            Example:
1444                               Int cputReq;
1445                               // returns the cput requirement of the job
1446                               cputReq = JobIntResReqGet(job, "cput");
1447
1448                     Size JobSizeResReqGet(Job job, String name)
1449                            Returns the value to resource specified in name as
1450                            required   by   the  job  (Job  Resource_List.name
1451                            attribute). Call this function for resources  with
1452                            values  that  are  of  Size  type. Sample resource
1453                            names are: file, mem, pmem, workingset,  pf,  ppf,
1454                            srfs_tmp,   srfs_wrk,  srfs_big,  srfs_fast,  sds,
1455                            psds. For a description of these  resource  names,
1456                            see                       pbs_resources_irix5(7B),
1457                            pbs_resources_sp2(7B),   pbs_resources_sunos4(7B),
1458                            pbs_resources_unicos8(7B),
1459                            pbs_server_attributes(7B),
1460                            pbs_resources_irix6(7B), pbs_resources_linux(7B).
1461
1462                            Example:
1463                               Size memReq;
1464                               // returns the memory requirement of the job
1465                               memReq = JobSizeResReqGet(job, "mem");
1466
1467                     String JobStringResReqGet(Job job, String name)
1468                            Returns the value to resource specified in name as
1469                            required  by  the  job   (Job   Resource_List.name
1470                            attribute).  Call this function for resources with
1471                            values that are of String  type.  Sample  resource
1472                            names  are: nodes, arch, neednodes. For a descrip‐
1473                            tion    of    these    resource     names,     see
1474                            pbs_resources_irix5(7B),    pbs_resources_sp2(7B),
1475                            pbs_resources_sunos4(7B),       pbs_resources_uni‐
1476                            cos8(7B),               pbs_server_attributes(7B),
1477                            pbs_resources_irix6(7B), pbs_resources_linux(7B).
1478
1479                            Example:
1480                               String nodes;
1481                               // returns the nodes requirement property of
1482                               // the job
1483                               nodes = JobStringResReqGet(job, "nodes");
1484
1485                     Int JobIntResUseGet(Job job, String name)
1486                            Returns the value to resource  specified  in  name
1487                            used   by   the   job   (Job   resources_used.name
1488                            attribute). Call this function for resources  with
1489                            values that are of Int type. Sample resource names
1490                            are: cput, pcput,  walltime,  mppt,  pmppt,  nice,
1491                            procs,  mppe,  ncpus, pncpus, nodect, srfs_assist,
1492                            mta,..., mth. For a description of these  resource
1493                            names,         see        pbs_resources_irix5(7B),
1494                            pbs_resources_sp2(7B),   pbs_resources_sunos4(7B),
1495                            pbs_resources_unicos8(7B),
1496                            pbs_server_attributes(7B),
1497                            pbs_resources_irix6(7B), pbs_resources_linux(7B).
1498
1499                            Example:
1500                               Int walltUse;
1501                               // returns the amount of walltime used by
1502                               // the job
1503                               walltUse = JobIntResUseGet(job, "walltime");
1504
1505                     Size JobSizeResUseGet(Job job, String name)
1506                            Returns  the  value  to resource specified in name
1507                            used   by   the   job   (Job   resources_used.name
1508                            attribute).  Call this function for resources with
1509                            values that are  of  Size  type.  Sample  resource
1510                            names  are:  file, mem, pmem, workingset, pf, ppf,
1511                            srfs_tmp,  srfs_wrk,  srfs_big,  srfs_fast,   sds,
1512                            psds.  For  a description of these resource names,
1513                            see                       pbs_resources_irix5(7B),
1514                            pbs_resources_sp2(7B),   pbs_resources_sunos4(7B),
1515                            pbs_resources_unicos8(7B),
1516                            pbs_server_attributes(7B),
1517                            pbs_resources_irix6(7B), pbs_resources_linux(7B).
1518
1519                            Example:
1520                               Size srfsUse;
1521                               // returns the amount of srfs_fast used by
1522                               // the job
1523                               srfsUse = JobSizeResUseGet(job, "srfs_fast");
1524
1525                     String JobStringResUseGet(Job job, String name)
1526                            Returns the value to resource  specified  in  name
1527                            used   by   the   job   (Job   resources_used.name
1528                            attribute). Call this function for resources  with
1529                            values  that  are  of String type. Sample resource
1530                            names are: nodes, arch, neednodes. For a  descrip‐
1531                            tion     of     these    resource    names,    see
1532                            pbs_resources_irix5(7B),    pbs_resources_sp2(7B),
1533                            pbs_resources_sunos4(7B),       pbs_resources_uni‐
1534                            cos8(7B),               pbs_server_attributes(7B),
1535                            pbs_resources_irix6(7B), pbs_resources_linux(7B).
1536
1537              (4) CNode-related functions
1538
1539                     Set CNode AllNodesGet(void)
1540                            Returns  list  of  nodes  that  are managed by the
1541                            server running on the local host.  This could also
1542                            include  those  nodes  that  were specified in the
1543                            scheduler configuration file for which the  sched‐
1544                            uler writer wants the system to periodically check
1545                            for information like state, property, and  so  on.
1546                            See pbs_sched_basl(8B) for a discussion of config‐
1547                            uration file format.
1548                            CAUTION: This function must be called from  inside
1549                            sched_main()  so  that  at every scheduling itera‐
1550                            tion, the most up to date Set CNode  structure  is
1551                            returned.  Do  not  call  this  from an assignment
1552                            statement intended to initialize  a  global  vari‐
1553                            able, as the statement will only be called once.
1554
1555                     CNode AllNodesLocalHostGet(void)
1556                            Returns the CNode object that represents the local
1557                            host. This is a simple function to call  for  non-
1558                            clustered systems where only 1 CNode exists. unset
1559                            value: NOCNODE
1560                            CAUTION: This function must be called from  inside
1561                            sched_main()  (or  from within functions called by
1562                            sched_main) so that at every scheduling iteration,
1563                            the  most  up to date CNode structure is returned.
1564                            Do not call  this  from  an  assignment  statement
1565                            intended  to  initialize a global variable, as the
1566                            statement will only be called once.
1567
1568                     String CNodeNameGet(CNode node)
1569                            Returns the unique (official)  name  of  the  node
1570                            (i.e. ResMom hostname in a 1 mom/node model). This
1571                            returns the same string that was specified in  the
1572                            configuration file. unset value: NULLSTR
1573
1574                     String CNodeOsGet(CNode node)
1575                            Returns  the  os  architecture  of  the node (i.e.
1576                            "irix5", "sp2"). unset value: NULLSTR
1577
1578                     Int CNodeStateGet( CNode node )
1579                            Returns the node's state.
1580
1581                            Return value:
1582                                   CNODE_OFFLINE,   CNODE_DOWN,    CNODE_FREE,
1583                                   CNODE_RESERVE,       CNODE_INUSE_EXCLUSIVE,
1584                                   CNODE_INUSE_SHARED, CNODE_UNKNOWN
1585
1586                     Int CNodeTypeGet( CNode node )
1587                            Returns the node's type.
1588
1589                            Return value:
1590                                   CNODE_TIMESHARED,            CNODE_CLUSTER,
1591                                   CNODE_UNKNOWN
1592
1593                     String CNodePropertiesGet(CNode node)
1594                            Returns  the  comma-separated  list of other names
1595                            the node is known by ( properties,  other  network
1596                            name).   For  example, "babbage.OpenPBS.org" maybe
1597                            the node name, but it  could  also  be  known  via
1598                            "babbage1, babbage2".  unset value: NULLSTR
1599
1600                     String CNodeVendorGet(CNode node)
1601                            Returns the name of the vendor for the hardware of
1602                            the machine  (i.e.  "sgi",  "ibm").  unset  value:
1603                            NULLSTR
1604
1605                     Int CNodeNumCpusGet(CNode node)
1606                            Returns  the  number of processors attached to the
1607                            node.  unset value: -1
1608
1609                     Size  CNodeMemTotalGet( CNode node, String type )
1610                            Returns total memory of type for the  node.   type
1611                            is  an  arbitrary string that the scheduler writer
1612                            defines in the scheduler configuration file. unset
1613                            value: -1b
1614                            Example:
1615                               // get total physical memory
1616                               CNodeMemTotalGet(node, "real")
1617                               // get total virtual memory
1618                               CNodeMemTotalGet(node, "virtual")
1619
1620                     Size  CNodeMemAvailGet( CNode node, String type )
1621                            Returns  available  memory  of  type for the node.
1622                            type is an arbitrary  string  that  the  scheduler
1623                            writer  defines  in  the  scheduler  configuration
1624                            file.  unset value: -1b
1625                            So sample calls will be:
1626                              // get available physical memory
1627                              CNodeMemAvailGet(node, "real")
1628                              // get available virtual memory
1629                              CNodeMemAvailGet(node, "virtual")
1630
1631                     Int CNodeIdletimeGet( CNode node )
1632                            Returns number of seconds in which no keystroke or
1633                            mouse  movement  has  taken  place on any terminal
1634                            connected to the node.  unset value: -1
1635
1636                     Float CNodeLoadAveGet( CNode  node )
1637                            Returns node's load average for  all  cpus.  unset
1638                            value: -1.0
1639
1640                     Int CNodeCpuPercentIdleGet( CNode  node )
1641                            Returns the percent of idle time that all the pro‐
1642                            cessors of the node have experienced.
1643
1644                     Int CNodeCpuPercentSysGet( CNode  node )
1645                            Returns the percent of time that all  the  proces‐
1646                            sors of the node have spent running kernel code.
1647
1648                     Int CNodeCpuPercentUserGet( CNode  node )
1649                            Returns  the  percent of time that all the proces‐
1650                            sors of the node have spent running user code.
1651
1652                     Int CNodeCpuPercentGuestGet( CNode  node )
1653                            Returns the percent of time that all  the  proces‐
1654                            sors  of the node have spent running a guest oper‐
1655                            ating system.
1656
1657                     Int CNodeNetworkBwGet( CNode node, String type )
1658                            Returns the bandwidth of  the  node's  network  of
1659                            type  in  bytes/second.   type  is  defined by the
1660                            scheduler writer in  the  scheduler  configuration
1661                            file.  unset value: -1
1662                            Some sample calls are:
1663                              CNodeNetworkBwGet( node, "hippi" );
1664                              CNodeNetworkBwGet( node, "fddi" );
1665
1666                     Size CNodeDiskSpaceTotalGet(CNode node, String name)
1667                            Returns  the node's total space on disk identified
1668                            by name where name is the device name  arbitrarily
1669                            defined  by  the scheduler writer in the scheduler
1670                            configuration file.  unset value: -1b
1671                            Example:
1672                              CNodeDiskSpaceTotalGet( node, "/scratch2" );
1673
1674                     Size CNodeDiskSpaceAvailGet(CNode node, String name)
1675                            Returns the node's available space on disk identi‐
1676                            fied  by name where name is arbitrarily defined by
1677                            the scheduler writer in the  scheduler  configura‐
1678                            tion file. unset value: -1b
1679                            Example:
1680                              CNodeDiskSpaceAvailGet( node, "/scratch1" );
1681
1682                     Size CNodeDiskSpaceReservedGet(CNode node, String name)
1683                            Returns  the  node's  reserved space on disk (user
1684                            quota?) identified by name where name is arbitrar‐
1685                            ily  defined by the scheduler writer in the sched‐
1686                            uler configuration file.  unset value: -1b
1687                            Example:
1688                              CNodeDiskSpaceReservedGet( node, "/scratch1" );
1689
1690                     Int CNodeDiskInBwGet( CNode node, String name )
1691                            Returns the write  bandwidth  (bytes/sec)  of  the
1692                            node's disk identified by name .  unset value: -1
1693                            Example:
1694                              CNodeDiskInBwGet( node, "/fast" );
1695
1696                     Int CNodeDiskOutBwGet( CNode node, String name )
1697                            Returns  read  bandwidth (bytes/sec) of the node's
1698                            disk identified by name .  unset value: -1
1699                            Example:
1700                              CNodeDiskOutBwGet( node, "/big" );
1701
1702                     Size CNodeSwapSpaceTotalGet( CNode node, String name )
1703                            Returns the node's total space on swap  identified
1704                            by  name  where name is arbitrarily defined by the
1705                            scheduler writer in  the  scheduler  configuration
1706                            file.  unset value: -1b
1707                            Example:
1708                              CNodeSwapSpaceTotalGet( node, "primary" );
1709
1710                     Size CNodeSwapSpaceAvailGet( CNode node, String name )
1711                            Returns  node's available space on swap identified
1712                            by name where name is the device name  arbitrarily
1713                            defined  by  the scheduler writer in the scheduler
1714                            configuration file.  unset value: -1b
1715                            Example:
1716                              CNodeSwapSpaceAvailGet( node, "secondary" );
1717
1718                     Int CNodeSwapInBwGet( CNode node, String name )
1719                            Returns swapin rate of  the   node's  swap  device
1720                            identified by name.
1721                            Example:
1722                              CNodeSwapInBwGet(node, "secondary");
1723
1724                     Int CNodeSwapOutBwGet( CNode node, String name )
1725                            Returns  the  swapout  rate  of  the   node's swap
1726                            device identified by name.  unset value: -1
1727                            Example:
1728                              CNodeSwapOutBwGet(node, "primary");
1729
1730                     Size CNodeTapeSpaceTotalGet( CNode node, String name )
1731                            Returns the node's total space on tape  identified
1732                            by  name  where name is arbitrarily defined by the
1733                            scheduler writer in  the  scheduler  configuration
1734                            file.  unset value: -1b
1735                            Example:
1736                              CNodeTapeSpaceTotalGet(node, "4mm");
1737
1738                     Size CNodeTapeSpaceAvailGet( CNode node, String name )
1739                            Returns the node's available space on tape identi‐
1740                            fied by name where name is arbitrarily defined  by
1741                            the  scheduler  writer in the scheduler configura‐
1742                            tion file.  unset value: -1b
1743                            Example:
1744                              CNodeTapeSpaceAvailGet(node, "8mm");
1745
1746                     Int CNodeTapeInBwGet( CNode node, String name )
1747                            Returns the write  bandwidth  (bytes/sec)  of  the
1748                            node's tape identified by name .  unset value: -1
1749                            Example:
1750                              CNodeTapeInBwGet( node, "4mm" );
1751
1752                     Int CNodeTapeOutBwGet( CNode node, String name )
1753                            Returns  the  read  bandwidth  (bytes/sec)  of the
1754                            node's tape identified by name .  unset value: -1
1755                            Example:
1756                            CNodeTapeOutBwGet( node, "8mm" );
1757
1758                     Size CNodeSrfsSpaceTotalGet( CNode node, String name )
1759                            Returns the node's  total  space  on  srfs  device
1760                            identified  by  name  where  name  is  arbitrarily
1761                            defined by the scheduler writer in  the  scheduler
1762                            configuration file.  unset value: -1b
1763                            Example:
1764                              CNodeSrfsSpaceTotalGet(node, "/fast");
1765
1766                     Size CNodeSrfsSpaceAvailGet( CNode node, String name )
1767                            Returns  the node's available space on srfs device
1768                            identified  by  name  where  name  is  arbitrarily
1769                            defined by the scheduler writer in some configura‐
1770                            tion file.  unset value: -1b
1771                            Example:
1772                              CNodeSrfsSpaceAvailGet( node, "/big" );
1773
1774                     Size CNodeSrfsSpaceReservedGet(CNode node, String name)
1775                            Returns the node's total amount of reserved  space
1776                            on  srfs  device  identified by name where name is
1777                            arbitrarily defined by the scheduler writer in the
1778                            scheduler configuration file.  unset value: -1b
1779                            Example:
1780                              CNodeSrfsSpaceReservedGet( node, "/fast" );
1781
1782                     Int CNodeSrfsInBwGet( CNode node, String name )
1783                            Returns  the  write  bandwidth  (bytes/sec) of the
1784                            node's srfs device identified  by  name  .   unset
1785                            value: -1
1786                            Example:
1787                              CNodeSrfsInBwGet( node, "/fast" );
1788
1789                     Int CNodeSrfsOutBwGet( CNode node, String name )
1790                            Returns  the  read  bandwidth  (bytes/sec)  of the
1791                            node's srfs device identified  by  name  .   unset
1792                            value: -1
1793                            Example:
1794                            CNodeSrfsOutBwGet( node, "/big" );
1795
1796              (5) Miscellaneous Functions
1797
1798                     DateTime datetimeGet()
1799                            gets the current date/time.
1800
1801                     Int datetimeToSecs(DateTime dt)
1802                            returns the # of seconds since epoch (beginning of
1803                            UNIX time - 00:00:00, January  1,  1970)  for  the
1804                            given date/time dt.
1805
1806                     Int JobAction( Job job, Int action, String param )
1807                            Performs  action  on  job  with  a param specified
1808                            depending on the action.  action can be:  SYNCRUN,
1809                            ASYNCRUN,  DELETE,  RERUN,  HOLD, RELEASE, SIGNAL,
1810                            MODIFYATTR, MODIFYRES where:
1811                              Action              Description
1812                              ===============     ==========================
1813                              SYNCRUN             runs the job synchronously,
1814                                                  meaning the call to
1815                                                  JobAction() will only
1816                                                  return when the job has
1817                                                  started running or when
1818                                                  an error has been
1819                                                  encountered.
1820                                                  Param value:
1821                                                   name of host(s) to run
1822                                                   job under.
1823
1824                              ASYNCRUN            runs the job asynchronously,
1825                                                  meaning the call to
1826                                                  JobAction() will return
1827                                                  immediately as soon as
1828                                                  the run request is
1829                                                  validated by the PBS server,
1830                                                  and not necessarily when
1831                                                  the job has started
1832                                                  execution.
1833                                                  Param value:
1834                                                    name of host(s) to run
1835                                                    job under.
1836
1837                              DELETE              deletes the job.
1838                                                  Param value:
1839                                                    "deldelay=<# of secs>"
1840                                                    - delay # of seconds
1841                                                      between the sending
1842                                                      of SIGTERM and SIGKILL
1843                                                      to the job before
1844                                                      getting deleted.
1845
1846                              RERUN                reruns the running job,
1847                                                   which involves terminating
1848                                                   the session leader of the
1849                                                   job and returning the job
1850                                                   to the queued state.
1851
1852                              HOLD                 places one or more holds
1853                                                   on the job.
1854                                                   Param value:
1855                                                    "u", "o", "s", "uo", "os",
1856                                                    "uos"
1857                                                    - type of holds to place
1858                                                      on job: u(ser), o(ther),
1859                                                      s(ystem).
1860
1861                              RELEASE              removes or releases
1862                                                   holds placed on jobs.
1863                                                   Param value:
1864                                                    "u", "o", "s", "uo", "os",
1865                                                    "uos"
1866                                                    - type of holds to remove
1867                                                      from job: u(ser), o(ther),
1868                                                      s(ystem).
1869
1870                              SIGNAL               sends a signal to the
1871                                                   executing job.
1872                                                   Param value:
1873                                                     "HUP", "SIGHUP",...
1874
1875                              MODIFYATTR           modifies the specified
1876                                                   attribute of the job to
1877                                                   the given value, when
1878                                                   the attrib_name is
1879                                                   != "Resource_List" or
1880                                                   "resources_used".
1881                                                   Param value:
1882                                                     "attrib_name=value"
1883
1884                              MODIFYRES            modifies the job's
1885                                                   Resource_List
1886                                                   attribute given the
1887                                                   res_name and the
1888                                                   res_value:
1889                                                   Resource_List.res_name=
1890                                                                 res_value
1891                                                   Param value:
1892                                                    "res_name=res_val"
1893                            param value depends on the action. Specify NULLSTR
1894                            if no value for this parameter is desired.
1895                            Return value: SUCCESS or FAIL.
1896                            NOTE: Any unrecognized action is ignored.
1897                            Example:
1898                              // run Job j synchronously
1899                              JobAction(j, SYNCRUN, NULLSTR);
1900
1901                              // run Job j asynchronously on host "db"
1902                              JobAction(j, ASYNCRUN, "db");
1903
1904                              // delete Job j
1905                              JobAction(j, DELETE, NULLSTR);
1906
1907                              // delete Job j with a delay of 5 secs
1908                              // between the sending of SIGTERM and
1909                              // SIGKILL
1910                              JobAction(j, DELETE, "deldelay=5");
1911
1912                              // rerun Job j
1913                              JobAction(j, RERUN, NULLSTR);
1914
1915                              // place a u(ser) hold on Job j
1916                              JobAction(j, HOLD, "u");
1917
1918                              // place an o(ther) hold on Job j
1919                              JobAction(j, HOLD, "o");
1920
1921                              // place a s(ystem) hold on Job j
1922                              JobAction(j, HOLD, "s");
1923
1924                              // place a default hold (u) on Job j
1925                              JobAction(j, HOLD, NULLSTR);
1926
1927                              // release u(ser) hold from Job j
1928                              JobAction(j, RELEASE, "u");
1929
1930                              // release o(ther) hold from Job j
1931                              JobAction(j, RELEASE, "o");
1932
1933                              // release s(ystem) hold from Job j
1934                              JobAction(j, RELEASE, "s");
1935
1936                              // release default hold (u) from Job j
1937                              JobAction(j, RELEASE, NULLSTR);
1938
1939                              // send SIGHUP signal to Job j
1940                              JobAction(j, SIGNAL, "SIGHUP");
1941
1942                              // update the comment attribute of Job
1943                              // j to "a message".
1944                              // The param format is: attribute_name=new_value
1945                              // Consult PBS documentation for a list of job
1946                              // attribute names that can be specified.
1947                              JobAction(j, MODIFYATTR, "comment=a message");
1948                              // update the Resource_List.cput attribute of Job
1949                              // j to 3600 seconds.
1950                              // The param format is: resource_name=new_value
1951                              // See pbs_resources* man page for a list of
1952                              // resource_names that can be specified.
1953                              JobAction(j, MODIFYRES, "cput=3600");
1954
1955                     QueJobFind(Que que,Fun Int func,Int cpr,Int value);
1956
1957                     QueJobFind(Que que,Fun String func,Int cpr,String value);
1958
1959                     QueJobFind(Que  que,Fun  DateTime  func,Int  cpr,DateTime
1960                     value);
1961
1962                     QueJobFind(Que que,Fun Size func,Int cpr,Size value);
1963
1964                            where cpr is one of: OP_EQ, OP_NEQ, OP_LE,  OP_LT,
1965                            OP_GE, OP_GT.  func is a function whose ONLY argu‐
1966                            ment is of Job type.  Job is the return type.
1967
1968                            Description: Applies func to every job  in  que  ,
1969                            and  return the first job that satisfies the logi‐
1970                            cal comparison: func(job) cpr value
1971
1972                            Example:
1973
1974                            Size JobVirtualMemAvailGet(Job job)
1975                            {
1976                                Size sz;
1977
1978                                sz = JobSizeResReqGet(job, "mem");
1979                                return(sz);
1980                            }
1981                            Int JobWallTimeReqGet(Job job)
1982                            {
1983                                Int wallt;
1984
1985                                wallt = JobIntResReqGet(job, "walltime");
1986                                return(wallt);
1987                            }
1988
1989                            Int JobCpuTimeUsedGet(Job job)
1990                            {
1991                                Int cput;
1992
1993                                cput = JobIntResUseGet(job, "cput");
1994                                return(cput);
1995                            }
1996
1997                            Que findQueByName(Set Que queues, String qname)
1998                            {
1999                                    Que q;
2000
2001                                    foreach(q in queues) {
2002                                            if( QueNameGet(q) EQ qname ) {
2003                                                   return(q);
2004                                            }
2005                                    }
2006                                    return(NOQUE);
2007                            }
2008                            sched_main()
2009                            {
2010                               Server s;
2011                               Que    que;
2012                               Set Que sq;
2013
2014                               // get local server
2015                               s = AllServersLocalHostGet();
2016
2017                               // get the queues of the Server s
2018                               sq = ServerQueuesGet(s);
2019
2020                               // get the queue named "fast" from the
2021                               // local server
2022                               que = findQueByName( sq, "fast" );
2023
2024                               // Find the 1st job whose walltime requirement
2025                               // is == 300s:
2026                               QueJobFind(que, JobWallTimeReqGet, OP_EQ, 300);
2027
2028                               // Find the 1st job whose email address to
2029                               // notify about job activity != "bayucan":
2030                               QueJobFind(que, JobEmailAddrGet, OP_NEQ,
2031                                                                  "bayucan");
2032
2033                               // Find the 1st job that was created after
2034                               // or on 3/3/1997:
2035                               QueJobFind(que, JobDateTimeCreatedGet, OP_GE,
2036                                                                    (3|3|1997));
2037
2038                               // Find the 1st job that was created after
2039                               // 3:3:44:
2040                               QueJobFind(que, JobDateTimeCreatedGet, OP_GT,
2041                                                                     (3:3:44));
2042
2043                               // Find the 1st job that was created after
2044                               // 3:3:44 on 3/3/1997:
2045                               QueJobFind(que, JobDateTimeCreatedGet, OP_GT,
2046                                                            (3|3|1997@3:3:44));
2047
2048                               // Find the 1st job whose cpu time used < 1600s:
2049                               QueJobFind(que, JobCpuTimeUsedGet, OP_LT, 1600);
2050
2051                               // Find the 1st job whose virtual memory
2052                               // requirement <= 300mb:
2053                               QueJobFind(que, JobVirtualMemAvailGet, OP_LE,
2054                                                                        300mb);
2055                            }
2056
2057                     Job QueJobFind( Que que, Fun Int func,      Int cpr)
2058
2059                     Job QueJobFind( Que que, Fun String func,   Int cpr)
2060
2061                     Job QueJobFind( Que que, Fun DateTime func, Int cpr)
2062
2063                     Job QueJobFind( Que que, Fun Size func,     Int cpr)
2064
2065                            where cpr can be one  of  the  following:  OP_MAX,
2066                            OP_MIN,  func is a function whose only argument is
2067                            of Job type.
2068
2069                            Description: Returns the Job with the max  or  min
2070                            value  found  for  func(job)  as  it is applied to
2071                            every job in que .
2072
2073                            Example:
2074                              Int JobCpuTimeReqGet(Job job)
2075                              {
2076                                Int cput;
2077
2078                                cput = JobIntResReqGet(job, "cput");
2079                                return(cput);
2080                              }
2081                              sched_main()
2082                              {
2083                                Que que;
2084                                Job job;
2085
2086                                // Find the Job with the highest cpu time
2087                                // requirement:
2088                                job = QueJobFind(que, JobCpuTimeReqGet, OP_MAX);
2089
2090                                // Find the Job with the minimum cpu time
2091                                // requirement:
2092                                job = QueJobFind(que, JobCpuTimeReqGet, OP_MIN);
2093                              }
2094
2095                     Que QueFilter(Que que,Fun Int func,Int cpr,Int value)
2096
2097                     Que  QueFilter(Que  que,Fun  String  func,Int  cpr,String
2098                     value)
2099
2100                     Que  QueFilter(Que  que,Fun  DateTime  func,Int  cpr,Date
2101                     value)
2102
2103                     Que QueFilter(Que que,Fun Size func,Int cpr,Size value)
2104
2105                            where cpr can be  one  of  the  following:  OP_EQ,
2106                            OP_NEQ,  OP_LE,  OP_LT,  OP_GE,  OP_GT,  func is a
2107                            function whose only argument is of Job type.
2108
2109                            Description: Applies func to every job  in  que  ,
2110                            and  returns  a  new  que containing all jobs that
2111                            satisfies the comparison condition: func(job)  cpr
2112                            value
2113
2114                            Example:
2115                              Int JobWallTimeReqGet(Job job)
2116                              {
2117                                Int wallt;
2118
2119                                wallt = JobIntResReqGet(job, "walltime");
2120                                return(wallt);
2121                              }
2122                              sched_main()
2123                              {
2124                                Que que;
2125                                Que newq;
2126
2127                                // Returns a new que containing all jobs in "que"
2128                                // with a walltime requirement == 300s:
2129                                newq = QueFilter(que, JobWallTimeReqGet, OP_EQ, 300);
2130
2131                                // Returns a new que containing all jobs in "que"
2132                                // with an email address != "bayucan":
2133                                newq = QueFilter(que, JobEmailAddrGet, OP_NEQ, "bayucan");
2134
2135                                // Returns a new que containing all jobs in "que"
2136                                // created after or on 3/3/1997:
2137                                newq = QueFilter(que, JobDateTimeCreatedGet, OP_GE,
2138                                                                     (3|3|1997));
2139
2140                                // Returns a new que containing all jobs in "que"
2141                                // created after 3:3:44:
2142                                newq = QueFilter(que, JobDateTimeCreatedGet, OP_GT,
2143                                                                      (3:3:44));
2144
2145                                // Returns a new que containing all jobs in "que"
2146                                // created after 3:3:44 on 3/3/1997:
2147                                newq = QueFilter(que, JobDateTimeCreatedGet, OP_GT,
2148                                                              (3|3|1997@3:3:44));
2149
2150                                // NOTE: The original "que" is not modified
2151                                // whatsoever.
2152                              }
2153
2154                     Int Sort(Set Job s, Fun Int      key, Int order)
2155
2156                     Int Sort(Set Job s, Fun String   key, Int order)
2157
2158                     Int Sort(Set Job s, Fun Float    key, Int order)
2159
2160                     Int Sort(Set Job s, Fun DateTime key, Int order)
2161
2162                     Int Sort(Set Job s, Fun Size     key, Int order)
2163
2164                            where s the set of jobs to sort.  key is the sort‐
2165                            ing key which is a function whose only argument is
2166                            of  Job  type,  order  is  the sorting order: ASC,
2167                            DESC.
2168
2169                            Description: sorts the elements of s ,  in  either
2170                            ASCending  or DESCending order of values that were
2171                            returned by the key function, as applied to  every
2172                            member  of  the set of jobs. The s object is modi‐
2173                            fied with this call. This returns SUCCESS or  FAIL
2174                            depending on outcome of the sort.
2175
2176                            Examples:
2177                              Size JobMemReqGet(Job job)
2178                              {
2179                                    Size mem;
2180
2181                                    mem = JobSizeResReqGet(job, "mem");
2182                                    return(mem);
2183                              }
2184
2185                              sched_main()
2186                              {
2187                                    Server  master;
2188
2189                                    Set Job jobs;
2190
2191                                    Int     order;
2192
2193                                    // get local server
2194                                    master = AllServersLocalHostGet();
2195
2196                                    jobs = ServerJobsGet(master);
2197                                    Sort(jobs, JobPriorityGet, ASC);
2198                                    Sort(jobs, JobIdGet, DESC);
2199                                    order = ASC;
2200                                    Sort(jobs, JobDateTimeCreatedGet, order);
2201                                    order = DESC;
2202                                    Sort(jobs, JobMemReqGet, order);
2203                              }
2204
2205                     Int Sort(Set Que s, Fun Int      key, Int order)
2206
2207                     Int Sort(Set Que s, Fun String   key, Int order)
2208
2209                     Int Sort(Set Que s, Fun Float    key, Int order)
2210
2211                     Int Sort(Set Que s, Fun DateTime key, Int order)
2212
2213                     Int Sort(Set Que s, Fun Size     key, Int order)
2214
2215                            where  s  the  set  of queues to sort.  key is the
2216                            sorting key which is a function whose  only  argu‐
2217                            ment  is  of Que type, order is the sorting order:
2218                            ASC, DESC.
2219
2220                            Description: sorts the elements of s ,  in  either
2221                            ASCending  or DESCending order of values that were
2222                            returned by the key function, as applied to  every
2223                            member of the set of queues. The s object is modi‐
2224                            fied with this call. This returns SUCCESS or  FAIL
2225                            depending on outcome of the sort.
2226
2227                            Examples:
2228                              Size QueMemAvailGet(Que que)
2229                              {
2230                                    Size mem;
2231
2232                                    mem = QueSizeResAvailGet(que, "mem");
2233                                    return(mem);
2234                              }
2235
2236                              sched_main()
2237                              {
2238                                    Server  master;
2239
2240                                    Set Que ques;
2241                                    Int     order;
2242
2243                                    // get local server
2244                                    master = AllServersLocalHostGet();
2245
2246                                    ques = ServerQueuesGet(master);
2247                                    Sort(ques, QuePriorityGet, ASC);
2248                                    Sort(ques, QueNameGet, ASC);
2249                                    order = DESC;
2250                                    Sort(ques, QueMemAvailGet, order);
2251                              }
2252
2253                     Int Sort(Set Server s, Fun Int      key, Int order)
2254
2255                     Int Sort(Set Server s, Fun String   key, Int order)
2256
2257                     Int Sort(Set Server s, Fun Float    key, Int order)
2258
2259                     Int Sort(Set Server s, Fun DateTime key, Int order)
2260
2261                     Int Sort(Set Server s, Fun Size     key, Int order)
2262
2263                            where  s  the  set of servers to sort.  key is the
2264                            sorting key which is a function whose  only  argu‐
2265                            ment  is  of  Server  type,  order  is the sorting
2266                            order: ASC, DESC.
2267
2268                            Description: sorts the elements of s ,  in  either
2269                            ASCending  or DESCending order of values that were
2270                            returned by the key function, as applied to  every
2271                            member  of  the  set  of servers.  The s object is
2272                            modified with this call. This returns  SUCCESS  or
2273                            FAIL depending on outcome of the sort.
2274
2275                            Examples:
2276                              Size ServerMemAvailGet(Server serv)
2277                              {
2278                                    Size mem;
2279
2280                                    mem = ServerSizeResAvailGet(serv, "mem");
2281                                    return(mem);
2282                              }
2283
2284                              sched_main()
2285                              {
2286                                    Set Server sserver;
2287
2288                                    Int     order;
2289
2290                                    Int     ret;
2291
2292                                    sserver = AllServersGet();
2293
2294                                    ret = Sort(sserver, ServerMaxRunJobsGet, ASC);
2295                                    Sort(sserver, ServerInetAddrGet, ASC);
2296
2297                                    order = DESC;
2298                                    Sort(sserver, ServerMemAvailGet, order);
2299                              }
2300
2301                     Int Sort(Set CNode s, Fun Int      key, Int order)
2302
2303                     Int Sort(Set CNode s, Fun String   key, Int order)
2304
2305                     Int Sort(Set CNode s, Fun Float    key, Int order)
2306
2307                     Int Sort(Set CNode s, Fun DateTime key, Int order)
2308
2309                     Int Sort(Set CNode s, Fun Size     key, Int order)
2310
2311                            where  s  the  set  of  nodes to sort.  key is the
2312                            sorting key which is a function whose  only  argu‐
2313                            ment is of CNode type, order is the sorting order:
2314                            ASC, DESC.
2315
2316                            Description: sorts the elements of s ,  in  either
2317                            ASCending  or DESCending order of values that were
2318                            returned by the key function, as applied to  every
2319                            member of the set of nodes.  The s object is modi‐
2320                            fied with this call. This returns SUCCESS or  FAIL
2321                            depending on outcome of the sort.
2322
2323                            Examples:
2324                              Size CNodeMyMemAvailGet(CNode cn)
2325                              {
2326                                    Size mem;
2327
2328                                    mem = CNodeMemAvailGet(cn, "virtual");
2329                                    return(mem);
2330                              }
2331
2332                              sched_main()
2333                              {
2334                                    Set CNode scnode;
2335
2336                                    Int     order;
2337
2338                                    scnode = AllNodesGet();
2339
2340                                    Sort(scnode, CNodeIdletimeGet, ASC);
2341                                    Sort(scnode, CNodeNameGet, ASC);
2342                                    order = DESC;
2343                                    Sort(scnode, CNodeMyMemAvailGet, order);
2344                              }
2345

CNode..Get() FUNCTIONS

2347       The return values of the CNode..Get() functions discussed in the previ‐
2348       ous section are obtained by sending resource queries to the CNode's MOM
2349       at every scheduling iteration.  For example, CNodeLoadAveGet(node) will
2350       return the value obtained from some <host resource> query  (this  could
2351       be  the  string  "loadave")  as  sent  to  the  node's MOM.  The "<host
2352       resource> -> CNode..Get()" mappings  are  established  internally,  but
2353       they  can  be  modified or more mappings can be added via the scheduler
2354       configuration file. The config file is discussed in pbs_sched_basl(8B).
2355       Mappings already established are given in the following:
2356
2357       For all architectures:
2358
2359          CNode..Get() actual call    host resource
2360          ========================    =============
2361          CNodeOsGet(node)            arch
2362          CNodeLoadAveGet(node)       loadave
2363          CNodeIdletimeGet(node)      idletime
2364
2365

SEE ALSO

2367       pbs_sched_basl(8B)  pbs_job_attributes(7B),   pbs_queue_attributes(7B),
2368       pbs_resources_irix5(7B),                         pbs_resources_sp2(7B),
2369       pbs_resources_sunos4(7B),                    pbs_resources_unicos8(7B),
2370       pbs_server_attributes(7B), and pbs_server(8B), pbs_resources_irix6(7B),
2371       pbs_resources_linux(7B).
2372
2373
2374
2375Local                                                               basl2c(1B)
Impressum