ROMS
Loading...
Searching...
No Matches
mod_pio_netcdf::pio_netcdf_get_lvar Interface Reference

Public Member Functions

subroutine pio_netcdf_get_lvar_0d (ng, model, ncname, myvarname, a, piofile, start, total)
 
subroutine pio_netcdf_get_lvar_1d (ng, model, ncname, myvarname, a, piofile, start, total)
 

Detailed Description

Definition at line 72 of file mod_pio_netcdf.F.

Member Function/Subroutine Documentation

◆ pio_netcdf_get_lvar_0d()

subroutine mod_pio_netcdf::pio_netcdf_get_lvar::pio_netcdf_get_lvar_0d ( integer, intent(in) ng,
integer, intent(in) model,
character (len=*), intent(in) ncname,
character (len=*), intent(in) myvarname,
logical, intent(out) a,
type (file_desc_t), intent(in), optional piofile,
integer, dimension(:), intent(in), optional start,
integer, dimension(:), intent(in), optional total )

Definition at line 4841 of file mod_pio_netcdf.F.

4843!
4844!=======================================================================
4845! !
4846! This routine reads requested logical scalar variable from specified !
4847! NetCDF file. The variable can be stored as an interger (0 or 1) or !
4848! as a character ('T' or 'F'). Reading a character variable is very !
4849! inefficient in parallel I/O. !
4850! !
4851! On Input: !
4852! !
4853! ng Nested grid number (integer) !
4854! model Calling model identifier (integer) !
4855! ncname NetCDF file name (string) !
4856! myVarName Variable name (string) !
4857! pioFile PIO file descriptor, TYPE(File_desc_t), OPTIONAL !
4858! pioFile%fh file handler !
4859! pioFile%iosystem IO system descriptor (struct) !
4860! start Starting index where the first of the data values !
4861! will be read along each dimension (integer, !
4862! OPTIONAL) !
4863! total Number of data values to be read along each !
4864! dimension (integer, OPTIONAL) !
4865! !
4866! On Ouput: !
4867! !
4868! A Read scalar variable (logical) !
4869! !
4870! Examples: !
4871! !
4872! CALL pio_netcdf_get_lvar (ng, iNLM, 'f.nc', 'VarName', A) !
4873! CALL pio_netcdf_get_lvar (ng, iNLM, 'f.nc', 'VarName', A(1)) !
4874! !
4875!=======================================================================
4876!
4877! Imported variable declarations.
4878!
4879 integer, intent(in) :: ng, model
4880
4881 integer, intent(in), optional :: start(:)
4882 integer, intent(in), optional :: total(:)
4883!
4884 character (len=*), intent(in) :: ncname
4885 character (len=*), intent(in) :: myVarName
4886!
4887 logical, intent(out) :: A
4888!
4889 TYPE (File_desc_t), intent(in), optional :: pioFile
4890!
4891! Local variable declarations.
4892!
4893 integer :: my_type, status
4894
4895 integer :: AI
4896 integer, dimension(1) :: my_AI
4897!
4898 character (len=1) :: Achar(1)
4899
4900 character (len=*), parameter :: MyFile = &
4901 & __FILE__//", pio_netcdf_get_lvar_0d"
4902!
4903 TYPE (File_desc_t) :: my_pioFile
4904 TYPE (Var_desc_t) :: my_pioVar
4905!
4906!-----------------------------------------------------------------------
4907! Read in an integer scalar variable.
4908!-----------------------------------------------------------------------
4909!
4910! If file descriptor is not provided, open NetCDF for reading.
4911!
4912 IF (.not.PRESENT(piofile)) THEN
4913 CALL pio_netcdf_open (ng, model, trim(ncname), 0, my_piofile)
4914 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
4915 ELSE
4916 my_piofile=piofile
4917 END IF
4918!
4919! Read in variable.
4920!
4921 status=pio_inq_varid(my_piofile, trim(myvarname), my_piovar)
4922 IF (status.eq.pio_noerr) THEN
4923 status=pio_inquire_variable(my_piofile, my_piovar, &
4924 & xtype = my_type)
4925 IF (status.eq.pio_noerr) THEN
4926 IF (my_type.eq.pio_int) THEN
4927 IF (PRESENT(start).and.PRESENT(total)) THEN
4928 status=pio_get_var(my_piofile, my_piovar, start, total, &
4929 & my_ai)
4930 ai=my_ai(1)
4931 ELSE
4932 status=pio_get_var(my_piofile, my_piovar, ai)
4933 END IF
4934 IF (status.eq.pio_noerr) THEN
4935 IF (ai.eq.0) THEN
4936 a=.false.
4937 ELSE
4938 a=.true.
4939 END IF
4940 END IF
4941 ELSE IF (my_type.eq.pio_char) THEN
4942 IF (PRESENT(start).and.PRESENT(total)) THEN
4943 status=pio_get_var(my_piofile, my_piovar, start, total, &
4944 & achar)
4945 ELSE
4946 status=pio_get_var(my_piofile, my_piovar, achar)
4947 END IF
4948 IF (status.eq.pio_noerr) THEN
4949 a=.false.
4950 IF ((achar(1).eq.'t').or.(achar(1).eq.'T')) THEN
4951 a=.true.
4952 END IF
4953 END IF
4954 END IF
4955 IF (founderror(status, pio_noerr, __line__, myfile)) THEN
4956 IF (master) WRITE (stdout,10) trim(myvarname), &
4957 & trim(ncname), &
4958 & trim(sourcefile)
4959 exit_flag=2
4960 ioerror=status
4961 END IF
4962 ELSE
4963 IF (master) WRITE (stdout,20) trim(myvarname), trim(ncname), &
4964 & trim(sourcefile)
4965 exit_flag=2
4966 ioerror=status
4967 END IF
4968 ELSE
4969 IF (master) WRITE (stdout,30) trim(myvarname), trim(ncname), &
4970 & trim(sourcefile)
4971 exit_flag=2
4972 ioerror=status
4973 END IF
4974!
4975! If file descriptor is not provided, close input NetCDF file.
4976!
4977 IF (.not.PRESENT(piofile)) THEN
4978 CALL pio_netcdf_close (ng, model, my_piofile, ncname, .false.)
4979 END IF
4980!
4981 10 FORMAT (/,' PIO_NETCDF_GET_LVAR_0D - error while reading ', &
4982 & 'variable:',2x,a,/,26x,'in input file:',2x,a, &
4983 & /,26x,'call from:',2x,a)
4984 20 FORMAT (/,' PIO_NETCDF_GET_LVAR_0D - error while inquiring ', &
4985 & 'type for variable:',2x,a,/,26x,'in input file:',2x,a, &
4986 & /,26x,'call from:',2x,a)
4987 30 FORMAT (/,' PIO_NETCDF_GET_LVAR_0D - error while inquiring ', &
4988 & ' descriptor for variable:',2x,a, &
4989 & /,26x,'in input file:',2x,a,/,26x,'call from:',2x,a)
4990!
4991 RETURN

