Interface between csh and fortran code

I have a script (csh) that calls the fortran executable. Each time the script calls fortran code, the counter must increment, and with this counter I must create a new output file.

Can I pass the variable to fortran code or is there an easy way to do the same.

I tried this code:

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

This works great. But when I call this routine separately in my fortran code through a script, it does not increase. It just has an initial value of "1" and the output files have been overwritten.

Any kind of help / suggestions would be much appreciated.

thanks
Praveen.

+4
source share
1 answer

Is this what you are looking for a way to pass an integer value from a shell script to fortran code? In this case, one way would be to use command line arguments, see, for example, here: http://gcc.gnu.org/onlinedocs/gfortran/GETARG.html

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

+3
source

Source: https://habr.com/ru/post/1342602/


All Articles