[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TRNSYS-users] Problems with dynamic arrays definition in new types



Jordi,
  Are you making a Type that is going to be in its own external dll or one that is going to be inside the TRNDll.dll. If you are going to link your component in to the rest of TRNDll.dll then you can add your allocatable arrays to TRNSYSData. If you are making a DLL that is external to TRNDll.dll then I would recommend that you create a new data module (called Type333Data.for or something) and add it to your project instead of modifying TRNSYSData.for and adding it to the project.

  Second, I would suggest that you stay away from trying to dynamically size the OUT() and OCHECK() arrays. The amount of spots reserved for those arrays is set by your Type during one of the initialization calls (when you set INFO(6) to the required number of outputs). What is normally done instead is to simply make the OUT() array big enough to handle the largest number of outputs that you anticipate having from your Type.
Cheers,
 David
 

At 10:14 5/25/2007, jordi cipriano wrote:
Dear David,
 
Many thanks, but I followed your instructions and when I compile my Type a lot of errors appear:
1. I wrote the following at the uses statement of my type:
USE TrnsysData, ONLY: STORED,OUT,OCHECK,a,b,c,r,Tn,Tnm05,Tnm1
These arrays are my allocatable arrays which I defined as allocatable within the Trnsysdata routine, as you suggested. The compilation error is:
Error: Name in only-list does not exist.   [STORED]
2. In my type I also included the allocate instructiion, after reading the values of the parameters, as:
IF(.NOT.ALLOCATED(STORED)) ALLOCATE(STORED(NSTORED),stat=istat)
And the compilation error is:
Error: This name does not have a type, and must have an explicit type.   [STORED]
and:
Error: An array-valued argument is required in this context.   [ALLOCATED]
 
Do you know what are the causes of these errors?
 
Many thanks again,
 
Jordi Cipriano
----- Original Message -----
From: David Bradley
To: jordi cipriano ; trnsys-users@engr.wisc.edu
Sent: Friday, May 25, 2007 12:14 AM
Subject: Re: [TRNSYS-users] Problems with dynamic arrays definition in new types

Jordi,
  You have run into an annoyance of Fortran. As soon as you leave the Type subroutine, the allocatable array disappears. What you need to do is define the allocatable array globally in a "data only module" Your ALLOCATE instruction stays where it is but then the array doesn't disappear. You can see what I mean if you look at the file TRNSYSData.for. You will see the lines:

C ********* DECLARE ALLOCATABLE ARRAYS FOR USE IN DYNDATA
DOUBLE PRECISION, ALLOCATABLE :: X1dd( : ,: ),X2dd( : ,: ),X3dd( : ,: )
DOUBLE PRECISION, ALLOCATABLE :: X4dd( : ,: ),YDATAdd( : ,: ),DATAINdd( : )
INTEGER , ALLOCATABLE :: LUSTORdd( : ), IPTdd( : )

those lines declare the allocatable arrays that are actually used in the DynamicData routine.
Cheers,
  David

At 11:03 5/24/2007, jordi cipriano wrote:
Dear Trnsys users,
 
I have a question concerning to the use of Dynamic arrays in new Trnsys types. I'm programming a new Type with fortran 90 and I'm using the instruction ALLOCATABLE to define the dimension of some arrays. This dimension is depending on an input defined in the proforma.
 
The issue is that I don't exactly know at which step iteration should I define the array dimension so that this dimenson keeps saved in each iteration. In other words, if I define the array dimension just bellow the variables definition, each time the trnsys call my type, the matrix appear as "Undefined pointer/array" until trnsys finds the ALLOCATE instruction. This happens even if I've already defined the dimension in previous iteration callings. This fact affects all the calculations because one of the arrays is the STORED array, which I use to update the temporary terms of my ecuations. 
 
Does anybody know who to solve this problem?
 
Many thanks,
 
Jordi Cipriano
BEE-Group
CIMNE-Terrassa
CIMNE. Spain

_______________________________________________
TRNSYS-users mailing list
TRNSYS-users@engr.wisc.edu
https://www.cae.wisc.edu/mailman/listinfo/trnsys-users

****************************************************************************************
Thermal Energy System Specialists (TESS), LLC
David BRADLEY                           2916 Marketplace Drive - Suite 104
Partner                                        Madison, WI 53719
Phone: (608) 274-2577 USA
Fax: (608) 278-1475
E-mail: bradley@tess-inc.com
Web Pages:  http://www.tess-inc.com    and      http://www.trnsys.com

"Providing software solutions for today's energy engineering projects"
****************************************************************************************

****************************************************************************************
Thermal Energy System Specialists (TESS), LLC
David BRADLEY                           2916 Marketplace Drive - Suite 104
Partner                                        Madison, WI 53719
Phone: (608) 274-2577 USA
Fax: (608) 278-1475
E-mail: bradley@tess-inc.com
Web Pages:  http://www.tess-inc.com     and      http://www.trnsys.com

"Providing software solutions for today's energy engineering projects"
****************************************************************************************