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

Come up with a way to shorten long lines that reference __FILE__ #16

Open
billsacks opened this issue Jul 6, 2018 · 3 comments
Open

Comments

@billsacks
Copy link
Member

From @billsacks on September 23, 2017 12:18

The pgi compiler enforces a line length of (I think) 264 characters after doing macro expansion. This can cause problems for lines using the __FILE__ macro, because this expands to the absolute path to that file. This was causing problems in CESM for some automated tests that had long paths to the bld directory. I have fixed that problem with a cime change, but this too-long-line problem is likely to come back to bite us at some point.

Some possible solutions:

  1. Do what CLM does: In each file, have:

      character(len=*), parameter, private :: sourcefile = &
           __FILE__

    then use sourcefile rather than __FILE__ in lines of code. This will still fail if the absolute path to the file is longer than about 256 characters, but it at least buys us some characters (because you're not adding the file path length to the source file line in which it's referenced).

  2. If the problem just occurs for source files that appear in the bld directory (because paths to the bld directory may be longer than paths to the source tree), then we could fix this just for files that are copied or generated in the bld directory. For example, for auto-generated io files, we could change references to __FILE__ to instead just give the file name without a path.

  3. We could consider a solution that uses just the file name itself rather than the full path, for all files. Some possibilities:

    a. Hard-code at the top of each file something like:

      character(len=*), parameter, private :: sourcefile = "myfilename.F90"

    b. Apparently PIO created its own _FILE_ macro in the past, which gave just the file name rather than its full path, though I don't understand exactly how it was done. (At a glance, it looks like PIO now uses solution (a).)

    c. There may be a way to do this via cmake. For example, see the cmake-based solution here: https://stackoverflow.com/questions/8487986/file-macro-shows-full-path. However, comments around that make it sound like a fragile solution. I've seen some other cmake-based solutions via googling, but they all seem either complex or fragile.

Copied from original issue: E3SM-Project/cism-piscees#64

@billsacks
Copy link
Member Author

From @worleyph on September 23, 2017 22:11

Hi @billsacks , see also ACME issue #548 . It would be nice to have a consistent solution across all components. Would just using FILENAME address this issue? No one was supportive (or at least they do not comment on) this suggestion in #548.

@billsacks
Copy link
Member Author

@worleyph As far as I know, __FILENAME__ is not a standard macro. For example, see https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html . If you know that this is a standard, universally-supported macro, I'd be very interested to know it, since that would certainly help us out!

@billsacks
Copy link
Member Author

From @worleyph on September 24, 2017 2:7

I know next to nothing ... so this is probably the reason no one picked up on the suggestion. Too bad - it seems like it would be useful, and at the time I made the suggestion I thought that it was available on at least one of our target systems with one of our compilers. Thanks for the response, and good luck finding a real solution. I run into this all of the time.

billsacks added a commit that referenced this issue Jun 23, 2021
Revert to previous hybrid gradient scheme

In a recent commit (89f6875), the hybrid gradient scheme was modified
to compute gradients at edges where an ice-covered land cell sits above
ice-free ocean. This commit reverts to the earlier rule that gradients
are set to zero where an ice-covered land sits above ice-free
ocean. Instead of computing a nonzero gradient, we compute a lateral
spreading term at these edges, assuming that the margin is a
marine-based cliff. Answer changes are modest, but generally reduce max
speeds at coastal margins and promote greater stability.
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

1 participant