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

Replacing a module in Makefile doesn't always work as expected #99

Open
rjleveque opened this issue Feb 22, 2016 · 6 comments
Open

Replacing a module in Makefile doesn't always work as expected #99

rjleveque opened this issue Feb 22, 2016 · 6 comments

Comments

@rjleveque
Copy link
Member

Another problem I discovered with the new Makefile system: if you replace a module with a local version, e.g. via:

MODULES = \
  amr_module.f90 \

where the local version has a different value of max1d, for example, and then do make new, this module will get compiled after the other modules listed in Makefile.amr_2d whereas it is supposed to be compiled first because other modules use this one.

Actually I think it's worse than that -- the other modules when compiled will use src/2d/amr_module.mod rather than the local version unless the other modules are also copied to the local directory and also added to the Makefile.

This suggests we shouldn't allow changing library modules in the Makefile in this manner, although the user could still add additional local modules that aren't replacing those in the library and that can be compiled after the library versions.

@rjleveque
Copy link
Member Author

Moreover, when I reverted back to the original Makefile and did make new, it still used the local amr_module.mod file left over from my testing with a smaller max1d, which is very strange since the compile log shows it using the library version.

@mjberger
Copy link
Contributor

this might explain why my i*8 recompilation didn’t work properly.

In the end i delete all *mod files - if I can find them all - and keep trying. modules still don’t work right.

— Marsha

On Feb 22, 2016, at 1:16 AM, Randall J. LeVeque [email protected] wrote:

Moreover, when I reverted back to the original Makefile and did make new, it still used the local amr_module.mod file left over from my testing with a smaller max1d, which is very strange since the compile log shows it using the library version.


Reply to this email directly or view it on GitHub.

@mandli
Copy link
Member

mandli commented Feb 22, 2016

@malchera has been having issues with this as well but I am not sure he's using the new makefiles.

@malchera
Copy link
Contributor

I am currently not able to reproduce the problem but what I do as a workaround is to delete all object files and module files within $CLAW along with a make new.
rm -f find $CLAW -regex '.*.(mod|o)$'``
The obvious drawback is that it requires me to always compile everything again, but I don't know if there's currently a better solution for that. This is also required when switching compilers, for example.
I pulled the new Makefiles from the repo so that I get the changes for Makefile.common, but for my examples I am using the old files since I did change a lot.

@mandli
Copy link
Member

mandli commented Feb 23, 2016

I have been exploring options to fix this today and have made the following observations regarding modules and compilation:

  • I was able to write a Python routine that parsed module dependencies but this was not a full-proof solution
  • Using pre-processor flags (like we do in C/C++ to not double include a header file) does not seem to work robustly
  • Modules are fundamentally one-way in their inclusions, i.e. circular dependencies do not work
  • Modules should really be used stateless and provide only definitions of custom types and subroutines
    • This includes parameters
    • This implies that the objects defined by the custom types must be passed between routines, not stored in the modules if possible
  • We could put all source code in one file and compile that one file but this would cause a recompile if anything is touched
  • I tried using cmake but did not find it a robust solution either

I am still thinking about where this leaves us.

@mandli
Copy link
Member

mandli commented Feb 23, 2016

BTW, I noticed that there are mistakes in the Makefile.geoclaw and Makefile.amrclaw files pointing to the wrong source in some cases. I will issue PRs for the fixes.

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

4 participants