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

Deprecate serial_cable and parallel_cable scripts #193

Merged
merged 1 commit into from
Dec 19, 2023

Conversation

SeanBryan51
Copy link
Collaborator

@SeanBryan51 SeanBryan51 commented Dec 11, 2023

This change simplifies the CABLE offline build system by deprecating the serial_cable and parallel_cable build scripts and moving their functionality into the Makefile.

Replace ls *.o in serial_cable and parallel_cable scripts with $(OBJS) in the Makefile where OBJS is a list of object files common to both serial and MPI. This is done so that:

  1. We leverage make syntax to simplify the rules for serial and mpi targets.
  2. We can replace the all target (which contains a list of object files as dependencies) with $(OBJS).
  3. We clean up the existing definition of LSRC in the Makefile and use this to generate a list of the required object files.
    See #193 for a sorted diff of the new LSRC variable against the previous LSRC and against the list of object file dependencies in the all target.

Tools for testing binary equivalence of executables (see ldd, nm and objdump tools), show that the serial and MPI executables are equivalent to their respective executable in the main branch.

Fixes #189


📚 Documentation preview 📚: https://cable--193.org.readthedocs.build/en/193/

Copy link
Collaborator Author

@SeanBryan51 SeanBryan51 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harshula has tools for checking binary equivalence between executable files, these should be used so we can verify we haven't introduced any unwanted changes from refactoring.

src/offline/serial_cable Outdated Show resolved Hide resolved
src/offline/parallel_cable Outdated Show resolved Hide resolved
src/offline/build3.sh Show resolved Hide resolved
src/offline/Makefile Outdated Show resolved Hide resolved
src/offline/Makefile Outdated Show resolved Hide resolved
Copy link
Collaborator

@JhanSrbinovsky JhanSrbinovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs on building might need corresponding revision

Copy link
Collaborator

@ccarouge ccarouge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. A couple of minor suggestions on the comments in the Makefile to make them more descriptive.

src/offline/Makefile Outdated Show resolved Hide resolved
src/offline/Makefile Outdated Show resolved Hide resolved
@SeanBryan51 SeanBryan51 force-pushed the 189-deprecate-serial_build-and-parallel_build branch 4 times, most recently from 4db3a87 to 6b1a2f7 Compare December 18, 2023 13:09
Copy link
Collaborator

@ccarouge ccarouge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Just curious: why were added dependencies needed at this point of the work? To fix the order of compilation?

@SeanBryan51
Copy link
Collaborator Author

Changes to LSRC variable

A sorted diff of the old LSRC variable vs new is as follows:

--- /home/189/sb8430/LSRC.txt	2023-12-18 13:07:13.869287000 +1100
+++ /home/189/sb8430/LSRC_new.txt	2023-12-19 10:08:10.295839000 +1100
@@ -1,6 +1,4 @@
 bgcdriver
-bgcdriver
-biogeochem_casa
 biogeochem_casa
 cable_abort
 cable_air
@@ -45,7 +43,6 @@
 casa_cnp
 casa_dimension
 casa_feedback
-casa_feedback
 casa_inout
 casa_ncdf
 casa_offline_inout
@@ -55,17 +52,15 @@
 casa_readbiome
 casa_rplant
 casa_sumcflux
-casa_sumcflux
 casa_variable
+cbl_albedo
 cbl_conductivity
 cbl_dryLeaf
 cbl_friction_vel
 cbl_fwsoil
 cbl_GW
-cbl_GW
 cbl_hyd_redistrib
 cbl_init_radiation
-cbl_LAI_canopy_height
 cbl_latent_heat
 cbl_model_driver_offline
 cbl_Oldconductivity
@@ -106,7 +101,6 @@
 POP
 pop_constants
 pop_def
-POPdriver
 pop_io
 POPLUC
 pop_types

This change adds one missing file (cbl_albedo.F90) and removes two files (POPdriver.F90 which no longer exists and cbl_LAI_canopy_height.F90 which is not required for the offline configuration).

A sorted diff of the list of object file dependencies in the all target vs the new LSRC variable is as follows:

--- /home/189/sb8430/common.txt	2023-12-18 13:03:52.769319000 +1100
+++ /home/189/sb8430/LSRC_new.txt	2023-12-19 10:08:10.295839000 +1100
@@ -16,6 +16,7 @@
 cable_iovars
 cable_LUC_EXPT
 cable_maths_constants_mod
