!*** CLSubmit ******************************************************************* !* !* submits a program to the batch queue. !* !* Creates an initialization file in the current directory, !* containing all qualifiers that are needed to run this !* program in Batch. Also creates a command file which submits !* this program to the batch queue, using the Init File that was created. !* The Init file and the Command file names will be !* of the format: ProgramName_Time.Extension, where ProgramName !* is the name of the program, time is in the format hhmmss, !* and Extension is .Init or .Com. The Command file will delete !* itself, and the initialization file, unless the user has used !* the /NODELete option on the command line. !* !* The program is submitted to the batch using the symbol, !* 'ProgramName'SubmitCommand. (For example, FastaSubmitCommand). !* If that symbol is not defined, the default symbol, GCGSubmitCommand !* is used. !* !* AFRC modifications insist on a Queue name for the batch job. !* The quename can be given on the command line with /Queue='quename'. !* If absent it is prompted for. !* !* This routine uses the VMS command Lib$Do_command to submit !* the program, therefore this routine will never return back !* to it's caller. !* !****************************************************************************** Subroutine CLSubmit() Implicit None Include 'GenInclude:CLCommon.inc' Character Command(256), FileName(256), SubmitSymbol(256) Character ComFileName(256) Integer ComFile, InitFile, I, J, Pos, Ptr Character CommandLine(255), OneLine(256) Character SubmitCommand(255) ! this can't be greater than 255 Character ThisDir(255), Qualifier(255), TempStr(2000) Character Progname(32), Trans(255), Token(5) Character*8 TimeBuf Logical Delete Logical OpenF, DCLGetSymbol, GetDir, CLGetBool Logical LogName Integer ImageName, StrCopy, Str_Len, StrFind ! AFRC modification get the batch queue name Logical CLGetParam, CLNoInteract Character QueName(100) Integer Getstring, StrToUpper Call ProgramName(ProgName) ! AFRC modification to create names based on the output filename If ( CLGetParam('OUTfile1', 1, FileName) ) Then Call AlphaNumFilter(FileName) ! remove '.' from the file name !* Need to restrict Filename to 32 characters ? Else Call Time(TimeBuf) Call AlphaNumFilter(TimeBuf) ! remove ':' from the time string Call SWriteF(FileName, '%s_%s', ProgName, TimeBuf) End if Call SWriteF(ComFileName, '%s.Com', FileName) If ( .not.OpenF(ComFile, ComFileName, 'w') ) & Call WriteF('\n Error. Unable to create a "%s" file to submit '// & ' to the batch queue.\n\b\s', ComFileName) !********************************************************** ! AFRC modification get the batch queue name Call StrCopy(QueName, 'OFFPEAK') If ( .not.CLGetParam('Queue', 2, QueName) ) Then If ( .not.CLNoInteract() ) then Call WriteF('\n Submit %s job to which batch queue '// & '(* %s *) ? ', Progname ,QueName) If ( GetString(QueName).eq.0 ) Continue End If End If Str_len = StrToUpper(QueName) !********************************************************** ! Create an Init file with a unique name, and put all the ! command line qualifiers into the init file. Call StrConCat(FileName, '.Init') If ( .not.OpenF(InitFile, FileName, 'w') ) & Call WriteF('\n **Error. Unable to create an initialization file,'// & ' "%s".\n\b\s', FileName) ! Make sure all the qualifiers are correctly loaded Call CLRemQual('BATch') ! make sure this is removed ! AFRC addition Call CLRemQual('Queue') ! make sure this is removed Call CLAddQual('Default') ! disable prompts in batch mode If ( .not.Ready ) Call CLParse ! Make sure CL structures are current ! add each qualifier to the init file. Call FWriteF(InitFile, '..\n') ! Note: if something on the command line does't begin with QUALMARKER, then ! it's a parameter, and we don't need to add it to the init file. ! we'll be adding it as a /qualifer=value... ! Use the internal command line ! to create the init file, so that we have the actual syntax as it was typed ! on the command line. Ptr = 0 Call StrCopy(TempStr, CLComLine) Qualifier(1) = QUALMARKER J = StrFind(QUALMARKER, TempStr) Do While ( J.ne.0 ) I = 2 Ptr = J + 1 Do While ( TempStr(Ptr).ne.QUALMARKER .and. & TempStr(Ptr).ne.' ' ) Qualifier(I) = TempStr(Ptr) Ptr = Ptr + 1 I = I + 1 End Do Qualifier(I) = Char(0) Call FWriteF(InitFile, '%s\n', Qualifier) Call StrShift(TempStr, -(Ptr-1) ) J = StrFind(QUALMARKER, TempStr) End Do ! ! This method is for recreating the command line from the internal structures ! that CLParse populated. Problem with using this method is that we loose ! how the qualifier value was put on the command line - important for strings ! which contain quotes! ! Do I = 1, QCount ! Call StrCopy(Qualifier, QUALMARKER) ! Call StrConCat(Qualifier, Quals(1,I)) ! If ( QValues(1,I).ne.Char(0) ) Then ! J = 1 ! Call StrCopy(Token, '=') ! Do While ( StrCopy(TempStr, QValues(J,I)).ne.0 ) ! Call SWriteF(Qualifier, '~%s%s', Token, TempStr) ! Call StrCopy(Token, ',') ! J = J + Str_Len(TempStr) + 1 ! End Do ! End If ! Call FWriteF(InitFile, '%s\n', Qualifier) ! End Do ! create a command file to submit to the batch queue If ( .not.LogName('GCGInitCommand',Trans) ) & Call StrCopy(Trans, 'GCG') Call FWriteF(ComFile, '$ %s\n', Trans) ! Define a symbol for the image they were running... Call ImageName(Command) Call FWriteF(ComFile, '$ Go := $%s\n', Command) ! Set default to the current directory. If ( GetDir(ThisDir) ) & Call FWriteF(ComFile, '$ Set Default %s\n', ThisDir) ! Type out the program and the initialization file being used. Call FWriteF(ComFile, '$ Write Sys$OutPut " Running %s '// & ' using : "\n', ProgName) Call FWriteF(ComFile, '$ Type %s\n', FileName) ! resubmit the program, using the command exactly as they used it ! from the command line. Call FWriteF(ComFile, '$ Go %s/Init=%s\n', OneLine, FileName) ! Delete the command file and the init file ! unless they said not to with /NODELete Delete = .TRUE. Call CLGetBool('DELete', Delete) If ( Delete ) Then Call FWriteF(ComFile, '$ Delete/NoLog %.5n\n', InitFile) Call FWriteF(ComFile, '$ Delete/NoLog %.5n\n', ComFile) End If Call WriteF('\n ** %s will run as a batch job.\n', ProgName) Call StrCopy(SubmitSymbol, ProgName) Call StrConcat(SubmitSymbol, 'SubmitCommand') ! If a symbol is not defined to submit this program to the batch queue, ! use the default symbol, 'GCGSubmitSymbol'. If that is not defined, ! use Submit/NoPrint. If ( .not.DCLGetSymbol(SubmitSymbol, Trans) ) Then Call StrCopy(SubmitSymbol, 'GCGSubmitCommand') If ( .not.DCLGetSymbol(SubmitSymbol, Trans) ) Then Call StrCopy(SubmitSymbol, 'Submit/NoPrint') Call StrCopy(Trans, SubmitSymbol) End If End If !* AFRC - Append the Queue name and COM file name as PARAMETERS to !* GCGSUBMITCOMMAND !* The GCGSUBMITCOMMAND symbol must be defined in the startup of GCG as: !* $ GCGSubmitCommand:==@gensitecom:gcgsubmit.com !* And the GENSITECOM:GCGSUBMIT.COM file's active line is: !* $ submit/notify/noprint/que='P1'/cpu=infinite/- !* log='f$environ("default")' 'P2' !* This gets a log file in the default directory. !* NB: f$environment with lib$do_command does not work. Call StrConcat(Trans, ' ') Call StrConcat(Trans, Quename) !* AFRC - recalculate the SubmitSymbol Call StrCopy(SubmitSymbol,Trans) Call SWriteF(SubmitCommand, '$ %s %s', SubmitSymbol, ComFileName) Call WriteF('\n\b ** %s was submitted to the %s queue.\n\n', & ProgName, Quename) Call Lib$Do_Command(SubmitCommand) End ! of CLSubmit