0

我想在 fortran 中测试和使用 PESTc,所以我写了一些非常简单且为 null 的东西,例如 (petscexe.F):

  PROGRAM petscexe
  INCLUDE 'petscsys.h'

  END PROGRAM petscexe

看看能不能正确导入头文件。

我用 gfortran 编译文件: gfortran petscexe.F -I /opt/local/lib/petsc/include/finclude

头文件位于我计算机中的此文件夹 (/opt/local/lib/petsc/include/finclude) 中。所以一切都应该没问题,但是...

错误是

Warning: petscsys.h:5: Illegal preprocessor directive

Warning: petscsys.h:6: Illegal preprocessor directive

Warning: petscsys.h:7: Illegal preprocessor directive

Warning: petscsys.h:9: Illegal preprocessor directive

Warning: petscsys.h:10: Illegal preprocessor directive

Warning: petscsys.h:11: Illegal preprocessor directive

Warning: petscsys.h:20: Illegal preprocessor directive

Warning: petscsys.h:22: Illegal preprocessor directive

Warning: petscsys.h:24: Illegal preprocessor directive

Warning: petscsys.h:87: Illegal preprocessor directive

Warning: petscsys.h:88: Illegal preprocessor directive

Warning: petscsys.h:89: Illegal preprocessor directive

Warning: petscsys.h:90: Illegal preprocessor directive

Warning: petscsys.h:91: Illegal preprocessor directive

Warning: petscsys.h:92: Illegal preprocessor directive

Warning: petscsys.h:93: Illegal preprocessor directive

Warning: petscsys.h:94: Illegal preprocessor directive

Warning: petscsys.h:119: Illegal preprocessor directive

Warning: petscsys.h:121: Illegal preprocessor directive

Warning: petscsys.h:123: Illegal preprocessor directive

Warning: petscsys.h:139: Illegal preprocessor directive

Warning: petscsys.h:143: Illegal preprocessor directive

Warning: petscsys.h:147: Illegal preprocessor directive

Warning: petscsys.h:153: Illegal preprocessor directive

Warning: petscsys.h:154: Illegal preprocessor directive

Warning: petscsys.h:156: Illegal preprocessor directive

Warning: petscsys.h:158: Illegal preprocessor directive

Warning: petscsys.h:159: Illegal preprocessor directive

Warning: petscsys.h:160: Illegal preprocessor directive

Warning: petscsys.h:162: Illegal preprocessor directive

Warning: petscsys.h:164: Illegal preprocessor directive

Warning: petscsys.h:165: Illegal preprocessor directive

Warning: petscsys.h:168: Illegal preprocessor directive

Warning: petscsys.h:170: Illegal preprocessor directive

Warning: petscsys.h:172: Illegal preprocessor directive

Warning: petscsys.h:234: Illegal preprocessor directive

Warning: petscsys.h:235: Illegal preprocessor directive

Warning: petscsys.h:236: Illegal preprocessor directive

Warning: petscsys.h:252: Illegal preprocessor directive

Warning: petscsys.h:254: Illegal preprocessor directive

Warning: petscsys.h:256: Illegal preprocessor directive

petscsys.h:18.6:
    Included at petscexe.F:2:

      PetscBool  PETSC_TRUE                                             
      1
Error: Unclassifiable statement at (1)
petscsys.h:19.6:
    Included at petscexe.F:2:

      PetscBool  PETSC_FALSE                                            
      1
Error: Unclassifiable statement at (1)
petscsys.h:23.29:
    Included at petscexe.F:2:

      parameter (PETSC_TRUE = .true.,PETSC_FALSE = .false.)             
                             1
Error: Can't convert LOGICAL(4) to REAL(4) at (1)
petscsys.h:25.6:
    Included at petscexe.F:2:

      PetscInt   PETSC_DECIDE,PETSC_DETERMINE                           
      1
Error: Unclassifiable statement at (1)
petscsys.h:28.6:
    Included at petscexe.F:2:

      PetscInt  PETSC_DEFAULT_INTEGER                                   
      1
