Welcome to the TRNSYS Users Forum.

The forum is a place where people can interact and have discussions about different topics involving the use of the TRNSYS software package. Here you can post topics for discussion or questions on using TRNSYS and get advice from other users or TRNSYS experts. This forum is not intended for detailed technical support. Users should contact their distributor’s hotline for such assistance.

Some tips for success on using the forum:

  • Follow the Forum Rules posted in Forum Administration.
  • There are categories for different types of topics and questions. Post your topic or question into the proper category.
  • Before posting a topic or question search the existing topics  (and the TRNSYS Users listserv archive or Post archive) to see if a similar topic or question has already been answered.
  • Use a descriptive topic name. Don’t use attention getting subjects, they don’t get attention and only annoy people.
  • State the version of TRNSYS and which add-ons your are using.
  • Include enough specific details for your topic of question to be answered. Just posting “Why am I getting an error?” without describing the specific error and what you are trying to do when you get the error will not receive a response that fixes your issue.
  • Remember when people help you, they are doing you a favor. Be patient, help people out by posting good descriptions of what you need help with, and be polite even if a response does not solve your issue.
  • Moderators may edit your post for clarity or move your topic to a more appropriate category.

Notifications
Clear all

Modification of Type 999 code

5 Posts
3 Users
0 Reactions
1,128 Views
0
Topic starter

Hello,

 

I would like to modify the Fortran code of Type 999. Firstly, I wanted to create new outputs: NX_tot, NY_tot and NZ_tot which will give me the number of meshes in the x, y and z directions. This number of meshes is already calculated in the TRNSYS code. Moreover, I have added, in the Type 999 outputs, some soil temperatures at different x, y and z coordinates of the system to be able to study the evolution of the soil temperature. I made these modifications to the Fortran file (.f90) and added these outputs to the TRNSYS file (.tmf). Here are the modifications I made to the code (.f90):

  • Declaration of more outputs: Call SetNumberofOutputs(40)
  • Added the units / dimensions of the output variables:

    Call SetOutputUnits(26,'DM1')   

    Call SetOutputUnits(27,'DM1')   

    Call SetOutputUnits(28,'DM1')   

    Call SetOutputUnits(29,'TE1')   

    Call SetOutputUnits(30,'TE1')   

    Call SetOutputUnits(31,'TE1')    

    Call SetOutputUnits(32,'TE1')   

    Call SetOutputUnits(33,'TE1')  

    Call SetOutputUnits(34,'TE1')    

    Call SetOutputUnits(35,'TE1')  

    Call SetOutputUnits(36,'TE1')   

    Call SetOutputUnits(37,'TE1')  

    Call SetOutputUnits(38,'TE1')   

    Call SetOutputUnits(39,'TE1')  

    Call SetOutputUnits(40,'TE1')

 

  • At the end of the code :

Call SetOutputValue(26,NX_tot)

 Call SetOutputValue(27,NY_tot)

 Call SetOutputValue(28,NZ_tot)

 Call SetOutputValue(29,Tf_Soil(1, 1, NZ_tot/2))

 Call SetOutputValue(30,Tf_Soil(2, 1, NZ_tot/2))

 Call SetOutputValue(31,Tf_Soil(3, 1, NZ_tot/2))

 Call SetOutputValue(32,Tf_Soil(NX_tot, 1, NZ_tot/2))

 Call SetOutputValue(33,Tf_Soil(1, 2, NZ_tot/2))

 Call SetOutputValue(34,Tf_Soil(1, 3, NZ_tot/2))

 Call SetOutputValue(35,Tf_Soil(1, NY_tot, NZ_tot/2))

 Call SetOutputValue(36,Tf_Soil(2, 2, NZ_tot/2))

 Call SetOutputValue(37,Tf_Soil(2, 3, NZ_tot/2))

 Call SetOutputValue(38,Tf_Soil(3, 2, NZ_tot/2))

 Call SetOutputValue(39,Tf_Soil(3, 3, NZ_tot/2))

 Call SetOutputValue(40,Tf_Soil(NX_tot/2, NY_tot/2, NZ_tot/2))

 

! Declaration of an array to store the values of Tf_soil at each time step for a given coordinate.

! Open the file to write

OPEN(NEWUNIT=output_unit, FILE='C:/TRNSYS18/MyProjects/resultats/Tf_Soil_Output.txt', STATUS='REPLACE', ACTION='WRITE')

 

! Main simulation loop

DO time_step = 1, total_time_steps

    ! Write the value of Tf_Soil for a specific coordinate

    WRITE(output_unit, *) time_step, Tf_Soil(NX_tot/2, NY_tot/2, NZ_tot/2)

END DO

 

! Close file

close(output_unit)

 

Unfortunately, when I run a program that worked with the initial Type 999, the following error appears:

TRNSYS Message     28 : The listed input referenced an output number beyond the allocated outputs for the connected type.  Reported information  : Unit 21 Type 65 Input 12 Connected to Unit 22 Type 999 Output 29

Unit 21 is a graph that plots the evolution of the temperature in the soil. It is linked to the output temperatures that I created in Type 999.

However, if I remove the printers and the graphics to be plotted in relation to the outputs created, the model runs correctly.

Do you know where this error could be coming from? Have I forgotten to declare variables or something else?

 

Thank you for your feedback.

2 Answers
0

@dianelr

My apologies if this is very obvious to you, but once you modify the source code you have to also compile it and turn it into a DLL using either the Intel Visual Fortran compiler or the TypeStudio.

If you did successfully compile the modified Type999 then I think the first thing to check is the *.log file. Among the notices written to the *.log file, you will find some information on which Types were found in which dlls. When you modified the Type999 code and compiled it, it went into a new dll and it is important that the TRNSYS engine load the new dll rather than the old one. My guess is that when you run your simulation the TRNSYS engine is still finding the original compiled Type999 and not your new version. 

~david

 

0
Topic starter

Dear David,

Thank you for your reply. I am trying to follow the instructions to compile and create a DLL file but I cannot. Should I follow the instructions in the following file: https://web.mit.edu/parmstr/Public/Documentation/08-ProgrammersGuide.pdf
Using “intel fortran” and the command line ifx NAMEFILE.f90 nothing works...
Do you have a file explaining the various steps involved in creating the DLL file for the developed code?

Thanks

A_Weiss A_Weiss 09/05/2025 5:12 pm

@dianelr The document you linked is for TRNSYS16 - is that the version of TRNSYS you are using? I don't believe Intel supports the compilers that were used to compile TRNSYS16 any longer, and that documentation is probably too far out of date to be relevant.

DianeLR Topic starter 13/05/2025 1:28 pm

@a_weiss I use TRNSYS 18. But I haven't found any other documentation about DLL compilations... Do you know where to find information?

A_Weiss A_Weiss 14/05/2025 3:41 pm

@dianelr Are you using the demo version of TRNSYS18, or the full version?

With the full version of TRNSYS18, you'll find documentation about writing Types and DLL compilations in the 07-ProgrammersGuide.pdf in the Documentation folder of your main TRNSYS18 directory.

Share: