Hi, I am trying to modify the Dflux routine, but when I add a print, and then run the ccx, those prints do not appear in the console.
Where should I look for those prints that I place in routines?
How to do debugging of my code?
Best regards
Hi, I am trying to modify the Dflux routine, but when I add a print, and then run the ccx, those prints do not appear in the console.
Where should I look for those prints that I place in routines?
How to do debugging of my code?
Best regards
You can try to write them to a *.txt file and use it later for debugging purposes.
thanks for your reply, can you give me some example how to define where the file is going to be stored and the way to write on it?
Well, Iām no programming expert but asked for ChatGPT to create something to help you:
PROGRAM CreateFileExample
CALL WriteToFile
END PROGRAM CreateFileExample
SUBROUTINE WriteToFile
IMPLICIT NONE
INTEGER :: fileUnit, ios
CHARACTER(len=100) :: fileName, text
CHARACTER(len=200) :: directory
! Specify the directory and file name
directory = './output/' ! You can change this path
fileName = TRIM(directory) // 'example_output.txt'
! Open the file for writing
OPEN(NEWUNIT=fileUnit, FILE=fileName, STATUS='NEW', ACTION='WRITE', IOSTAT=ios)
! Check for any errors in file opening
IF (ios /= 0) THEN
PRINT *, 'Error opening file: ', fileName
STOP
END IF
! Write some text to the file
text = 'Hello, this is a test write to a file!'
WRITE(fileUnit, *) text
! Close the file after writing
CLOSE(fileUnit)
PRINT *, 'File written successfully: ', fileName
END SUBROUTINE WriteToFile
Also some additional information is presented:
Explanation:
directory: This specifies where the file will be saved. You can change './output/' to another directory if you wish.
fileName: This is the complete path including the directory and the file name where the text file will be saved.
OPEN: The OPEN statement is used to open a new file for writing. The NEWUNIT keyword assigns a unique file unit number to fileUnit.
WRITE: The WRITE statement writes the string text to the file.
CLOSE: This ensures that the file is properly saved and closed.
Make sure the directory (like './output/') exists, or you can modify the code to create it first if needed.
For me, it worked to write the following line in the code so that I can see the output in the terminal:
write(*,*) 'C(1,1)',C(1,1)
which writes the Text āC(1,1)ā followed by a value which is stored in the Array C at position (1,1)
Print to screen still the best way to debug f77