Skip to main content
FluidEarth Portal Header version 3

FluidEarth Portal

Go Search
  
FluidEarth Portal > FluidEarth Discussions > passed arguments setting issues  

FluidEarth Discussions

Modify settings and columns
Discussions board for FluidEarth Users
  
View: 
Post
Started: 10/06/2010 15:56
Attachment
Picture: ZZhang
ZZhang
passed arguments setting issues.
Hi, Gordon,
I have several questions about how to set passed arguments in attached pdf file.
The rar file contains the two example model.
Look forward to your reply. Thank you.
Posted: 11/06/2010 10:26
Attachment
Picture Placeholder: GGlasgow
GGlasgow
hi,
 
i'm going to have to answer this one in a couple of separate replies, i'm afraid, as there are potentially a few things to cover.
 
to get you started, i have spotted a couple of things straight away:
 
1. ths strings in Engine.f90 of DIVAST_hydro do not match the strings in DIVAST_Hydro.xml. basically, you have "..._IN" in the fortran code, but "..._OUT" in the .xml file. no data will be coming in to your code, whether 1D, 2D or 3D until you get this sorted out. also, the size of both the OUT and IN arrays that are passing/receiving code must be the same size - for ThreeD01_OUT/IN, you had different sized arrays in the two different xml files. i didn't check the others, but you will need to make sure this is right.
 
2. the way your code loops over 3D variables (over i,j,k) in the GET/SET methods (both codes) doesn't look right to me. attached a jpg showing how i quickly rewrote this. basically, i treat k as the outer loop as i want all i,j in a single plane to be looped over first and then i want to change to another plane
 
i think these changes will get you going - attached is an OUT.txt from DIVAST_AdveDiffu where i changed the string in your Engine.f90 (see jpg) composition and the get/set methods. the composition ran, and the variable i was passing ThreeD01 seemed to increase in both output files
 
have a go at making these changes and see if you get data to move between the models. i will go through your code in more detail a little later in the day, and post any more changes if i find them.
 
hope this helps,
 
gordon 
Posted: 11/06/2010 10:53
Picture Placeholder: GGlasgow
GGlasgow
sorry, i missed a part of the answer before.
 
to decide how to set 'M' and 'N', you need to remember how the SDK is using these two values; basically, all that happens is it creates a single one-dimensional array of size M.N, which is why i use a one-dimensional echange_item array in my code to handle the data that comes in and out.
 
so if you wish to use this method to pass i tile of 3D data, you need to work out 'M' and 'N' so that their product equals I.J.K.
 
...for example, i like to use
 
M = I.J and N = K (because i am creating K number of tiles, each one with I.J elements, as my last post suggests)
 
but you might prefer
 
M = I and N = J.K
 
or
 
M = 1 and N = I.J.K
 
or
 
M = I.J.K and I = 1
 
so it's really up to you to choose the best approach that suits the way you write your code - as i say, i like to create tiles each one I.J in size, and i have K of them.
 
when i get a little time, i will create a better element set for you:

"FluidEarth.Sdk.ElementSetCubeRegular"

that allows you to specify an I, J and K rather than an N and M.
 
this won't make any difference to your model code at all - all that will happen is you will change your XML files to use this new element set rather than the old Grid version. in both cases, the SDK will create a 1D array which is equal to I.J.K as above.
will try to do this this weekend,
 
gordon
Posted: 11/06/2010 11:29
Picture: ZZhang
ZZhang
Thank you very much, Gordon. 
You give me very useful advice. I will change my model. If I get new issues, I will ask you.
Posted: 15/06/2010 18:56
Attachment
Picture: ZZhang
ZZhang
Hi Gordon,
 
I have modified my engine and .xml file, so it can pass the 2D and 3D strings very well.
However, it can't pass parameters and 1D strings. The message shows 'Index was outside the bounds of the array'.I set the parameters and 1D strings in engine according to the examples(boundary,spill,reservoir). I think I made mistakes, but I could't find out them.  
I attach the two models and logfile. Can you check it for me? Thanks very much.
Posted: 15/06/2010 22:35
Attachment
Picture Placeholder: GGlasgow
GGlasgow
hi,
 
if you want to pass parameters (single values) you will need to use the same technique as the reservoir/spill/boundary models and specify 'coords' on which to exchange data. attached a jpg showing your xml file with a domain defined in coords. note addition of 'indices' to these element sets. i made this change to both of your xml files, and your composition ran successfully.
 
