t(is,1+nsc)
Hi,
I have been trying to plot the concentration of a passive scalar by using t(is,1+nsc) at posdat. The code looks something like this, with scalar 1 being an active scalar, and scalar 2 a passive one: do is=1,ncell / ip=iclmap(is) / pph2(ip)=p(is)*t(is,2) / t(is,3)=pph2(ip) / enddo / I have written this program in POSDAT and everytime I run it, I get either a 'negative density found in more than 100 cells' error message or 'a memory image file is created as core'. Is there anything wrong with this? Thanks, Isidro 
Re: t(is,1+nsc)
If you want to define the value of a scalar explicitly, you should use the SCALFN subroutine. You shouldn't write directly to the scalar array T in POSDAT. From the point of view of Fortran, your coding is correct but maybe there is something wrong with the declaration of pph2. One thing to remember is that big arrays should always be put into common blocks  otherwise they may be too big for the stack and you'll get a coredump.

Re: t(is,1+nsc)
hi,
I have tried doing what you said but have got no results. First, I selected the solution method to be defined by user coding, then I passed to SCALFN the scalar that should be plotted via a common block and then I code something like this: if(is.eq.2)then / phi=sc(ip) / endif. It ran, but SCALFN was not called. I double checked it with: write(60,*)'x'. After this I found out that the only way to call this subroutine is turning the scalar solver on (which is what someone told me not to do). Anyway I turned it on and SCALFN was now being called, but this time a core dumped! Could you tell me how exactly have you done it? I appreciate your help, many thanks, isidro 
Re: t(is,1+nsc)
You should turn the scalar solver on if you use SCALFN to define the scalar explicitly, but turn it off if you use POSDAT to write directly to the T() array directly. You should only use the POSDAT approach for passive scalars.
How do you declare the sc() array? Does the core dump occur if you comment out all lines containing this array? If so, you know this arary is the cause of the problem. 
Re: t(is,1+nsc)
It is very simple, suppose I would like to plot the mole fraction of sc(1) of a mixture of sc(1) and sc(2) at posdat. First of all I define a parameter 'alpha=maximum cell number', then I define a variable 'common/isidro1/mfsc1(alpha)'. Then I start coding by looping all cells with: do is=1,nctmxu / ip=iclmap(is) / this gives me prostar cell numbers. Now I narrow the loop to a region of interest with an if statement: if(ictid(is).eq.1). Now I calculate the mole fraction (let 'mw' mean molecular weight) with: mfsc1(ip)=((t(is,2)*den(is)*vol(is))/mwsc1)/((t(is,2)*den(is)*vol(is))/mwsc1)+((t(is,3)*den(is)*vol(is))/mwsc2)) / endif / enddo; voila! Now the problem is, how to plot 'mfsc(ip)'. My first try was to define a passive scalar sc3, turn the solver off, and use t(is,4)= mfsc(ip) directly in POSDAT. This gave me a 'negative densities' error. Then I turned the solver on and chose to solve it via SCALFN, as you suggested. I copied the common block to SCALFN.f and coded: if(is.eq.3)then / phi=mfsc(ip) / endif. When I ran it a core dumped. I am sure that there must be a very simple error to this very simple problem, I would be greatful if you could tell me what is wrong with it, by doing this you will also help me keep some of my few hair. kind regards,isidro

Re: t(is,1+nsc)
I would definitely use SCALFN and not POSDAT. There is no need for an mfsc array in SCALFN, as you have access to SCALAR() already. I suspect the core dump is related to the mfsc array (did you try commenting it out?).

Re: t(is,1+nsc)
Hi Here is how I fixed a similar problem. Scalar defined as passive, turning on the solver and defining the solution method as "user". I am working under SGIUNIX In scalfn.f : define in common block scal(nbmax,nctmax) save last if (intflg(100).eq.0) then last=ntcell+1 intflg(100)=100 endif
!calculates only once per cell loop if (last.ge.ipstar) then do i=nbmax nctmax scal(i)=your equation enddo endif last=ipstar phi=scal(ipstar) Hope it helps! Cheers Roadracer 
All times are GMT 4. The time now is 17:33. 