On Wed, Aug 29, 2012 at 10:28 AM, Roc Wang <span dir="ltr"><<a href="mailto:pengxwang@hotmail.com" target="_blank">pengxwang@hotmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div><div dir="ltr">
Thanks for the kindly reply.<br><br>By saying petscdef files, do you mean petscXXXdef, where XXX is the corresponding component of PETSc, such as vec, mat, et. al.?<br><br>I tried the following approach, but it still doesn't work.  The errors come out since there are some PETSc variables defined in Module MyParameter.  The compiler cannot find PETSc datatype. The conflict is that some PESTs variables have to defined in Module MyParameter, and other PETSc variables and PETSc subroutines are defined and called in another Module MySub.  Any hints and suggestions would be appreciated very much. Thanks.<br>
</div></div></blockquote><div><br></div><div>It is done this way here:  <a href="http://www.mcs.anl.gov/petsc/petsc-current/src/snes/examples/tutorials/ex5f90.F.html">http://www.mcs.anl.gov/petsc/petsc-current/src/snes/examples/tutorials/ex5f90.F.html</a></div>
<div>and works fine.</div><div><br></div><div>   Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div dir="ltr">!--------------the way I declared the PETSc files<br>
<br>   Module MyParameter<br>       Implicit none<br>#include "finclude/petscsysdef.h"     ! Put all petscXXXdef,h  in the module<br>#include "finclude/petscvecdef.h"<br>
#include "finclude/petscmatdef.h"<br>#include "finclude/petscpcdef.h"<br>#include "finclude/petsckspdef.h"<br><br>
 <br>      Integer::  ... ...<br>      Real:: ... ...     ! There are some PETSc variables defined in this Module<br>  <br><br>   End Module MyParameter<br><br>  Module MySub<br>       Use Myparameter<br>     Contains<br>
       ... ...<br>     Subroutine MyPETSc_APP()<br>#include "finclude/petscsys.h"<br>#include "finclude/petscvec.h"<br>#include "finclude/petscmat.h"<br>#include "finclude/petscpc.h"<br>
#include "finclude/petscksp.h"<br><br>#include "finclude/petscsys.h90"<br>#include "finclude/petscmat.h90"<br>#include "finclude/petscvec.h90"<br>      Implicit none<br>      ... ...<br>
      Call MatSetType(A_Mat, MATAIJ, ierr)<br>      ... ...<br>    End Subroutine MyPETSc_APP<br>
       ... ...<br>  EndModule MySub<br><br> Main Program<br>      Use MyParameter<br>      Use MySub<br> ... ...<br> ... ...<br> End <br><br><div><div></div><hr>Date: Tue, 28 Aug 2012 16:00:58 -0500<br>From: <a href="mailto:dharmareddy84@gmail.com" target="_blank">dharmareddy84@gmail.com</a><br>
To: <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br>Subject: Re: [petsc-users] variable declaration in Fortran90<br><br>From what i understand, you should #include the corresponding petscdef files in the module and the petsc headers in the subroutine.<br>
<br>petsc version installed on machine is petsc-3.2-p5<br>I use a single include file: #include "finclude/petscdef.h" in the module<br>
and in the subroutines (including the ones that are defined after contains in the module) and program.<br>#include "finclude/petsc.h"<br> you can use #include "finclude/petsc.h90" if you are using the things such as vecgetArrayF90<br>

<br><div>On Tue, Aug 28, 2012 at 3:45 PM, Roc Wang <span dir="ltr"><<a href="mailto:pengxwang@hotmail.com" target="_blank">pengxwang@hotmail.com</a>></span> wrote:<br><blockquote style="border-left:1px solid rgb(204,204,204);padding-left:1ex">




<div><div dir="ltr">
Hello,<br><br><br>   I am developing Fortran90 code with PETSc.  Several Modules are defined in the code. Such as<br><br>  Module MyParameter<br>       Implicit none<br>#include "finclude/petscsys.h"<br>#include "finclude/petscvec.h"<br>

#include "finclude/petscmat.h"<br>#include "finclude/petscpc.h"<br>#include "finclude/petscksp.h"<br>#include "finclude/petscvec.h90"<br>#include "finclude/petscmat.h90"<br>

 <br>      Integer::  ... ...<br>      Real:: ... ...<br>  <br><br>  End Module MyParameter<br><br>  Module MySub<br>       Use Myparameter<br>     Contains<br>       ... ...<br>      Call MatSetType(A_Mat, MATAIJ, ierr)<br>

       ... ...<br>  EndModule MySub<br><br> <br> Main Program<br>      Use MyParameter<br>      Use MySub<br> ... ...<br> ... ...<br> End <br><br> If I put all the modules in a single .F90 file, the compilation can be done successfully. However, If I put the modules in separated files,  the following error information comes out:<br>

<br> Error: Symbol 'mataij' at (1) has no IMPLICIT type.<br><br> In addition, if I use PetscInt,    PetscErrorCode to declare variables in Module MySub, the similar errors come out.  How declare the variable with PETSc type in separate files? Thanks.<br>

<br>  <br><br>   <br><br><br>   <br><span class="HOEnZb"><font color="#888888">                                         </font></span></div></div><span class="HOEnZb"><font color="#888888">
</font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><br>-- <br>-----------------------------------------------------<br>Dharmendar Reddy Palle<br>Graduate Student<br>Microelectronics Research center,<br>
University of Texas at Austin,<br>
10100 Burnet Road, Bldg. 160<br>MER 2.608F, TX 78758-4445<br>e-mail: <a href="mailto:dharmareddy84@gmail.com" target="_blank">dharmareddy84@gmail.com</a><br>Phone: <a href="tel:%2B1-512-350-9082" value="+15123509082" target="_blank">+1-512-350-9082</a><br>
United States of America.<br><br></font></span></div>                                       </div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>