Skip to content

Commit

Permalink
Merge pull request #587 from c-merchant/nc_check_subroutine
Browse files Browse the repository at this point in the history
Resolution to Issue #336 - updated nc_check
  • Loading branch information
hkershaw-brown authored Dec 13, 2023
2 parents c95a630 + a1e063c commit 707fe9a
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 57 deletions.
34 changes: 0 additions & 34 deletions assimilation_code/modules/utilities/utilities_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ module utilities_mod
error_handler, &
to_upper, &
squeeze_out_blanks, &
nc_check, & ! remove this; moved to netcdf_utils
next_file, & ! deprecate this
logfileunit, &
nmlfileunit, &
Expand Down Expand Up @@ -1321,39 +1320,6 @@ subroutine set_tasknum (tasknum)

end subroutine set_tasknum

!-----------------------------------------------------------------------

!>@todo FIXME: remove this once all other code is calling
!>this from the netcdf_utilities_mod instead.

subroutine nc_check(istatus, subr_name, context)

use netcdf

integer, intent (in) :: istatus
character(len=*), intent(in) :: subr_name
character(len=*), intent(in), optional :: context

! if no error, nothing to do here. we are done.
if(istatus == nf90_noerr) return


! something wrong. construct an error string and call the handler.

! context is optional, but is very useful if specified.
! if context + error code > 512, the assignment will truncate.
if (present(context) ) then
msgstring1 = trim(context) // ': ' // trim(nf90_strerror(istatus))
else
msgstring1 = nf90_strerror(istatus)
endif

! this does not return
call error_handler(E_ERR, 'nc_check', msgstring1, source, text2=subr_name)

end subroutine nc_check


!-----------------------------------------------------------------------
!> convert a string to upper case *in place*

Expand Down
4 changes: 2 additions & 2 deletions assimilation_code/programs/compute_error/compute_error.f90
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ program compute_error

use utilities_mod, only : initialize_utilities, &
error_handler, nmlfileunit, E_MSG, E_ERR, &
find_namelist_in_file, nc_check, &
find_namelist_in_file, &
check_namelist_read, finalize_utilities, &
do_nml_file, do_nml_term

use netcdf_utilities_mod, only : nc_check
use netcdf

implicit none
Expand Down
4 changes: 3 additions & 1 deletion models/NCOMMAS/model_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module model_mod

use utilities_mod, only : register_module, error_handler, &
E_ERR, E_WARN, E_MSG, logfileunit, get_unit, &
nc_check, do_output, to_upper, &
do_output, to_upper, &
find_namelist_in_file, check_namelist_read, &
open_file, file_exist, find_textfile_dims, &
file_to_text
Expand All @@ -44,6 +44,8 @@ module model_mod

use random_seq_mod, only: random_seq_type, init_random_seq, random_gaussian

use netcdf_utilities_mod, only : nc_check

use typesizes
use netcdf

Expand Down
4 changes: 2 additions & 2 deletions models/am2/model_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module model_mod
use time_manager_mod, only : time_type, set_time, print_time, set_calendar_type, GREGORIAN
use utilities_mod, only : open_file, close_file, find_namelist_in_file, check_namelist_read, &
register_module, error_handler, file_exist, E_ERR, E_WARN, E_MSG, &
nmlfileunit, do_output, nc_check, do_nml_file, do_nml_term, logfileunit
nmlfileunit, do_output, do_nml_file, do_nml_term, logfileunit
use mpi_utilities_mod, only : my_task_id, task_count
use location_mod, only : location_type, get_close_maxdist_init, &
get_close_obs_init, get_close_obs, set_location, &
Expand All @@ -33,7 +33,7 @@ module model_mod
get_index_for_type_of_obs, get_quantity_for_type_of_obs
! We'll need to add a kind_cloud_fraction to correspond to AM2 prog var
use location_mod, only: VERTISSURFACE, VERTISLEVEL