References mod_scalars::exit_flag, strings_mod::founderror(), mod_iounits::ioerror, mod_parallel::master, mod_scalars::noerror, mod_pio_netcdf::pio_netcdf_close(), mod_pio_netcdf::pio_netcdf_open(), mod_iounits::sourcefile, and mod_iounits::stdout.

Here is the call graph for this function:

◆ pio_netcdf_get_lvar_1d()

subroutine mod_pio_netcdf::pio_netcdf_get_lvar::pio_netcdf_get_lvar_1d ( integer, intent(in) ng,
integer, intent(in) model,
character (len=*), intent(in) ncname,
character (len=*), intent(in) myvarname,
logical, dimension(:), intent(out) a,
type (file_desc_t), intent(in), optional piofile,
integer, dimension(:), intent(in), optional start,
integer, dimension(:), intent(in), optional total )

Definition at line 4994 of file mod_pio_netcdf.F.

4996!
4997!=======================================================================
4998! !
4999! This routine reads requested logical 1D-array variable from !
5000! specified NetCDF file. The variable can be stored as an !
5001! interger (0 or 1) or as a character ('T' or 'F'). Reading !
5002! a character variable is very inefficient in parallel I/O. !
5003! !
5004! On Input: !
5005! !
5006! ng Nested grid number (integer) !
5007! model Calling model identifier (integer) !
5008! ncname NetCDF file name (string) !
5009! myVarName Variable name (string) !
5010! pioFile PIO file descriptor, TYPE(File_desc_t), OPTIONAL !
5011! pioFile%fh file handler !
5012! pioFile%iosystem IO system descriptor (struct) !
5013! start Starting index where the first of the data values !
5014! will be read along each dimension (integer, !
5015! OPTIONAL) !
5016! total Number of data values to be read along each !
5017! dimension (integer, OPTIONAL) !
5018! !
5019! On Ouput: !
5020! !
5021! A Read 1D-array variable (logical) !
5022! !
5023! Examples: !
5024! !
5025! CALL pio_netcdf_get_lvar (ng, iNLM, 'f.nc', 'VarName', A) !
5026! CALL pio_netcdf_get_lvar (ng, iNLM, 'f.nc', 'VarName', A(0:)) !
5027! CALL pio_netcdf_get_lvar (ng, iNLM, 'f.nc', 'VarName', A(:,1)) !
5028! !
5029!=======================================================================
5030!
5031! Imported variable declarations.
5032!
5033 integer, intent(in) :: ng, model
5034
5035 integer, intent(in), optional :: start(:)
5036 integer, intent(in), optional :: total(:)
5037!
5038 character (len=*), intent(in) :: ncname
5039 character (len=*), intent(in) :: myVarName
5040!
5041 logical, intent(out) :: A(:)
5042!
5043 TYPE (File_desc_t), intent(in), optional :: pioFile
5044!
5045! Local variable declarations.
5046!
5047 integer :: i, my_type, status
5048
5049 integer, dimension(SIZE(A,1)) :: AI
5050!
5051 character (len=1), dimension(SIZE(A,1)) :: Achar
5052
5053 character (len=*), parameter :: MyFile = &
5054 & __FILE__//", pio_netcdf_get_lvar_1d"
5055!
5056 TYPE (File_desc_t) :: my_pioFile
5057 TYPE (Var_desc_t) :: my_pioVar
5058!
5059!-----------------------------------------------------------------------
5060! Read in an integer scalar variable.
5061!-----------------------------------------------------------------------
5062!
5063! If file descriptor is not provided, open NetCDF for reading.
5064!
5065 IF (.not.PRESENT(piofile)) THEN
5066 CALL pio_netcdf_open (ng, model, trim(ncname), 0, my_piofile)
5067 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
5068 ELSE
5069 my_piofile=piofile
5070 END IF
5071!
5072! Read in variable.
5073!
5074 status=pio_inq_varid(my_piofile, trim(myvarname), my_piovar)
5075 IF (status.eq.pio_noerr) THEN
5076 status=pio_inquire_variable(my_piofile, my_piovar, &
5077 & xtype = my_type)
5078 IF (status.eq.pio_noerr) THEN
5079 IF (my_type.eq.pio_int) THEN
5080 IF (PRESENT(start).and.PRESENT(total)) THEN
5081 status=pio_get_var(my_piofile, my_piovar, start, total, &
5082 & ai)
5083 ELSE
5084 status=pio_get_var(my_piofile, my_piovar, ai)
5085 END IF
5086 IF (status.eq.pio_noerr) THEN
5087 DO i=1,SIZE(a,1)
5088 IF (ai(i).eq.0) THEN
5089 a(i)=.false.
5090 ELSE
5091 a(i)=.true.
5092 END IF
5093 END DO
5094 END IF
5095 ELSE IF (my_type.eq.pio_char) THEN
5096 IF (PRESENT(start).and.PRESENT(total)) THEN
5097 status=pio_get_var(my_piofile, my_piovar, start, total, &
5098 & achar)
5099 ELSE
5100 status=pio_get_var(my_piofile, my_piovar, achar)
5101 END IF
5102 IF (status.eq.pio_noerr) THEN
5103 DO i=1,SIZE(a,1)
5104 a(i)=.false.
5105 IF ((achar(i).eq.'t').or.(achar(i).eq.'T')) THEN
5106 a(i)=.true.
5107 END IF
5108 END DO
5109 END IF
5110 END IF
5111 IF (founderror(status, pio_noerr, __line__, myfile)) THEN
5112 IF (master) WRITE (stdout,10) trim(myvarname), &
5113 & trim(ncname), &
5114 & trim(sourcefile)
5115 exit_flag=2
5116 ioerror=status
5117 END IF
5118 ELSE
5119 IF (master) WRITE (stdout,20) trim(myvarname), trim(ncname), &
5120 & trim(sourcefile)
5121 exit_flag=2
5122 ioerror=status
5123 END IF
5124 ELSE
5125 IF (master) WRITE (stdout,30) trim(myvarname), trim(ncname), &
5126 & trim(sourcefile)
5127 exit_flag=2
5128 ioerror=status
5129 END IF
5130!
5131! If file descriptor is not provided, close input NetCDF file.
5132!
5133 IF (.not.PRESENT(piofile)) THEN
5134 CALL pio_netcdf_close (ng, model, my_piofile, ncname, .false.)
5135 END IF
5136!
5137 10 FORMAT (/,' PIO_NETCDF_GET_LVAR_1D - error while reading ', &
5138 & 'variable:',2x,a,/,26x,'in input file:',2x,a, &
5139 & /,26x,'call from:',2x,a)
5140 20 FORMAT (/,' PIO_NETCDF_GET_LVAR_1D - error while inquiring ', &
5141 & 'type for variable:',2x,a,/,26x,'in input file:',2x,a, &
5142 & /,26x,'call from:',2x,a)
5143 30 FORMAT (/,' PIO_NETCDF_GET_LVAR_1D - error while inquiring ', &
5144 & ' descriptor for variable:',2x,a, &
5145 & /,26x,'in input file:',2x,a,/,26x,'call from:',2x,a)
5146!
5147 RETURN

References mod_scalars::exit_flag, strings_mod::founderror(), mod_iounits::ioerror, mod_parallel::master, mod_scalars::noerror, mod_pio_netcdf::pio_netcdf_close(), mod_pio_netcdf::pio_netcdf_open(), 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: