HyperStudy

Sample Script: Running Solvers on Unix, Without a Unix Mapped Drive

Sample Script: Running Solvers on Unix, Without a Unix Mapped Drive

Previous topic Next topic Expand/collapse all hidden text  

Sample Script: Running Solvers on Unix, Without a Unix Mapped Drive

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

When you are running solvers on Unix, without a Unix mapped drive, the files are kept locally on the PC. Files are copied to a temporary location on the Unix machine, where the solver is executed, result files are then copied back to the study_directory on the PC where output responses are evaluated. HyperStudy sets a process environment variable called STUDY_PC_PATH, which facilitates this process. The value of this process environment variable is set to the full path of the current run directory on the PC. This environment variable changes with each run.

For this scenario, a PC batch file and a Unix shell script are required. The PC batch file should be entered as the "Solver Execution Script" on the "Do nominal run" page of HyperStudy. Below is an example of a PC batch file and Unix shell script which may be used (with minor modifications) to perform this task.

Other points to note with regard to the example scripts provided below:

When entering the values for the variables, it is important not to leave spaces after the last character or surrounding the '=' symbol.
The file uses rcp and rsh commands, check with your system administrator to see if these are enabled in your network.
The batch file was created for Windows NT 4.0.
The UNIX shell script was created on IRIX 6.5.
You want to test to see that your batch file and script are working correctly before using HyperStudy, you will need to replace "%STUDY_PC_PATH%" in the batch file with the full path for the directory containing your test file.  Then at the command prompt simply type: "batch_filename.bat input_filename".
It is possible to adapt the Unix script to run with a queuing system.  See Working with Network Queuing Systems on Unix.

 

Batch File

In the example batch file you should only need to edit the USER INPUT SECTION. However, depending on your system, you may need to alter other parts of the file. Five variables need to be defined in the USER INPUT SECTION of the batch file:

username:

This is the username for the Unix account used.

unix_root:

This is the home directory on the Unix machine for the username defined above.

unix_tmp_dir:

This is a subdirectory of the user's Unix home directory where the input file will be written to.

unix_script:

This is the complete path, including file name, of the Unix shell script shown below, which is called upon to execute the solver on the Unix machine.

UNIX_machine:

This is the name of the Unix machine where the solver is executed.

hmtoggle_plus1Example Batch File

@echo off                                                                                                                                                                              

 

::::#### USER INPUT SECTION ###########################################

 

:: Please Input relevant information after '=' sign on each of the

:: lines in this section.

::

:: For information on what information is required on each line, go to

:: the 'Interacting with your system' page of the HyperStudy manual.

         

 

set username=user1

 

set unix_root=/home/user1

 

set unix_tmp_dir=study_dir/scratch

 

set unix_script=/home/user1/study_dir/scripts/study1.sh

 

set UNIX_machine=UNIX1

 

 

::::#### END OF USER INPUT SECTION ####################################

 

cls

echo.

echo.

echo ---------------------------------------------------

echo User Defined Shell Parameters on PC

echo ---------------------------------------------------

echo User name....................: %username%

echo UNIX home of user............: %unix_root%

echo UNIX Temp Dir................: %unix_root%/%unix_tmp_dir%

echo Unix run script..............: %unix_script%

echo Remote Unix Machine..........: %UNIX_machine%

echo.

echo.

 

 

set pc_dir=%STUDY_PC_PATH%

 

set input_deck=%1%

 

echo.

echo.

echo -------------------------------------------------------------

echo Copying input deck from PC to Unix ...

echo.

echo.

 

cd %pc_dir%

 

c:/winnt/system32/rcp.exe "%input_deck%" "%UNIX_machine%.%username%:%unix_tmp_dir%"

 

 

echo.

echo.

echo ...Done.

echo -------------------------------------------------------------

 

echo.

echo.

echo -------------------------------------------------------------

echo Launching Unix Shell...

echo.

echo.

c:/winnt/system32/rsh.exe %UNIX_machine% -l %username% "%unix_script% %unix_tmp_dir%/%input_deck%"

echo.

echo.

echo ...Unix Shell Done.

echo -------------------------------------------------------------

 

echo.

echo.

echo ------------------------------------------------------------

echo Moving all files back from unix to PC...

 

c:/winnt/system32/rcp.exe -b "%UNIX_machine%.%username%:%unix_tmp_dir%/*" "."

 

echo.

echo Deleting all files from %unix_root%/%unix_tmp_dir%...

echo.

c:/winnt/system32/rsh.exe %UNIX_machine% -l %username% "rm -f %unix_tmp_dir%/*"

 

echo ...Done.

echo ------------------------------------------------------------

 

 

Unix Shell Script

In the example Unix Shell script you should only need to edit the USER INPUT SECTION. However, depending on your system, you may need to alter other parts of the file. Four variables need to be defined in the USER INPUT SECTION of the Unix shell script:

unix_root:

This is the user's home directory on the Unix machine (same as for the batch file above).

unix_tmp_dir:

This is a subdirectory of the user's Unix home directory where the input file will be written to (same as for the batch file above).

UNIX_machine:

This is the name of the Unix machine where the solver is executed (same as for the batch file above).

exe_path:

This is the complete path, including file name, of the solver executable to be used on the input file.

hmtoggle_plus1UNIX Shell Script

#!/bin/sh                                                                                                                                                                              

######## USER INPUT SECTION ###########################################

 

# Please Input relevant information after '=' sign on each of the

# lines in this section.

#

# For information on what information is required on each line, go to

# the 'Interacting with your system' page of the HyperStudy manual.

 

unix_root=/home/user1

 

unix_tmp_dir=study_dir/scratch

 

UNIX_machine=UNIX1

 

exe_path=/soft/solver/solver.exe

 

 

######## END OF USER INPUT SECTION ####################################

 

echo -----------------------------------------------

echo User Defined Shell Paramters on UNIX

echo -----------------------------------------------

 

echo Unix home of User...................$unix_root

 

echo Unix Temp Dir.......................$unix_tmp_dir

 

echo Remote Unix Machine.................$UNIX_machine

 

echo Path of SOLVER Executable...........$exe_path

 

 

input_deck=$1

 

echo

echo

echo

echo -------------------------------------------------

echo "Stripping cntrl M's ....."

 

to_unix $unix_root/$input_deck $unix_root/$input_deck.tmp

mv -f $unix_root/$input_deck.tmp $unix_root/$input_deck

 

echo

echo

echo ...Done.

echo -------------------------------------------------

echo

echo

 

 

echo

echo -------------------------------------------------

echo "Launching SOLVER......"

echo

echo

echo "$exe_path $unix_root/$input_deck"

$exe_path $unix_root/$input_deck

 

exit