I'm a newbie in Fortran coding also in GNU Fortran and Code::Blocks.
I've installed codeblocks-20.03mingw-setup on Win10 and now trying to run this piece of code from scratch:
program hello
implicit none
real :: x = 0.0
x = dcosd(x)
write(*,*) x
end program
But in some reason I'm getting this Build message:
C:\...\Hello_Test\main.f90|7|Error: Function 'dcosd' has no IMPLICIT type|
If I delete the line implicit none I get this message instead:
C:\...\Hello_Test\main.f90|5|undefined reference to `dcosd_'|
I'm pretty sure DCOSD is kind a standard functoun in gFortran. I tried some some solutions for "IMPLICIT type" problem, but with no result. I think the solution shuld be pretty obvious for experienced people but it eludes me.
First to clarify,
dcosd()is not a standard intrinsic function in Fortran. It used to be available as an extension to the standard by some compilers. Fortran 2023 brings the generic versioncosd()as a standard intrinsic function, but modern Fortran standards do not really work too much with the specific functions likedcosd()and it has not been made standard.GCC version 7 is quite old.
dcosd()is recognized in your code by versions 10 and later (I tested 10, 11, 12 and 13). For versions 7-9 you need the option-fdec-math, mentioned by francescalus in the first comment, to enable the non-standard extension.However, with these later versions or with the
-fdec-mathoption you will get another errorThat will be fixed by
double precision :: x = 0.Or you can change
dcosd()to the genericcosd(). In that case the single precision version will be used and the code will compile with eitherrealordouble precisionin GCC version 10 and later.