Reputation: 63
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?
Upvotes: 2
Views: 228
Reputation: 6999
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.
Upvotes: 3