use netcdf_utilities_mod, only : nc_check
implicit none
private

Expand Down
2 changes: 1 addition & 1 deletion models/forced_barot/obs/obs_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module obs_mod
use utilities_mod, only : file_exist, open_file, close_file, &
register_module, error_handler, E_ERR, E_MSG, &
nmlfileunit, find_namelist_in_file, &
check_namelist_read, nc_check, do_output
check_namelist_read, do_output

implicit none
private
Expand Down
3 changes: 1 addition & 2 deletions models/mpas_atm/mpas_dart_obs_preprocess.f90
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ program mpas_dart_obs_preprocess

use types_mod, only : r8, missing_r8, earth_radius, RAD2DEG, DEG2RAD, i8
use utilities_mod, only : error_handler, E_MSG, find_namelist_in_file, &
check_namelist_read, nc_check, initialize_utilities, &
check_namelist_read, initialize_utilities, &
finalize_utilities
use time_manager_mod, only : time_type, operator(>=), operator(<), operator(>), operator(<=), &
increment_time, decrement_time, operator(-), operator(+), &
Expand Down Expand Up @@ -74,7 +74,6 @@ program mpas_dart_obs_preprocess
cell_ok_to_interpolate, is_global_grid, &
get_bdy_mask, get_cell_center_coords
use ensemble_manager_mod, only : ensemble_type, init_ensemble_manager, end_ensemble_manager

use netcdf

implicit none
Expand Down
4 changes: 2 additions & 2 deletions models/mpas_atm/update_bc.f90
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ program update_bc
use types_mod, only : r8
use utilities_mod, only : initialize_utilities, finalize_utilities, &
find_namelist_in_file, check_namelist_read, &
logfileunit, open_file, close_file, nc_check, &
logfileunit, open_file, close_file, &
get_next_filename, E_ERR, error_handler
use time_manager_mod, only : time_type, print_time, print_date, operator(-), &
get_time, get_date, operator(/=)
Expand All @@ -37,7 +37,7 @@ program update_bc

use netcdf_utilities_mod, only : nc_open_file_readonly, &
nc_open_file_readwrite, &
nc_get_dimension_size, & ! Ha
nc_get_dimension_size, &
nc_close_file

use netcdf
Expand Down
4 changes: 2 additions & 2 deletions models/mpas_ocn/model_mod_check.f90
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ program model_mod_check
!----------------------------------------------------------------------

use types_mod, only : r8, digits12, metadatalength, MISSING_R8, rad2deg
use utilities_mod, only : initialize_utilities, finalize_utilities, nc_check, &
use utilities_mod, only : initialize_utilities, finalize_utilities, &
open_file, close_file, find_namelist_in_file, &
check_namelist_read, nmlfileunit, do_nml_file, do_nml_term, &
E_MSG, E_ERR, error_handler, get_unit
Expand Down Expand Up @@ -44,7 +44,7 @@ program model_mod_check
get_model_analysis_filename, analysis_file_to_statevector, &
statevector_to_analysis_file, get_analysis_time, &
write_model_time, get_grid_dims

use netcdf_utilities_mod, only : nc_check
use netcdf
use typesizes

Expand Down
4 changes: 2 additions & 2 deletions models/pe2lyr/model_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module model_mod

use types_mod, only : r8, MISSING_R8
use time_manager_mod, only : time_type, set_time
use utilities_mod, only : file_exist, open_file, close_file, nc_check, &
use utilities_mod, only : file_exist, open_file, close_file, &
register_module, error_handler, E_ERR, E_MSG
use random_seq_mod, only : random_seq_type, init_random_seq, random_gaussian
use location_mod, only : location_type, get_location, set_location, get_dist, &
Expand All @@ -23,7 +23,7 @@ module model_mod
use obs_kind_mod, only : QTY_U_WIND_COMPONENT, QTY_V_WIND_COMPONENT, &
QTY_GEOPOTENTIAL_HEIGHT


