2

Since Fortran subroutines require everything to be declared, we can't easily write a custom print subroutine with the same power and flexibility as the print statement.

Throughout the code we have print statements each with multiple if statements to handle the parallel processing and the chosen debug output mode. Many different types of variables with different formats are printed, including matrices with their respective do-loops.

We simply want to write a print statement as normal in addition to one integer which represents its debug mode and then find a way to include all of the appropriate if statements for each of these. Trying to achieve this with a subroutine is achievable with a generic interface but requires huge amounts of interface cases covering all of the possible input arrangements. Whereas, this is much more straightforward with preprocessing replacement. Am I missing something majorly useful?

2
  • 1
    please show an example , Commented Jul 23, 2017 at 3:15
  • Note that print is NOT an intrinsic procedure. It is a Fortran language statement and that is VERY different and obeys completely different rules. Commented Jul 23, 2017 at 8:30

1 Answer 1

3

one device you may find useful, use the intrinsic write internal to a string, then pass the string to your debug-handling subroutine, eg:

    character(len=100) :: string
    ...
    write(string,*)"var1:",var1,"var2:",var2
    call debugout(string,debugflags)

then in the subroutine you can have your switches to decide what to do with the string.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, that is a very useful

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.