Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Total number of bodies exceeds NMAX (ONLY in close6 execution) #21

Closed
sretsa opened this issue Mar 16, 2020 · 33 comments
Closed

Total number of bodies exceeds NMAX (ONLY in close6 execution) #21

sretsa opened this issue Mar 16, 2020 · 33 comments

Comments

@sretsa
Copy link

sretsa commented Mar 16, 2020

Hi everyone,

I have realized during test of hundreds small particles that when the number of bodies in small.in is greater than 200, close6 execution crashes giving the following error:
ERROR: The total number of bodies exceeds NMAX.
I have made the pertinent changes in mercury.inc and swift.inc. The mercury6 and element6 executions work fine with any number of small bodies (always according to the specified limits on the .inc files) but close6 execution crashes at the 200th small body. For example, if the Moon is where all small bodies are having a close encounter (they launch from the Moon's surface) the list of the close encounter (dmin, orbital elements, etc.) is completed until 200th body.

I cannot figure out why this is happening. Any help will be much welcomed! thanks

PS: Current parameters defined:
in swift.inc
NPLMAX = 2002
NTPMAX = 2000

in mercury.inc
parameter (NMAX = 4003)
parameter (CMAX = 8000)
parameter (NMESS = 100)
parameter (HUGE = 9.9d29)
parameter (NFILES = 50)

See attachments for big.in, small.in, param.in
i_VgitTEST.tar.gz

@texadactyl
Copy link
Contributor

texadactyl commented Mar 16, 2020

The source file close6.for will not even compile with those parameter values:

gfortran -g -O2 -Wline-truncation -Wsurprising -Werror -o ./close6 ./close6.for
./close6.for:832:31:

  832 |         write (*,'(/,3a)') mem(121)(1:lmem(121)),mem(87)(1:lmem(87)),
      |                               1
Error: Array reference at (1) is out of bounds (121 > 100) in dimension 1 [-Werror]
./close6.for:832:43:

  832 |         write (*,'(/,3a)') mem(121)(1:lmem(121)),mem(87)(1:lmem(87)),
      |                                           1
Error: Array reference at (1) is out of bounds (121 > 100) in dimension 1 [-Werror]
./close6.for:832:43:

  832 |         write (*,'(/,3a)') mem(121)(1:lmem(121)),mem(87)(1:lmem(87)),
      |                                           1
Error: Array reference at (1) is out of bounds (121 > 100) in dimension 1 [-Werror]
./close6.for:306:37:

  306 |         write (*,'(2a,/,a,i10)') mem(121)(1:lmem(121)),
      |                                     1
Error: Array reference at (1) is out of bounds (121 > 100) in dimension 1 [-Werror]
./close6.for:306:49:

  306 |         write (*,'(2a,/,a,i10)') mem(121)(1:lmem(121)),
      |                                                 1
Error: Array reference at (1) is out of bounds (121 > 100) in dimension 1 [-Werror]
./close6.for:306:49:

  306 |         write (*,'(2a,/,a,i10)') mem(121)(1:lmem(121)),
      |                                                 1
Error: Array reference at (1) is out of bounds (121 > 100) in dimension 1 [-Werror]
./close6.for:307:30:

  307 |      %    infile(i)(1:60),mem(104)(1:lmem(104)),line_num
      |                              1
Error: Array reference at (1) is out of bounds (104 > 100) in dimension 1 [-Werror]
./close6.for:307:42:

  307 |      %    infile(i)(1:60),mem(104)(1:lmem(104)),line_num
      |                                          1
Error: Array reference at (1) is out of bounds (104 > 100) in dimension 1 [-Werror]
./close6.for:307:42:

  307 |      %    infile(i)(1:60),mem(104)(1:lmem(104)),line_num
      |                                          1
Error: Array reference at (1) is out of bounds (104 > 100) in dimension 1 [-Werror]
f951: all warnings being treated as errors
make: *** [Makefile:27: close6] Error 1

The problem is that parameter (NMESS = 100) caused the miscompile. You must have changed that to get the compiles to work before running the 3 programs.

@texadactyl
Copy link
Contributor

texadactyl commented Mar 16, 2020

I changed NMESS back to 200 (original value) but kept your other parameters.

base) elkins@biostar:~/projects/mercury-master$ mercury6
   Integrating massive bodies and particles up to the same epoch.
   Beginning the main integration.
 Date:       2119  8  6.4   dE/E: -4.79971E-13   dL/L: -2.81091E-13
 Date:       2229  2 15.8   dE/E: -4.79807E-13   dL/L: -2.61420E-13
 Date:       2338  8 24.1   dE/E: -1.97181E-13   dL/L: -1.94135E-13
 Date:       2448  2 29.3   dE/E: -4.84736E-13   dL/L: -3.12712E-13
 Date:       2557  9 11.9   dE/E: -4.15394E-13   dL/L: -2.84584E-13
 Date:       2667  3 22.5   dE/E:  3.28799E-13   dL/L: -1.55345E-13
 Date:       2776  9 28.9   dE/E:  5.13821E-13   dL/L: -1.18577E-13
 Date:       2886  4  6.5   dE/E:  3.96005E-14   dL/L: -4.56474E-13
 Date:       2995 10 18.9   dE/E:  6.32622E-14   dL/L: -4.88462E-13
 Date:       3105  5  2.0   dE/E:  1.14694E-12   dL/L: -1.31445E-13
 Date:       3214 11 10.4   dE/E:  5.12999E-13   dL/L: -4.65299E-13
 Date:       3324  5 22.7   dE/E:  2.86898E-13   dL/L: -6.88296E-13
 Date:       3433 11 30.4   dE/E: -2.41875E-13   dL/L: -8.90704E-13
   Integration complete.
(base) elkins@biostar:~/projects/mercury-master$ element6
(base) elkins@biostar:~/projects/mercury-master$ close6
(base) elkins@biostar:~/projects/mercury-master$ 

No early terminations and no crashes.
I do not know if the results are valid. See attached ZIP file.
results.zip

@texadactyl
Copy link
Contributor

texadactyl commented Mar 16, 2020

Please note that these 20-to-30-year-old Fortran programs are fragile in terms of self-diagnosing and error prevention. You can see that they root from older Fortran programs that obeyed 80-column cards and 121-character-line printers.

Recently, some capability towards enhanced parameterization and error checking has been added but the code remains far from "perfect". If I had a magic wand, this code would be all Java or some other strong type-checking language. This project is a great candidate for rewrite by some enterprising Physics upper division or graduate students.

I am sure that 4xxi would welcome suggestions and a helping hand if you find areas of improvement.

@sretsa
Copy link
Author

sretsa commented Mar 17, 2020

Hi texadactyl!
Thanks for your response.
Mine still crashes... but because your compilation is with only 2 small bodies (APOLLO and APOPHIS) I have more than 200 (I generate them with an external programme). But I do not get why mercury6 and element6 do not crash and close6 yes.
NMESS = 200 does not solve the issue.

Regards

@sretsa
Copy link
Author

sretsa commented Mar 17, 2020

This is the file I am using for small bodies.

i_VgitTEST.tar.gz

@texadactyl
Copy link
Contributor

You never before mentioned big.in, param.in, and small.in. That would have been helpful.

@sretsa
Copy link
Author

sretsa commented Mar 17, 2020

Sorry, no, I did not mention the files specifically. I said I used 200 small bodies, which I took for granted it was clear as the name of the file usually is "small.in" for small bodies.
I will edit that for clarification.

@texadactyl
Copy link
Contributor

Okay, using your versions of big.in, param.in, and small.in:

mercury6
   Integrating massive bodies and particles up to the same epoch.
   Beginning the main integration.
   Integration complete.
(base) elkins@biostar:~/projects/mercury-master$ element6
(base) elkins@biostar:~/projects/mercury-master$ close6

No aborts/crashes.
See attached ZIP of generated files.
generated_files.zip

@texadactyl
Copy link
Contributor

The *.in files are attached.
in_files.zip

@texadactyl
Copy link
Contributor

texadactyl commented Mar 17, 2020

Is it possible that you have made other changes than what is listed here thus far?
My mercury.inc and swift.inc files are attached.

mercury.inc.txt

swift.inc.txt

@sretsa
Copy link
Author

sretsa commented Mar 17, 2020

In my case still gives the same error. I downloaded again mercury6_2.for, element6.for, and close6.for
used my .inc files (mercury.inc and swift.inc) and your input files. Still crashes at close6:

esther@esther-hp ~/Escritorio/mercury-master/git_trial $ ./mercury6 && ./element6
   Integrating massive bodies and particles up to the same epoch
   Beginning the main integration.
   Integration complete.
esther@esther-hp ~/Escritorio/mercury-master/git_trial $ ./close6
 ERROR: The total number of bodies exceeds NMAX.

May be if I could see the rest of your files, cause I do not see what is going on

@sretsa
Copy link
Author

sretsa commented Mar 17, 2020

Is it possible that you have made other changes than what is listed here thus far?
My mercury.inc file is attached.

mercury.inc.txt

I will give a look

@texadactyl
Copy link
Contributor

The rest of my files are the same as the project defaults (*.sample).

@sretsa
Copy link
Author

sretsa commented Mar 17, 2020

I have identical .inc files as the ones you just posted. And for the trial I just re-downloaded .for files

@texadactyl
Copy link
Contributor

What about the *.in files that I posted?

@texadactyl
Copy link
Contributor

They are essentially what you supplied.

@sretsa
Copy link
Author

sretsa commented Mar 17, 2020

What about the *.in files that I posted?

I used yours for the compile and execution (which in turn are mines originally uploaded).

@texadactyl
Copy link
Contributor

So, our *.inc and *.in files are identical?

@sretsa
Copy link
Author

sretsa commented Mar 17, 2020

yes they are. I check the .txt and for the .in you used mines.
Here it is what I am using and the output. Note that all .aei files are created but when close6 is executed, 48 small bodies and the first 200th Moon close encounters.

git_in.tar.gz
git_output.tar.gz

@texadactyl
Copy link
Contributor

So, starting over .....

(base) elkins@biostar:~/projects/mercury-master$ make rm-gen
rm -f ./{ *.dmp *.clo *.out *.tmp *.aei } 2> /dev/null
(base) elkins@biostar:~/projects/mercury-master$ make unbuild
rm -f ./element6 ./close6 ./mercury6
(base) elkins@biostar:~/projects/mercury-master$ make build
gfortran -g -O2 -Wline-truncation -Wsurprising -Werror -o ./close6 ./close6.for
gfortran -g -O2 -Wline-truncation -Wsurprising -Werror -o ./element6 ./element6.for
gfortran -g -O2 -Wline-truncation -Wsurprising -Werror -o ./mercury6 ./mercury6_2.for
(base) elkins@biostar:~/projects/mercury-master$ mercury6
   Integrating massive bodies and particles up to the same epoch.
   Beginning the main integration.
   Integration complete.
(base) elkins@biostar:~/projects/mercury-master$ element6
(base) elkins@biostar:~/projects/mercury-master$ close6
(base) elkins@biostar:~/projects/mercury-master$ 

No crashes. *.in files and generated files are attached.
in_files.zip

generated_files.zip

@texadactyl
Copy link
Contributor

  1. Remove existing generated files: make rm-gen
  2. Un-build Fortran programs: make unbuild
  3. Build Fortran programs: make build
  4. mercury6
  5. element6
  6. close6

That's what you did too?

@texadactyl
Copy link
Contributor

Steps 2 & 3 are only necessary if an *.inc file is changed.

@sretsa
Copy link
Author

sretsa commented Mar 17, 2020

  1. Remove existing generated files: make rm-gen
  2. Un-build Fortran programs: make unbuild
  3. Build Fortran programs: make build
  4. mercury6
  5. element6
  6. close6

That's what you did too?

No, I was not doing steps 2 & 3.

@sretsa
Copy link
Author

sretsa commented Mar 17, 2020

Steps 2 & 3 are only necessary if an *.inc file is changed.

Now it does not crash

@texadactyl
Copy link
Contributor

Okay, that means that you changed mercury.inc after you compiled but did not recompile to pick up the changes.

But, excellent. I hope that your results are interesting now!

@texadactyl
Copy link
Contributor

What language do you normally program in? If C, this is like changing a .h file but not recompiling the dependent *.c files, right?

All's well that ends well.

@sretsa
Copy link
Author

sretsa commented Mar 17, 2020

Many thanks!! I did not know about these 2 commands of building/unbuilding. I checked the Read.Me and that is not stated there. May be I missed it and it is stated somewhere else. Definetely thank you. I'm quite foreign to Fortran and I highly doubt I had figure this out on my own.
I am closing the thread.
Regards

@sretsa sretsa closed this as completed Mar 17, 2020
@texadactyl
Copy link
Contributor

You are most welcome.

YES, the documentation leaves a lot to be desired. I wrote up a separate bug report on that subject.

Happy computing!

@sretsa
Copy link
Author

sretsa commented Mar 17, 2020

What language do you normally program in? If C, this is like changing a .h file but not recompiling the dependent *.c files, right?

All's well that ends well.

Well, if it can be considered a programming language at all... Matlab. It was a while ago since last I had to preocupy about compilations and .h .c files on C :S

Thanks again!

@texadactyl
Copy link
Contributor

Out of curiosity, are you a Physicist?
Any association with Caltech?

@sretsa
Copy link
Author

sretsa commented Mar 17, 2020

Out of curiosity, are you a Physicist?
Any association with Caltech?

Uy no. I'm from UPC (Polytechnic University of Catalonia, Spain). Master student in aerospace engineering, Space track. Actually, after the first overview on mercury6 and Chamber's paper I was a bit lost... coming from engineering my physics knowledge was too tangential to completely follow the explanations!!

@sretsa
Copy link
Author

sretsa commented Mar 18, 2020

May be nobody reads to this far but it can be helpful if someone is in the same situation... before, I was recompiling mercury only doing this (as suggested in the Read.me):

esther@esther-hp ~/Escritorio/mercury-master/git_trial $ f77 -o mercury6 mercury6_2.for && f77 -o element6 element6.for && f77 -o close6 close6.for

Instead of the steps 2 and 3 of make unbuild/build.

@texadactyl
Copy link
Contributor

Best to follow steps outlined in issue #22 for preparation and execution.
Hopefully, the 4xxi team will update the README.md instructions soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@texadactyl @sretsa and others