i think you will have problems with the 1d arrays, which you will need to treat like 2d or 3d arrays - use N=1 and M=size of array to get going.  i'll try to get 1D and 3D element set put together as soon as possible.
 
hope this helps,
 
gordon
Posted: 23/06/2010 11:37
Attachment
Picture: ZZhang
ZZhang

Hi Gordon,

 

I have changed the models as youradvice. I got a new issue. If I just pass the Parameter, OneD and TwoD, it can get right result. If I add the ThreeD on, the others (Parameter, OneD and TwoD) can’t pass the right result. I have checked the Engine.f90 and .XML file, but I couldn’t find out the reason. 

So what do you think cause this issue?

Thanks very much.


Posted: 23/06/2010 13:20
Attachment
Picture Placeholder: GGlasgow
GGlasgow
Hi,
 
it looks as though you are almost there - i've gone through your code and can make two suggesstions as to why this isn't working as you expect.
 
1.  when you setup your exchange_item array, you have made it too small for the 3D variables. at present, it is (xsize*ysize) but it really needs to be (xsize*ysize*3) to cope with the 3D variables. i don't really know what happens when the array you are reading into is too small, but it doesn't look as though it's working properly.
 
2. this second part is only for completeness, but i would reset the exchange_item array to 0.0 every time a new input variable is read-in (i.e. in 'Get'). not sure if this is strictly necessary, but is certainly something i would try to do.
 
i made both of these changes and i seemed to get the right results (attached), but you will know better than me - have a look and see if t6his is now behaving properly.
 
hope this helps, but if not let me know and i can go through things a little more thoroughly.
 
gordon
Posted: 05/08/2010 01:00
Attachment
Picture: ZZhang
ZZhang
hi Gordon,
 
The issues i asked before have been solved. I've got new issues. Maybe some is just for DIVAST, because of the calculating scheme. You can find issues in the attached pdf file.
Thanks.
Zhidong
Posted: 05/08/2010 13:01
Attachment
Picture Placeholder: GGlasgow
GGlasgow
hi,
 
i've had a quick look at your issues and think i can help with the second one, but need a little more information about the first. attached a pdf that goes through my thoughts on both.
to help with the first problem, i'll really need to know when it is failing (i.e. at compile or runtime) and if at runtime, whether it is in initialise, get, set or compute. i will also need to know a little more if you can provide a little more information, i can certainly try to help.
 
for the second problem, what you have to do is create two different routes through the CIRCLE subroutine - one for each sub-timestep. in the pdf i have shown you the approach i use for this, which involves checking the value of a 'flag' variable added to the call to CIRCLE.
 
hope this helps - let me know if not.
 
gordon
Posted: 06/08/2010 11:02
Picture: ZZhang
ZZhang
Hi,Gordon, as for the first issue, the second model gets the array and parameter same time in subroutine set(), and i allocate the array in function initialise_post(), but at this time the parameter hasn't been passed. so how can i get the parameter firstly, then allocate the array and then get data of the array? in fact, i don't have to solve this issue. as you mentioned, if i create the array much larger than the parameter (needed) in both models (same size), it also can pass data very well. as for the second issue, i need more time to solve it. thanks. zhidong

Posted: 06/08/2010 13:34
Picture Placeholder: GGlasgow
GGlasgow
hi,
 
i think that if you try to allocate the array in initialise_post(), you will always get the problem you describe.
 
the best solution is likely to be to allocate the array in set().
 
one way to do this would be to allocate the array with a dummy length in initialise_post() and at the same time set a boolean variable to .false. to indicate that it is only temporary. when you receive the parameter through set() and if this flag is set to false, you can deallocate the temporary array and reallocate it to be the correct size and also set the flag to .true.
 
you may also need to make sure that your timestep and get() calculations are not performed before the flag is changed to .true. as well, as this would probably cause errors.
 
but whichever way you do this, i can see it becoming complicated.
 
personally, i would have thought the safest approach would be to set the array size in the .omi file (if at all possible) and if not then use a larger array size as with your existing workaround. not terribly efficient, but it should work.
 
let me know how you get on with the second problem - i would hope from looking at the DIVAST code on the portal that the apporach i outlined will work. if not, let me know and i can help come up with something else if needed.
 
 
gordon