ROMS
Loading...
Searching...
No Matches
mod_netcdf::netcdf_get_ivar Interface Reference

Public Member Functions

subroutine netcdf_get_ivar_0d (ng, model, ncname, myvarname, a, ncid, start, total)
 
subroutine netcdf_get_ivar_1d (ng, model, ncname, myvarname, a, ncid, start, total)
 
subroutine netcdf_get_ivar_2d (ng, model, ncname, myvarname, a, ncid, start, total)
 

Detailed Description

Definition at line 59 of file mod_netcdf.F.

Member Function/Subroutine Documentation

◆ netcdf_get_ivar_0d()

subroutine mod_netcdf::netcdf_get_ivar::netcdf_get_ivar_0d ( integer, intent(in) ng,
integer, intent(in) model,
character (len=*), intent(in) ncname,
character (len=*), intent(in) myvarname,
integer, intent(out) a,
integer, intent(in), optional ncid,
integer, dimension(:), intent(in), optional start,
integer, dimension(:), intent(in), optional total )

Definition at line 4931 of file mod_netcdf.F.

4933!
4934!=======================================================================
4935! !
4936! This routine reads requested integer scalar variable from specified !
4937! NetCDF file. !
4938! !
4939! On Input: !
4940! !
4941! ng Nested grid number (integer) !
4942! model Calling model identifier (integer) !
4943! ncname NetCDF file name (string) !
4944! myVarName Variable name (string) !
4945! ncid NetCDF file ID (integer, OPTIONAL) !
4946! start Starting index where the first of the data values !
4947! will be read along each dimension (integer, !
4948! OPTIONAL) !
4949! total Number of data values to be read along each !
4950! dimension (integer, OPTIONAL) !
4951! !
4952! On Ouput: !
4953! !
4954! A Read scalar variable (integer) !
4955! !
4956! Examples: !
4957! !
4958! CALL netcdf_get_ivar (ng, iNLM, 'file.nc', 'VarName', ivar) !
4959! CALL netcdf_get_ivar (ng, iNLM, 'file.nc', 'VarName', ivar(1)) !
4960! !
4961!=======================================================================
4962!
4963! Imported variable declarations.
4964!
4965 integer, intent(in) :: ng, model
4966
4967 integer, intent(in), optional :: ncid
4968 integer, intent(in), optional :: start(:)
4969 integer, intent(in), optional :: total(:)
4970!
4971 character (len=*), intent(in) :: ncname
4972 character (len=*), intent(in) :: myVarName
4973!
4974 integer, intent(out) :: A
4975!
4976! Local variable declarations.
4977!
4978 integer :: my_ncid, status, varid
4979
4980 integer, dimension(1) :: my_A
4981
4982#if !defined PARALLEL_IO && defined DISTRIBUTE
4983 integer, dimension(2) :: ibuffer
4984#endif
4985!
4986 character (len=*), parameter :: MyFile = &
4987 & __FILE__//", netcdf_get_ivar_0d"
4988!
4989!-----------------------------------------------------------------------
4990! Read in an integer scalar variable.
4991!-----------------------------------------------------------------------
4992!
4993! If NetCDF file ID is not provided, open NetCDF for reading.
4994!
4995 IF (.not.PRESENT(ncid)) THEN
4996 CALL netcdf_open (ng, model, trim(ncname), 0, my_ncid)
4997 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
4998 ELSE
4999 my_ncid=ncid
5000 END IF
5001!
5002! Read in variable.
5003!
5004 IF (inpthread) THEN
5005 status=nf90_inq_varid(my_ncid, trim(myvarname), varid)
5006 IF (status.eq.nf90_noerr) THEN
5007 IF (PRESENT(start).and.PRESENT(total)) THEN
5008 status=nf90_get_var(my_ncid, varid, my_a, start, total)
5009 a=my_a(1)
5010 ELSE
5011 status=nf90_get_var(my_ncid, varid, a)
5012 END IF
5013 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
5014 WRITE (stdout,10) trim(myvarname), trim(ncname), &
5015 & trim(sourcefile), nf90_strerror(status)
5016 exit_flag=2
5017 ioerror=status
5018 END IF
5019 ELSE
5020 WRITE (stdout,20) trim(myvarname), trim(ncname), &
5021 & trim(sourcefile), nf90_strerror(status)
5022 exit_flag=2
5023 ioerror=status
5024 END IF
5025 END IF
5026
5027#if !defined PARALLEL_IO && defined DISTRIBUTE
5028!
5029! Broadcast read variable to all processors in the group.
5030!
5031 ibuffer(1)=exit_flag
5032 ibuffer(2)=ioerror
5033 CALL mp_bcasti (ng, model, ibuffer)
5034 exit_flag=ibuffer(1)
5035 ioerror=ibuffer(2)
5036 IF (exit_flag.eq.noerror) THEN
5037 CALL mp_bcasti (ng, model, a)
5038 END IF
5039#endif
5040!
5041! If NetCDF file ID is not provided, close input NetCDF file.
5042!
5043 IF (.not.PRESENT(ncid)) THEN
5044 CALL netcdf_close (ng, model, my_ncid, ncname, .false.)
5045 END IF
5046!
5047 10 FORMAT (/,' NETCDF_GET_IVAR_0D - error while reading variable:', &
5048 & 2x,a,/,22x,'in input file:',2x,a,/,22x,'call from:',2x,a, &
5049 & /,22x,a)
5050 20 FORMAT (/,' NETCDF_GET_IVAR_0D - error while inquiring ID for ', &
5051 & 'variable:',2x,a,/,22x,'in input file:',2x,a,/,22x, &
5052 & 'call from:',2x,a,/,22x,a)
5053!
5054 RETURN

