- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there
I need to run a software (TNO DIANA) as a subroutine in an iterative procedure of my Fortran program.
The company says it is not possible, but the software has a command box which can be linked to Visual Fortran Compiler. The software can be run from the command box and with a .bat file.
So I can write a run file and ask DIANA to do several analyses but I cannot interrupt it to let my Fortran program generate the required data file for the next run.
I am just wondering if there is any command in FORTRAN can be used for running a software or is there any program can be used for this purpose?
Regards
Hamid
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
use ifport
integer :: result
result = SYSTEM("c:Programsmyprog.exe")
for example.
Other than that, you will have to check with TNO DIANA or hope that someone else on the Forum is a Diana user and has done what you are looking to do.
ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
use ifport
integer :: result
result = SYSTEM("c:Programsmyprog.exe")
for example.
Other than that, you will have to check with TNO DIANA or hope that someone else on the Forum is a Diana user and has done what you are looking to do.
ron
Many thanks Ronald.
Is it possible to run a .bat file from my program? In fact running the bat file, runs DIANA, then performs an analysis.
Hamid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You might also try looking at the Windows API routine "Createprocess"
3rd party interfaces for Fortran like Winteracter simplify the use of CreateProcess with simple commands like:
Call IOsExecute(CommandChar)
whereCommandChar is a Character string with whatever you wish to pass to the operating system.
brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Many thanks Ronald.
Is it possible to run a .bat file from my program? In fact running the bat file, runs DIANA, then performs an analysis.
Hamid
sure, modify the example to:
result = SYSTEM("c:mydirmybatch.bat")
but keep in mind that there is no data sharing between the external .bat or program run by SYSTEM and the main program. So in this case, you'd need to run the Diana program as above, then perhaps use OPEN statements to open the results file and read everything into the program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sure, modify the example to:
result = SYSTEM("c:mydirmybatch.bat")
When I try to run the bat file with
result = SYSTEM("D:testf1.bat")
the command in the bat file (diana file1.dat file1.com) is read and shown, but my program says diana' is not recognized as an internal or external command, operable program or batch file.
In fact, the bat file must be run in the command box of DIANA. But how can I do that from within my code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You might also try looking at the Windows API routine "Createprocess"
3rd party interfaces for Fortran like Winteracter simplify the use of CreateProcess with simple commands like:
Call IOsExecute(CommandChar)
whereCommandChar is a Character string with whatever you wish to pass to the operating system.
brian
Many thanks Brian.
I don't know anything about that you said. Can it be used to run the bat filewith the command box?
Hamid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Many thanks Brian.
I don't know anything about that you said. Can it be used to run the bat filewith the command box?
Hamid
I think the answer is 'no'.
You are asking, can Fortran launch this 'command box' - probably yes. You would have to know the name of the program that launches the 'command box'. You could go to TNO and ask "How do I start the command box from a command line window?" and they could give you the command needed to start your command box.
BUT you cannot start this command box AND have the program put the name of the batch file in the text box and click OK or ENTER or whatnot.
The only possible way is if the command box program accepts the batch file name as an argument.
This you'll have to work out with TNO, but I guess they have already said this is impossible.
ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can they work in conjunction with my code? How much are they roughly? How can I get them?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1) create one program called RUNDIANA. What this program will do is to call DIANA using the SYSTEM command to call the BAT file which call DIANA with the options required and then close.
2)create your second, main progrm which has the main loop:
2a)delete anyBAT file,
2b)create a new BAT file with the options you want for calling DIANA
2c)save/close the BAT file,
2d)call the program RUNDIANA to execute DIANA.
OnceRUNDIANA exits and returns control to your second, main program, you have code toevaluate the output files from DIANA. Once that is completed, then simplyloops to 2a) above
The 3rd party vendors have system calls/interfaces which can assist you with this. but you'll need to check their documentation/contact them. winteracter.com is one i use.
brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Appreciated very much Brian. But how can I do step 1)? I can probably create a program which calls the command box of DIANA. But, how the BAT file can be called?
What I do by hand is to write the name of the BAT file in the command box and press enter. I need to do it automatically inthe loop of my program.
Hamid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When I try to run the bat file with
result = SYSTEM("D:testf1.bat")
the command in the bat file (diana file1.dat file1.com) is read and shown, but my program says diana' is not recognized as an internal or external command, operable program or batch file.
In fact, the bat file must be run in the command box of DIANA. But how can I do that from within my code?
The system wil interpret the command "diana file1.dat file1.com" as meaning "diana.EXE file1.dat file1.com" and will look for the program diane.exe in the local directory. If it cannot find it there, or if it cannot find it somewhere in the path held in the PATH environment variable, then you will get the message shown.
Clearly, the system does not know where to find diane.exe, so you must tell it where to find it, either by supplying the full path to diane e.g.
d:mypathtodianadiana.exe file1.dat file1.com
or by modifying PATH before you try and execute "diana file1.dat file1.com" as follows:
PATH=d:mypathtodiana;%PATH%
diana file1.dat file1.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The system wil interpret the command "diana file1.dat file1.com" as meaning "diana.EXE file1.dat file1.com" and will look for the program diane.exe in the local directory. If it cannot find it there, or if it cannot find it somewhere in the path held in the PATH environment variable, then you will get the message shown.
Clearly, the system does not know where to find diane.exe, so you must tell it where to find it, either by supplying the full path to diane e.g.
d:mypathtodianadiana.exe file1.dat file1.com
or by modifying PATH before you try and execute "diana file1.dat file1.com" as follows:
PATH=d:mypathtodiana;%PATH%
diana file1.dat file1.com
Appreciated very much for your comment.
I could not find the executable file of the command box, but as you said adding the following line to the BAT file could solve the problem.
PATH=C:Program FilesDiana 9.3bin;%PATH%
The next thing I need is to delete a file, e.g. a DAT, from may program. I will probably ask it in a new discussion.
Many thanks
Hamid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Appreciated very much for your comment.
I could not find the executable file of the command box, but as you said adding the following line to the BAT file could solve the problem.
PATH=C:Program FilesDiana 9.3bin;%PATH%
The next thing I need is to delete a file, e.g. a DAT, from may program. I will probably ask it in a new discussion.
Many thanks
Hamid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for this. I've got the following three books in my office and usually check them before starting a new discussion.
1- FORTRAN 77 and Numerical Methods for Engineers, Borse, G. J., PWS-Kent, 1991.
2- Fortran 90 Programming,Ellis, T. M. R, Philips, I. R. and Lahey, T. M.. Addison-Wesley, 1994.
3- FORTRAN with Engineering Applications, Koffman, E. B. and Friedman F. L., Addison-Wesley, 1993.
If you know a more comprehensive reference, please kindly let me know.
Many thanks
Hamid

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page