gfortran

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

早过忘川 提交于 2019-12-02 06:31:16
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 francescalus If your question is "why?", then note that Fortran specifies a maximum line length (if the line consists solely of

Floating-point exceptions are signalling in new gfortran version

泄露秘密 提交于 2019-12-02 04:49:49
I am currently working to debug a subroutine of some software that my boss has written back in the 90s. There seems to be a floating-point exception that occurs in a do loop of a particular subroutine: 16 irad=1,incmax rr1=rr2 rr2=rr2+rdiv if(rr1.gt.rlimit) goto 16 if(pts(irad).gt.0.0) then discrm=(rmsden(mt,irad)/pts(irad)) 1 -((average(mt,irad)**2)/(pts(irad)**2)) else discrm=0.0 endif if(discrm.ge.0.0) then rmsden(mt,irad)=sqrt(discrm) else rmsden(mt,irad)=0.0 endif average(mt,irad)=average(mt,irad)/pts(irad) average(mt,irad)=(average(mt,irad)*100.0)/bigmost(mt) rmsden(mt,irad)=(rmsden(mt

passing pointer arguments in fortran

。_饼干妹妹 提交于 2019-12-02 04:23:26
问题 I am wondering what is the proper way to write the following code? PROGRAM foo INTEGER :: x REAL(KIND=8), TARGET, DIMENSION(0: 10) :: array REAL(KIND=8), POINTER, DIMENSION(:) :: ptr ptr => array CALL bar(ptr) END PROGRAM foo SUBROUTINE bar (ptr) REAL(KIND=8), POINTER, DIMENSION(:) :: ptr INTEGER x DO x =0, 10 ptr(x) = 2 // seg faults ENDDO END SUBROUTINE bar It works if I declare ptr in bar as REAL(KIND=8), DIMENSION(0:10) . But in general I might not know the size of the passed-in array, so

2D array concatenation in fortran

落爺英雄遲暮 提交于 2019-12-02 04:03:14
问题 Fortran 2003 has square bracket syntax for array concatenation, Intel fortran compiler supports it too. I wrote a simple code here for matrix concatenation: program matrix implicit none real,dimension (3,3) :: mat1,mat2 real,dimension(3,6):: mat3 integer i mat1=reshape( (/1,2,3,4,5,6,7,8,9/),(/3,3/)) mat2=reshape( (/1,2,3,4,5,6,7,8,9/),(/3,3/)) mat3=[mat1,mat2] !display do i=1,3,1 write(*,10) mat3(i,:) 10 format(F10.4) end do end program But I get error as mat3=[mat1,mat2] Error: Incompatible

Error: Invalid character in name at (1)

只谈情不闲聊 提交于 2019-12-02 03:40:34
I am trying to compile a fortran file along with some .h files in FORTRAN. The .h files contain definition for common blocks of variable. When I compile them in Fortran, I get the following error: integer knue,ke,knumu,kmu,knutau,ktau,ku,kd,kc,ks,kt,kb,kgamma, 1 Error: Invalid character in name at (1) The code where this error occurs is, Now my question is, does this "1" point where the error is? The lines of code which this errors points is, integer knue,ke,knumu,kmu,knutau,ktau,ku,kd,kc,ks,kt,kb,kgamma, & kw,kz,kgluon,kh1,kh2,kh3,khc,ksnue,kse1,kse2,ksnumu,ksmu1, & ksmu2,ksnutau,kstau1

How to create functions in Fortran?

≡放荡痞女 提交于 2019-12-02 03:08:17
I'm sure the solution to this is extremely basic, but I'm having a hard time figuring out how to use functions in Fortran. I have the following simple program: PROGRAM main IMPLICIT NONE INTEGER :: a,b a = 3 b = 5 PRINT *,funct(a,b) END PROGRAM FUNCTION funct(a,b) IMPLICIT NONE INTEGER :: funct INTEGER :: a,b funct = a + b END FUNCTION I've tried several variations of this, including assigning a data type before FUNCTION, assigning the result of funct to another variable in the main program and printing that variable, and moving the FUNCTION block above the PROGRAM block. None of these worked.

fortran 95 rounding up on it's own

扶醉桌前 提交于 2019-12-02 02:46:47
I decided to learn the fortran95 language (reason why is not important). However being a beginner I ran into a weird problem I really can't explain, therefor I need help. I have the insertion sort algorithm: subroutine insertion_sort_REAL4(array, array_len) implicit none !parameners integer :: array_len real (kind=4), dimension(array_len) :: array !variables integer :: i,key,hole_pos do i = 0,array_len key = array(i) hole_pos = i; do while ((hole_pos > 0.0) .and. (key < array(hole_pos - 1))) array(hole_pos) = array(hole_pos - 1) hole_pos = hole_pos - 1 end do array(hole_pos) = key end do

gfortran error: unexpected element '\\' in format string at (1)

北战南征 提交于 2019-12-02 02:25:39
I have a project written in VS2010 with Intel Visual Fortran. I have a dump subroutine to write a 2D matrix into file: subroutine Dump2D(Name,Nx,Ny,Res) implicit none integer i,j,Nx,Ny real(8) :: Res(Nx,Ny) character(len=30) name,Filename logical alive write(filename,*) trim(Name),".dat" Write(*,*) "Saving ",trim(Name)," Please wait..." open (10,file=filename) do i=1,Ny Write(10,FMt="(D21.13\)") (Res(j,i),j=1,Nx) Write(10,*) end do close(10) Write(*,*) "Save ",trim(Name),"Complete!" return end subroutine Dump2D It is ok to compile and run. But when I compile in emacs using gfortran it gives me

2D array concatenation in fortran

你说的曾经没有我的故事 提交于 2019-12-02 02:11:41
Fortran 2003 has square bracket syntax for array concatenation, Intel fortran compiler supports it too. I wrote a simple code here for matrix concatenation: program matrix implicit none real,dimension (3,3) :: mat1,mat2 real,dimension(3,6):: mat3 integer i mat1=reshape( (/1,2,3,4,5,6,7,8,9/),(/3,3/)) mat2=reshape( (/1,2,3,4,5,6,7,8,9/),(/3,3/)) mat3=[mat1,mat2] !display do i=1,3,1 write(*,10) mat3(i,:) 10 format(F10.4) end do end program But I get error as mat3=[mat1,mat2] Error: Incompatible ranks 2 and 1 in assignment I expect the output as 1 2 3 1 2 3 4 5 6 4 5 6 7 8 9 7 8 9 Can someone

Error: Invalid character in name at (1)

醉酒当歌 提交于 2019-12-02 01:41:14
问题 I am trying to compile a fortran file along with some .h files in FORTRAN. The .h files contain definition for common blocks of variable. When I compile them in Fortran, I get the following error: integer knue,ke,knumu,kmu,knutau,ktau,ku,kd,kc,ks,kt,kb,kgamma, 1 Error: Invalid character in name at (1) The code where this error occurs is, Now my question is, does this "1" point where the error is? The lines of code which this errors points is, integer knue,ke,knumu,kmu,knutau,ktau,ku,kd,kc,ks