how to run fortran subroutines using the editor - fortran

I'm not familiar with fotran but for some specific computation, I need to run a subroutine. I installed Force 2.0 editor. The program I need to run includes several sub-routines. The below is the related subroutine I need to run:
SUBROUTINE DEHANTTIDEINEL(XSTA,YR,MONTH,DAY,FHR,XSUN,XMON,DXTIDE)
How can I run the codes within DEHANTTIDEINEL subroutine while entering the input variables using Force editor?

Related

How to call (or compile) C++ code from Matlab 2016

I'm new with Matlab-C combination and I'm very lost. Any help will be very thankful.
Essentially, what I want is to use a C++ code from a simple matlab script. I've created some variables' values in matlab in order to give them as inputs to the C++ code and then capture theirs output of that C++ code and loading them into matlab.
I have a main.cpp and a makefile into the same folder. (they work well)
I've created a simple test.m file to create the variables' values for the C++ code and then, recover their outputs.
What I've done is to run the makefile using the mac terminal by typing
make
in order to create an executable called "benchmark". Each time I need to change a tiny variable's value from my matlab script, I must go to the terminal again, type
./benchmark
and then goes again to the matlab and run the test.m file to update the inputs of the C++ code. As you see, this is not the optimal way to work it.
So I'm wondering how to pass values created in matlab and in the same script updating the ./benchmark executable.
Thanks in advance guys.

Run Python script inside C++ with Python.h

I'm currently aware of this turotial, but I don't see anything in the tutorial that just simply runs a script. If I have a file pySolve.py how can I just call it to be executed inside of my code? No input is required as the C++ end generates all files needed before calling the python solve script.
You need to call PyRun_File or one of its variants. And of course first you must call Py_Initialize. You can see example usage of these functions in my open-source project here: https://github.com/jzwinck/pccl/blob/master/run.cpp

Looking for executable-based test framework

I've inherited an old program that works, but has pretty ugly source code. I need to make the code nicer without changing the functionality. This program takes an input file, performs all sorts of calculations and generates an output file.
The program is currently written in a C/C++ combination. At first I'm going to keep it a C++ program, but in the not-so-far future I'm going to convert it, or parts of it, to Python.
Naturally, the original developers haven't taken the time to create unit tests, or any other kind of test. Since I want to make sure my modifications haven't changed the program's behavior, I want to start by creating some tests. These will not be unit tests, but rather tests of the entire program.
I want each test to take one input file and a set of command line arguments, run the program and compare the output (which is the output file, stdout output and stderr output) to the expected output.
Since I need to support both C++ and Python, the test framework needs to be language agnostic - it should be able to run an executable, collect stdout and stderr and compare them, as well as another file, to the prerecorded outputs.
I couldn't find a test framework that can do that. Is there anything like that? I'd rather not develop one myself.
Well, off the top of my head, you could certainly run the executable with your desired inputs in python using subprocess or some similar module, parse the output and then use the unittest module to set expectations on what sort of output you're looking for.

Preventing Embedded Python from Running Shell Commands?

I want to embed Python 3.x in our C++ application to allow scripting of maintenance and other tasks. It so far does everything we need including file manipulation.
The problem is that to meet some specifications (like PCI), we aren't allowed to arbitrarily run shell commands such as with subprocess.call or popen.
Is there a way to prevent and similar calls from working in embedded Python?
One option is to remove all the modules that allow running arbitrary shell commands, i.e.: subprocess.py*, os.py*... and include only the modules that the end users are allowed to have immediate access to.
Unless your application is really locked down I don't think you can prevent someone from loading their own python module from an arbitrary directory (with import) so I don't think you can prevent execution of arbitrary code as long as you have python embedded.

Program Interaction and testing via bash script

I've just completed the coding section of simple homework assignment for my C++ class. The second part of the assignment requires us to verify our code's input validation. (The program takes several different values as inputs from a user and prints those values to a file)
I was hoping that I could use bash script for this. Is there any way to use bash script to run and interact with a program? How can I put the program's output into a variable (note that program has a series of input requests and outputs).
Thanks
To build on #Travis' answer, create two files: one holds your inputs (input.txt) and one holds the expected output (expected_output.txt). Then do the following:
./myprogram <input.txt >output.txt
diff output.txt expected_output.txt
If the diff command has any output, there's a problem.
You can do much of this with a shell script but you might want to consider using some other testing tools instead like CppUnit or expect.