<div>Hi,</div>
<div>&nbsp;</div>
<div>I can compile and run with visual fortran by putting all the declarations inside a subroutine e.g.</div>
<div>&nbsp;</div>
<div>module ada<br><br>...<br><br>subroutine ddd<br>&nbsp;</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 &quot;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&quot;<br>&lt;other includes&gt;<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>&nbsp;</div>
<div><br>end module ada</div>
<div>&nbsp;</div>
<div>However, on my school&#39;s server which uses ifort, I get errors both using your way and my way e.g.</div>
<div>&nbsp;</div>
<p>#define PETSC_AVOID_DECLARATIONS<br>#include &quot;include/finclude/petsc.h&quot;<br>#include &quot;include/finclude/petscvec.h&quot;<br>#include &quot;include/finclude/petscmat.h&quot;<br>#include &quot;include/finclude/petscksp.h&quot;
<br>#include &quot;include/finclude/petscpc.h&quot;<br>#include &quot;include/finclude/petscmat.h90&quot;<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>&nbsp;</div>
<div>I compile using </div>
<div>&nbsp;</div>
<div>ifort -r8 -132 -fPIC -g&nbsp;-c -static-libcxa -O3&nbsp; -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>&nbsp;</div>
<div>and get the error msg:</div>
<div>&nbsp;</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>&nbsp;</div>
<div>fortcom: Error: temp.f90, line 18: Syntax error, found IDENTIFIER &#39;TEST_VEC&#39; when expecting one of: =&gt; = . ( : %<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.&nbsp;&nbsp; [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.&nbsp;&nbsp; [TEST_VEC]<br>Vec test_vec<br>----^<br>compilation aborted for temp.f90 (code 1)</div>
<div>&nbsp;</div>
<div>I also tried shifting the declarations after the &quot;program test&quot; line but it also failed. There is no problem if I changed the code to fixed format.</div>
<div>&nbsp;</div>
<div>Thanks<br>&nbsp;</div>
<div>&nbsp;</div>
<div><br>&nbsp;</div>
<div><span class="gmail_quote">On 8/6/07, <b class="gmail_sendername">Satish Balay</b> &lt;<a href="mailto:balay@mcs.anl.gov">balay@mcs.anl.gov</a>&gt; 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>&gt; &gt; #define PETSC_AVOID_DECLARATIONS<br>&gt; &gt; #include &quot;include/finclude/petsc.h&quot;<br>&gt; &gt; #include &quot;include/finclude/petscvec.h90&quot;&nbsp;&nbsp;&lt;--- This should be removed from here..
<br>&gt; &gt; &lt;other includes&gt;<br>&gt; &gt; #undef PETSC_AVOID_DECLARATIONS<br>&gt; &gt;<br>&gt; &gt; moudle foobar<br>&gt; &gt; &lt;other module stuff&gt;<br>&gt; &gt; end module<br><br><br>Satish<br><br>On Mon, 6 Aug 2007, Ben Tay wrote:
<br><br>&gt; Hi,<br>&gt;<br>&gt; I tried to use<br>&gt;<br>&gt; #define PETSC_AVOID_DECLARATIONS<br>&gt; #include &quot;include/finclude/petsc.h&quot;<br>&gt; &lt;other includes&gt;<br>&gt; #undef PETSC_AVOID_DECLARATIONS
<br>&gt;<br>&gt;<br>&gt; module ada<br>&gt; ...<br>&gt;<br>&gt; subroutine ....<br>&gt;<br>&gt; end module ada<br>&gt;<br>&gt; but the compiler says that the module is placed in the wrong order. Anyway, I<br>&gt; just move the top 4 lines into the subroutine instead and it worked. Thanks
<br>&gt;<br>&gt; module ada<br>&gt;<br>&gt; ...<br>&gt;<br>&gt; subroutine ddd<br>&gt;<br>&gt; #define PETSC_AVOID_DECLARATIONS<br>&gt; #include &quot;include/finclude/petsc.h&quot;<br>&gt; &lt;other includes&gt;<br>&gt; #undef PETSC_AVOID_DECLARATIONS
<br>&gt;<br>&gt; ....<br>&gt;<br>&gt; end subroutine ddd<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; Satish Balay wrote:<br>&gt; &gt; you can use .F90 suffix for free-from preprocesed code. [or use<br>&gt; &gt; compiler options to force it always use free-form]
<br>&gt; &gt;<br>&gt; &gt; And when using fortran modules use the following organization:<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; #define PETSC_AVOID_DECLARATIONS<br>&gt; &gt; #include &quot;include/finclude/petsc.h&quot;<br>
&gt; &gt; &lt;other includes&gt;<br>&gt; &gt; #undef PETSC_AVOID_DECLARATIONS<br>&gt; &gt;<br>&gt; &gt; moudle foobar<br>&gt; &gt; &lt;other module stuff&gt;<br>&gt; &gt; end module<br>&gt; &gt;<br>&gt; &gt; subroutine xyz()
<br>&gt; &gt; use foobar<br>&gt; &gt; implicit none<br>&gt; &gt; #include &quot;include/finclude/petsc.h&quot;<br>&gt; &gt; &lt;other includes&gt;<br>&gt; &gt; &lt;code&gt;<br>&gt; &gt; end subroutine<br>&gt; &gt; &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;
<br>&gt; &gt;<br>&gt; &gt; Satish<br>&gt; &gt;<br>&gt; &gt; On Mon, 6 Aug 2007, Ben Tay wrote:<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; &gt; Hi,<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; I&#39;ve no problem writing out codes in fortran fixed format with PETSc.
<br>&gt; &gt; &gt; However,<br>&gt; &gt; &gt; is it possible to do it in fortran free format as well?<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; I&#39;m using visual fortran and there&#39;s error.<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; original :
<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; test.F<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; module global_data<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;implicit none<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;save<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; #include &quot;include/finclude/petsc.h&quot;
<br>&gt; &gt; &gt; #include &quot;include/finclude/petscvec.h&quot;<br>&gt; &gt; &gt; #include &quot;include/finclude/petscmat.h&quot;<br>&gt; &gt; &gt; #include &quot;include/finclude/petscksp.h&quot;<br>&gt; &gt; &gt; #include &quot;include/finclude/petscpc.h&quot;
<br>&gt; &gt; &gt; #include &quot;include/finclude/petscmat.h90&quot;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;Vec&nbsp;&nbsp;&nbsp;&nbsp;xx,b_rhs<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; ....<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; How can I change this code to fortran free format *.f90?
<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; Thanks<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt;<br>&gt;<br><br></blockquote></div><br>