Ok, I understand now. I just tested your recommended code on my school's linux server which uses ifort. It works w/o any error. Here's the code:
#define PETSC_AVOID_DECLARATIONS #include "include/finclude/petsc.h" #include "include/finclude/petscvec.h" #undef PETSC_AVOID_DECLARATIONS module foobar Vec abc contains subroutine xyz() implicit none #include "include/finclude/petsc.h" #include "include/finclude/petscvec.h" Vec fbar integer ierr call PetscInitialize(PETSC_NULL_CHARACTER,ierr) end subroutine end module Everything is similar to your recommended format except the "use foobar" is removed. The strange thing is when I try to compile on my windows's visual fortran, it gives lots of error. The errors all point to mpif.h. Some errors are: d:\cygwin\codes\MPICH\SDK\include\mpif.h(1) : Error: Syntax error, found END-OF-STATEMENT when expecting one of: ( : % . = => C -^ d:\cygwin\codes\MPICH\SDK\include\mpif.h(2) : Error: Syntax error, found END-OF-STATEMENT when expecting one of: ( : % . = => C -^ d:\cygwin\codes\MPICH\SDK\include\mpif.h(3) : Error: Syntax error, found INTEGER_CONSTANT '1993' when expecting one of: ( % . = => C (C) 1993 by Argonne National Laboratory and Mississipi State University. -------^ My include directory uses d:\cygwin\codes\MPICH\SDK\include. So how should I deal with this mistake? I do all my code writing and basic debugging on the visual fortran and I only run my working code on linux. Hence, I did not try your recommendation on the linux. When I reduced the errors to just 3 (none explicit declaration of PETSC_NULL_CHARACTER etc), I thought I'm going in the right direction. But in fact I was on the wrong track. Thank you very much and sorry for the inconvenience. Satish Balay wrote: >> However, doing this gave me more errors. Hence, I've followed >> another >> > > If you get errors with the recommended model - you sould report the > erros [not silently try something else - and then report erros with > this something else] > > I can't help you anymore unless you can report problems with a > reproduceable test code that I can comiile locally. > > Satish > > On Thu, 9 Aug 2007, Ben Tay wrote: > > >> Hi Satish, >> >> I am sorry if I have made you angry. I may have missed out some important >> points which you tried to highlight. I was converting several of my .F fixed >> format files to .f90 (or .F90) free format and some files which don't need >> declaration of PETSc type variable worked while some don't. >> >> However, I must clarify that the .f90 or .F90 did not bother me after a while >> since in visual fortran or ifort, using the option -fpp enables the .f90 >> files >> to be preprocessed too. Of course, if .F90 was used, -fpp is not required. >> >> In my sample file shown just now, I did not have any include statments in my >> subroutine. They're only present in the module 's section. Checking your >> prev. >> email, you indeed mention that the PETSc includes files must be in each and >> every subroutine. However, doing this gave me more errors. Hence, I've >> followed another user (Paul T Bauman) 's recommendation which states that >> only >> preprocessed statements not inside the module needs to be placed inside the >> subroutine. With this, I only has 3 errors, which concerns PETSC_COMM_SELF, >> PETSC_NULL_INTEGER and PETSC_NULL_CHARACTER not having an explicit type. I >> figured out that using: >> >> MPI_Comm PETSC_COMM_SELF >> >> >> will eliminate 1 error, although it was not required before. However, what >> about the other 2? Should I defined them as integer or character and give >> them >> a value using parameter? What value should I give them? You mention this in >> your prev email: >> >> integer NORM_MAX >> parameter NORM_MAX=3 >> >> >> You also give a template to follow. I also tried to cut and paste and use it >> but it gave lots of error. I had used it in visual fortran : >> >> #define PETSC_AVOID_DECLARATIONS >> #include "include/finclude/petsc.h" >> #include "include/finclude/petscvec.h" >> #undef PETSC_AVOID_DECLARATIONS >> >> module foobar >> >> Vec abc >> >> contains >> subroutine xyz() >> use foobar >> implicit none >> #include "include/finclude/petsc.h" >> #include "include/finclude/petscvec.h" >> #include "include/finclude/petscvec.h90" >> >> Vec fbar >> >> >> end subroutine >> end module >> >> As said above, upon removing the include files in the subroutine and the "use >> foobar" statement, everything's ok. You can give it a try too. >> >> Lastly, I understand that you have been helping a lot of users and there's >> really a lot of stupid users around (I know I'm one of them ;-) ). Thank you >> for your patience. >> >> Satish Balay wrote: >> >>> On Thu, 9 Aug 2007, Ben Tay wrote: >>> >>> >>> >>>> Hi, >>>> >>>> Guess I'm too used to typing .f90 ;-) .... I've changed it to .F90 before >>>> but >>>> perhaps at that time the error I got didn't disappear so I didn't bother >>>> after >>>> that. >>>> >>> I'm sorry - but you can't keep silently discarding the sugestions we >>> make and keep reporting the same issues multiple times.. >>> >>> This is frustrating. >>> >>> >>> >>>> I'm working in windows so I thought the capital letter doesn't really >>>> matter. >>>> >>>> >>> I've indicated this before. Most compilers use .F90 for prerpocessed >>> free form. And you keep indicating this is what you require. [Most >>> compilers don't preprocess .f90 files] >>> >>> >>> >>>> Moreover, .f90 also works with my ifort in linux. Is it really >>>> important? If so, I'll change all my .f90 to F90. Thanks for highlighting. >>>> >>>> Here's a sample code test.F90: >>>> >>>> >>> I'll need a test code that can reproduce the problems you report. >>> >>> >>> >>>> module global_data >>>> >>>> implicit none >>>> >>>> save >>>> >>>> #define PETSC_AVOID_DECLARATIONS >>>> #include "include/finclude/petsc.h" >>>> #include "include/finclude/petscvec.h" >>>> #include "include/finclude/petscmat.h" >>>> #include "include/finclude/petscksp.h" >>>> #include "include/finclude/petscpc.h" >>>> #undef PETSC_AVOID_DECLARATIONS >>>> >>>> integer :: size_x,size_y >>>> >>>> Mat A_mat ! /* sparse matrix */ >>>> >>>> !MPI_Comm PETSC_COMM_SELF - commented out will result in error >>>> >>>> contains >>>> >>>> subroutine allo_var >>>> >>>> >>> Again you are ignoring the sample template I sent you. You need to >>> include PETSc include files in every subroutine. >>> >>> I'm sorry I can't repeat this anymore. >>> >>> Satish >>> >>> >>> >>>> !allocate memory for variables >>>> >>>> integer :: status(2),ierr,k >>>> >>>> size_x=10;size_y=10 >>>> >>>> call PetscInitialize(PETSC_NULL_CHARACTER,ierr) >>>> >>>> call >>>> MatCreateSeqAIJ(PETSC_COMM_SELF,size_x*size_y,size_x*size_y,13,PETSC_NULL_INTEGER,A_mat,ierr) >>>> >>>> end subroutine allo_var >>>> >>>> end module global_data >>>> >>>> I got "Error: This name does not have a type, and must have an explicit >>>> type. >>>> [PETSC_NULL_CHARACTER]". Same for PETSC_NULL_INTEGER and PETSC_COMM_SELF. >>>> >>>> It was ok when I'm programming in fixed format. >>>> >>>> Thanks >>>> >>>> Satish Balay wrote: >>>> >>>> >>>>> On Thu, 9 Aug 2007, Ben Tay wrote: >>>>> >>>>> >>>>> >>>>>> Hi, >>>>>> >>>>>> when I changed my global.F to global.f90, >>>>>> >>>>>> >>>>> Any perticular reason why you keep using .f90 suffix even though I've >>>>> recommended using .F90 suffix [for preprocessed free form] a few >>>>> times? >>>>> >>>>> >>>>> >>>>>> I was told that PETSC_COMM_SELF, PETSC_NULL_INTEGER and >>>>>> PETSC_NULL_CHARACTER does not have a type. >>>>>> >>>>>> >>>>> Please send a test code that demonstrates this problem. >>>>> >>>>> Satish >>>>> >>>>> >>>>> >>>>> >>>> >>>> >>> >>> >> > > >
