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

CMake for reg2grb2 #268

Conversation

BrianCurtis-NOAA
Copy link
Contributor

Add a CMakeLists.txt to be able to create reg2grb2.x for coupled-crow after the merge of CMake work from #264

Linked issue:
#263

Waiting on:
Pull #264

@BrianCurtis-NOAA BrianCurtis-NOAA linked an issue Feb 16, 2021 that may be closed by this pull request
@JessicaMeixner-NOAA
Copy link
Contributor

Maybe it's just me, but this seems it could be independent of #264 and doesn't really need to wait for it?In addition, as this does not delete sorc/reg2grb2.fd/Makefile or update the build script sorc/build_reg2grb2.sh and is just adding a file, couldn't this just go in now?

*Corrected link lib names
@BrianCurtis-NOAA
Copy link
Contributor Author

I did test the file manually putting it into Rahul's CMake work with feature/cmake, and it built the executable.
You are correct that the file can go in now without any issue.
Once the cmake work is brought over to feature/coupled-crow I can make the edits to CMakeLists.txt get it where it needs to be.

@KateFriedman-NOAA
Copy link
Member

@BrianCurtis-NOAA Checking in...is this draft PR still needed? Thanks!

@BrianCurtis-NOAA
Copy link
Contributor Author

Has reg2grb2 been removed or already ported to cmake elsewhere? I believe I was waiting on the CMake build to be ported into coupled-crow.

@BrianCurtis-NOAA
Copy link
Contributor Author

Yeah missed the cmake port completely. Let me get this added to the sorc CMakeLists.txt.
@WalterKolczynski-NOAA how would I test this is working once I get these last changes in?

@WalterKolczynski-NOAA
Copy link
Contributor

As long as it builds and runs, it's fine as far as I'm concerned. I don't have any tests to confirm output for reg2grb2.

@BrianCurtis-NOAA
Copy link
Contributor Author

OK, I'll test on hera and switch this to ready when done.

@BrianCurtis-NOAA
Copy link
Contributor Author

BrianCurtis-NOAA commented May 20, 2021

Moving to ready.

@BrianCurtis-NOAA BrianCurtis-NOAA marked this pull request as ready for review May 20, 2021 14:38
@BrianCurtis-NOAA
Copy link
Contributor Author

Please hold for now while I check on something.

@BrianCurtis-NOAA
Copy link
Contributor Author

I left out the find package calls, my reg2grb2 builds OK, but the build on sorc fails with the enkf_chgres_recenter_nc.fd directory

[ 19%] Building Fortran object regrid_nemsio.fd/CMakeFiles/regrid_nemsio.x.dir/netcdfio_interface.f90.o
/scratch1/NCEPDEV/nems/Brian.Curtis/git/BrianCurtis-NOAA/global-workflow/sorc/enkf_chgres_recenter_nc.fd/input_data.f90(5): error #7002: Error in opening the compiled module file.  Check INCLUDE paths.   [MODULE_NCIO]
 use module_ncio
-----^
/scratch1/NCEPDEV/nems/Brian.Curtis/git/BrianCurtis-NOAA/global-workflow/sorc/enkf_chgres_recenter_nc.fd/input_data.f90(53): error #6457: This derived type name has not been declared.   [DATASET]
 type(Dataset) :: indset
------^
/scratch1/NCEPDEV/nems/Brian.Curtis/git/BrianCurtis-NOAA/global-workflow/sorc/enkf_chgres_recenter_nc.fd/input_data.f90(54): error #6457: This derived type name has not been declared.   [DIMENSION]
 type(Dimension) :: ncdim
------^
/scratch1/NCEPDEV/nems/Brian.Curtis/git/BrianCurtis-NOAA/global-workflow/sorc/enkf_chgres_recenter_nc.fd/input_data.f90(319): error #6457: This derived type name has not been declared.   [DATASET]
 type(Dataset) :: refdset
------^
/scratch1/NCEPDEV/nems/Brian.Curtis/git/BrianCurtis-NOAA/global-workflow/sorc/enkf_chgres_recenter_nc.fd/input_data.f90(68): error #6404: This name does not have a type, and must have an explicit type.   [INDSET]
 indset = open_dataset(input_file)
