[petsc-users] variable declaration in Fortran90

Roc Wang pengxwang at hotmail.com
Wed Aug 29 10:28:15 CDT 2012


Thanks for the kindly reply.

By saying petscdef files, do you mean petscXXXdef, where XXX is the corresponding component of PETSc, such as vec, mat, et. al.?

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.

!--------------the way I declared the PETSc files

   Module MyParameter
       Implicit none
#include "finclude/petscsysdef.h"     ! Put all petscXXXdef,h  in the module
#include "finclude/petscvecdef.h"

#include "finclude/petscmatdef.h"
#include "finclude/petscpcdef.h"
#include "finclude/petsckspdef.h"


 
      Integer::  ... ...
      Real:: ... ...     ! There are some PETSc variables defined in this Module
  

   End Module MyParameter

  Module MySub
       Use Myparameter
     Contains
       ... ...
     Subroutine MyPETSc_APP()
#include "finclude/petscsys.h"
#include "finclude/petscvec.h"
#include "finclude/petscmat.h"
#include "finclude/petscpc.h"
#include "finclude/petscksp.h"

#include "finclude/petscsys.h90"
#include "finclude/petscmat.h90"
#include "finclude/petscvec.h90"
      Implicit none
      ... ...
      Call MatSetType(A_Mat, MATAIJ, ierr)
      ... ...
    End Subroutine MyPETSc_APP

       ... ...
  EndModule MySub

 Main Program
      Use MyParameter
      Use MySub
 ... ...
 ... ...
 End 

Date: Tue, 28 Aug 2012 16:00:58 -0500
From: dharmareddy84 at gmail.com
To: petsc-users at mcs.anl.gov
Subject: Re: [petsc-users] variable declaration in Fortran90

>From what i understand, you should #include the corresponding petscdef files in the module and the petsc headers in the subroutine.

petsc version installed on machine is petsc-3.2-p5
I use a single include file: #include "finclude/petscdef.h" in the module

and in the subroutines (including the ones that are defined after contains in the module) and program.
#include "finclude/petsc.h"
 you can use #include "finclude/petsc.h90" if you are using the things such as vecgetArrayF90


On Tue, Aug 28, 2012 at 3:45 PM, Roc Wang <pengxwang at hotmail.com> wrote:





Hello,


   I am developing Fortran90 code with PETSc.  Several Modules are defined in the code. Such as

  Module MyParameter
       Implicit none
#include "finclude/petscsys.h"
#include "finclude/petscvec.h"

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

 
      Integer::  ... ...
      Real:: ... ...
  

  End Module MyParameter

  Module MySub
       Use Myparameter
     Contains
       ... ...
      Call MatSetType(A_Mat, MATAIJ, ierr)

       ... ...
  EndModule MySub

 
 Main Program
      Use MyParameter
      Use MySub
 ... ...
 ... ...
 End 

 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:


 Error: Symbol 'mataij' at (1) has no IMPLICIT type.

 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.


  

   


   
 		 	   		  


-- 
-----------------------------------------------------
Dharmendar Reddy Palle
Graduate Student
Microelectronics Research center,
University of Texas at Austin,

10100 Burnet Road, Bldg. 160
MER 2.608F, TX 78758-4445
e-mail: dharmareddy84 at gmail.com
Phone: +1-512-350-9082
United States of America.

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120829/c40e478b/attachment.html>


More information about the petsc-users mailing list