How to debug my solver

Discussion about building and installing Elmer
Post Reply
spacedout
Posts: 108
Joined: 30 Mar 2020, 23:27
Antispam: Yes

How to debug my solver

Post by spacedout »

Good evening to all


If I want to debug mySolver.F90, do I have to replace

elmerf90 mySolver.f90 -o mySolver

by something like for example

elmerf90 mySolver.f90 -o -g -O0 mySolver

hoping that these extra switches will override those of elmerf90.bat

or do I have to edit elmerf90.bat itself and replace

-g -DNDEBUG by something like for example -g -O0 -DFULLDEBUG


Best regards,

Marc
raback
Site Admin
Posts: 4189
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: How to debug my solver

Post by raback »

Hi Marc,

I think that if you have conflicting flags then the latter one usually prevails (in gnu compiler stack). So your first assumption should be ok.

I found a discussion on the topic that may be relevant:
https://stackoverflow.com/questions/405 ... tches-to-g

-Peter
spacedout
Posts: 108
Joined: 30 Mar 2020, 23:27
Antispam: Yes

Re: How to debug my solver

Post by spacedout »

Yes, thanks, these overridden compilation switches most probably work but I came about something more serious:

gdb ElmerSolver case.sif

only knows about the symbols from the Elmer source files. But of course, I want to debug my solvers whose names are contained in case.sif

(and this will be an issue for any debugger).


And another unrelated question:

What is the meaning of the -J switch with elmerf90 and thus f95? I could not find any information on it by either Googling it or typing info, man or help f95 under Linux.

I saw somebody use it as

elmerf90 -o flnm.so -J$ANYPATH flnm.F90

($ANYPATH is a folder path - I tried the current folder i.e. I typed -J.
and there was no complaint)

Yours truly
Marc
raback
Site Admin
Posts: 4189
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: How to debug my solver

Post by raback »

Hi

If you have arguments use:

Code: Select all

gdb --args ElmerSolver case.sif
You can also use "ELMERSOLVER_STARTINFO" to define the sif file. This was needed in the earlier days when command-line arguments where not always working. I think they were standardized in Fortran2008 and gradually got implemented.

-Peter
spacedout
Posts: 108
Joined: 30 Mar 2020, 23:27
Antispam: Yes

Re: How to debug my solver

Post by spacedout »

Yes, works great ! Thank you Peter.

How about something harder now: How would I debug a parallel version of the above:

mpirun -n 2 ElmerSolver_mpi case.sif

?

Have a nice week-end
Marc
spacedout
Posts: 108
Joined: 30 Mar 2020, 23:27
Antispam: Yes

Re: How to debug my solver

Post by spacedout »

Well, I guess it cannot be done, which is really too bad as I was really interested in coupling elmer to openfoam through

mpirun -n 2 myFoamsolver -parallel : -n 2 ElmerSolver_mpi case.sif

but unfortunately this quickly results in corrupted memory or aborted processes. I am not interested in openfoam's or elmer's internal mpi processes but only in the mpi coupling between the two.

Maybe the only to debug it is to insert a huge amount of print statements in all solvers whose names can be found in case.sif.
raback
Site Admin
Posts: 4189
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: How to debug my solver

Post by raback »

Hi

Note that you get more output when you set "Max Output Level" to a high value. Usually it is ~5 for production runs, I set it to ~10 for more verbose output, and 32 is the maximum output for desperate people.

This output is printed by process "0" in parallel simulation. To get output from all processes you can toggle with "Max Output Partition".

Finally, there is the (rather fresh) possibility to direct output to file. For serial you could redirect easily always but for parallel runs it makes life easier as every process writes to its own file. From the output it is possible to determine at least the interval where things fell apart.

Code: Select all

Simulation
  ...
  Max Output Level = 20  ! 1-32
  Max Output Partition = 100
  Output To File = Logical True
-Peter
Post Reply