Silverfrost Forums

Welcome to our forums

calling fortran code from CSHELL

12 Mar 2013 6:05 #11726

Hi all I wrote a fortran program which need as inputs :

  • a binary file named : Filename
  • the fortran unit of this binary file : Fileunit
  • 4 real values : freqA , freqZ , dsx , dsy
  • 1 integer : dfreq

The ouput is a 3D array named ' radmat '

I actually want to know how to run my fortran program [the excutable is called ' ishellexe '], i think i need to specify in the same line the input values , but i do not know how please help me

#!/bin/csh -f echo'' echo' modal acoustic radiation impedance ' setxvar=($argv[1])

set dfreq = $xvar[7] set dsx = $xvar[11] set dsy = $xvar[12] set freqA = $xvar[13] set freqZ = $xvar[14] set Fileunit = $xvar[27] set Filename = $xvar[31]

set Filename = ‘eval echo $Filename‘

ishellexe

echo ' end of computation' echo ''

13 Mar 2013 12:38 #11730

You could consider using the routine GET_COMMAND_ARGUMENT and place the values in your batch file. The .bat command could be something like:

ishellexe %Filename% %freqA% %freqZ% %dsx% %dsy% %dfreq%

The fortran code needs to be something like DO I = 1,6 call get_Command_Argument (i, String, l, status) select case (i) case (1) file_name = string case (2:6) read (string, '(bn,f10.0)', iostat=iostat) val(i) end select END DO

You would need to add some status and iostat tests. Including some other command line options, such as /freqA to name the arguments might also help, as would be assuming some default values.

Why do you need to provide Fileunit ?

Otherwise you need to provide the answers in a text file and either read from the file or provide the answers via '< text_file'

Apollo batch files provide data input from the .bat file via <$, which unfortunately DOS never adopted. I'm sure there are other batch processors, better than cmd.exe which provide this, but my suggestion above does work in a cmd.exe environment.

John

13 Mar 2013 10:01 #11739

John when reading the binary file i need to go throug the records of the file for that i need the fileunit.

but this is not the problem.

I am using a module called ISHELL , it is from msc nastran. the vaules of dfreq, freqA, freqZ, dsx, dsy, filename and fileunit are already specified.

so now i am unsing CSHELL scripting to parse these values and input them to my fortran program:

this should be ok according to the documentation of msc nastran setxvar=($argv[1])

set dfreq = $xvar[7] set dsx = $xvar[11] set dsy = $xvar[12] set freqA = $xvar[13] set freqZ = $xvar[14] set Fileunit = $xvar[27] set Filename = $xvar[31]

set Filename = ‘eval echo $Filename‘

but now the problem is as i said how to provide this to the fortran program:

is it like this ? ishellexe %Filename% %freqA% %freqZ% %dsx% %dsy% %dfreq%

or like this ishellexe $Filename $freqA $freqZ $dsx $dsy $dfreq

and how i should change my fortran program accordingly?

thank you john

17 Mar 2013 6:02 #11796

I'm a bit confused by your question. I assumed your 'module' was some .bat (like) script that you used to run your program ishellexe.exe

What is the module ISHELL ? It does not appear to be a FORTRAN module.

John

Please login to reply.