References mod_scalars::exit_flag, mod_parallel::inpthread, mod_iounits::ioerror, mod_netcdf::netcdf_close(), mod_netcdf::netcdf_open(), mod_scalars::noerror, mod_iounits::sourcefile, and mod_iounits::stdout.

Here is the call graph for this function:

◆ netcdf_get_ivar_1d()

subroutine mod_netcdf::netcdf_get_ivar::netcdf_get_ivar_1d ( integer, intent(in) ng,
integer, intent(in) model,
character (len=*), intent(in) ncname,
character (len=*), intent(in) myvarname,
integer, dimension(:), intent(out) a,
integer, intent(in), optional ncid,
integer, dimension(:), intent(in), optional start,
integer, dimension(:), intent(in), optional total )

Definition at line 5057 of file mod_netcdf.F.

5059!
5060!=======================================================================
5061! !
5062! This routine reads requested integer 1D-array variable from !
5063! specified NetCDF file. !
5064! !
5065! On Input: !
5066! !
5067! ng Nested grid number (integer) !
5068! model Calling model identifier (integer) !
5069! ncname NetCDF file name (string) !
5070! myVarName Variable name (string) !
5071! ncid NetCDF file ID (integer, OPTIONAL) !
5072! start Starting index where the first of the data values !
5073! will be read along each dimension (integer, !
5074! OPTIONAL) !
5075! total Number of data values to be read along each !
5076! dimension (integer, OPTIONAL) !
5077! !
5078! On Ouput: !
5079! !
5080! A Read 1D-array variable (integer) !
5081! !
5082! Examples: !
5083! !
5084! CALL netcdf_get_ivar (ng, iNLM, 'file.nc', 'VarName', ivar) !
5085! CALL netcdf_get_ivar (ng, iNLM, 'file.nc', 'VarName', ivar(0:)) !
5086! CALL netcdf_get_ivar (ng, iNLM, 'file.nc', 'VarName', ivar(:,1)) !
5087! !
5088!=======================================================================
5089!
5090! Imported variable declarations.
5091!
5092 integer, intent(in) :: ng, model
5093
5094 integer, intent(in), optional :: ncid
5095 integer, intent(in), optional :: start(:)
5096 integer, intent(in), optional :: total(:)
5097!
5098 character (len=*), intent(in) :: ncname
5099 character (len=*), intent(in) :: myVarName
5100!
5101 integer, intent(out) :: A(:)
5102!
5103! Local variable declarations.
5104!
5105 integer :: my_ncid, status, varid
5106
5107#if !defined PARALLEL_IO && defined DISTRIBUTE
5108 integer, dimension(2) :: ibuffer
5109#endif
5110!
5111 character (len=*), parameter :: MyFile = &
5112 & __FILE__//", netcdf_get_ivar_1d"
5113!
5114!-----------------------------------------------------------------------
5115! Read in an integer 1D-array variable.
5116!-----------------------------------------------------------------------
5117!
5118! If NetCDF file ID is not provided, open NetCDF for reading.
5119!
5120 IF (.not.PRESENT(ncid)) THEN
5121 CALL netcdf_open (ng, model, trim(ncname), 0, my_ncid)
5122 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
5123 ELSE
5124 my_ncid=ncid
5125 END IF
5126!
5127! Read in variable.
5128!
5129 IF (inpthread) THEN
5130 status=nf90_inq_varid(my_ncid, trim(myvarname), varid)
5131 IF (status.eq.nf90_noerr) THEN
5132 IF (PRESENT(start).and.PRESENT(total)) THEN
5133 status=nf90_get_var(my_ncid, varid, a, start, total)
5134 ELSE
5135 status=nf90_get_var(my_ncid, varid, a)
5136 END IF
5137 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
5138 WRITE (stdout,10) trim(myvarname), trim(ncname), &
5139 & trim(sourcefile), nf90_strerror(status)
5140 exit_flag=2
5141 ioerror=status
5142 END IF
5143 ELSE
5144 WRITE (stdout,20) trim(myvarname), trim(ncname), &
5145 & trim(sourcefile), nf90_strerror(status)
5146 exit_flag=2
5147 ioerror=status
5148 END IF
5149 END IF
5150
5151#if !defined PARALLEL_IO && defined DISTRIBUTE
5152!
5153! Broadcast read variable to all processors in the group.
5154!
5155 ibuffer(1)=exit_flag
5156 ibuffer(2)=ioerror
5157 CALL mp_bcasti (ng, model, ibuffer)
5158 exit_flag=ibuffer(1)
5159 ioerror=ibuffer(2)
5160 IF (exit_flag.eq.noerror) THEN
5161 CALL mp_bcasti (ng, model, a)
5162 END IF
5163#endif
5164!
5165! If NetCDF file ID is not provided, close input NetCDF file.
5166!
5167 IF (.not.PRESENT(ncid)) THEN
5168 CALL netcdf_close (ng, model, my_ncid, ncname, .false.)
5169 END IF
5170!
5171 10 FORMAT (/,' NETCDF_GET_IVAR_1D - error while reading variable:', &
5172 & 2x,a,/,22x,'in input file:',2x,a,/,22x,'call from:',2x,a, &
5173 & /,22x,a)
5174 20 FORMAT (/,' NETCDF_GET_IVAR_1D - error while inquiring ID for ', &
5175 & 'variable:',2x,a,/,22x,'in input file:',2x,a,/,22x, &
5176 & 'call from:',2x,a,/22x,a)
5177!
5178 RETURN

References mod_scalars::exit_flag, mod_parallel::inpthread, mod_iounits::ioerror, mod_netcdf::netcdf_close(), mod_netcdf::netcdf_open(), mod_scalars::noerror, mod_iounits::sourcefile, and mod_iounits::stdout.

Here is the call graph for this function:

◆ netcdf_get_ivar_2d()

subroutine mod_netcdf::netcdf_get_ivar::netcdf_get_ivar_2d ( integer, intent(in) ng,
integer, intent(in) model,
character (len=*), intent(in) ncname,
character (len=*), intent(in) myvarname,
integer, dimension(:,:), intent(out) a,
integer, intent(in), optional ncid,
integer, dimension(:), intent(in), optional start,
integer, dimension(:), intent(in), optional total )

Definition at line 5181 of file mod_netcdf.F.

5183!
5184!=======================================================================
5185! !
5186! This routine reads requested integer 2D-array variable from !
5187! specified NetCDF file. !
5188! !
5189! On Input: !
5190! !
5191! ng Nested grid number (integer) !
5192! model Calling model identifier (integer) !
5193! ncname NetCDF file name (string) !
5194! myVarName Variable name (string) !
5195! ncid NetCDF file ID (integer, OPTIONAL) !
5196! start Starting index where the first of the data values !
5197! will be read along each dimension (integer, !
5198! OPTIONAL) !
5199! total Number of data values to be read along each !
5200! dimension (integer, OPTIONAL) !
5201! !
5202! On Ouput: !
5203! !
5204! A Read 2D-array variable (integer) !
5205! !
5206! Examples: !
5207! !
5208! CALL netcdf_get_ivar (ng, iNLM, 'file.nc', 'VarName', ivar) !
5209! CALL netcdf_get_ivar (ng, iNLM, 'file.nc', 'VarName', ivar(0:,:)) !
5210! CALL netcdf_get_ivar (ng, iNLM, 'file.nc', 'VarName', ivar(0:,0:))!
5211! CALL netcdf_get_ivar (ng, iNLM, 'file.nc', 'VarName', ivar(:,:,1))!
5212! !
5213!=======================================================================
5214!
5215! Imported variable declarations.
5216!
5217 integer, intent(in) :: ng, model
5218
5219 integer, intent(in), optional :: ncid
5220 integer, intent(in), optional :: start(:)
5221 integer, intent(in), optional :: total(:)
5222!
5223 character (len=*), intent(in) :: ncname
5224 character (len=*), intent(in) :: myVarName
5225!
5226 integer, intent(out) :: A(:,:)
5227!
5228! Local variable declarations.
5229!
5230 integer :: my_ncid, status, varid
5231
5232#if !defined PARALLEL_IO && defined DISTRIBUTE
5233 integer, dimension(2) :: ibuffer
5234#endif
5235!
5236 character (len=*), parameter :: MyFile = &
5237 & __FILE__//", netcdf_get_ivar_2d"
5238!
5239!-----------------------------------------------------------------------
5240! Read in an integer 2D-array variable.
5241!-----------------------------------------------------------------------
5242!
5243! If NetCDF file ID is not provided, open NetCDF for reading.
5244!
5245 IF (.not.PRESENT(ncid)) THEN
5246 CALL netcdf_open (ng, model, trim(ncname), 0, my_ncid)
5247 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
5248 ELSE
5249 my_ncid=ncid
5250 END IF
5251!
5252! Read in variable.
5253!
5254 IF (inpthread) THEN
5255 status=nf90_inq_varid(my_ncid, trim(myvarname), varid)
5256 IF (status.eq.nf90_noerr) THEN
5257 IF (PRESENT(start).and.PRESENT(total)) THEN
5258 status=nf90_get_var(my_ncid, varid, a, start, total)
5259 ELSE
5260 status=nf90_get_var(my_ncid, varid, a)
5261 END IF
5262 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
5263 WRITE (stdout,10) trim(myvarname), trim(ncname), &
5264 & trim(sourcefile), nf90_strerror(status)
5265 exit_flag=2
5266 ioerror=status
5267 END IF
5268 ELSE
5269 WRITE (stdout,20) trim(myvarname), trim(ncname), &
5270 & trim(sourcefile), nf90_strerror(status)
5271 exit_flag=2
5272 ioerror=status
5273 END IF
5274 END IF
5275
5276#if !defined PARALLEL_IO && defined DISTRIBUTE
5277!
5278! Broadcast read variable to all processors in the group.
5279!
5280 ibuffer(1)=exit_flag
5281 ibuffer(2)=ioerror
5282 CALL mp_bcasti (ng, model, ibuffer)
5283 exit_flag=ibuffer(1)
5284 ioerror=ibuffer(2)
5285 IF (exit_flag.eq.noerror) THEN
5286 CALL mp_bcasti (ng, model, a)
5287 END IF
5288#endif
5289!
5290! If NetCDF file ID is not provided, close input NetCDF file.
5291!
5292 IF (.not.PRESENT(ncid)) THEN
5293 CALL netcdf_close (ng, model, my_ncid, ncname, .false.)
5294 END IF
5295!
5296 10 FORMAT (/,' NETCDF_GET_IVAR_2D - error while reading variable:', &
5297 & 2x,a,/,22x,'in input file:',2x,a,/,22x,'call from:',2x,a, &
5298 & /,22x,a)
5299 20 FORMAT (/,' NETCDF_GET_IVAR_2D - error while inquiring ID for ', &
5300 & 'variable:',2x,a,/,22x,'in input file:',2x,a,/,22x, &
5301 & 'call from:',2x,a,/,22x,a)
5302!
5303 RETURN

References mod_scalars::exit_flag, mod_parallel::inpthread, mod_iounits::ioerror, mod_netcdf::netcdf_close(), mod_netcdf::netcdf_open(), mod_scalars::noerror, mod_iounits::sourcefile, and mod_iounits::stdout.

Here is the call graph for this function:

The documentation for this interface was generated from the following file: