wrf-model / WRF

The official repository for the Weather Research and Forecasting (WRF) model
Other
1.18k stars 658 forks source link

Add if test for ftn compiler version (for derecho) in compile file #1987

Closed kkeene44 closed 4 months ago

kkeene44 commented 5 months ago

TYPE: no impact

KEYWORDS: compile, version, compiler, ftn, derecho

SOURCE: internal

DESCRIPTION OF CHANGES: Problem: When compiling WRF on NCAR's Derecho HPC, and choosing a Cray option during configuration (for e.g., "INTEL (ftn/icc): Cray XC"), the compile script isn't able to determine the compiler version because "ftn" is not included in the "if" test to checks versions in the "compile" script. This means the compiler version is not printed in the compile log, which could be problematic for several reasons.

Solution: Added a line to the "compile" file compiler version "if" test to print out the compiler version information when "ftn" is used.

LIST OF MODIFIED FILES: M compile

TESTS CONDUCTED:

  1. Tested a compile when choosing "INTEL (ftn/icc): Cray XC" during configuration. Now the compiler version prints out to the compile log.
  2. Are the Jenkins tests all passing?
kkeene44 commented 5 months ago

@islas I added you as a reviewer in case you think there is a better way to do this, or in case I'm not considering something that could cause an issue down the road.

islas commented 5 months ago

I think at this point it might be easier to write something more generic that doesn't rely on a hard-coded string. Maybe something like:

compVersion=$( $comp[1] --version 2>/dev/null || $comp[1] -V 2>/dev/null )
if [ -n "$compVersion" ]; then
  printf "%s\n" "$version"
else
  ...message about can't find version...
fi

That would, for any compiler, attempt first --version and then -V if that fails forwarding any error messages to /dev/null so as to not pollute the compiler version output. Using printf should faithfully reproduce the output as if the correct command had just be found without relying on non-POSIX standard echo -e

Edit: I wrote this for sh compliance.. but configure is in csh so some syntax will have to change.

islas commented 5 months ago

Okay, not as clean but I think the least convoluted way that doesn't involve different shell invocations, file redirection, or other fragile setups:

$comp[1] -V >& /dev/null
if ( $status == 0 ) then
  $comp[1] --version
else
  $comp[1] --version >& /dev/null
  if ( $status == 0 ) then
    $comp[1] -V
  else
    ...msg...
  endif
endif
kkeene44 commented 5 months ago

@islas Thank you so much for looking into this. The way you propose makes a lot more sense and keeps it universal. I'll modify the code with your suggestion and update the PR. Thanks, again!

kkeene44 commented 4 months ago

It looks like this was already taken care of by #1942, so I'm closing this.