C++Guns – RoboBlog

12.02.2016

/proc status

Filed under: Allgemein — Tags: — Thomas @ 20:02

Code snipped to read /proc status with fortran. E.g. used memory and so... ! original: http://hiliev.eu/posts/recipe-obtaining-peak-vm-memory-size-in-pure-fortran.html module ProcStatus contains !---------------------------------------------------------------! ! Returns current process virtual memory size ! ! Requires Linux procfs mounted at /proc ! !---------------------------------------------------------------! ! Output: vmsize - vmsize VM size in kB ! !---------------------------------------------------------------! function getVmSize() result(vmsize) implicit none integer :: […]

26.01.2016

Evaluation of logical operations

Filed under: Allgemein — Tags: , , — Thomas @ 21:01

Spass mit dem Standard. Aus dem Fortran 90/95 Standard [1] Kapitel 7.1.7.6. Evaluation of logical intrinsic operations The rules given in 7.2.4 specify the interpretation of logical intrinsic operations. Once the interpretation of an expression has been established in accordance with those rules, the processor may evaluate any other expression that is logically equivalent, provided […]

04.05.2015

storing into constants (Bug of the day 4)

Filed under: Allgemein — Tags: — Thomas @ 17:05

From the Layhey Fortran 95 compiler user guide. -[N]PCA Protext Constant Arguments Compile only. Default npca Specify -pca to prevent invoked subprograms from storing into constants. Example call sub(5) print *, 5 end subroutine sub(i) i = i + 1 end This example would print 5 using -pca and 6 using -npca. Greatest bullshit I've […]

11.04.2015

Local variable will not retain values between function invocations (Bug of the day 2)

Filed under: Allgemein — Tags: — Thomas @ 07:04

Lokale Variablen behalten ihren Wert NICHT zwischen Funktionsaufrufe! Es gibt in diesem Beispiel keinen Compilerfehler und auch keinen von Fortran erkannten Laufzeitfehler. Es gibt Compiler Warnings die diesen Fehler zeigen, aber dazu bedarf es mehr Code. Ich habe dieses Beispiel möglichst klein und übersichtlich gehalten. Ausgabe ohne Optimierung und ohne Fehler kater@ktux:~$ gfortran -Wall -Wextra […]

10.04.2015

Bug of the day 1

Filed under: Allgemein — Tags: — Thomas @ 08:04

Der bug of the day kommt diesmal von mir! Ich hab mir von eine Hand voll 3D Punkten neue Z Werte berechnet. Aber hab den Z Wert im Punkt nie aktualisiert. Und anstatt in der Ausgabedatei nun Bloedsinn steht oder lauter 0 Eintraege, finden sich dort Werte die mit einen berechneten immer ein bis zwei […]

09.02.2015

gfortran bug

Filed under: Allgemein — Tags: — Thomas @ 18:02

Jo en Bug. So assigment subroutine und gfort 4.8 4.9. Vllt geht es in 5.0 ja wieder. gfortramnbug.F90

26.01.2015

Fortran save, data, static, global, parameter WTF?

Filed under: Allgemein — Tags: — Thomas @ 23:01

Whats the difference between between save, static, global, local and parameter variables? Save and static are two words for the same thing. I found a nice definition of what save do in the Fortran 77 Standard [1] Within a function or subroutine subprogram, an entity specified by a SAVE statement does not become undefined as […]

17.01.2015

suppress "unused dummy argument" warning in fortran

Filed under: Allgemein — Tags: — Thomas @ 18:01

Here is my way to supress the "unused dummy argument" warning. I'm searched a long time but did not find a solution which works on any compiler and newer fortran standard. In C/C++ it is very easy. Just write (void)variable; But this just trigger an "Unclassifiable statement" error. #define UNUSED(x) if(size( (/(x)/) ) < 0) […]

20.12.2014

Fortran COMMON is deadly

Filed under: Allgemein — Tags: — Thomas @ 22:12

In Fortran 77 gibt es den COMMON Block. Das sind sowas wie globale Variablen die man umbenennen kann. Gleich im nächsten Standard (1990) hat man das wieder rausgenommen, weil es eine unheimliche Scheisse ist. (Die Erkenntnis hat ja nur 13 Jahre gedauert). Folgenden Beispiel zeigt warum. SUBROUTINE PREVENTSTART COMMON /ROCKETCONTROL/ ISTARTCOUNTDOWN, ITIMELEFT ! stop the […]

20.10.2014

howto allocate array in C++ and pass it back to fortran

Filed under: Allgemein — Tags: , , — Thomas @ 12:10

test.cpp #include < stdlib.h > // fortran can only call C routines extern "C" { // we need the address of the fortran pointer thus a pointer of a pointer. void myC_func(int **arr) { // we cannot use new() here because fortran deallocate() use free() instead of delete[] *arr = (int*) malloc(12*sizeof(int)); for(int i=0; i […]

« Newer PostsOlder Posts »

Powered by WordPress