gfortran

Understanding the backtrace error in fortran

六月ゝ 毕业季﹏ 提交于 2019-12-02 10:25:58
I get the following error when I execute a fortran code compiled with gfortran . The error is followed by a backtrace for this error pointing to memory locations. Program received signal SIGSEGV: Segmentation fault - invalid memory reference. Backtrace for this error: #0 0x2b2f8e39da2d in ??? #1 0x2b2f8e39cc63 in ??? #2 0x311823256f in ??? #3 0x311827a7be in ??? #4 0x2b2f8e39cff2 in ??? #5 0x2b2f8e4adde6 in ??? #6 0x2b2f8e4ae047 in ??? #7 0x2b2f8e4a62d7 in ??? #8 0x40482a in instrument_ at /home/user/model/instrument.f:90 #9 0x406c1e in funcdet at /home/user/model/funcsynth.f:67 #10 0x406c98

Why is the counter variable unexpectedly increased in every subroutine call? [duplicate]

我的未来我决定 提交于 2019-12-02 10:16:03
问题 This question already has answers here : Does Fortran preserve the value of internal variables through function and subroutine calls? (3 answers) Why is there an implied SAVE attribute in Fortran? [duplicate] (1 answer) Fortran assignment on declaration and SAVE attribute gotcha (2 answers) Closed last year . [EDITORIAL: I have read this question but (while in hindsight it is ultimately related in the same way that every question here is related -- i.e., "Why do computers malfunction?") that

Type * error in gfortran

拥有回忆 提交于 2019-12-02 10:12:47
When I run my code I get the following error for all the statements that have the following format. Is there any problem with the type statement? If yes kindly provide me with a solution. I running my code on a Ubuntu 14.10 system. The program is very long hence I am not posting it now however if required I can surely send it. recfunk_ascii.f:622.12: type *,'enter back-azimuth limits ib1,ib2 (integers!)' 1 Error: Invalid character in name at (1) Type is an obsolete and completely non-standard statement (see http://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vnbi/index.html ). It is not portable

Error: Expected a right parenthesis in expression at (1)

∥☆過路亽.° 提交于 2019-12-02 10:06:41
问题 its showing Expected a right parenthesis in expression, although i have checked it many times do i= 0, m-1 do j= 0, n-1 k1(i,j)=-0.001*(((y(i,j)/dx)*((0.02651995*pho(i+3,j))-(0.18941314*pho(i+2,j))+(0.79926643*pho(i+1,j))-(0.79926643*pho(i-1,j))+(0.18941314*pho(i-2,j))-(0.02651995*pho(i-3,j))))+((x(i,j)/dy)*((0.02651995*pho(i+3,j))-(0.18941314*pho(i+2,j))+(0.79926643*pho(i+1,j))-(0.79926643*pho(i-1,j))+(0.18941314*pho(i-2,j))-(0.02651995*pho(i-3, j))))) enddo enddo 回答1: If your question is

integer, do loop, fortran, error

被刻印的时光 ゝ 提交于 2019-12-02 09:08:06
I have the following fortran code defined under. I am trying to change the length of the do loop if i change the value of n. When i try to compile i get the error: ‘a’ argument of ‘floor’ intrinsic at (1) must be REAL. But when i change q and w to be defined as real i get another error message. How can i fix this? q and w is clearly a integer when i use floor(...) subroutine boundrycon(n,bc,u,v) !input integer :: n,bc !output real(8) :: u(n+2,n+2), v(n+2,n+2) !lokale integer :: j,i,w,q n=30 q=floor(n/2) w=(floor(n/2)+floor(n/6)) do j=q,w u(q,j)=0.0; v(q+1,j)=-v(q,j); u(w,j)=0.0; v(w+1,j)=-v(w

Why does using command PRINT in Fortran overwrite the input file?

十年热恋 提交于 2019-12-02 09:03:29
I'm writing my code and using input and output feature in Fortran. The code looks like this ( only for simplification ): PROGRAM TEST REAL, DIMENSION(1000):: A REAL:: B INTEGER::T !Defining input and output OPEN(UNIT=1, FILE='input.dat', STATUS='OLD') OPEN(UNIT=2, FILE='output.dat', STATUS='NEW') !Reading from file "input.dat" READ(1,*) (A(I),I=1,1000) !Just for initial condition B=0.0 DO T=1, 10 PRINT *, 'Step =', T DO I=1, 1000 B=B+1.0 A(I)=A(I)/B END DO END DO !Writing results into file "output.dat" DO I=1, 1000 WRITE (2,100) I, A(I) END DO 100 FORMAT (' ',T3, I12, T17, F14.4) END PROGRAM

SHARED option in OPEN Statement in the Fortran standard

佐手、 提交于 2019-12-02 08:49:19
问题 In this documentation HP Fortran doc, the OPEN statement accept SHARED and READONLY options. In this documentation Standard Fortran 2008 doc, the OPEN statement dosn't accept SHARED or READONLY options. Since I'm using gfortran comes with gcc 4.4.7 to compile a Fortran source file on Linux,I used a ruse to get around half the problem. I used OPEN(...,ACTION=READ,...) instead of READONLY. But can't find an other ruse (:)) to replace SHARED Option. (Like Something=Shared ). Anyone have a ruse

gfortran debugging with gdb: w_powf.c: No such file or directory

♀尐吖头ヾ 提交于 2019-12-02 08:16:02
I have a Fortran program I am debuging. I have a list of varables and one of the expected variables is almost double its expected value. So I compiled the program, with debug flags, and commenced debugging: the program name is hfock $gdb hfock (gdb) break hfock (gdb) run Starting program: /home/e/Desktop/hfock hfock Breakpoint 1, hfock () at hfock.f:16 16 ZETA1 = 2.173171 (gdb) s 17 ZETA2 = 1.188530 (gdb) s 18 WRITE (*, '( "Zeta1:", F7.4 / "Zeta2:", F7.4 )' ) ZETA1, ZETA2 (gdb) s Zeta1: 2.1732 Zeta2: 1.1885 21 PLUS=ZETA1+ZETA2 (gdb) s 22 PROD=ZETA1*ZETA2 (gdb) s 23 DIFF=ZETA1-ZETA2 (gdb) s 24

Can we create pure functions in Fortran which generate random numbers?

ぃ、小莉子 提交于 2019-12-02 07:34:34
问题 My goal is to write a pure function using random numbers which can be used in a DO CONCURRENT structure. The compiler does not seem to permit this. mwe.f95:8:30: call init_seed ( ) 1 Error: Subroutine call to ‘init_seed’ at (1) is not PURE mwe.f95:9:36: call random_number ( y ) 1 Error: Subroutine call to intrinsic ‘random_number’ at (1) is not PURE mwe.f95:16:8: use myFunction 1 Fatal Error: Can't open module file ‘myfunction.mod’ for reading at (1): No such file or directory compilation

gfortran, DLL, underscore

强颜欢笑 提交于 2019-12-02 07:30:35
I want to access some subroutines from a third party DLL. The functions use STDCALL as the calling convention. Running dumpbin /export foo.dll gives me something like: ... 7 6 00004B40 Foo@16 ... I compile my code using: gfortran test.f90 -o test.exe -Wl,foo.dll I get an error: undefined reference to '_foo_' (note the underscores). I have tried adding the -mrtd compilation flag, as well as other flags I googled, all to no avail. How can I tell fortran to not add the underscores? edit: A bit of clarification is in order. I have an existing DLL to which I do not have the source to. This DLL is