Update: get_command_argument
sounds really helpful, however, I believe am using an older version of Fortran. (I think 90?)
I am new to Fortran and need to use a Fortran code to calculate something. I need to call this Fortran code repeatedly from a Matlab program that would be impractical to rewrite in Fortran, so I am using the "system" command in matlab to call the program, which is basically like calling from the command line. Currently, the the fortran code contains a main function and several subroutines (the main one, FUNFIT, is dependent on the others and takes X, Y as inputs), and currently looks something like this:
implicit double precision (A-H), double precision (O-Z)
X = 5;
Y = 7;
call FUNFIT(X,Y,Pn,FN,UN,CV,CH,CHI,PM,US)
end
subroutine FUNFIT(X, Y, Pn,FN,UN,CV,CH,CHI,PM,US)
*I don't think details are needed here*
end
subroutine SOME_OTHER_SUBROUTINE( . . .)
I want to be able to call FUNFIT from the command line (allowing it to have access to the other subroutines) and input X, Y. So basically, I want to directly call FUNFIT from a shell, with inputs given.
However, I am having trouble with calling the code and defining the inputs. I have not been able to find an example of a Fortran "main" function with an input. If I just compile it with the "main" function commented out, I don't know how to call FUNFIT. How can I call FUNFIT (either directly, or through the use of a main function) from the command line and directly input values of X, Y each time? I am at a loss. I know it is ridiculous, but my first attempt has been to re-write and re-compile the program with new values of X, Y each time I call it, which has been prohibitively slow. Thanks for helping out this novice Fortran programmer.