Link error when I use DSIN in fortran - fortran

My complier is Intel Fortran Compiler 11.0.3451.2005. IDE is Microsoft Visual Studio 2005.
When I use
WRITE(*,*) DSIN(0.8)
There will be a link error, seems there's no such function.
Why? How to fix it?
Thanks.

dsin would expect a double precision argument. sin(0.8d0) and dsin(0.8d0) are identical.
Just use sin and let the machine figure which version of the sine function to use, based on the actual type of the argument.

Related

VSCode missing std::as_const()?

I have double checked several times that I am running either C++17 or above, yet this problem keeps occurring and I really don't understand why.
I am simply trying to call a const member function by using std::as_const(), which shouldn't be causing any fuss. Maybe it's missing from the utility library? But how could that be?
If anyone has an idea why this is happening I'd appreciate an answer.
VSCode telling me Utility library doesn't have std::as_const()
To summarize the back and forth in the comments:
Visual Studio Code relies on an external compiler to build and analize sources
Your compiler is the one that is likely old, not Visual Studio Code
Verify that your compiler is current
Update to a new compiler by upgrading MinGW.
In this case OP had an old compiler gcc 6.3.0 from Dec/2016 that did not support the features he wanted.

'DETECT' keyword errors in BoundaryFill Algorithm

I want to use boundary fill algorithm with cpp in Visual Studio Environment. I tried to run some code parts for it, but I faced to face an error at every turn. This error is about 'DETECT' keyword in codes. The most of codes include that lines:
int gd=DETECT,gm,n,ch,xc,yc,r,bcolor,fcolor;
initgraph(&gd,&gm,"");
I have an error as "the definition 'DETECT' is undefined" because of this usage.
How can I overcome this problem?
PS: You can reach example code that I used from this link -> http://www.hhhprogram.com/2013/05/draw-circle-and-fill-color-using-boundary-fill-algorithm.html
Thank you.
add header for DETECT, that may solve the issue.
I think this code is Turbo C++ specific ( will work with Turbo C++ only) and will not work in Visual Studio unless you add proper library which contains those BGI.h and initgraph and gd= DETECT blah blah blah whatever you are using.
To draw graphics in your C program you should have some graphics library with your C compiler. Normally you have to download that and link to the compiler yourself. Turbo C++ by default contains graphics.h which provides some basic graphics functions. If you want to use that in your Visual C++ compiler you have to add that so that Visual C++ compiler can recognize what initgraph, gd = DETECT is. I do not know how to add graphics.h in Visual C++ and I would not recommend that. I won't recommend using turbo c++ either. Instead, you can download and install OpenGL with your Visual studio. If you want simpler thing then go for Dev-Cpp and Allegro.

FGETC library name in Fortran?

Is there a library that I can explicitly link to my Fortran code to find FGETC function? I'm getting linker errors for unresolved external symbol for the fgetc function and I tried using 'USE IFPORT' but that broke a bunch of other stuff. I am building in Visual Studio 2008 and using Intel Fortran Composer XE 2011 compiler.
Since FGETC is a non-standard function which Intel packages in the IFPORT module I'm not sure you have any alternative to use-associating it. If use-associating the whole module causes problems, you might get away with
use ifport, only : fgetc

Integrate MATLAB code in Visual Studio 2010 (C++)

I've seen that it is possible to call MATLAB functions from VS2010 (VC++). I was wondering if it is possible to create executable files using VC++ that do not require any MATLAB software on the computer (like the MATLAB Compiler Runtime (MCR))?
I would like to create a program written in VC++ that calls some of the MATLAB functions, but is completely standalone and can run from any Windows computer without the need of any prior MATLAB software to have been installed.
Thanks.
It is not possible to install without MCR in any documented way and I even think that it is not legal.
However, there are some examples like Imatest, who managed to do it in some of their earlier versions.
Edit(1)
I almost forgot about MatlabCoder. If you buy it, it can transform your Matlab code directly into c code. But it will not work with some of the toolboxes, like image processing.

OpenCV, Matlab and STL containers

Many functions in the latest release of OpenCV require the use of STL containers. I run into problems when trying to use them in a Matlab MEX file. I am compiling the MEX files from within Matlab. Both OpenCV and Matlab use the "/MD" flag which is "Multithreaded DLL" for code generation.
Compiler: MSVC++ 9.0
Matlab 2010a
OpenCV latest from SVN, 2.11 I think.
The code I am using is very simple:
vector<KeyPoint> keypoints_vec;
SurfFeatureDetector surf;
surf.detect(cvImg,keypoints_vec);
This compiles but crashes when run in a Matlab MEX file. The crash is within OpenCV in vector::resize. The old interface (without STL containers) works fine but is deprecated. How can I use STL containers between Matlab and OpenCV?
I fought with this very problem in the last two days. The problem is this:
libmex.dll (and a whole Matlab) uses Microsoft.VC80.CRT (version=8.0.50727.4053)
But your OpenCV uses Microsoft.VC90.CRT (version=9.0.21022.8)
So you can use the previous version of VC (VS 2005 with SP1 as far as I know), or as a workaround, you can use gcc (MINGW) (in this case they use totally different stl, so they can't interfere).
I did the latter and it works, and it will work with the next versions of Matlab (hopefully).
A long time ago I had problems with Matlab <-> VS interop. It might be some microsoft visual c++ runtime library discrepancy. Check what runtime lib is required by matlab and what version does your visual studio have. I remember using Depends to get the dll dependencies for my program. Check your call stack after crashing (by attaching your msdev debugger) it might give you some hints.
It was a long time ago so I'm just giving hints of what I remember.
I had a similar problem in the past few days, and was able to resolve the issue with some help from the friendly folks at MathWorks.
From the original post at http://www.mathworks.com/matlabcentral/answers/9294-mex-dynamic-memory-management-issue-with-std-vector-in-linked-external-dll-segmentation-error :
You are probably seeing an incompatibility between the stl library and or compiler options used by your pre-compiled dll and those used by MATLAB and the MEX command. MATLAB 2009b was built with MSVC 2005.
You may be able to fix the problem by changing the options used by mex or by building your mex file directly with MSVC. One example of an option that may effect things is SECURE_SCL=0. I would start by building your test program with the options MATLAB is using to find the problematic option then try removing that option when building the mex file.
Because of this sort of incompatibility use of stl objects in the api's of third party compiled libraries is usually a bad idea.
Following his advice, I removed the SECURE_SCL=0 option from the mex options file at
C:\Users\ThePit\AppData\Roaming\MathWorks\MATLAB\R2009b\mexopts.bat
Then recompiled the mex file, now everything works like a charm - the function is returning the correct data and segmentation error no longer occurs.
The data in a vector should still be stored as a single contiguous block
std::vector<int> data;
int *array = &data[0];
int *array = &data.front();
Should give you 'c' style pointers to the data, try passing these to matlab
see also: How does the C++ STL vector template store its objects in the Visual Studio compiler implementation?