CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   fortran error for g77 compiler (https://www.cfd-online.com/Forums/main/10699-fortran-error-g77-compiler.html)

vishwas January 26, 2006 21:27

fortran error for g77 compiler
 
This queston is related to fortran coding I am running a fortran coode in Linux using g77 I get the following error when I compile the error. This error is related to the symbol (ampers and) & which I use as continuation of statement on next line. the error is read(11,*) (((x(i,j,k,n),i=1,ii(n)),j=1,jj(n)),k=1,kk(n)),^

& (((y(i,j,k,n),i=1,ii(n)),j=1,jj(n)),k=1,kk(n)), ^ Expression at (^) has incorrect data type or rank for its context (This is the error for first line) Statement at (^) begins with invalid token [info -f g77 M LEX] (This the error for second line) Can somebody tell me how to remove it

Thank you

ag January 26, 2006 21:42

Re: fortran error for g77 compiler
 
Make sure the ampersand is in column 6.

Renato. January 26, 2006 21:44

Re: fortran error for g77 compiler
 
I've got lost when trying to understand your read statement. This problem can be due your implicit loops in the read statement (unbalanced parentheses or arrays with wrong rank). Why don't you try to rewrite this sentence with explicit loops? It would be easier to understand where is your problem...

Cheers

Renato

Renato. January 26, 2006 21:47

Re: fortran error for g77 compiler
 
Yeah Ag,

it's the first think Vishwas must check ;-)

vishwas January 26, 2006 22:20

Re: fortran error for g77 compiler
 
This queston is related to fortran coding. I am running a fortran code in Linux using g77. I get the following error when I compile the error. This error is related to the symbol (ampers and) & which I use as continuation of statement on next line. The ampersand is in column 6.

read(11,*) (((x(i,j,k,n),i=1,ii(n)),j=1,jj(n)),k=1,kk(n)),^

&(((y(i,j,k,n),i=1,ii(n)),j=1,jj(n)),k=1,kk(n)) ,

^

Expression at ^ has incorrect data type or rank for its context (This is the error for first line) Statement at (^) begins with invalid token [info -f g77 M LEX] (This the error for second line) Can somebody tell me how to remove it.

Thank you


andy January 27, 2006 05:47

Re: fortran error for g77 compiler
 
Assuming the third line you have not shown is something like:

& n=1,4)

you have missed a bracket at the beginning for the index n.


m. malik January 27, 2006 12:11

Re: fortran error for g77 compiler
 
Consider using explit loops: do i = 1, ii(n) do j = 1, jj(n) do k = 1, kk(n)

read (11,*) x(i,j,k,n), y(i,j, k,n) end do end do endo

m. malik January 27, 2006 12:29

Re: fortran error for g77 compiler
 
I hope it's obvious that in what I suggested in previous mail, there are seven (7) lines.

AnotherCFDUser January 29, 2006 20:35

Re: fortran error for g77 compiler
 
Malik's suggestion will lead to slightly different behaviour from the original code (which will read the data from a single line rather than from ii(n)*jj(n)*kk(n) separate lines). This could be fixed by using a format statement in the read.


AnotherCFDUser January 29, 2006 20:44

Re: fortran error for g77 compiler
 
As mentioned previously for FORTRAN 77 the code should read something like this:

123456 READ(11,*) 12345& (((x(i,j,k,n),i=1,ii(n)),j=1,jj(n)),k=1,kk(n)), 12345& (((y(i,j,k,n),i=1,ii(n)),j=1,jj(n)),k=1,kk(n)), 12345& (((z(i,j,k,n),i=1,ii(n)),j=1,jj(n)),k=1,kk(n))

where 12345 should be replaced with spaces.

You may also like to use a different character.

If the compiler is actually expecting f90 or f95 you may like to try:

READ(11,*) & (((x(i,j,k,n),i=1,ii(n)),j=1,jj(n)),k=1,kk(n)), & (((y(i,j,k,n),i=1,ii(n)),j=1,jj(n)),k=1,kk(n)), & (((z(i,j,k,n),i=1,ii(n)),j=1,jj(n)),k=1,kk(n))

If neither of these work perhaps you could post some more details of the code (which looks like a pretty standard PLOT3D reader).


vm January 30, 2006 17:16

Re: fortran error for g77 compiler
 
this works with my compiler:

read(11,*)((((x(i,j,k,n),i=1,ii(n)),j=1,jj(n)),k=1 ,kk(n)), & (((y(i,j,k,n),i=1,ii(n)),j=1,jj(n)),k=1,kk(n)),n=1 ,4)

& is in column 6



All times are GMT -4. The time now is 06:40.