-^
/scratch1/NCEPDEV/nems/Brian.Curtis/git/BrianCurtis-NOAA/global-workflow/sorc/enkf_chgres_recenter_nc.fd/input_data.f90(68): error #6404: This name does not have a type, and must have an explicit type.   [OPEN_DATASET]
 indset = open_dataset(input_file)
----------^
/scratch1/NCEPDEV/nems/Brian.Curtis/git/BrianCurtis-NOAA/global-workflow/sorc/enkf_chgres_recenter_nc.fd/input_data.f90(71): error #6404: This name does not have a type, and must have an explicit type.   [NCDIM]
 ncdim = get_dim(indset, 'grid_xt'); i_input = ncdim%len
-^
/scratch1/NCEPDEV/nems/Brian.Curtis/git/BrianCurtis-NOAA/global-workflow/sorc/enkf_chgres_recenter_nc.fd/input_data.f90(71): error #6404: This name does not have a type, and must have an explicit type.   [GET_DIM]
 ncdim = get_dim(indset, 'grid_xt'); i_input = ncdim%len
---------^
/scratch1/NCEPDEV/nems/Brian.Curtis/git/BrianCurtis-NOAA/global-workflow/sorc/enkf_chgres_recenter_nc.fd/input_data.f90(71): error #6460: This is not a field name that is defined in the encompassing structure.   [LEN]
 ncdim = get_dim(indset, 'grid_xt'); i_input = ncdim%len
-----------------------------------------------------^
/scratch1/NCEPDEV/nems/Brian.Curtis/git/BrianCurtis-NOAA/global-workflow/sorc/enkf_chgres_recenter_nc.fd/input_data.f90(74): error #6404: This name does not have a type, and must have an explicit type.   [GET_IDATE_FROM_TIME_UNITS]
 idate = get_idate_from_time_units(indset)
---------^
/scratch1/NCEPDEV/nems/Brian.Curtis/git/BrianCurtis-NOAA/global-workflow/sorc/enkf_chgres_recenter_nc.fd/input_data.f90(174): error #6632: Keyword arguments are invalid without an explicit interface.   [ERRCODE]
 call read_vardata(indset, 'dzdt', work3d, errcode=iret)
-------------------------------------------^
/scratch1/NCEPDEV/nems/Brian.Curtis/git/BrianCurtis-NOAA/global-workflow/sorc/enkf_chgres_recenter_nc.fd/input_data.f90(192): error #6632: Keyword arguments are invalid without an explicit interface.   [ERRCODE]
 call read_vardata(indset, 'rwmr', work3d, errcode=iret)
-------------------------------------------^
/scratch1/NCEPDEV/nems/Brian.Curtis/git/BrianCurtis-NOAA/global-workflow/sorc/enkf_chgres_recenter_nc.fd/input_data.f90(209): error #6632: Keyword arguments are invalid without an explicit interface.   [ERRCODE]
 call read_vardata(indset, 'icmr', work3d, errcode=iret)
-------------------------------------------^
/scratch1/NCEPDEV/nems/Brian.Curtis/git/BrianCurtis-NOAA/global-workflow/sorc/enkf_chgres_recenter_nc.fd/input_data.f90(226): error #6632: Keyword arguments are invalid without an explicit interface.   [ERRCODE]
 call read_vardata(indset, 'snmr', work3d, errcode=iret)
-------------------------------------------^
/scratch1/NCEPDEV/nems/Brian.Curtis/git/BrianCurtis-NOAA/global-workflow/sorc/enkf_chgres_recenter_nc.fd/input_data.f90(243): error #6632: Keyword arguments are invalid without an explicit interface.   [ERRCODE]
 call read_vardata(indset, 'grle', work3d, errcode=iret)
