4996
 4997
 4998
 4999
 5000
 5001
 5002
 5003
 5004
 5005
 5006
 5007
 5008
 5009
 5010
 5011
 5012
 5013
 5014
 5015
 5016
 5017
 5018
 5019
 5020
 5021
 5022
 5023
 5024
 5025
 5026
 5027
 5028
 5029
 5030
 5031
 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
 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
 5061
 5062
 5063
 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
 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
 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