<div dir="ltr"><div>Dear Barry,</div><div><br></div><div>I tried to build a simple code with the same things I mentioned to you on last e-mail but it worked, which is more strange to me. So I built two branches on my git code to show you the problem:</div><div><br></div><div>git code: <a href="https://github.com/SoilRos/ANISOFLOWPACK">https://github.com/SoilRos/ANISOFLOWPACK</a></div><div><br></div><div>Branch: PETSc_debug_boolean_0</div><div>The first one is a simple code which is working for what was designed. Forget sample problems, just compile and run the ANISOFLOW executable on src folder, if there are some verbose messages then the program is working.</div><div><br></div><div>Branch: PETSc_debug_boolean_1</div><div>The second one is just a modification of the first one adding the two booleans mentioned above in 01_Types.F90 file. I tried it in mac El Capitan and Ubuntu (with Valgrind) and PETSc 3.7.3 and 3.7.2 respectively, both with the same segmentation fault.</div><div><br></div><div>PD: Although I already fixed it compressing the three booleans into one integer, I think is better if we try to figure out why there is a segmentation fault because I had similar problems before.</div><div>PD2: Please obviate the variable description because are pretty out of date. I'm trying to change it, so it can be confusing.</div><div><br></div><div>Best wishes,</div><div>Santiago Ospina</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-08-05 15:54 GMT-05:00 Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
> On Aug 1, 2016, at 4:41 PM, Santiago Ospina De Los Rios <<a href="mailto:sospinar@unal.edu.co">sospinar@unal.edu.co</a>> wrote:<br>
><br>
> 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>
> 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>
><br>
><br>
> Later I use it in the main program, with something like this<br>
><br>
> 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_<wbr>WORLD,ierr)<br>
> ...<br>
> CALL PetscFinalize(ierr)<br>
><br>
> END PROGRAM<br>
><br>
><br>
> 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>
> Valgrind message:<br>
> ==5160==<br>
> ==5160== Invalid read of size 1<br>
<br>
</div></div> It is curious that it says "of size 1" when we declare PetscBool to be a logical*4 I don't see anything obviously wrong.<br>
<br>
Please send a simple code we can compile and run that reproduces the problem.<br>
<span class="HOEnZb"><font color="#888888"><br>
Barry<br>
</font></span><div class="HOEnZb"><div class="h5">> ==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>
><br>
> 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.<br>
><br>
> Santiago Ospina<br>
> --<br>
><br>
> --<br>
> Att:<br>
><br>
> Santiago Ospina De Los Ríos<br>
> National University of Colombia<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></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>