replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - calling fortran code from CSHELL
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

calling fortran code from CSHELL

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
joemezni



Joined: 14 Jan 2013
Posts: 8

PostPosted: Tue Mar 12, 2013 7:05 pm    Post subject: calling fortran code from CSHELL Reply with quote

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 ''
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2615
Location: Sydney

PostPosted: Wed Mar 13, 2013 1:38 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
joemezni



Joined: 14 Jan 2013
Posts: 8

PostPosted: Wed Mar 13, 2013 11:01 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2615
Location: Sydney

PostPosted: Sun Mar 17, 2013 7:02 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group