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

Re: [TRNSYS-users] A question about using cycles of variables



Mehdi,
 That is a good question and there are a number of ways that you can solve it. The most "correct" would probably be to define your arrays as "allocatable" and then create them and fill them in once your simulation has started. However, that is a bit too formal sometimes so what I have often done is to set a maximum allowable number of inputs in the Fortran code and size your arrays based on that maximum. Then you can read from the Trnsys input file how many inputs there actually are and check to make sure that it doesn't exceed the maximum. For example:

      PARAMETER (NIMAX=21)
      DIMENSION XIN(NIMAX),YCHECK(NIMAX)
...
      DATA YCHECK /'CF1','CF1','TE1','TE1','TE1','HT1','HT1','HT1','HT1'
     1            ,'HT1','IR1','IR1','IR1','IR1','DG1','DG1','DG1','DG1'
     1            ,'MF1','PW1','HT1'/

...

        !CALL THE TYPE CHECK SUBROUTINE TO COMPARE WHAT THIS COMPONENT REQUIRES TO WHAT IS SUPPLIED
       IF (INFO(4).EQ.28) THEN
        NP=28 ; NI=20
      ELSE
        NP=34 ; NI=21
      ENDIF
     
      !CALL TYPECK TO CHECK FOR CORRECT INPUT FILE SPECIFICATIONS
      CALL TYPECK(1,INFO,NI,NP,ND)

        !CALL THE RCHECK SUBROUTINE TO SET THE CORRECT INPUT AND OUTPUT TYPES FOR THIS COMPONENT
        CALL RCHECK(INFO,YCHECK,OCHECK)

I took the code above from the Type37 subroutine (in Trnsys16) which can have either 28 or 34 parameters and either 20 or 21 inputs.
Best,
 David



On 2/7/2011 17:15, Mehdi Shahrestani wrote:

Dear everybody

 

I have a question about using cycles of variables (Vol2 of manual page 26).

Is it possible to create cycle for inputs instead of parameters?

I am writing a new component for different arrangements. This new component would be well organised if the cycle can be created for inputs.

If you are saying yes; how can I manage the “DATA YCHECK” in FORTRAN script? Is it possible that I put “IF” in “DATA YCHECK” line?

 

Many thanks for your time spending on it.

Regards

Mehdi

 

 

 

 

 

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

-- 
***************************
David BRADLEY
Principal
Thermal Energy Systems Specialists, LLC
22 North Carroll Street - suite 370
Madison, WI  53703 USA

P:+1.608.274.2577
F:+1.608.278.1475
d.bradley@tess-inc.com

http://www.tess-inc.com
http://www.trnsys.com