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

Add GSI "NCO"-mode build option for operational installs #743

Closed
KateFriedman-NOAA opened this issue Apr 19, 2022 · 6 comments
Closed

Add GSI "NCO"-mode build option for operational installs #743

KateFriedman-NOAA opened this issue Apr 19, 2022 · 6 comments
Assignees
Labels
ON HOLD production update Processing update in production

Comments

@KateFriedman-NOAA
Copy link
Member

Description

The GSI has a "NCO" mode installation option that prunes unneeded files during an operational installation. It is currently commented out in build_gsi.sh and is easily missed during installation:

./build_all_cmake.sh "PRODUCTION" "$cwd/gsi.fd"
##./build_all_cmake.sh "PRODUCTION" "$cwd/gsi.fd" "NCO"  # use this line for pruned NCO install

An operations/nco-mode option can be made to allow NCO SPAs to install the GSI with this prune option in a seamless fashion, instead of having to open build_gsi.sh, comment out the current build line, and uncomment the prune build line.

A suggested (and tentatively tested) way to do this is:

  1. update build_all.sh to have a -o argument flag, similar to checkout.sh:
diff --git a/sorc/build_all.sh b/sorc/build_all.sh
--- a/sorc/build_all.sh
+++ b/sorc/build_all.sh
@@ -9,6 +9,24 @@ set +x
 #                   Anything other than "true"  will use libraries locally.
 #------------------------------------
 
+while getopts "o" option;
+do
+ case $option in
+  o)
+   echo "Received -o flag for operational build settings"
+   export build_mode="NCO"
+   ;;
+  :)
+   echo "option -$OPTARG needs an argument"
+   ;;
+  *)
+   echo "invalid option -$OPTARG, exiting..."
+   exit
+   ;;
+ esac
+done
+
+export build_mode=${build_mode:-"EMC"}
 export USE_PREINST_LIBS="true"
 
 #------------------------------------
