I'm writing a small automation application which submits a job to nastran in batch mode. How can I know that the nastran has completed the job? Because once after that I have to copy the result file from the server ( nastran is in server ) to the local system to extract the results. So how to know nastran has completed?
That is dependent the language you use to write the application and what method you use to launch the application. The method may have an option to wait for the command to complete before proceeding, or it may return the process ID of the nastran application.
Again, this is dependent on the language you are using and the functions that particular language has for querying process ID's.
You have not provided enough information (what platform are you running on, what operating system, what language your application is written in, what function was used to launch the Nastran process, ....) to allow a more meaningful answer.
Maybe it helps to run Nastran in foreground.
If you use the Nastran commandline switch batch=no, Nastran will be submitted in foreground and your automation application will wait until the Nastran Solve is finished.
Just use the following commandline:
Nastran job.dat batch=no
I may write my application in C++
and the server has the linux OS.
I'm not very clear how to do:
My automation application (say App1) is written in C++ and it is in my desktop.
I have all the files ( .dat, .bdf and .set ) files in my desktop.
Now I would like to submit the job in a server ( HPC server) which has linux OS.
HPC system has a command like "runnas" which takes an xml file as a parameter. [ runnas -f <xmlfilename> ]
The xml file has all the attributes to run the job ( like job name,input files,number of cpu etc ).
So how to proceed?
Should I write another c++ application ( say App2 ) which launches nastran and wait for the nastran to complete. And App2 can be launched from main application (App1) which is running in my desktop.
When I understand you right you are submitting your Nastran job via a queueing system on the HPC. Runnas is your submit script. Do you know which queueing system is used?
Queueing systems have applications to check the status of your jobs. For example LSF has a tool called bjobs to check the status of the running jobs.
Not sure about the queuing system. But there is perl script to query the status of the submitted job and when I checked the script, it internally uses fqstat to know job status.
It seems to be Grid Engine.
I assume the python script returns a list of all jobs with JobID and status. So if your Nastran job is finished, the JobId will not appear in the list anymore.
You could do the following:
You said you get the Job Id when you submit the job. After you submitted from the client, your
local App1 can run the python script to get the list of running (and pending) jobs. Check if your jobId appears in the list. If so, rerun the python script after a certain timeout. If not, you are done.
Check with your IT for a good value for the timeout. Running the fqstat too often will increase server load (especially if you are not the only person running App1). Maybe you could use 60sec.