SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Staff SED Projects SED Products and Publications Search SED Pages
Dataplot Vol 1 Vol 2

EXECUTE

Name:
    EXECUTE (LET)
Type:
    Let Subcommand
Purpose:
    Execute an external program.
Description:
    The external program is executed with the command

      LET Y = EXECUTE <file> X

    The above command will write the data in the variable X to the file "dpst1f.dat" and then execute the command

      <file>     < dpst1f.dat     >     dpst2f.dat

    The output in file "dpst2f.dat" will be read into the variable Y.

    Note that the first line written to dpst1f.dat will be an integer that specifies the number of lines in X.

    Although this command was motivated primarily to be used within a FUNCTION BLOCK or a STATISTIC BLOCK, it can be used independently of function blocks and statistic blocks.

    The LET FUNCTION command can be used to define functions in Dataplot. The FUNCTION BLOCK command can be used to define functions that cannot be defined using the LET FUNCTION command. For functions that cannot be defined using Dataplot commands within a function block, then the EXECUTE command provides an alternative that allows you to create your own functions in whatever language is most convenient.

Syntax:
    LET <y> = EXECUTE <file> <x>
    where <file> is the name of the external file to be executed;
                <x> is a variable containing data that will be read from standard input of the external program;
                and <y> is a variable containing data that will be written to standard output by the external program.
Examples:
    LET Y = EXECUTE ./SUM.EXE .DAT X
    LET Y = EXECUTE "MY FILES\OPT.EXE" X
Note:
    The specified file name should be given as a literal string. If the file name is stored in a string, you can use the "^" character as in

      LET Y = EXECUTE ^FNAME X
Note:
    If the external file name contans hyphens or spaces, you need to enclose the file name in double quotes ("). For Linux/Unix and Mac OS X systems, if the external file is in the current directory, you may need to add a "./" in front of the file name (alternatively you can specifiy the absolute path name).

    The file name is currently limited to 80 characters.

Note:
    Although the program examples below execute Fortran programs, you are not limited to this. You can create the external program in any language that is convenient for you as long as that language can generate executable files that can be executed from the command line and can read from standard input and write to standard output.
Note:
    Dataplot will write the specified variable to "dpst1f.dat" using a Fortran E15.7 format. One value per line will be written. It is up to you to create the data needed by your external program. The COMBINE command can be used to create a combination of parameters and variables into a single variable.

    It may be that you need to read additional information into the external program. You can have your external program read any additional needed files.

Default:
    None
Synonyms:
    None
Related Commands: Applications:
    Functions
Implementation Date:
    2016/02
Program 1:
     
    . Step 1:   Create the external program (for Linux)
    .
    capture script test.f
          program test
    c
    c     Test Dataplot LET ... EXECUTE .... command.
    c
    c     For this simple example, read in a data set and
    c     compute the mean and standard deviation.
    c
          real x(10000)
    c
          xmean=0.0
          xsd=0.0
          nval=0
          read(*,*,end=9020,err=9020)nval
    c
          sum1=0.0
          do 10 i=1,min(nval,10000)
             read(*,*,end=19,err=9020)x(i)
             sum1=sum1 + x(i)
       10 continue
       19 continue
          if(nval.ge.1)then
            xmean=sum1/real(nval)
          endif
    c
          if(nval.gt.1)then
            sum1=0.0
            do 20 i=1,nval
               sum1=sum1 + (x(i)-xmean)**2
      20    continue
            xsd=sum1/real(nval-1)
          endif
    c
     9020 continue
          write(*,*)xmean
          write(*,*)xsd
    c
          stop
          end
    end of capture
    .
    system gfortran -o test.exe  test.f
    .
    . Step 2:   Read the Data
    .
    skip 25
    read zarr13.dat x
    .
    . Step 3:   Test the command
    .
    let y = execute ./test.exe  x
    let ymean = y(1)
    let ysd   = y(2)
        
Program 2:
     
    . Step 1:   Create and compile the Fortran code
    .
    capture script exec2.for
          program exec
    c
    c     Test Dataplot LET ... EXECUTE .... command.
    c
    c     For this simple example, read in a data set and
    c     compute the 2-parameter Weibull log-likelihood
    c     equations (specifically, solve for the shape parameter).
    c
          real x(10000)
    c
          nval=0
          read(*,*,end=9020,err=9020)nval
          read(*,*,end=9020,err=9020)g
    c
          sum1=0.0
          sum2=0.0
          sum3=0.0
          do 10 i=1,10000
             read(*,*,end=19,err=9020)aval
             z=log(aval)
             y2=aval**g
             w=y2*z
             sum1=sum1 + w
             sum2=sum2 + y2
             sum3=sum3 + z
       10 continue
       19 continue
    c
          n=nval-1
          c1=sum3/real(n)
          c2=1.0/g
          a=c2-(sum1/sum2) + c1
    c
     9020 continue
          write(*,*)a
    c
          stop
          end
    end of capture
    .
    system gfortran -o exec2.exe  exec2.for
    .
    . Step 1:   Read the data
    .
    skip 25
    read weibbury.dat x
    skip 0
    .
    . Step 2:   Define the function block
    .
    capture function block one f a g
    let z = execute ./exec2.exe x
    let a  = z(1)
    end of capture
    .
    list function block one
    .
    . Step 3:   Plot the function
    .
    title offset 2
    title case asis
    label case ais
    y1label Function Response A
    x1label G Parameter 
    title Function Block with Plot Command
    plot f for g = 2 0.05 20
    .
    . Step 3:   Now use it to solve an equation
    .
    let yroot = roots f wrt g for g = 2  20
    let ztemp = yroot(1)
    .
    line dash
    drawsdsd 15 0 85 0
    drawdsds ztemp 20 ztemp 90
        
    The following output is generated
     ROOTS OF AN EQUATION
           ROOT VARIABLE                     = G
           SPECIFIED LOWER LIMIT OF INTERVAL =         2.0000000000
           SPECIFIED UPPER LIMIT OF INTERVAL =        20.0000000000
      
           NUMBER OF ROOTS FOUND IN INTERVAL =        1
      
     ROOT     1 =    8.117594
      
      
     THE NUMBER OF VALUES GENERATED FOR THE VARIABLE YROOT    =        1
      
     THE FIRST          COMPUTED VALUE OF YROOT    =   0.8117594E+01 (ROW     1)
     NOTE--THE ABOVE VALUE WAS THE ONLY VALUE COMPUTED FOR THIS VARIABLE.
        
    plot generated by sample program
Date created: 02/29/2016
Last updated: 12/11/2023

Please email comments on this WWW page to alan.heckert@nist.gov.