f2py : comment line using .f90 file - f2py

When using f2py with a .f90 file, does one have to use the flag !f2py instead of Cf2py?
I use the intel fortran compiler and it seems compile to a .pyd file if I use !f2py. If I use Cf2py, it fails.
Thanks for your help.

Yes.
It doesn't have to do with f2py, if you are using .f90 the compiler will assume free form, and in free form comments begin only with !. In fixed form they begin also with C.

Related

Why does “filename.m” gets deleted when I use “dynare” command in Octave?

I wrote a model to solve using dynare in octave. After writing the model, I save it with “.m” format. Then I type “dynare filename” in octave’s command window to run the model but instead the file gets deleted.
Oddly, it doesn’t happen if I use the command on a file with “.mod” format.
I’m using Octave 5.2.0 since the dynare only works with this version.
Please help me if you can. Tnx a lot.
I guess you used Dynare 4.5 instead of the recent stable release 4.6. As documented in the manual, the only supported file-types in Dynare are .mod and .dyn. You cannot name your file .m as Dynare will preprocess your .mod-file and create an m-file with the same name. Usually, you would get an explicit error message. However, in Octave, the following code is executed first:
% Workaround for a strange bug with Octave: if there is any call to exist(fname)
% before the call to the preprocessor, then Octave will use the old copy of
% the .m instead of the newly generated one. Deleting the .m beforehand
% fixes the problem.
if isoctave && length(dir([fname(1:(end-4)) '.m'])) > 0
delete([fname(1:(end-4)) '.m'])
end
Dynare 4.6 instead moved to Matlab-classes. There you will get an explicit error message.

Failed to create shared library with wx and STL, "multiple definition" error?

I tried to build a shared library using wx and STL, and failed in an error of "multiple definition of". Please refer to:
https://code.google.com/p/gppanel/issues/detail?id=7
The declaration of wxPointListNode is not found in the sources. The suspicious lines are like these:
include/mathplot.h:85:WX_DECLARE_LIST(wxPoint, PointList);
include/mathplot.h:87:WX_DEFINE_LIST(PointList);
include/gpLineLayer.h:16:typedef std::deque<mpPointLayer*> mpPointList_t;
What the problem is?
Without the actual code this is just a guess, but I suspect that
include/mathplot.h:87:WX_DEFINE_LIST(PointList);
generates the full definition of PointList, including a non-templated method wxPointListNode::DeleteData. mathplot.h is included by all of the .cpp files (gpPanel.cpp, gpSeries.cpp, and baseData.cpp). Each cpp file is compiled into a .o file, so each has its own definition of DeleteData, and when you try to link the .o files together into lib/libgpPanel.so the linker issues the errors you're reporting.
The definition of the method needs to be in its own cpp file that's compiled and linked in.
All wxWidgets methods with DEFINE in their name expand into a definition of something and a definition can only be used once in a module, so it typically can't appear in a header file (unless you can guarantee that it's included by only a single source file). So just don't put it there.
Moreover, if this is your code, you should avoid using the legacy WX_DECLARE_LIST macro at all and just use std::list<> or std::vector<> instead. Or, if you really want to use only wx (which can only be important if you are targeting some embedded platform without good STL implementation), then use wxVector<>.

Erlang: calling rr(?MODULE) from beam executable?

I'm not entirely sure how to define an Erlang function within an Erlang module. I'm getting the following error:
11> invoke_record:invoke().
** exception error: undefined function erlang:rr/1
From this simple code trying to invoke the rr(?MODULE). from within the beam executable in order to "initialize" records so that it doesn't need to be called from the shell every time.
-module(invoke_record).
-export([invoke/0]).
-record(process, {pid,
reference="",
lifetime=0
}).
invoke() ->
erlang:rr(?MODULE).
The command rr("file.hrl"). is meant to be be used only in shell for debugging purposes.
As other users highlighted in their answers, the correct way to import a record (or a function) contained in a .hrl file within your erlang code consists in using the command -include("file.hrl').
Once you have included the .hrl file in your code (and usually in a module based on OTP behaviours this is done after the -export(...) part) you can refer to the Erlang record (or function) without any problem.
rr is a shell command. You cannot use it it compiled code.
http://www.erlang.org/doc/man/shell.html
If your intent is to read many record definitions in the shell, in order to facilitate the debug, you can write a file containing all needed include statements and simply invoke rr once in the shell.
in rec.hrl:
-include("include/bank.hrl").
-include("include/reply.hrl").
and in the in the shell
1> rr("rec.hrl").
[account,reply]
2>
I didn't find any way to execute this automatically, when starting the VM.
When working on a project, you can gather all necessary includes and other command line arguments that you want to use for that particular project in a plain text file. After having made the plain text file, you can start your shell:
erl -args_file FileName
where FileName is the name of the plain text file. Note that all command line arguments accepted by erl are allowed. See also erl Flags in the ERTS Reference Manual

Boost Library Import Into Metatrader (MT4) Script File

I am working within a Metatrader script file and need to call a function within a Boost library. Anyone know if this is possible? If so how do you configure the import?
This is possible.
Check this out: http://docs.mql4.com/basis/preprosessor/import
If you look at most metaquotes mql examples, they import stdlib and stderror . The built in help section in the editor will also have info on how to do this.
Yes, it is really possible.
But all is not as you might imagine.
Of course, it depends on what you want to do, but main idea is to create a DLL and include it to your EA as Dmitry said.
All your functions must be defined like this:
extern "C" __declspec(dllexport) int doSomething(...)
{ ... }
So you may call it from your terminal.
Be careful with c++ types in Metatrader.
In a DLL you can do what you want according to your declaration -- with all data you'll get.
Don't forgot to check your DLL for dependencies (using Dependency Walker) to see what other DLLs your library is using (you must provide them to your Metatrader terminal, copy to terminal.exe location folder, or add folder with your DLLs to your systems path).

Is there Octave's equivalent for iPython's "!"

For example,
!vim
in iPython opens vim. Is there such a thing in Octave?
The following might work system("vim");
If you want the interactivity of calling something inside of Octave and interactivity with it directly try exec("vim") instead.
See Controlling Subprocesses for more examples.
Otherwise you can either combine calls to system, fork and exec or extend octave with Python/iPython or C++.
If you only want to run another process then , the already suggested system() or exec() should work.
However, if you plan on using this to simply open up a text editor and edit an Octave file, set the value of EDITOR with EDITOR ("vim") (you can add this to your .octaverc file) and then use edit (foo) to open up the foo function on the text editor.