-------------------------------------------^
/scratch1/NCEPDEV/nems/Brian.Curtis/git/BrianCurtis-NOAA/global-workflow/sorc/enkf_chgres_recenter_nc.fd/input_data.f90(261): error #6632: Keyword arguments are invalid without an explicit interface.   [ERRCODE]
    call read_vardata(indset, 'cld_amt', work3d, errcode=iret)
-------------------------------------------------^
/scratch1/NCEPDEV/nems/Brian.Curtis/git/BrianCurtis-NOAA/global-workflow/sorc/enkf_chgres_recenter_nc.fd/input_data.f90(280): error #6632: Keyword arguments are invalid without an explicit interface.   [ERRCODE]
 call read_vardata(indset, 'dpres', work3d, errcode=iret)
--------------------------------------------^
/scratch1/NCEPDEV/nems/Brian.Curtis/git/BrianCurtis-NOAA/global-workflow/sorc/enkf_chgres_recenter_nc.fd/input_data.f90(286): error #6632: Keyword arguments are invalid without an explicit interface.   [ERRCODE]
 call read_vardata(indset, 'delz', work3d, errcode=iret)
-------------------------------------------^
/scratch1/NCEPDEV/nems/Brian.Curtis/git/BrianCurtis-NOAA/global-workflow/sorc/enkf_chgres_recenter_nc.fd/input_data.f90(324): error #6404: This name does not have a type, and must have an explicit type.   [REFDSET]
 refdset = open_dataset(ref_file)
-^
/scratch1/NCEPDEV/nems/Brian.Curtis/git/BrianCurtis-NOAA/global-workflow/sorc/enkf_chgres_recenter_nc.fd/input_data.f90(324): error #6404: This name does not have a type, and must have an explicit type.   [OPEN_DATASET]
 refdset = open_dataset(ref_file)
-----------^
compilation aborted for /scratch1/NCEPDEV/nems/Brian.Curtis/git/BrianCurtis-NOAA/global-workflow/sorc/enkf_chgres_recenter_nc.fd/input_data.f90 (code 1)
make[2]: *** [enkf_chgres_recenter_nc.fd/CMakeFiles/enkf_chgres_recenter_nc.x.dir/input_data.f90.o] Error 1
make[1]: *** [enkf_chgres_recenter_nc.fd/CMakeFiles/enkf_chgres_recenter_nc.x.dir/all] Error 2

I'm not sure if you want to get that fixed before merging, as reg2grb2 build succeeds.

@WalterKolczynski-NOAA
Copy link
Contributor

Are there no changes needed to build_reg2grb2.sh or reg2grb2.fd/Makefile to use cmake?

@BrianCurtis-NOAA
Copy link
Contributor Author

BrianCurtis-NOAA commented Jun 14, 2021

@WalterKolczynski-NOAA OK so the build issue above was actually an issue with hpc-stack that I got taken care of (at least on hera). Make sure that the ncio build from hpc-stack has a module_ncio.mod and not module_fv3gfs_ncio.mod. The script and the makefile are no longer needed. The build completes on Hera.

Now that ncio is available in the hpc-stack, removed the workaround
that cloned the ncio repository.

Refs: NOAA-EMC#268
Reordered the build workflow utils script so that machine-setup, which
determines the target machine, is called before $target is used to
determine the appropriate modulefile.

Also added error checking so the script exits immediately if the
modulefile is missing instead of trying to build.

Refs: NOAA-EMC#268
WGRIB2 and landsfcutil are needed to build workflow utils but were
not included in the modulefiles.

Refs: NOAA-EMC#268
With reg2grb2 added to the workflow utils being built with cmake, the
executable needed to be added to the list of executables linked by the
linker script.

Refs: NOAA-EMC#268
Now that reg2grb2 is part of the workflow_utils cmake build, the old
build script is no longer available and a separate entry is no longer
needed for build_all.

Refs: NOAA-EMC#268
@WalterKolczynski-NOAA
Copy link
Contributor

@BrianCurtis-NOAA Take a look at the additional changes I made. System now builds using build_all and link_fv3gfs creates the appropriate link to the executable in the exec directory.

