<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><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><br>!--------------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 id="SkyDrivePlaceholder"></div><hr id="stopSpelling">Date: Tue, 28 Aug 2012 16:00:58 -0500<br>From: dharmareddy84@gmail.com<br>To: petsc-users@mcs.anl.gov<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 class="ecxgmail_quote">On Tue, Aug 28, 2012 at 3:45 PM, Roc Wang <span dir="ltr"><<a href="mailto:pengxwang@hotmail.com">pengxwang@hotmail.com</a>></span> wrote:<br><blockquote class="ecxgmail_quote" 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> </div></div>
</blockquote></div><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">dharmareddy84@gmail.com</a><br>Phone: +1-512-350-9082<br>United States of America.<br><br></div> </div></body>
</html>