开发者

Interface between csh and fortran code

I have a script (csh) which calls a fortran executable. Each time the script calls the fortran code a counter should be incremented and using that counter I have to create a new output file.

Can I pass a variable to my fortran code or is there a simple way of doing the same.

I have tried this cod开发者_运维技巧e:

 program callsave  
c  
 implicit none  
       integer i,j  
c  
do j = 1, 10  
  call trysave(i)  
  print *, i  
end do  
stop  
end  
c  
subroutine trysave(i)  
       integer k  
       data k /1/  
       save k  
       i = k  
       k = k + 1  
           end subroutine  
c  

This works fine individually. But when I call this subroutine separately in my fortran code through the script, it is not getting incremented. It just has the initial value '1', and the output files been overwritten.

Any type of help/suggestion would greatly be appreciated.

Thanks

Praveen.


Is it that you're looking for a way of passing an integer value from the shell script to the fortran code? In that case, one way would be to use command line arguments, see e.g. here: http://gcc.gnu.org/onlinedocs/gfortran/GETARG.html

I'm not sure what is the official status of the getarg() routine, but by experience it works fine in gfortran, intel and PGI compilers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