+cable_metutils
 cable_namelist_input
 cable_other_constants_mod
 cable_output
@@ -54,11 +55,18 @@
 casa_variable
 cbl_albedo
 cbl_conductivity
+cbl_dryLeaf
+cbl_friction_vel
+cbl_fwsoil
 cbl_GW
 cbl_hyd_redistrib
 cbl_init_radiation
+cbl_latent_heat
 cbl_model_driver_offline
 cbl_Oldconductivity
+cbl_photosynthesis
+cbl_pot_evap_snow
+cbl_qsat
 cbl_radiation
 cbl_remove_trans
 cbl_rhoch
@@ -75,13 +83,16 @@
 cbl_soilfreeze
 cbl_soilsnow_data
 cbl_soilsnow_init_special
-cbl_soilsnow_init_special
 cbl_soilsnow_main
 cbl_spitter
 cbl_stempv
+cbl_SurfaceWetness
 cbl_surfbv
 cbl_thermal
 cbl_trimb
+cbl_wetleaf
+cbl_within_canopy
+cbl_zetar
 grid_constants_cbl
 landuse3
 landuse_constant

The OBJS variable (derived from LSRC) includes files that were missing from the all target. This is because OBJS must contain the source files that are required at the linking step, otherwise the compiler will complain. It is likely that files which were missing were being compiled somewhere along the dependency chain. The OBJS variable also lists the source files in a different order to how it was in the all target. This changes the order of how source files are compiled (hence the changes to *.o dependency rules). Note, this does not ensure that target dependencies for all *.o files are correct. Only the minimal required changes to make the compilation work have been made.

@SeanBryan51 SeanBryan51 changed the title Deprecate serial_build and parallel_build scripts Deprecate serial_cable and parallel_cable scripts Dec 19, 2023
@SeanBryan51
Copy link
Collaborator Author

SeanBryan51 commented Dec 19, 2023

Looks good to me.

Just curious: why were added dependencies needed at this point of the work? To fix the order of compilation?

The changes to dependencies was a result of using the $(OBJS) instead of the all target. I have updated the PR description and provided an explanation for the diff between OBJS and the object file dependencies in all.

This change simplifies the CABLE offline build system by deprecating the
`serial_cable` and `parallel_cable` build scripts and moving their
functionality into the Makefile.

Replace `ls *.o` in `serial_cable` and `parallel_cable` scripts with
`$(OBJS)` in the Makefile where `OBJS` is a list of object files common
to both serial and MPI. This is done so that:

1. We leverage `make` syntax to simplify the rules for `serial` and
   `mpi` targets.
2. We can replace the `all` target (which contains a list of object
   files as dependencies) with `$(OBJS)`.
3. We clean up the existing definition of `LSRC` in the Makefile and use
   this to generate a list of the required object files.

See [#193][PR] for a sorted diff of the new `LSRC` variable against the
previous `LSRC` and against the list of object file dependencies in the
`all` target.

Tools for testing binary equivalence of executables (see `ldd`, `nm` and
`objdump` tools), show that the serial and MPI executables are
equivalent to their respective executable in the main branch.

Fixes #189

[PR]: #193
@SeanBryan51 SeanBryan51 force-pushed the 189-deprecate-serial_build-and-parallel_build branch from 2ae8556 to 4926bb1 Compare December 19, 2023 02:29
Copy link

@harshula harshula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! Good work simplifying the build system and making it more maintainable.

@SeanBryan51 SeanBryan51 merged commit 8ba8c9e into main Dec 19, 2023
3 checks passed
@SeanBryan51 SeanBryan51 deleted the 189-deprecate-serial_build-and-parallel_build branch December 19, 2023 04:15
SeanBryan51 added a commit to CABLE-LSM/benchcab that referenced this pull request Dec 20, 2023
The `serial_cable` and `parallel_cable` scripts were deprecated in
CABLE-LSM/CABLE#193. This change does the same
in the benchcab source code.

For code branches that require the serial_cable and parallel_cable
scripts can use the `build_script` key as a work around.

Fixes #223
@access-hive-bot
Copy link

This pull request has been mentioned on ACCESS Hive Community Forum. There might be relevant details there:

https://forum.access-hive.org.au/t/benchcab-python-based-software-for-the-evaluation-of-cable/873/7

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

Successfully merging this pull request may close these issues.

Move serial_build and parallel_build functionality into Makefile
5 participants