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

[TRNSYS-users] Writing a simple output component for TRNSYS 17



Hello everyone,

I'd like to write a simple component for TRNSYS 17 to write some output into a file, just for getting familiar with TRNSYS component development. I used the Simulation Studio to create a code skeleton, where I have added the folowing code lines:

!Do Any Last Call Manipulations Here
      If(getIsLastCallofSimulation()) Then
     
        logical_unit = NINT(getParameterValue(1)) !get the logical unit; logical_unit is the first parameter
        filePath = getLUFileName(logical_unit) !get the file by logical unit
      
        CLOSE(unit=logical_unit)
        
        OPEN(unit=logical_unit,file=filePath,access='append'&
        ,status='old',action='') !reopen the file
     
   
        write(logical_unit,*) 'hello world'  !just  a simple test
    
        CLOSE(unit=logical_unit)
     
        Return
      EndIf

It is no problem to compile the code (using Intel Visual Fortran Compiler 11.1 and Visual Studio 2008), but I got the runtime error: severe(46) inconsistent OPEN/CLOSE parameters, ...
Without the action parameter in the OPEN statement I got the runtime error: severe(47): write to a READONLY file,...

Has anyone an idea how to solve this problem or how to write a Component to write output into a file?

Thanks and best regards
Sven

-- 
Sven Böttcher
Dipl.-Inf.
Wissenschaftlicher Mitarbeiter

Technische Universität Dortmund
Fakultät Architektur und Bauingenieurwesen
Lehrstuhl Klimagerechte Architektur

Baroper Straße 301
D-44227 Dortmund

Fon +49(0) 231 755 5248
Mobil +49(0) 179 755 04 09
Fax +49(0) 231 755 5423