@WalterKolczynski-NOAA WalterKolczynski-NOAA added the coupled Issues related to the coupled branch label Jun 23, 2021
@BrianCurtis-NOAA
Copy link
Contributor Author

Looks good to me! Thanks.

Copy link
Contributor

@aerorahul aerorahul left a comment

Choose a reason for hiding this comment

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

please see comments.

@@ -5,35 +5,19 @@ set -eux
readonly UTILS_DIR=$(cd "$(dirname "$($cmd -f -n "${BASH_SOURCE[0]}" )" )" && pwd -P)

# Adapt for global-workflow structure.
target=${target:-"NULL"}
source ${UTILS_DIR}/machine-setup.sh > /dev/null 2>&1
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this required?
which mahcine is requiring this to be sourced that supports the global workflow?

Copy link
Contributor

Choose a reason for hiding this comment

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

When I tried running build_workflow_utils stand-alone, $target isn't defined until it is set by machine-setup, so it was using NULL, then quietly not loading a modulefile because there wasn't one for NULL, then cmake would fail.

Comment on lines +15 to +17
else
echo "FATAL: modulefile $modulefile not found!"
exit 1
Copy link
Contributor

Choose a reason for hiding this comment

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

This assumes that on every machine there has to be a modulefile.
If the software stack is in path, a modulefile is not required.
Which machine is this failing on?

Copy link
Contributor

Choose a reason for hiding this comment

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

The need for this came to me based on the above comment. In the context of global-workflow, I don't know that manually loading a module beforehand is a use case to support, and I'd prefer the error to specify the actual problem rather than cmake just failing.

Comment on lines +16 to +20
landsfcutil::landsfcutil_d
ip::ip_d
sp::sp_d
bacio::bacio_4
w3nco::w3nco_4
Copy link
Contributor

Choose a reason for hiding this comment

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

has anyone verified that all of these are actually used in this program?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went through the makefile and compared which ones were being linked. I didn't go through the code line by line.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a question for @BrianCurtis-NOAA, but landsfcutil is a new dependency for this PR, so I assume yes for that at least.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aerorahul the old build_reg2grb2.sh has landsfcutil in a LIBS export which was then used in the makefile that was used to build reg2grb2. I don't see any subroutines that seem to be using any landsfcutil subroutines, but if needed I will spend more time on going line by line to see if i missed something. Let me know.

@WalterKolczynski-NOAA
Copy link
Contributor

@aerorahul Unless you want me to hold this, I'd like to get it merged.

@aerorahul
Copy link
Contributor

@aerorahul Unless you want me to hold this, I'd like to get it merged.

Please go ahead.

@WalterKolczynski-NOAA WalterKolczynski-NOAA merged commit 9694bbb into NOAA-EMC:feature/coupled-crow Jun 24, 2021
lgannoaa pushed a commit to lgannoaa/global-workflow that referenced this pull request Feb 9, 2022
kayeekayee pushed a commit to kayeekayee/global-workflow that referenced this pull request May 30, 2024
…itial, ocn -> wat, merra2 threading (NOAA-EMC#279)

* changed .gitmodules to point to merra2 ccpp/physics
* remove GFDL_atmos_cubed_sphere and ccpp-framework from .git module
* remove IPD gfsphysics
* Update .gitmodules and submodule pointer for ccpp-physics for code review and testing
* Remove interstitial zorl composites
* Update .gitmodules and submodule pointer fpor ccpp-physics for code review and testing
* Remove or replace references to IPD in comments in atmos_model.F90
* Initialize Sfcprop%zorlx to clear_val instead of huge
* Update submodule pointer for ccpp-physics
* Rename Fortran variables and CCPP standard names / long names of surface composites from ocean to water
* Rename Sfcprop%zorlw to Sfcprop%zorlwav
* Rename Sfcprop%zorlo to Sfcprop%zorlw
* update submodule pointer for ccpp-physics
* Revert change to .gitmodules and update submodule pointer for ccpp-physics
Co-authored-by: anning.cheng <anning.cheng@noaa.gov>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coupled Issues related to the coupled branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

port reg2grb2 to cmake
5 participants