WAVEWATCH III  beta 0.0.1
scrip_netcdfmod.f90
Go to the documentation of this file.
1 !|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2 
4 
5  !BOP
6  ! !MODULE: SCRIP_NetCDFMod
7  !
8  ! !DESCRIPTION:
9  ! This module contains netCDF error handling functions and the
10  ! use of the netCDF module for all netCDF functions.
11  !
12  ! !REVISION HISTORY:
13  ! SVN:$Id: $
14  !
15  ! !USES:
16 
17  use scrip_kindsmod
18  use scrip_errormod
19  use netcdf
20 
21  implicit none
22  private
23  save
24 
25  ! !DEFINED PARAMETERS:
26 
27  ! !PUBLIC MEMBER FUNCTIONS:
28 
29  public :: scrip_netcdferrorcheck
30 
31  !EOP
32  !BOC
33  !EOC
34  !***********************************************************************
35 
36 contains
37 
38  !***********************************************************************
39  !BOP
40  ! !IROUTINE: SCRIP_NetcdfErrorCheck
41  ! !INTERFACE:
42 
43  function scrip_netcdferrorcheck(netcdfStat, errorCode, rtnName, &
44  errorMsg)
45 
46  ! !DESCRIPTION:
47  ! This routine checks netCDF status flags from netCDF routines.
48  ! On error, it adds an error message to the error log and returns
49  ! both a true value to the calling routines as well as setting the
50  ! error code to fail. It is used in the same manner is the
51  ! SCRIP\_ErrorCheck function.
52  !
53  ! !REVISION HISTORY:
54  ! same as module
55 
56  ! !OUTPUT PARAMETERS:
57 
58  logical (SCRIP_logical) :: &
60 
61  integer (SCRIP_i4), intent(out) :: &
62  errorcode ! returned SCRIP error flag
63 
64  ! !INPUT PARAMETERS:
65 
66  integer (SCRIP_i4), intent(in) :: &
67  netcdfstat ! status flag from netCDF call
68 
69  character (*), intent(in) :: &
70  rtnname, &! name of calling routine
71  errormsg ! error message for logging
72 
73  !EOP
74  !BOC
75  !-----------------------------------------------------------------------
76  !
77  ! local variables
78  !
79  !-----------------------------------------------------------------------
80 
81  character (SCRIP_charLength) :: &
82  ncerrmsg ! netCDF error message
83 
84  !-----------------------------------------------------------------------
85  !
86  ! if no error, return false and a successful errorCode
87  !
88  !-----------------------------------------------------------------------
89 
90  if (netcdfstat == nf90_noerr) then
91  errorcode = scrip_success
92  scrip_netcdferrorcheck = .false.
93 
94  !-----------------------------------------------------------------------
95  !
96  ! if an error is detected, return a true value and call the SCRIP
97  ! error handlers to log the error. Log both the netCDF error msg
98  ! as well as the error passed by the calling routine.
99  !
100  !-----------------------------------------------------------------------
101 
102  else
103 
104  scrip_netcdferrorcheck = .true.
105  ncerrmsg = nf90_strerror(netcdfstat)
106  call scrip_errorset(errorcode, rtnname, ncerrmsg)
107  call scrip_errorset(errorcode, rtnname, errormsg)
108 
109  endif
110 
111  !-----------------------------------------------------------------------
112  !EOC
113 
114  end function scrip_netcdferrorcheck
115 
116  !***********************************************************************
117 
118 end module scrip_netcdfmod
119 
120 !|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
scrip_netcdfmod
Definition: scrip_netcdfmod.f90:3
scrip_errormod::scrip_errorset
subroutine, public scrip_errorset(errorCode, rtnName, errorMsg)
Definition: scrip_errormod.f90:81
scrip_errormod::scrip_success
integer(scrip_i4), parameter, public scrip_success
Definition: scrip_errormod.f90:42
scrip_kindsmod
Definition: scrip_kindsmod.f90:3
scrip_errormod
Definition: scrip_errormod.f90:3
scrip_netcdfmod::scrip_netcdferrorcheck
logical(scrip_logical) function, public scrip_netcdferrorcheck(netcdfStat, errorCode, rtnName, errorMsg)
Definition: scrip_netcdfmod.f90:45