use netcdf_utilities_mod, only : nc_check
use pe2lyr_mod, only : modelvars, modelvars_init, rk4
use spharmt_mod, only : sphere, getvrtdiv, spharm, spharmt_init, getuv

Expand Down
3 changes: 2 additions & 1 deletion models/rose/model_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ module model_mod
use utilities_mod, only : file_exist, open_file, close_file, &
error_handler, E_ERR, E_MSG, E_WARN, nmlfileunit, &
do_output, find_namelist_in_file, check_namelist_read, &
do_nml_file, do_nml_term, nc_check
do_nml_file, do_nml_term
use random_seq_mod, only : random_seq_type, init_random_seq, random_gaussian
use obs_kind_mod, only : QTY_U_WIND_COMPONENT, QTY_V_WIND_COMPONENT,&
QTY_TEMPERATURE
use netcdf_utilities_mod, only : nc_check
use typesizes
use netcdf

Expand Down
4 changes: 2 additions & 2 deletions models/wrf_hydro/create_identity_streamflow_obs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ program create_identity_streamflow_obs

use location_mod, only : VERTISHEIGHT, location_type, get_location

use utilities_mod, only : nc_check, nmlfileunit, do_nml_file, do_nml_term, &
use utilities_mod, only : nmlfileunit, do_nml_file, do_nml_term, &
initialize_utilities, finalize_utilities, &
find_namelist_in_file, check_namelist_read, &
error_handler, E_ERR, E_MSG, &
Expand Down Expand Up @@ -47,7 +47,7 @@ program create_identity_streamflow_obs
get_number_of_links

use sort_mod, only : index_sort

use netcdf_utilities_mod, only : nc_check
use netcdf

implicit none
Expand Down
3 changes: 1 addition & 2 deletions observations/forward_operators/obs_def_GRACE_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,12 @@ module obs_def_GRACE_mod
use utilities_mod, only : register_module, E_ERR, E_MSG, error_handler, &
check_namelist_read, find_namelist_in_file, &
nmlfileunit, do_output, do_nml_file, do_nml_term, &
nc_check, file_exist, is_longitude_between
file_exist, is_longitude_between

use assim_model_mod, only : interpolate

use ensemble_manager_mod, only : ensemble_type
use obs_def_utilities_mod, only : track_status

use typesizes
use netcdf

Expand Down
4 changes: 2 additions & 2 deletions observations/obs_converters/USGS/convert_streamflow.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ program convert_streamflow

use location_mod, only : VERTISHEIGHT

use utilities_mod, only : nc_check, initialize_utilities, finalize_utilities, &
use utilities_mod, only : initialize_utilities, finalize_utilities, &
nmlfileunit, do_nml_file, do_nml_term, &
find_namelist_in_file, check_namelist_read, &
error_handler, E_ERR, E_MSG, find_textfile_dims, &
Expand All @@ -39,7 +39,7 @@ program convert_streamflow

use obs_utilities_mod, only : getvar_real, getvar_int, get_or_fill_QC, add_obs_to_seq, &
create_3d_obs, getvar_int, getdimlen, set_missing_name

use netcdf_utilities_mod, only : nc_check
use netcdf

implicit none
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module obs_seq_utilities_mod


use types_mod, only : r8, MISSING_R8, MISSING_I
use utilities_mod, only : nc_check, E_MSG, E_ERR, error_handler
use utilities_mod, only : E_MSG, E_ERR, error_handler
use obs_def_mod, only : obs_def_type, set_obs_def_time, set_obs_def_kind, &
set_obs_def_error_variance, set_obs_def_location, &
get_obs_def_time, get_obs_def_location, &
Expand Down Expand Up @@ -46,7 +46,6 @@ module obs_seq_utilities_mod
destroy_obs, destroy_obs_sequence, &
get_num_key_range, get_obs_key


use netcdf

implicit none
Expand Down

0 comments on commit 707fe9a

Please sign in to comment.