@echo off
REM Sample Isight Abaqus component custom GRID script configuration file
REM For 64bit target machine(Windows) save to <fiperinstall>\win_b64\reffiles\SMAFIPconfig\AbqLSFScript.bat
REM For 64bit target machine(Linux) save to <fiperinstall>\win_b64\reffiles\SMAFIPconfig\AbqLSFScript.sh
REM For 32bit target machine(Windows) save to <fiperinstall>\intel_a\reffiles\SMAFIPconfig\AbqLSFScript.bat
REM For 32bit target machine(Linux) save to <fiperinstall>\intel_a\reffiles\SMAFIPconfig\AbqLSFScript.bat
REM SSH is used for remote execution of Abaqus
REM Assumes Putty is the local ssh client on the Isight machine
REM Embeds password directly in Putty calls, could use a key agent instead
REM Assumes Isight is being executed on Windows and no shared file system exists

REM ---------------------------------------------------------------------
REM Set the following parameters in this file for your environment
set remotemachine=
set remoteworkingdir=
set username=
set password=
set abaquscommand=abaqus.bat

REM ---------------------------------------------------------------------
REM  1) Make unique remote working directory
plink %remotemachine% -l %username% -pw %password% mkdir %remoteworkingdir%/*ID*

REM ---------------------------------------------------------------------
REM  2) Copy Abaqus input (inp) file to remote working directory
pscp.exe -pw %password% *inp_file* %username%@%remotemachine%:%remoteworkingdir%/*ID*

REM ---------------------------------------------------------------------
REM  3) Execute Abaqus solver on remote machine
plink %remotemachine% -l %username% -pw %password% cd %remoteworkingdir%/*ID*; %abaquscommand% inp=*inp_file* job=*inp_cmd**ID* interactive
REM for Abaqus 6.10 and higher, add the *StudyRunCount* command line argument for reduced Abaqus analysis token consumption
REM plink %remotemachine% -l %username% -pw %password% cd %remoteworkingdir%/*ID*; %abaquscommand% inp=*inp_file* job=*inp_cmd**ID* *StudyRunCount* interactive

REM ---------------------------------------------------------------------
REM  4) Extract output parameters from Abaqus output (odb) file
pscp.exe -pw %password% exec.exe %username%@%remotemachine%:%remoteworkingdir%/*ID*
pscp.exe -pw %password% config.txt %username%@%remotemachine%:%remoteworkingdir%/*ID*
plink %remotemachine% -l %username% -pw %password% cd %remoteworkingdir%/*ID*; %abaquscommand% exec.exe -odb *inp_cmd**ID*.odb -config config.txt

REM ---------------------------------------------------------------------
REM  5) Copy params.txt, odb, and dat files back to local machine
REM     File copies of odb and dat are optional and only required if storing as Isight file parameters
pscp.exe -pw %password% %username%@%remotemachine%:%remoteworkingdir%/*ID*/params.txt params.txt
pscp.exe -pw %password% %username%@%remotemachine%:%remoteworkingdir%/*ID*/paramsdone.txt paramsdone.txt
pscp.exe -pw %password% %username%@%remotemachine%:%remoteworkingdir%/*ID*/*inp_cmd**ID*.dat *inp_cmd*.dat
pscp.exe -pw %password% %username%@%remotemachine%:%remoteworkingdir%/*ID*/*inp_cmd**ID*.odb *inp_cmd*.odb

REM ---------------------------------------------------------------------
REM  6) Clean up remote working directory (optional)
plink %remotemachine% -l %username% -pw %password% rm -rf %remoteworkingdir%/*ID*
