[Solved] Fortran iso_c_binding standard: Error: Type mismatch in argument ‘test_variable’ at (1); passed INTEGER(8) to TYPE(c_ptr) [closed]

Fortran iso_c_binding standard: Error: Type mismatch in argument ‘test_variable’ at (1); passed INTEGER(8) to TYPE(c_ptr) [closed] solved Fortran iso_c_binding standard: Error: Type mismatch in argument ‘test_variable’ at (1); passed INTEGER(8) to TYPE(c_ptr) [closed]

[Solved] What is the: Correct way for subtraction in Fortran

You are simply mis-reading your output. You claim that the output is: -4.59045 That claim is contradicted by the screenshot. The actual output is: -4.5904569E-10 That is a very small number, very close to zero. Note also that your actual value is specified to 10 significant digits, commensurate with the relative error that your program … Read more

[Solved] fortran code do not cycle

As stated already in the comments, your program has many code style problems (wrong intentation, …) as well as not using best Fortran practises (e.g. implicit none). Your problem can be solved by trivial usage of a debugger. An obvious problem is that you are using uninitialized variables in the functions: subroutine f(x,y,fx,fy) : rho, … Read more

[Solved] Can I parallelize my program?

Your code is fairly straightforward with lots of independent parallel loops. These parallel loops appear to be wrapped in an outer convergence do while loop, so as long as you keep the data on the device for all iterations of the convergence loop, you won’t be bottlenecked by transfers. I would recommend starting with compiler … Read more

[Solved] Gnuplot vector fortran

First of all, you are making a data file plotdata.txt at the beginning of the program, while trying to plot file.dat later, so that Gnuplot cannot find the latter. After fixing this, you can attach -persist option to keep the graph on the screen as call execute_command_line(“gnuplot -persist plotvel.txt”) Otherwise the graph disappears instantly and … Read more

[Solved] Fortran with MPI error

You must tell the compiler about the MPI stuff (mainly variables). The modern way is introducing use mpi in every scope. In the old days it was also done using include “mpif.h” but that has several disadvantages. Namely, because it is compatible with FORTRAN 77, it does not introduce explicit interfaces for any MPI subroutines … Read more

[Solved] fortran & openmp: put multiple do-s and section-s in the same parallel enviroment

You can and probably should amortize the runtime overhead of creating and destroying an OpenMP parallel region by putting all of your parallel constructions – in this case, two do loops and a pair of sections – within a single parallel region. The following code compiles and executes as expected. program main implicit none integer … Read more

[Solved] pgi cuda fortran compiling error

You’re calling this a “cuda fortran” code, but it is syntactically incorrect whether you want to ultimately run the subroutine on the host (CPU) or device (GPU). You may wish to refer to this blog post as a quick start guide. If you want to run the subroutine increment on the GPU, you have not … Read more

[Solved] How to simplify this Fortran function?

It is possible to write this using recursion. Note that count_present(p_1, p_2, …, p_n, p_{n+1}) returns the value count_present(p_1, p_2, …, p_n) unless all p_1, …, p_{n+1} are present and .TRUE.. In this latter case the result is n+1. count_present(p_1) returns 1 if p_1 is .TRUE., 0 otherwise. recursive function count_present(p1, p2, p3, p4, p5, … Read more

[Solved] POINTER keyword in FORTRAN equivalent in C/C++

According to the above page, the correspondence between Cray pointer and C pointer may be something like this (note, however, that Cray pointer is not the same as standardized pointer in modern Fortran). Fortran: integer a( 3 ), i integer*8 ptr pointer( ptr, b(*) ); integer b a(:) = 10 print *, “a = “, … Read more

[Solved] Fortran Program Crashes when running

I ran your code through the NAG Fortran Compiler (on Linux). The version you have posted doesn’t compile for me: > nagfor -mtrace=all -u -C=all -C=undefined valuefuncmat.f90 … Error: valuefuncmat.f90, line 100: Syntax error detected at )@, … That of course is easy to rectify (i.e., change line 100 to write(*,'(20G12.4)’) vOUT(i,:)). With that done, … Read more