CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Siemens (https://www.cfd-online.com/Forums/siemens/)
-   -   segmentation fault (https://www.cfd-online.com/Forums/siemens/54813-segmentation-fault.html)

Sheila August 22, 2005 18:41

segmentation fault
 
Hi everyone,

I am using sormom.f and I am running with double precision. I get segmentation fault if I set S1U S2U to some calculated value, but if I set them to 0.0 I dont get it... Any idea why and how to correct this?

Sheila

4xF August 23, 2005 04:11

Re: segmentation fault
 
Remember that the subroutine SORMOM.F is called for every cell individually. Check that your code respects this feature and also check that you are not accessing S1U and S2U as arrays.

Sheila August 23, 2005 07:31

Re: segmentation fault
 
Hi 4xF,

there is nothing in my code to invalidate any of what you have mentioned above. I have written S1U and s2U in terms of cell distances,velocities and viscosity. All of these are from common blocks provided by STAR.

My program seem to work for some mesh and not work for others. It definitely works for small mesh (36x400) and not for (47x400) for example on a 2 m length. These are quite small number meshes.

Sheila

Oliver August 23, 2005 08:27

Re: segmentation fault
 
But nevertheless, a segmentation fault in this context most often points to a bad array access (access of an invalid memory address).

This sort of problem could sometimes result in a segmentation fault, sometimes in bad results, depending on array sizes.

Please check your code again, especially the array accesses. Possibly you could post some of the important code lines.

Oliver

Sheila August 23, 2005 19:51

Re: segmentation fault
 
Its strange when I run the code with 45x400 or 49x400 cells its fine, but it only gives segmentation fault when runwith 47x400...

Ok, here is some part of my code,

C --- DISTANCES C

XEP = CX(1,IPE)-CX(1,IPSTAR)

XWP = CX(1,IPSTAR)-CX(1,IPW)

DX = DXX(IPSTAR) . . C --- WEIGHTING FACTOR

WFE = 0.5*DX/XEP . . C ---------- U MOMENTUM C

UP = UG(1,IPSTAR)

UPE = UG(1,IPE)

UPW = UG(1,IPW) . . C --- VISCOSITIES C

VISC = VIST

VISTE = VISTG(IPE)

VISTW = VISTG(IPW) . . . C --- COEFFICIENTS C

CON = 4./3.

AE = VISTEF/(DX*XEP)

AW = VISTWF/(DX*XWP) . . .

S1U = CON*((VISTWF*VWNS/DY)-(VISTEF*VENS/DY))/(TW*DX +SMALL)

S1U = S1U + ((VISTNF*VNEW/DX) - (VISTSF*VSEW/DX))/(DY+SMALL)

S1U = S1U + (AE*UPE + AW*UPW)*CON + AN*UPN + AS*UPS

S2U = (AE+AW)*CON + AN + AS . . .

Oliver August 24, 2005 03:05

Re: segmentation fault
 
Hi Sheila,

the code does not look bad. You should be careful with your divisions by dx, xep ... You should add everywhere a small where your denominator potentially could go to zero. But that shouldn't be the problem.

For me it would be interesting if you use 3.1x or 3.2x because it makes a difference for your local array definitions especially if they are dimensioned automatically with parm.inc. I assume that dxx, ug and vistg are arrays defined in your code. Perhaps these arrays have not the correct size? Sometimes it is helpful to compile the subroutines with debugging option as depending on compiler and operating system the problem line is shown together with the segmentation fault.

In cases like that I add print lines into the user subroutine code to find the exact position of the problem. Then you could concentrate on the arrays in that range. You could also add some variable output into these debugging print lines to better understand what is happening.

I know that it is a nasty job but usually it is a programming glitch which causes the segmentation fault. Segmentation faults in Fortran are most often access of array positions outside of the valid/defined range. Sometimes those accesses do not produce an error as they simply access a value of the following array but sometimes the memory position in question is not accessible and produces a segmentation fault.

Good luck

Oliver

Sheila August 24, 2005 14:11

Re: segmentation fault
 
I am using v3,15. All the parameters I am using are provided by STAR support team. And there is no problem with SMALL as those variables are always non-zero.

I always run with debugging and there is no problem reported when I starlink the case. It is running now for a higher number of mesh, it just would'nt run with that specific number of mesh (47x400) for some reason. And only with double precision.

Thanks for your comments and helps. :)

Rodrigo M.S. de Oliveira September 27, 2005 21:16

Re: segmentation fault
 
Have you tried the command

ulimit -s unlimited

before running the software?


Sheila October 9, 2005 05:40

Re: segmentation fault
 
I just tried it, it still is giving me segmentation fault :(


All times are GMT -4. The time now is 16:18.