<div>Hi,</div>
<div> </div>
<div>I can compile and run with visual fortran by putting all the declarations inside a subroutine e.g.</div>
<div> </div>
<div>module ada<br><br>...<br><br>subroutine ddd<br> </div>
<div style="DIRECTION: ltr"><span class="q"><br>#define <span id="highlight_tag" style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-WEIGHT: bold; PADDING-BOTTOM: 0px; COLOR: #ee6600; PADDING-TOP: 0px; BACKGROUND-COLOR: yellow; EE6600: ">
PETSC</span>_AVOID_DECLARATIONS<br>#include "include/finclude/<span id="highlight_tag" style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-WEIGHT: bold; PADDING-BOTTOM: 0px; COLOR: #ee6600; PADDING-TOP: 0px; BACKGROUND-COLOR: yellow; EE6600: ">
petsc</span>.h"<br><other includes><br>#undef <span id="highlight_tag" style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-WEIGHT: bold; PADDING-BOTTOM: 0px; COLOR: #ee6600; PADDING-TOP: 0px; BACKGROUND-COLOR: yellow; EE6600: ">
PETSC</span>_AVOID_DECLARATIONS<br><br></span></div>
<div style="DIRECTION: ltr">....<br><br>end subroutine ddd<br> </div>
<div><br>end module ada</div>
<div> </div>
<div>However, on my school's server which uses ifort, I get errors both using your way and my way e.g.</div>
<div> </div>
<p>#define PETSC_AVOID_DECLARATIONS<br>#include "include/finclude/petsc.h"<br>#include "include/finclude/petscvec.h"<br>#include "include/finclude/petscmat.h"<br>#include "include/finclude/petscksp.h"
<br>#include "include/finclude/petscpc.h"<br>#include "include/finclude/petscmat.h90"<br>#undef PETSC_AVOID_DECLARATIONS</p>
<p>program test</p>
<p>implicit none</p>
<p>integer :: x,y</p>
<p>Vec test_vec</p>
<p>x=1</p>
<p>print *, x</p>
<p>end program test<br></p>
<div> </div>
<div>I compile using </div>
<div> </div>
<div>ifort -r8 -132 -fPIC -g -c -static-libcxa -O3 -I/lsftmp/g0306332/petsc-2.3.3-p0 -I/lsftmp/g0306332/petsc-2.3.3-p0/bmake/atlas3 -I/lsftmp/g0306332/petsc-2.3.3-p0/include -I/lsftmp/g0306332/petsc-2.3.3-p0/externalpackages/hypre-
2.0.0/atlas3/include -I/lsftmp/g0306332/mpich2/include temp.f90</div>
<div> </div>
<div>and get the error msg:</div>
<div> </div>
<div>fortcom: Warning: Bad # preprocessor line<br>fortcom: Warning: Bad # preprocessor line<br>fortcom: Warning: Bad # preprocessor line<br>fortcom: Warning: Bad # preprocessor line<br>fortcom: Warning: Bad # preprocessor line
<br>fortcom: Warning: Bad # preprocessor line<br>fortcom: Warning: Bad # preprocessor line<br>fortcom: Warning: Bad # preprocessor line<br> </div>
<div>fortcom: Error: temp.f90, line 18: Syntax error, found IDENTIFIER 'TEST_VEC' when expecting one of: => = . ( : %<br>Vec test_vec<br>----^<br>fortcom: Error: temp.f90, line 18: This name does not have a type, and must have an explicit type. [VEC]
<br>Vec test_vec<br>^<br>fortcom: Error: temp.f90, line 18: This name does not have a type, and must have an explicit type. [TEST_VEC]<br>Vec test_vec<br>----^<br>compilation aborted for temp.f90 (code 1)</div>
<div> </div>
<div>I also tried shifting the declarations after the "program test" line but it also failed. There is no problem if I changed the code to fixed format.</div>
<div> </div>
<div>Thanks<br> </div>
<div> </div>
<div><br> </div>
<div><span class="gmail_quote">On 8/6/07, <b class="gmail_sendername">Satish Balay</b> <<a href="mailto:balay@mcs.anl.gov">balay@mcs.anl.gov</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">This is incorrect usage.<br><br>If you are getting errors with the correct usage, send us the error<br>messages, with your code, and we can sugest fixes.
<br><br>- one issue could be<br><br>> > #define PETSC_AVOID_DECLARATIONS<br>> > #include "include/finclude/petsc.h"<br>> > #include "include/finclude/petscvec.h90" <--- This should be removed from here..
<br>> > <other includes><br>> > #undef PETSC_AVOID_DECLARATIONS<br>> ><br>> > moudle foobar<br>> > <other module stuff><br>> > end module<br><br><br>Satish<br><br>On Mon, 6 Aug 2007, Ben Tay wrote:
<br><br>> Hi,<br>><br>> I tried to use<br>><br>> #define PETSC_AVOID_DECLARATIONS<br>> #include "include/finclude/petsc.h"<br>> <other includes><br>> #undef PETSC_AVOID_DECLARATIONS
<br>><br>><br>> module ada<br>> ...<br>><br>> subroutine ....<br>><br>> end module ada<br>><br>> but the compiler says that the module is placed in the wrong order. Anyway, I<br>> just move the top 4 lines into the subroutine instead and it worked. Thanks
<br>><br>> module ada<br>><br>> ...<br>><br>> subroutine ddd<br>><br>> #define PETSC_AVOID_DECLARATIONS<br>> #include "include/finclude/petsc.h"<br>> <other includes><br>> #undef PETSC_AVOID_DECLARATIONS
<br>><br>> ....<br>><br>> end subroutine ddd<br>><br>><br>><br>><br>> Satish Balay wrote:<br>> > you can use .F90 suffix for free-from preprocesed code. [or use<br>> > compiler options to force it always use free-form]
<br>> ><br>> > And when using fortran modules use the following organization:<br>> ><br>> ><br>> > #define PETSC_AVOID_DECLARATIONS<br>> > #include "include/finclude/petsc.h"<br>
> > <other includes><br>> > #undef PETSC_AVOID_DECLARATIONS<br>> ><br>> > moudle foobar<br>> > <other module stuff><br>> > end module<br>> ><br>> > subroutine xyz()
<br>> > use foobar<br>> > implicit none<br>> > #include "include/finclude/petsc.h"<br>> > <other includes><br>> > <code><br>> > end subroutine<br>> > <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<br>> ><br>> > Satish<br>> ><br>> > On Mon, 6 Aug 2007, Ben Tay wrote:<br>> ><br>> ><br>> > > Hi,<br>> > ><br>> > > I've no problem writing out codes in fortran fixed format with PETSc.
<br>> > > However,<br>> > > is it possible to do it in fortran free format as well?<br>> > ><br>> > > I'm using visual fortran and there's error.<br>> > ><br>> > > original :
<br>> > ><br>> > > test.F<br>> > ><br>> > > module global_data<br>> > ><br>> > > implicit none<br>> > ><br>> > > save<br>> > ><br>> > > #include "include/finclude/petsc.h"
<br>> > > #include "include/finclude/petscvec.h"<br>> > > #include "include/finclude/petscmat.h"<br>> > > #include "include/finclude/petscksp.h"<br>> > > #include "include/finclude/petscpc.h"
<br>> > > #include "include/finclude/petscmat.h90"<br>> > ><br>> > > Vec xx,b_rhs<br>> > ><br>> > > ....<br>> > ><br>> > > How can I change this code to fortran free format *.f90?
<br>> > ><br>> > > Thanks<br>> > ><br>> > ><br>> > ><br>> ><br>> ><br>> ><br>><br>><br><br></blockquote></div><br>