<div dir="ltr">Hello there,<br><br>I'm having problems defining some variables into derived types in Fortran. Before, I had a similar problems with an allocatable array "PetsInt" but I solved it just doing a non-collective Petsc Vec. Today I'm having troubles with "PetscBool" or "Logical":<br><br>In a module which define the variables, I have the following:<br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">MODULE ANISOFLOW_Types<br><br> IMPLICIT NONE<br><br>#include <petsc/finclude/petscsys.h><br>#include <petsc/finclude/petscvec.h><br> <br>...<br><br> TYPE ConductivityField<br> PetscBool :: DefinedByCvtZones=.FALSE. ! It produces the segmentation fault.<br> PetscBool :: DefinedByPptZones=.FALSE. ! It produces the segmentation fault.<br> PetscBool :: DefinedByCell=.FALSE.<br> ! Conductivity defined by zones (Local):<br> Vec :: ZoneID<br> TYPE(Tensor),ALLOCATABLE :: Zone(:)<br> ! Conductivity defined on every cell (Local):<br> Vec :: Cell<br> END TYPE ConductivityField<br><br><br> TYPE SpecificStorageField<br> PetscBool :: DefinedByStoZones=.FALSE. ! It produces the segmentation fault.<br> PetscBool :: DefinedByPptZones=.FALSE. ! It produces the segmentation fault.<br> PetscBool :: DefinedByCell=.FALSE.<br> ! Specific Storage defined by zones (Local):<br> Vec :: ZoneID<br> Vec :: Zone<br> ! Specific Storage defined on every cell (Global).:<br> Vec :: Cell<br> END TYPE SpecificStorageField<br><br> TYPE PropertiesField<br> TYPE(ConductivityField) :: Cvt<br> TYPE(SpecificStorageField) :: Sto<br> ! Property defined by zones (Local):<br> PetscBool :: DefinedByPptZones=.FALSE.<br> Vec :: ZoneID<br> END TYPE PropertiesField<br><br>...<br><br>CONTAINS<br><br>...<br><br>END MODULE ANISOFLOW_Types<br></blockquote><br><br>Later I use it in the main program, with something like this <br><div><div><div><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">PROGRAM ANISOFLOW<br><br> USE ANISOFLOW_Types, ONLY : ... ,PropertiesField, ...<br> ...<br><br> IMPLICIT NONE<br> <br>#include <petsc/finclude/petscsys.h><br><br> ...<br> TYPE(PropertiesField) :: PptFld<br> ...<br><br> CALL PetscInitialize(PETSC_COMM_WORLD,ierr)<br> ...<br> CALL PetscFinalize(ierr)<br><br>END PROGRAM<br></blockquote><br><br></div><div>When I run the program appears a Segmentation Fault, which disappears when I comment the booleans marked in the code. Because I need them, I used Valgrind to figure out what is happening but it is yet a mistery to me.<br><br></div><div>Valgrind message:<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">==5160==<br>==5160== Invalid read of size 1<br>==5160== at 0x4FB2156: petscinitialize_ (zstart.c:433)<br>==5160== by 0x4030EA: MAIN__ (ANISOFLOW.F90:29) # line of petsc inizalitation<br>==5160== by 0x404380: main (ANISOFLOW.F90:3) # line of "USE ANISOFLOW_Types, ONLY : ... ,PropertiesField, ..."<br>==5160== Address 0xc54fff is not stack'd, malloc'd or (recently) free'd<br>==5160==<br><br>Program received signal SIGSEGV: Segmentation fault - invalid memory reference.<br><br>Backtrace for this error:<br>#0 0x699E777<br>#1 0x699ED7E<br>#2 0x6F0BCAF<br>#3 0x4FB2156<br>#4 0x4030EA in anisoflow at ANISOFLOW.F90:29<br></blockquote><div> </div></div>I think it is maybe related with petsc because the error popped out just in its initialization, so if you know what's going on, I would appreciate to tell me.<div><br></div><div>Santiago Ospina<br></div><div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><br><div><span style="color:rgb(136,136,136)">-- <br><span style="font-family:Tahoma">Att:<br style="text-indent:0px!important"><br style="text-indent:0px!important">Santiago Ospina De Los Ríos<br style="text-indent:0px!important">National University of Colombia<br></span></span></div></div></div></div></div></div>
</div></div></div></div>