@@ -74,7 +92,7 @@ fi
 #------------------------------------
 $Build_gsi && {
 echo " .... Building gsi .... "
-./build_gsi.sh > $logs_dir/build_gsi.log 2>&1
+./build_gsi.sh ${build_mode} > $logs_dir/build_gsi.log 2>&1
 rc=$?
 if [[ $rc -ne 0 ]] ; then
     echo "Fatal error in building gsi."

This would also allow other component builds to utilize an operations/nco-mode-like argument if needed down the road.

  1. update build_gsi.sh to use build_mode and if build_mode is "NCO" (EMC=default) the "NCO" flag would be used during the GSI build:
diff --git a/sorc/build_gsi.sh b/sorc/build_gsi.sh
index 1f202a80..5dad6731 100755
--- a/sorc/build_gsi.sh
+++ b/sorc/build_gsi.sh
@@ -4,6 +4,7 @@ set -eux
 source ./machine-setup.sh > /dev/null 2>&1
 cwd=`pwd`
 
+build_mode=${1:-"EMC"}
 USE_PREINST_LIBS=${USE_PREINST_LIBS:-"true"}
 if [ $USE_PREINST_LIBS = true ]; then
   export MOD_PATH=/scratch3/NCEPDEV/nwprod/lib/modulefiles
@@ -20,8 +21,11 @@ if [ ! -d "../exec" ]; then
 fi
 
 cd gsi.fd/ush/
-./build_all_cmake.sh "PRODUCTION" "$cwd/gsi.fd"
-##./build_all_cmake.sh "PRODUCTION" "$cwd/gsi.fd" "NCO"  # use this line for pruned NCO install
-
+if [ "$build_mode" = "NCO" ]; then
+  # Pruned NCO install. Warning: this will delete unneeded development files under gsi.fd. Run once with confidence.
+  ./build_all_cmake.sh "PRODUCTION" "$cwd/gsi.fd" "NCO"
+else
+  ./build_all_cmake.sh "PRODUCTION" "$cwd/gsi.fd"
+fi
 exit

Acceptance Criteria (Definition of Done)

A developer or NCO SPA can run build_all.sh with an operations/nco-mode flag (e.g. -o) and invoke the GSI pruning build without having to edit build_gsi.sh.

Dependencies

This option can be added but not used in operational installations until the GSI is updated to adjust their build scripts pruning. As is, the GSI prune deletes the build folder which contains the lib/libfv3gfs_ncio.a library file used by the enkf_chgres_recenter_nc code during its build. The following build error occurs in the enkf_chgres_recenter_nc build when the GSI prune occurs before it during installation:

+ cd /lfs/h1/ops/prod/packages/gfs.v16.2.0.traceback/sorc/enkf_chgres_recenter_nc.fd
+ export 'FFLAGS=-O3 -qopenmp -traceback -fp-model precise'
+ FFLAGS='-O3 -qopenmp -traceback -fp-model precise'
+ export FV3GFS_NCIO_LIB=/lfs/h1/ops/prod/packages/gfs.v16.2.0.traceback/sorc/gsi.fd/build/lib/libfv3gfs_ncio.a
+ FV3GFS_NCIO_LIB=/lfs/h1/ops/prod/packages/gfs.v16.2.0.traceback/sorc/gsi.fd/build/lib/libfv3gfs_ncio.a
+ export FV3GFS_NCIO_INC=/lfs/h1/ops/prod/packages/gfs.v16.2.0.traceback/sorc/gsi.fd/build/include
+ FV3GFS_NCIO_INC=/lfs/h1/ops/prod/packages/gfs.v16.2.0.traceback/sorc/gsi.fd/build/include
+ '[' '!' -f /lfs/h1/ops/prod/packages/gfs.v16.2.0.traceback/sorc/gsi.fd/build/lib/libfv3gfs_ncio.a ']'
+ echo 'BUILD ERROR: missing GSI library file'
BUILD ERROR: missing GSI library file
+ echo 'Missing file: /lfs/h1/ops/prod/packages/gfs.v16.2.0.traceback/sorc/gsi.fd/build/lib/libfv3gfs_ncio.a'
Missing file: /lfs/h1/ops/prod/packages/gfs.v16.2.0.traceback/sorc/gsi.fd/build/lib/libfv3gfs_ncio.a
+ echo 'Please build the GSI first (build_gsi.sh)'
Please build the GSI first (build_gsi.sh)
+ echo EXITING...
EXITING...
+ exit 1

Pinging @MichaelLueken-NOAA @RussTreadon-NOAA for their knowledge of this issue. Can target this update for GFSv16.3 or later.

@KateFriedman-NOAA KateFriedman-NOAA added the production update Processing update in production label Apr 19, 2022
@KateFriedman-NOAA KateFriedman-NOAA self-assigned this Apr 19, 2022
@RussTreadon-NOAA
Copy link
Contributor

NOAA-EMC/GSI PR #327 will update the current GSI build. Subsequent work on the updated build in NOAA-EMC/GSI, g-w change(s), or a combination of both may render issue #743 obsolete.

@MichaelLueken
Copy link

@KateFriedman-NOAA As @RussTreadon-NOAA noted, the GSI's CMake build system will be refactored with NOAA-EMC/GSI's PR #327. As part of this refactor, all includes, libraries, and executables will be installed within a new install directory. Having said that, the new ush/build_4nco_global.sh build script will mimic the behavior of our current ush/build_all_cmake.sh script. So, once this change is merged to the authoritative repository, the includes and libraries will need to be moved out of the build directory before it is pruned.

I am concerned that, when NCO agreed to allow projects to move forward with CMake, that they weren't given enough information about how CMake goes about generating Makefiles. CMake creates very specialized Makefiles, not general Makefiles that can be used to build both release and debug executables. The version of the Makefile created is dictated by the entry used in -DCMAKE_BUILD_TYPE (this value can be either Release or Debug, not both). With this in mind, Bugzilla 1218 shouldn't even exist, as it goes against the methodology that CMake uses to create Makefiles in the first place. For CMake build Makefiles, two separate build directories - build.release and build.debug should be used, with the build.release having a Makefile that was generated using -DCMAKE_BUILD_TYPE=Release and the build.debug having a Makefile that was generated using -DCMAKE_BUILD_TYPE=Debug.

@KateFriedman-NOAA
Copy link
Member Author

@MichaelLueken-NOAA @aerorahul This issue will become moot because of PRs #839 and #840 , correct? Thanks!

@MichaelLueken
Copy link

@KateFriedman-NOAA Yes, following the inclusion of PRs #839 and #840, this issue will become moot, since the sticking point of the fv3gfs_ncio library and include files will no longer cause issues with compiling the enkf_chgres_recenter_nc utility.

@KateFriedman-NOAA
Copy link
Member Author

@MichaelLueken-NOAA Awesome, thanks for confirming!

@WalterKolczynski-NOAA
Copy link
Contributor

It sounds like this issue should be closed as moot?

@KateFriedman-NOAA KateFriedman-NOAA closed this as not planned Won't fix, can't repro, duplicate, stale Sep 9, 2022
kayeekayee pushed a commit to kayeekayee/global-workflow that referenced this issue May 30, 2024
…rent (NOAA-EMC#743)

* Modifications to replace numerous p2p transfers in fill_nested_grid_cpl by a single MPI_Bcast

* Add reason for including ESMF in fv_control_init. Add code to cleanup structures associated with Bcast_comm

* Get rid of unneeded mpp_sync_self

* Use mpp_broadcast instead of MPI_Bcast at the request of NOAA-GFDL

* Get rid of mpp pelist scoping calls in fill_nested_grid_cpl().  This depends on NOAA-GFDL/FMS#1246 to be functional.  More efficient 'if' test in fill_nested_grid_cpl()

* Bcast_comm and sending_proc variables not needed anymore

* New member of the fv_atmos_type type called BcastMember allows more efficient determination of ranks involved in the mpp_broadcast call in fill_nested_grid_cpl routine

* Port to FMS-2023.02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ON HOLD production update Processing update in production
Projects
None yet
Development

No branches or pull requests

4 participants