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

Improve error handling in the orog code #909

Closed
GeorgeGayno-NOAA opened this issue Mar 7, 2024 · 2 comments · Fixed by #914
Closed

Improve error handling in the orog code #909

GeorgeGayno-NOAA opened this issue Mar 7, 2024 · 2 comments · Fixed by #914
Assignees
Labels
bug Something isn't working

Comments

@GeorgeGayno-NOAA
Copy link
Collaborator

GeorgeGayno-NOAA commented Mar 7, 2024

The orog code has a routine that checks for NetCDF i/o errors. However, it does not stop processing if an error is detected - it just prints the error to the log file.

  subroutine netcdf_err( err, string )
      integer, intent(in) :: err
      character(len=*), intent(in) :: string
      character(len=256) :: errmsg
      include "netcdf.inc"

      if( err.EQ.NF_NOERR )return
      errmsg = NF_STRERROR(err)
      print*, trim(string), ': ', trim(errmsg)

      return
    end subroutine netcdf_err

I suspect that programmers have been calling this routine with the expectation that the program will stop if there is an error.

@GeorgeGayno-NOAA GeorgeGayno-NOAA added the bug Something isn't working label Mar 7, 2024
@GeorgeGayno-NOAA GeorgeGayno-NOAA self-assigned this Mar 7, 2024
@GeorgeGayno-NOAA
Copy link
Collaborator Author

As a test, I commented out the copy of the gmted2010 data to the working directory in fv3gfs_make_orog.sh

diff --git a/ush/fv3gfs_make_orog.sh b/ush/fv3gfs_make_orog.sh
index 6fcff667..4ae30615 100755
--- a/ush/fv3gfs_make_orog.sh
+++ b/ush/fv3gfs_make_orog.sh
@@ -83,7 +83,7 @@ cd $workdir

 cp ${indir}/topography.antarctica.ramp.30s.nc .
 cp ${indir}/landcover.umd.30s.nc .
-cp ${indir}/topography.gmted2010.30s.nc .
+#cp ${indir}/topography.gmted2010.30s.nc .
 if [ $inorogexist -eq 1 ]; then
    cp $inputorog .
 fi

This should result in an error.

Running the regression tests showed the open of this file failed, the error handler was called, but processing continued. The 'oro' files contained zeroes for the terrain height.

  Attempt to open/read UMD 30sec slmsk.
  UMD lake, UMD(50,50)=    0
  Call read_g to read global topography
 Open file topography.gmted2010.30s.nc: No such file or directory
 Inquire varid of topo: NetCDF: Not a valid ID
 Read topo: NetCDF: Not a valid ID

 global0 max=           0  min=           0  sum=                     0
  i_count_notset=           0
 global0 mean=                     0  std.dev=                     0  ko9s=
   933120000           0   933120000
  After read_g, glob(500,500)=      0

GeorgeGayno-NOAA pushed a commit to GeorgeGayno-NOAA/UFS_UTILS that referenced this issue Mar 12, 2024
Prepend 'FATAL ERROR' to the error message as required
by NCO.

Fixes ufs-community#909.
@GeorgeGayno-NOAA
Copy link
Collaborator Author

Rerunning the above test with the fix at 33a8df2 shows the program stops, as it should:

  UMD lake, UMD(50,50)=    0
  Call read_g to read global topography
 FATAL ERROR: Open file topography.gmted2010.30s.nc: No such file or directory
abort:

real    0m0.288s
user    0m0.013s
sys     0m0.258s
+ iret=134

GeorgeGayno-NOAA pushed a commit to GeorgeGayno-NOAA/UFS_UTILS that referenced this issue Mar 12, 2024
GeorgeGayno-NOAA pushed a commit to GeorgeGayno-NOAA/UFS_UTILS that referenced this issue Mar 13, 2024
GeorgeGayno-NOAA pushed a commit to GeorgeGayno-NOAA/UFS_UTILS that referenced this issue Mar 13, 2024
GeorgeGayno-NOAA pushed a commit to GeorgeGayno-NOAA/UFS_UTILS that referenced this issue Mar 19, 2024
GeorgeGayno-NOAA added a commit to GeorgeGayno-NOAA/UFS_UTILS that referenced this issue Mar 20, 2024
GeorgeGayno-NOAA added a commit to GeorgeGayno-NOAA/UFS_UTILS that referenced this issue Mar 22, 2024
GeorgeGayno-NOAA added a commit that referenced this issue Mar 22, 2024
Update the netcdf_error routine to stop processing if an error occurs. Update error messages
to comply with NCO requirements. Cleanup/fix the error handling for the read of the RAMP data.
If read of RAMP data fails, stop program execution.

Fixes #909.
BinLiu-NOAA pushed a commit to hafs-community/UFS_UTILS that referenced this issue Jul 10, 2024
Update the netcdf_error routine to stop processing if an error occurs. Update error messages
to comply with NCO requirements. Cleanup/fix the error handling for the read of the RAMP data.
If read of RAMP data fails, stop program execution.

Fixes ufs-community#909.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant