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

Public Member Functions

subroutine netcdf_put_lvar_0d (ng, model, ncname, myvarname, a, start, total, ncid, varid)
 
subroutine netcdf_put_lvar_1d (ng, model, ncname, myvarname, a, start, total, ncid, varid)
 
subroutine netcdf_put_lvar_2d (ng, model, ncname, myvarname, a, start, total, ncid, varid)
 

Detailed Description

Definition at line 102 of file mod_netcdf.F.

Member Function/Subroutine Documentation

◆ netcdf_put_lvar_0d()

subroutine mod_netcdf::netcdf_put_lvar::netcdf_put_lvar_0d ( integer, intent(in) ng,
integer, intent(in) model,
character (len=*), intent(in) ncname,
character (len=*), intent(in) myvarname,
logical, intent(in) a,
integer, dimension(:), intent(in) start,
integer, dimension(:), intent(in) total,
integer, intent(in), optional ncid,
integer, intent(in), optional varid )

Definition at line 7962 of file mod_netcdf.F.

7964!
7965!=======================================================================
7966! !
7967! This routine writes a logical scalar variable into a NetCDF file. !
7968! If the NetCDF ID is not provided, it opens the file, writes data, !
7969! and then closes the file. !
7970! !
7971! The input logical data is converted to integer such that .FALSE. !
7972! is interpreted as zero, and .TRUE. is interpreted as one. !
7973! !
7974! On Input: !
7975! !
7976! ng Nested grid number (integer) !
7977! model Calling model identifier (integer) !
7978! ncname NetCDF file name (string) !
7979! myVarName Variable name (string) !
7980! A Data value(s) to be written (logical) !
7981! start Starting index where the first of the data values !
7982! will be written along each dimension (integer) !
7983! total Number of data values to be written along each !
7984! dimension (integer) !
7985! ncid NetCDF file ID (integer, OPTIONAL) !
7986! varid NetCDF variable ID (integer, OPTIONAL) !
7987! !
7988! On Ouput: !
7989! !
7990! exit_flag Error flag (integer) stored in MOD_SCALARS !
7991! ioerror NetCDF return code (integer) stored in MOD_IOUNITS !
7992! !
7993! Notice: This routine must be used to write only nontiled variables. !
7994! !
7995!=======================================================================
7996!
7997! Imported variable declarations.
7998!
7999 integer, intent(in) :: ng, model
8000
8001 integer, intent(in) :: start(:), total(:)
8002
8003 integer, intent(in), optional :: ncid, varid
8004!
8005 logical, intent(in) :: A
8006!
8007 character (len=*), intent(in) :: ncname
8008 character (len=*), intent(in) :: myVarName
8009!
8010! Local variable declarations.
8011!
8012 integer :: my_ncid, my_varid, status
8013
8014 integer :: AI
8015 integer, dimension(1) :: my_AI
8016
8017#if !defined PARALLEL_IO && defined DISTRIBUTE
8018 integer, dimension(2) :: ibuffer
8019#endif
8020!
8021 character (len=*), parameter :: MyFile = &
8022 & __FILE__//", netcdf_put_lvar_0d"
8023!
8024!-----------------------------------------------------------------------
8025! Read in a floating-point scalar variable.
8026!-----------------------------------------------------------------------
8027!
8028! If file ID is not provided, open file for writing.
8029!
8030 IF (.not.PRESENT(ncid)) THEN
8031 CALL netcdf_open (ng, model, trim(ncname), 1, my_ncid)
8032 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
8033 ELSE
8034 my_ncid=ncid
8035 END IF
8036!
8037! If variable ID is not provided, inquire its value.
8038!
8039 IF (outthread) THEN
8040 IF (.not.PRESENT(varid)) THEN
8041 status=nf90_inq_varid(my_ncid, trim(myvarname), my_varid)
8042 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
8043 WRITE (stdout,10) trim(myvarname), trim(ncname), &
8044 & trim(sourcefile), nf90_strerror(status)
8045 exit_flag=3
8046 ioerror=status
8047 END IF
8048 ELSE
8049 my_varid=varid
8050 END IF
8051!
8052! Convert logical data to integer: .FALSE. is interpreted as zero, and
8053! .TRUE. is interpreted as one.
8054!
8055 IF (a) THEN
8056 ai=1
8057 ELSE
8058 ai=0
8059 END IF
8060!
8061! Write out logical data as integers.
8062!
8063 IF (exit_flag.eq.noerror) THEN
8064 IF ((start(1).eq.0).and.(total(1).eq.0)) THEN
8065 status=nf90_put_var(my_ncid, my_varid, ai)
8066 ELSE
8067 my_ai(1)=ai
8068 status=nf90_put_var(my_ncid, my_varid, my_ai, start, total)
8069 END IF
8070 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
8071 WRITE (stdout,20) trim(myvarname), trim(ncname), &
8072 & trim(sourcefile), nf90_strerror(status)
8073 exit_flag=3
8074 ioerror=status
8075 END IF
8076 END IF
8077 END IF
8078
8079#if !defined PARALLEL_IO && defined DISTRIBUTE
8080!
8081! Broadcast error flags to all processors in the group.
8082!
8083 ibuffer(1)=exit_flag
8084 ibuffer(2)=ioerror
8085 CALL mp_bcasti (ng, model, ibuffer)
8086 exit_flag=ibuffer(1)
8087 ioerror=ibuffer(2)
8088#endif
8089!
8090! Close file.
8091!
8092 IF (.not.PRESENT(ncid)) THEN
8093 CALL netcdf_close (ng, model, my_ncid, ncname, .false.)
8094 END IF
8095!
8096 10 FORMAT (/,' NETCDF_PUT_LVAR_0D - error while inquiring ID for ', &
8097 & 'variable:',2x,a,/,22x,'in input file:',2x,a,/,22x, &
8098 & 'call from:',2x,a,/,22x,a)
8099 20 FORMAT (/,' NETCDF_PUT_LVAR_0D - error while writing variable:', &
8100 & 2x,a,/,22x,'in input file:',2x,a,/,22x,'call from:',2x,a, &
8101 & /,22x,a)
8102!
8103 RETURN

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

Here is the call graph for this function:

◆ netcdf_put_lvar_1d()

subroutine mod_netcdf::netcdf_put_lvar::netcdf_put_lvar_1d ( integer, intent(in) ng,
integer, intent(in) model,
character (len=*), intent(in) ncname,
character (len=*), intent(in) myvarname,
logical, dimension(:), intent(in) a,
integer, dimension(:), intent(in) start,
integer, dimension(:), intent(in) total,
integer, intent(in), optional ncid,
integer, intent(in), optional varid )

Definition at line 8106 of file mod_netcdf.F.

8108!
8109!=======================================================================
8110! !
8111! This routine writes a logical 1D-array variable into a file. If !
8112! the NetCDF ID is not provided, it opens the file, writes data, !
8113! and then closes the file. !
8114! !
8115! The input logical data is converted to integer such that .FALSE. !
8116! is interpreted as zero, and .TRUE. is interpreted as one. !
8117! !
8118! On Input: !
8119! !
8120! ng Nested grid number (integer) !
8121! model Calling model identifier (integer) !
8122! ncname NetCDF file name (string) !
8123! myVarName Variable name (string) !
8124! A Data value(s) to be written (logical) !
8125! start Starting index where the first of the data values !
8126! will be written along each dimension (integer) !
8127! total Number of data values to be written along each !
8128! dimension (integer) !
8129! ncid NetCDF file ID (integer, OPTIONAL) !
8130! varid NetCDF variable ID (integer, OPTIONAL) !
8131! !
8132! On Ouput: !
8133! !
8134! exit_flag Error flag (integer) stored in MOD_SCALARS !
8135! ioerror NetCDF return code (integer) stored in MOD_IOUNITS !
8136! !
8137! Notice: This routine must be used to write only nontiled variables. !
8138! !
8139!=======================================================================
8140!
8141! Imported variable declarations.
8142!
8143 integer, intent(in) :: ng, model
8144
8145 integer, intent(in) :: start(:), total(:)
8146
8147 integer, intent(in), optional :: ncid, varid
8148!
8149 logical, intent(in) :: A(:)
8150!
8151 character (len=*), intent(in) :: ncname
8152 character (len=*), intent(in) :: myVarName
8153!
8154! Local variable declarations.
8155!
8156 integer :: i, my_ncid, my_varid, status
8157
8158 integer, dimension(SIZE(A,1)) :: AI
8159
8160#if !defined PARALLEL_IO && defined DISTRIBUTE
8161 integer, dimension(2) :: ibuffer
8162#endif
8163!
8164 character (len=*), parameter :: MyFile = &
8165 & __FILE__//", netcdf_put_lvar_1d"
8166!
8167!-----------------------------------------------------------------------
8168! Read in a floating-point scalar variable.
8169!-----------------------------------------------------------------------
8170!
8171! If file ID is not provided, open file for writing.
8172!
8173 IF (.not.PRESENT(ncid)) THEN
8174 CALL netcdf_open (ng, model, trim(ncname), 1, my_ncid)
8175 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
8176 ELSE
8177 my_ncid=ncid
8178 END IF
8179!
8180! If variable ID is not provided, inquire its value.
8181!
8182 IF (outthread) THEN
8183 IF (.not.PRESENT(varid)) THEN
8184 status=nf90_inq_varid(my_ncid, trim(myvarname), my_varid)
8185 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
8186 WRITE (stdout,10) trim(myvarname), trim(ncname), &
8187 & trim(sourcefile), nf90_strerror(status)
8188 exit_flag=3
8189 ioerror=status
8190 END IF
8191 ELSE
8192 my_varid=varid
8193 END IF
8194!
8195! Convert logical data to integer: .FALSE. is interpreted as zero, and
8196! .TRUE. is interpreted as one.
8197!
8198 DO i=1,SIZE(a,1)
8199 IF (a(i)) THEN
8200 ai(i)=1
8201 ELSE
8202 ai(i)=0
8203 END IF
8204 END DO
8205!
8206! Write out logical data as integers.
8207!
8208 IF (exit_flag.eq.noerror) THEN
8209 status=nf90_put_var(my_ncid, my_varid, ai, start, total)
8210 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
8211 WRITE (stdout,20) trim(myvarname), trim(ncname), &
8212 & trim(sourcefile), nf90_strerror(status)
8213 exit_flag=3
8214 ioerror=status
8215 END IF
8216 END IF
8217 END IF
8218
8219#if !defined PARALLEL_IO && defined DISTRIBUTE
8220!
8221! Broadcast error flags to all processors in the group.
8222!
8223 ibuffer(1)=exit_flag
8224 ibuffer(2)=ioerror
8225 CALL mp_bcasti (ng, model, ibuffer)
8226 exit_flag=ibuffer(1)
8227 ioerror=ibuffer(2)
8228#endif
8229!
8230! Close file.
8231!
8232 IF (.not.PRESENT(ncid)) THEN
8233 CALL netcdf_close (ng, model, my_ncid, ncname, .false.)
8234 END IF
8235!
8236 10 FORMAT (/,' NETCDF_PUT_LVAR_1D - error while inquiring ID for ', &
8237 & 'variable:',2x,a,/,22x,'in input file:',2x,a,/,22x, &
8238 & 'call from:',2x,a,/,22x,a)
8239 20 FORMAT (/,' NETCDF_PUT_LVAR_1D - error while writing variable:', &
8240 & 2x,a,/,22x,'in input file:',2x,a,/,22x,'call from:',2x,a, &
8241 & /,22x,a)
8242!
8243 RETURN

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

Here is the call graph for this function:

◆ netcdf_put_lvar_2d()

subroutine mod_netcdf::netcdf_put_lvar::netcdf_put_lvar_2d ( integer, intent(in) ng,
integer, intent(in) model,
character (len=*), intent(in) ncname,
character (len=*), intent(in) myvarname,
logical, dimension(:,:), intent(in) a,
integer, dimension(:), intent(in) start,
integer, dimension(:), intent(in) total,
integer, intent(in), optional ncid,
integer, intent(in), optional varid )

Definition at line 8246 of file mod_netcdf.F.

8248!
8249!=======================================================================
8250! !
8251! This routine writes a logical 2D-array variable into a file. If !
8252! the NetCDF ID is not provided, it opens the file, writes data, !
8253! and then closes the file. !
8254! !
8255! The input logical data is converted to integer such that .FALSE. !
8256! is interpreted as zero, and .TRUE. is interpreted as one. !
8257! !
8258! On Input: !
8259! !
8260! ng Nested grid number (integer) !
8261! model Calling model identifier (integer) !
8262! ncname NetCDF file name (string) !
8263! myVarName Variable name (string) !
8264! A Data value(s) to be written (logical) !
8265! start Starting index where the first of the data values !
8266! will be written along each dimension (integer) !
8267! total Number of data values to be written along each !
8268! dimension (integer) !
8269! ncid NetCDF file ID (integer, OPTIONAL) !
8270! varid NetCDF variable ID (integer, OPTIONAL) !
8271! !
8272! On Ouput: !
8273! !
8274! exit_flag Error flag (integer) stored in MOD_SCALARS !
8275! ioerror NetCDF return code (integer) stored in MOD_IOUNITS !
8276! !
8277! Notice: This routine must be used to write only nontiled variables. !
8278! !
8279!=======================================================================
8280!
8281! Imported variable declarations.
8282!
8283 integer, intent(in) :: ng, model
8284
8285 integer, intent(in) :: start(:), total(:)
8286
8287 integer, intent(in), optional :: ncid, varid
8288!
8289 logical, intent(in) :: A(:,:)
8290!
8291 character (len=*), intent(in) :: ncname
8292 character (len=*), intent(in) :: myVarName
8293!
8294! Local variable declarations.
8295!
8296 integer :: i, j, my_ncid, my_varid, status
8297
8298 integer, dimension(SIZE(A,1),SIZE(A,2)) :: AI
8299
8300#if !defined PARALLEL_IO && defined DISTRIBUTE
8301 integer, dimension(2) :: ibuffer
8302#endif
8303!
8304 character (len=*), parameter :: MyFile = &
8305 & __FILE__//", netcdf_put_lvar_2d"
8306!
8307!-----------------------------------------------------------------------
8308! Read in a floating-point scalar variable.
8309!-----------------------------------------------------------------------
8310!
8311! If file ID is not provided, open file for writing.
8312!
8313 IF (.not.PRESENT(ncid)) THEN
8314 CALL netcdf_open (ng, model, trim(ncname), 1, my_ncid)
8315 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
8316 ELSE
8317 my_ncid=ncid
8318 END IF
8319!
8320! If variable ID is not provided, inquire its value.
8321!
8322 IF (outthread) THEN
8323 IF (.not.PRESENT(varid)) THEN
8324 status=nf90_inq_varid(my_ncid, trim(myvarname), my_varid)
8325 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
8326 WRITE (stdout,10) trim(myvarname), trim(ncname), &
8327 & trim(sourcefile), nf90_strerror(status)
8328 exit_flag=3
8329 ioerror=status
8330 END IF
8331 ELSE
8332 my_varid=varid
8333 END IF
8334!
8335! Convert logical data to integer: .FALSE. is interpreted as zero, and
8336! .TRUE. is interpreted as one.
8337!
8338 DO j=1,SIZE(a,2)
8339 DO i=1,SIZE(a,1)
8340 IF (a(i,j)) THEN
8341 ai(i,j)=1
8342 ELSE
8343 ai(i,j)=0
8344 END IF
8345 END DO
8346 END DO
8347!
8348! Write out logical data as integers.
8349!
8350 IF (exit_flag.eq.noerror) THEN
8351 status=nf90_put_var(my_ncid, my_varid, ai, start, total)
8352 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
8353 WRITE (stdout,20) trim(myvarname), trim(ncname), &
8354 & trim(sourcefile), nf90_strerror(status)
8355 exit_flag=3
8356 ioerror=status
8357 END IF
8358 END IF
8359 END IF
8360
8361#if !defined PARALLEL_IO && defined DISTRIBUTE
8362!
8363! Broadcast error flags to all processors in the group.
8364!
8365 ibuffer(1)=exit_flag
8366 ibuffer(2)=ioerror
8367 CALL mp_bcasti (ng, model, ibuffer)
8368 exit_flag=ibuffer(1)
8369 ioerror=ibuffer(2)
8370#endif
8371!
8372! Close file.
8373!
8374 IF (.not.PRESENT(ncid)) THEN
8375 CALL netcdf_close (ng, model, my_ncid, ncname, .false.)
8376 END IF
8377!
8378 10 FORMAT (/,' NETCDF_PUT_LVAR_2D - error while inquiring ID for ', &
8379 & 'variable:',2x,a,/,22x,'in input file:',2x,a,/,22x, &
8380 & 'call from:',2x,a,/,22x,a)
8381 20 FORMAT (/,' NETCDF_PUT_LVAR_2D - error while writing variable:', &
8382 & 2x,a,/,22x,'in input file:',2x,a,/,22x,'call from:',2x,a, &
8383 & /,22x,a)
8384!
8385 RETURN

References mod_scalars::exit_flag, mod_iounits::ioerror, mod_netcdf::netcdf_close(), mod_netcdf::netcdf_open(), mod_scalars::noerror, mod_parallel::outthread, 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: