Compiling .for on PGI Fortran (Please advise)

Hey everyone, I am new to PGI Workstation.

I would like to ask about the process of compiling a .for code (the name of the code I have is exactly = Plates.for )

I have read the manual on how to do that, I should preprocess my code first…I am not sure why I have to do that, and even how to do it.

I followed the instructions, but it is not exactly clear for .for codes, this is what I tried in the command line:

pgfortran -Mfixed -F Plates.for
pgfortran -o Plates.f

but I always end up with “syntax error at or near +” when I do the second command…

I want to reach Plates.exe and I am sure I am doing this compiling process wrong. Could someone please help me. Thank you!

Hi A.Torky,

Try using “-Mpreprocess” instead. i.e. “pgfortran -Mpreprocess Plates.for”.

You could instead rename the file to “Plates.FOR”, in which case “-Mpreprocess” is implied (all upper case suffix names indicated that the file will be preprocessed).

  • Mat

Thank you for your kind reply Mat

I still have the issue that Syntax errors appear related to the type of fortran code “.for”

The errors are:
“syntax error at or near +” … at the end of the line
“syntax error at or near &” … at the end of the line
“syntax error …unbalanced parentheses”

If I may add, this code was done on Fortran PowerStation 4.0 and these severe errors did not appear there because it allowed for such techniques in coding for the type .for, and I used to compile and receive the .exe file.

I am sure there are steps to do in order for these errors not to appear while compiling, but I am not aware how to do it… can you please have a look and help me?

can you please have a look and help me?

Sure. Can you please post a small reproducing example?

  • Mat
      program Test
      implicit none
      integer , parameter :: n = 500
      integer :: a(n), b(n), c(n), i

      open (3, file=' This is the example_1.txt',                      
	& status='unknown')
      a = 1
      b = 3

      do i=1, n
		c(i)= 2.5666*a(i)+7.66668*b(i)+4.55555*a(i)*b(i)+
	+  a(i)*a(i)
	
      enddo

      write(3,*)
      write(3,*) ' Values =', c

      end program Test

My code is populated with such “+” and parenthesis completed down several lines and this one is called Examples.for and runs on another compiler fine.

Thank you for your patience, I really appreciate it.

Ahmed

You’re off one column. Add a space before the “&” and “+” to get them into the sixth column.

% cat test.for
       program Test
       implicit none
       integer , parameter :: n = 500
       integer :: a(n), b(n), c(n), i

       open (3, file=' This is the example_1.txt',
     &  status='unknown')
       a = 1
       b = 3

       do i=1, n
       c(i)= 2.5666*a(i)+7.66668*b(i)+4.55555*a(i)*b(i)+
     + a(i)*a(i)

       enddo

       write(3,*)
       write(3,*) ' Values =', c

       end program Test
% pgf90 test.for

That worked perfectly. Thanks for the help Mat!