LWKDIR (Assist to Set-up Working Dir. and Process Parameters, etc.)


PROMPT, PREMSG, DPCINI, DPCENT, STRDTM, LRTRIM,
ABEND, ABENDM, OPNPIN, CLSPIN, LWKDIR,
PARMIN, GPARMA, GPARMI, GPARMF, GPARMD,
GPARMIF, GPARMID, GPARMI2, GPARMF2, GPARMD2
GETARGS
   To realize this group's functions, the main source program 'lwkdir.c' and
  additional sources of 'opnpin.c' and 'getargs.f90' are used cooperatively.

NAME
    prompt / premsg - Output message to screen with/without NewLine.
    dpcini / dpcent - Display the progress of loop operation.
    strdtm - Get Date/Time string at the moment.
    lrtrim - Get character length of a string trimmed off right spaces.
    abend  - Error exit with "ERROR n" output to <stderr>.
    abendm - Error exit with "[ABEND] message" output to <stderr>.
    opnpin / clspin - Provide a chance to select predefined data file 
                      as a data source for reading process parameters.
    lwkdir - Display HOME (~) and CURRENT (.) directory paths, prompt and wait
             for specifying Working Directory Path, and then dispay absolute
             path name of that directory and filename list in it.
             The absolute pathname of the directory is returned as a string
             (with trailing '/'), which can be used to specify absolute
             filename simply by appending short filename.
         Here the "Working Directory" does not mean the change of Current
         Working Directory environment, but offers the easier way of
         specifying absolute path to target file.
    parmin / gparma / gparmi / gparmf / gparmd
     / gparmif / gparmid / gparmi2 / gparmf2 / gparmd2
           - Output prompt message and read process parameter(s).
    getargs - Get array of parameter strings of the command which initiated
             the main program process.

SYNOPSIS

      call prompt(mesg)
  mesg  [char]  Message string to output.
          Output message to screen ("stderr" output).
      call premsg(mesg) 
  mesg  [char]  Message string to output.
          Output message with NewLine to screen ("stderr" output).

      call dpcini(pmsg)
  pmsg  [char]  Heading string (30 chars or less) for the progress display.
      call dpcent(m, n)
  n     [int]   Total number of loops.
  m     [int]   Number of loops executed already.
          The ratio of progress is considered to be (m / n).

      call strdtm(sdtm)
  sdtm  [char*20]   Character variable of 20 bytes long.
          String in the form of "YYYY-MM-DD hh:mm:ss " is given.

      nc = lrtrim(chrs)
  chrs  [char]  String to be processed.
  nc    [int]   Character length after trimming right spaces for "chrs".

      call abend(icd)
  icd   [int]   Code number to be output to <stderr>.
      call abendm(msg)
  msg   [char]  Message text to be output to <stderr>.

      call opnpin()
          Give a chance to select predefined data file for parameter input.
          If NULL string is specified, process parameters are read from 
          Keyboard as usual.  This mechanism is effective for "lwkdir" 
          function and "parmin/gparm?i/gparm??" routines until "clspin" 
          is called.
      call clspin()
          Finalize the "opnpin" mechanism.

          Source codes of opnpin.c and getargs.f90 files are incorporated with
          lwkdir.c to realize opnpin() and clspin() functions.

      nch = lwkdir(len, dnm)
  len   [int]   Maximum length of string variable 'dnm'.
  dnm   [char]  String variable to return the absolute pathname of Working
                Directory.  (must be of size more than 'len'.)
  nch   [int]   Number of characters returned in 'dnm'.

          The string returned in 'dnm' is in the form of FORTRAN language
          string having a trailing SPACE character(s).
          If the length of path string of specified working directory is equal
          to or larger than 'len', the process is terminated abnomally with
          an error message output.

          If the length of path string of HOME (~), CURRENT (.), or Working
          Directory specifier is larger than 80, the process is terminated
          abnomally with an error message output.

      call parmin(str, lbuf, buf)
  str   [char]   Prompt message string.
  lbuf  [int]    Maximum size (in bytes) to input to buf.
  buf   [char]   Raw input string.
          Output prompt message and input raw string under "opnpin" control.

      call gparma(str, lnam, nam)
      call gparmi(str, iv)
      call gparmf(str, fv)
      call gparmd(str, dv)
      call gparmif(str, iv, fv)
      call gparmid(str, iv, dv)
      call gparmi2(str, iv, jv)
      call gparmf2(str, fv, gv)
      call gparmd2(str, dv, ev)
  str   [char]   Prompt message string.
  lnam  [int]    Maximum size (in bytes) to input to nam.
  nam   [char]   String parameter without in-between white space is given.
  iv,jv [int]    Integer value parameter is given.
  fv,gv [float]  Floating value parameter is given.
  dv,ev [double] Double floating value parameter is given.
          Output prompt message and read parameter(s) under "opnpin" control.

      call getargs(m, args, n)
  m      [int]    Number of elements of array 'args'.
  args   [char]   Array of character areas to receive parameter strings.
                  If the length of parameter string is not equal to the size
                  of array element, the string is shortened, or the rest is
                  filled with blank character(s).
  n      [int]    The number of parameter strings actually received is given.

EXAMPLE

  character(80) :: wdr; character(120) :: fnam
  call premsg('--- start ---')
  call opnpin()
  ldr = lwkdir(80,wdr) + 1
  fnam = wdr
  call gparma('Enter filename ==> ', 121-ldr, fnam(ldr:120))
  open(10,file=fnam,status='old')
  write(6,'(a,a)') 'Input file : ', fnam(1:lrtrim(fnam))
      :
      :
  call clspin()
  call dpcini('Loop operation - ')
  do i=1,imax
    do j=1,jmax
        :
        :
      call dpcent((i-1)*jmax+j, imax*jmax)
    enddo
  enddo
      :
      :
  if (.....) call abend(90)
      :
      :