Error: Unclassifiable statement at (1)
petscsys.h:31.6:
    Included at petscexe.F:2:

      PetscFortranDouble PETSC_DEFAULT_DOUBLE_PRECISION                 
      1
Error: Unclassifiable statement at (1)
petscsys.h:34.6:
    Included at petscexe.F:2:

      PetscEnum PETSC_FP_TRAP_OFF                                       
      1
Error: Unclassifiable statement at (1)
petscsys.h:35.6:
    Included at petscexe.F:2:

      PetscEnum PETSC_FP_TRAP_ON                                        
      1
Error: Unclassifiable statement at (1)
petscsys.h:43.6:
    Included at petscexe.F:2:

      PetscFortranAddr PETSC_VIEWER_DRAW_WORLD                          
      1
Error: Unclassifiable statement at (1)
petscsys.h:44.6:
    Included at petscexe.F:2:

      PetscFortranAddr PETSC_VIEWER_DRAW_SELF                           
      1
Error: Unclassifiable statement at (1)
petscsys.h:45.6:
    Included at petscexe.F:2:

      PetscFortranAddr PETSC_VIEWER_SOCKET_WORLD                        
      1
Error: Unclassifiable statement at (1)
petscsys.h:46.6:
    Included at petscexe.F:2:

      PetscFortranAddr PETSC_VIEWER_SOCKET_SELF                         
      1
Error: Unclassifiable statement at (1)
petscsys.h:47.6:
    Included at petscexe.F:2:

      PetscFortranAddr PETSC_VIEWER_STDOUT_WORLD                        
      1
Error: Unclassifiable statement at (1)
petscsys.h:48.6:
    Included at petscexe.F:2:

      PetscFortranAddr PETSC_VIEWER_STDOUT_SELF                         
      1
Error: Unclassifiable statement at (1)
petscsys.h:49.6:
    Included at petscexe.F:2:

      PetscFortranAddr PETSC_VIEWER_STDERR_WORLD                        
      1
Error: Unclassifiable statement at (1)
petscsys.h:50.6:
    Included at petscexe.F:2:

      PetscFortranAddr PETSC_VIEWER_STDERR_SELF                         
      1
Error: Unclassifiable statement at (1)
petscsys.h:51.6:
    Included at petscexe.F:2:

      PetscFortranAddr PETSC_VIEWER_BINARY_WORLD                        
      1
Error: Unclassifiable statement at (1)
petscsys.h:52.6:
    Included at petscexe.F:2:

      PetscFortranAddr PETSC_VIEWER_BINARY_SELF                         
      1
Error: Unclassifiable statement at (1)
petscsys.h:53.6:
    Included at petscexe.F:2:

      PetscFortranAddr PETSC_VIEWER_MATLAB_WORLD                        
      1
Error: Unclassifiable statement at (1)
petscsys.h:54.6:
    Included at petscexe.F:2:

      PetscFortranAddr PETSC_VIEWER_MATLAB_SELF                         
      1
Error: Unclassifiable statement at (1)
petscsys.h:75.6:
    Included at petscexe.F:2:

      PetscEnum PETSC_INT                                               
      1
Error: Unclassifiable statement at (1)
petscsys.h:76.6:
    Included at petscexe.F:2:

      PetscEnum PETSC_DOUBLE                                            
      1
Error: Unclassifiable statement at (1)
petscsys.h:77.6:
    Included at petscexe.F:2:

      PetscEnum PETSC_COMPLEX                                           
      1
Error: Unclassifiable statement at (1)
petscsys.h:78.6:
    Included at petscexe.F:2:

      PetscEnum PETSC_LONG                                              
      1
Error: Unclassifiable statement at (1)
petscsys.h:79.6:
    Included at petscexe.F:2:

      PetscEnum PETSC_SHORT                                             
      1
Error: Unclassifiable statement at (1)
Fatal Error: Error count reached limit of 25.

这是什么错误?非常感谢!

4

1 回答 1

1

在进行编译时,您必须使用 -cpp -dM 作为必要的标志。此外,您必须使用 C++/C 风格,即#include + ...,用于包含 .

于 2014-09-03T05:54:46.870 回答