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

Public Member Functions

subroutine netcdf_put_svar_0d (ng, model, ncname, myvarname, a, start, total, ncid, varid)
 
subroutine netcdf_put_svar_1d (ng, model, ncname, myvarname, a, start, total, ncid, varid)
 
subroutine netcdf_put_svar_2d (ng, model, ncname, myvarname, a, start, total, ncid, varid)
 
subroutine netcdf_put_svar_3d (ng, model, ncname, myvarname, a, start, total, ncid, varid)
 

Detailed Description

Definition at line 108 of file mod_netcdf.F.

Member Function/Subroutine Documentation

◆ netcdf_put_svar_0d()

subroutine mod_netcdf::netcdf_put_svar::netcdf_put_svar_0d ( integer, intent(in) ng,
integer, intent(in) model,
character (len=*), intent(in) ncname,
character (len=*), intent(in) myvarname,
character (len=*), 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 8388 of file mod_netcdf.F.

8390!
8391!=======================================================================
8392! !
8393! This routine writes a string scalar variable into a file. If !
8394! the NetCDF ID is not provided, it opens the file, writes data, !
8395! and then closes the file. The CDL of the scalar variable has !
8396! one-dimension in the NetCDF file for the number of characters: !
8397! !
8398! char string(Nchars) CDL !
8399! !
8400! character (len=Nchars) :: string F90 !
8401! !
8402! to write a scalar string use: !
8403! !
8404! start = (/1/) !
8405! total = (/Nchars/) !
8406! !
8407! On Input: !
8408! !
8409! ng Nested grid number (integer) !
8410! model Calling model identifier (integer) !
8411! ncname NetCDF file name (string) !
8412! myVarName Variable name (string) !
8413! A Data value(s) to be written (string) !
8414! start Starting index where the first of the data values !
8415! will be written along each dimension (1D vector !
8416! integer) !
8417! total Number of data values to be written along each !
8418! dimension (1D vector integer) !
8419! ncid NetCDF file ID (integer, OPTIONAL) !
8420! varid NetCDF variable ID (integer, OPTIONAL) !
8421! !
8422! On Ouput: !
8423! !
8424! exit_flag Error flag (integer) stored in MOD_SCALARS !
8425! ioerror NetCDF return code (integer) stored in MOD_IOUNITS !
8426! !
8427!=======================================================================
8428!
8429! Imported variable declarations.
8430!
8431 integer, intent(in) :: ng, model
8432
8433 integer, intent(in) :: start(:), total(:)
8434
8435 integer, intent(in), optional :: ncid, varid
8436!
8437 character (len=*), intent(in) :: A
8438 character (len=*), intent(in) :: ncname
8439 character (len=*), intent(in) :: myVarName
8440!
8441! Local variable declarations.
8442!
8443 integer :: my_ncid, my_varid, status
8444
8445#if !defined PARALLEL_IO && defined DISTRIBUTE
8446 integer, dimension(2) :: ibuffer
8447#endif
8448!
8449 character (len=LEN(A)), dimension(1) :: my_A
8450
8451 character (len=*), parameter :: MyFile = &
8452 & __FILE__//", netcdf_put_svar_0d"
8453!
8454!-----------------------------------------------------------------------
8455! Write out a scalar string.
8456!-----------------------------------------------------------------------
8457!
8458! If file ID is not provided, open file for writing.
8459!
8460 IF (.not.PRESENT(ncid)) THEN
8461 CALL netcdf_open (ng, model, trim(ncname), 1, my_ncid)
8462 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
8463 ELSE
8464 my_ncid=ncid
8465 END IF
8466!
8467! If variable ID is not provided, inquire its value.
8468!
8469 IF (outthread) THEN
8470 IF (.not.PRESENT(varid)) THEN
8471 status=nf90_inq_varid(my_ncid, trim(myvarname), my_varid)
8472 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
8473 WRITE (stdout,10) trim(myvarname), trim(ncname), &
8474 & trim(sourcefile), nf90_strerror(status)
8475 exit_flag=3
8476 ioerror=status
8477 END IF
8478 ELSE
8479 my_varid=varid
8480 END IF
8481!
8482! Write out data.
8483!
8484 IF (exit_flag.eq.noerror) THEN
8485 IF ((start(1).eq.1).and.(total(1).eq.1)) THEN
8486 status=nf90_put_var(my_ncid, my_varid, a)
8487 ELSE
8488 my_a(1)=a
8489 status=nf90_put_var(my_ncid, my_varid, my_a, start, total)
8490 END IF
8491 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
8492 WRITE (stdout,20) trim(myvarname), trim(ncname), &
8493 & trim(sourcefile), nf90_strerror(status)
8494 exit_flag=3
8495 ioerror=status
8496 END IF
8497 END IF
8498 END IF
8499
8500#if !defined PARALLEL_IO && defined DISTRIBUTE
8501!
8502! Broadcast error flags to all processors in the group.
8503!
8504 ibuffer(1)=exit_flag
8505 ibuffer(2)=ioerror
8506 CALL mp_bcasti (ng, model, ibuffer)
8507 exit_flag=ibuffer(1)
8508 ioerror=ibuffer(2)
8509#endif
8510!
8511! Close input NetCDF file.
8512!
8513 IF (.not.PRESENT(ncid)) THEN
8514 CALL netcdf_close (ng, model, my_ncid, ncname, .false.)
8515 END IF
8516!
8517 10 FORMAT (/,' NETCDF_PUT_SVAR_0D - error while inquiring ID for ', &
8518 & 'variable:',2x,a,/,22x,'in input file:',2x,a,/,22x, &
8519 & 'call from:',2x,a,/,22x,a)
8520 20 FORMAT (/,' NETCDF_PUT_SVAR_0D - error while writing variable:', &
8521 & 2x,a,/,22x,'in input file:',2x,a,/,22x,'call from:',2x,a, &
8522 & /,22x,a)
8523!
8524 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_svar_1d()

subroutine mod_netcdf::netcdf_put_svar::netcdf_put_svar_1d ( integer, intent(in) ng,
integer, intent(in) model,
character (len=*), intent(in) ncname,
character (len=*), intent(in) myvarname,
character (len=*), 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 8527 of file mod_netcdf.F.

8529!
8530!=======================================================================
8531! !
8532! This routine writes a string 1D-array variable into a file. If !
8533! the NetCDF ID is not provided, it opens the file, writes data, !
8534! and then closes the file. The CDL of the 1D-array variable has !
8535! two-dimensions in the NetCDF file, and the first dimension is !
8536! the number of characters: !
8537! !
8538! char string(dim1, Nchars) CDL !
8539! !
8540! character (len=Nchars) :: string(dim1) F90 !
8541! !
8542! to write a single array element at location (i) use: !
8543! !
8544! start = (/1, i/) !
8545! total = (/Nchars, 1/) !
8546! !
8547! On Input: !
8548! !
8549! ng Nested grid number (integer) !
8550! model Calling model identifier (integer) !
8551! ncname NetCDF file name (string) !
8552! myVarName Variable name (string) !
8553! A Data value(s) to be written (1D string array) !
8554! start Starting index where the first of the data values !
8555! will be written along each dimension (2D vector !
8556! integer) !
8557! total Number of data values to be written along each !
8558! dimension (2D vector integer) !
8559! ncid NetCDF file ID (integer, OPTIONAL) !
8560! varid NetCDF variable ID (integer, OPTIONAL) !
8561! !
8562! On Ouput: !
8563! !
8564! exit_flag Error flag (integer) stored in MOD_SCALARS !
8565! ioerror NetCDF return code (integer) stored in MOD_IOUNITS !
8566! !
8567!=======================================================================
8568!
8569! Imported variable declarations.
8570!
8571 integer, intent(in) :: ng, model
8572
8573 integer, intent(in) :: start(:), total(:)
8574
8575 integer, intent(in), optional :: ncid, varid
8576!
8577 character (len=*), intent(in) :: A(:)
8578
8579 character (len=*), intent(in) :: ncname
8580 character (len=*), intent(in) :: myVarName
8581!
8582! Local variable declarations.
8583!
8584 integer :: my_ncid, my_varid, status
8585
8586#if !defined PARALLEL_IO && defined DISTRIBUTE
8587 integer, dimension(2) :: ibuffer
8588#endif
8589!
8590 character (len=*), parameter :: MyFile = &
8591 & __FILE__//", netcdf_put_svar_1d"
8592!
8593!-----------------------------------------------------------------------
8594! Write out a string 1D array or array element.
8595!-----------------------------------------------------------------------
8596!
8597! If NetCDF file ID is not provided, open NetCDF for writing.
8598!
8599 IF (.not.PRESENT(ncid)) THEN
8600 CALL netcdf_open (ng, model, trim(ncname), 1, my_ncid)
8601 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
8602 ELSE
8603 my_ncid=ncid
8604 END IF
8605!
8606! If variable ID is not provided, inquire its value.
8607!
8608 IF (outthread) THEN
8609 IF (.not.PRESENT(varid)) THEN
8610 status=nf90_inq_varid(my_ncid, trim(myvarname), my_varid)
8611 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
8612 WRITE (stdout,10) trim(myvarname), trim(ncname), &
8613 & trim(sourcefile), nf90_strerror(status)
8614 exit_flag=3
8615 ioerror=status
8616 END IF
8617 ELSE
8618 my_varid=varid
8619 END IF
8620!
8621! Write out data.
8622!
8623 IF (exit_flag.eq.noerror) THEN
8624 status=nf90_put_var(my_ncid, my_varid, a, start, total)
8625 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
8626 WRITE (stdout,20) trim(myvarname), trim(ncname), &
8627 & trim(sourcefile), nf90_strerror(status)
8628 exit_flag=3
8629 ioerror=status
8630 END IF
8631 END IF
8632 END IF
8633
8634#if !defined PARALLEL_IO && defined DISTRIBUTE
8635!
8636! Broadcast error flags to all processors in the group.
8637!
8638 ibuffer(1)=exit_flag
8639 ibuffer(2)=ioerror
8640 CALL mp_bcasti (ng, model, ibuffer)
8641 exit_flag=ibuffer(1)
8642 ioerror=ibuffer(2)
8643#endif
8644!
8645! Close input NetCDF file.
8646!
8647 IF (.not.PRESENT(ncid)) THEN
8648 CALL netcdf_close (ng, model, my_ncid, ncname, .false.)
8649 END IF
8650!
8651 10 FORMAT (/,' NETCDF_PUT_SVAR_1D - error while inquiring ID for ', &
8652 & 'variable:',2x,a,/,22x,'in input file:',2x,a,/,22x, &
8653 & 'call from:',2x,a,/,22x,a)
8654 20 FORMAT (/,' NETCDF_PUT_SVAR_1D - error while writing variable:', &
8655 & 2x,a,/,22x,'in input file:',2x,a,/,22x,'call from:',2x,a, &
8656 & /,22x,a)
8657!
8658 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_svar_2d()

subroutine mod_netcdf::netcdf_put_svar::netcdf_put_svar_2d ( integer, intent(in) ng,
integer, intent(in) model,
character (len=*), intent(in) ncname,
character (len=*), intent(in) myvarname,
character (len=*), 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 8661 of file mod_netcdf.F.

8663!
8664!=======================================================================
8665! !
8666! This routine writes a string 2D-array variable into a file. If !
8667! the NetCDF ID is not provided, it opens the file, writes data, !
8668! and then closes the file. The CDL of the 2D-array variable has !
8669! three-dimensions in the NetCDF file, and the first dimension is !
8670! the number of characters: !
8671! !
8672! char string(dim2, dim1, Nchars) CDL !
8673! !
8674! character (len=Nchars) :: string(dim1, dim2) F90 !
8675! !
8676! to write a single array element at location (i,j) use: !
8677! !
8678! start = (/1, i, j/) !
8679! total = (/Nchars, 1, 1/) !
8680! !
8681! On Input: !
8682! !
8683! ng Nested grid number (integer) !
8684! model Calling model identifier (integer) !
8685! ncname NetCDF file name (string) !
8686! myVarName Variable name (string) !
8687! A Data value(s) to be written (2D string array) !
8688! start Starting index where the first of the data values !
8689! will be written along each dimension (3D vector !
8690! integer) !
8691! total Number of data values to be written along each !
8692! dimension (3D vector integer) !
8693! ncid NetCDF file ID (integer, OPTIONAL) !
8694! varid NetCDF variable ID (integer, OPTIONAL) !
8695! !
8696! On Ouput: !
8697! !
8698! exit_flag Error flag (integer) stored in MOD_SCALARS !
8699! ioerror NetCDF return code (integer) stored in MOD_IOUNITS !
8700! !
8701!=======================================================================
8702!
8703! Imported variable declarations.
8704!
8705 integer, intent(in) :: ng, model
8706
8707 integer, intent(in) :: start(:), total(:)
8708
8709 integer, intent(in), optional :: ncid, varid
8710!
8711 character (len=*), intent(in) :: A(:,:)
8712
8713 character (len=*), intent(in) :: ncname
8714 character (len=*), intent(in) :: myVarName
8715!
8716! Local variable declarations.
8717!
8718 integer :: my_ncid, my_varid, status
8719
8720#if !defined PARALLEL_IO && defined DISTRIBUTE
8721 integer, dimension(2) :: ibuffer
8722#endif
8723!
8724 character (len=*), parameter :: MyFile = &
8725 & __FILE__//", netcdf_put_svar_2d"
8726!
8727!-----------------------------------------------------------------------
8728! Write out a string array element or full 2D array.
8729!-----------------------------------------------------------------------
8730!
8731! If NetCDF file ID is not provided, open NetCDF for writing.
8732!
8733 IF (.not.PRESENT(ncid)) THEN
8734 CALL netcdf_open (ng, model, trim(ncname), 1, my_ncid)
8735 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
8736 ELSE
8737 my_ncid=ncid
8738 END IF
8739!
8740! If variable ID is not provided, inquire its value.
8741!
8742 IF (outthread) THEN
8743 IF (.not.PRESENT(varid)) THEN
8744 status=nf90_inq_varid(my_ncid, trim(myvarname), my_varid)
8745 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
8746 WRITE (stdout,10) trim(myvarname), trim(ncname), &
8747 & trim(sourcefile), nf90_strerror(status)
8748 exit_flag=3
8749 ioerror=status
8750 END IF
8751 ELSE
8752 my_varid=varid
8753 END IF
8754!
8755! Write out data.
8756!
8757 IF (exit_flag.eq.noerror) THEN
8758 status=nf90_put_var(my_ncid, my_varid, a, start, total)
8759 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
8760 WRITE (stdout,20) trim(myvarname), trim(ncname), &
8761 & trim(sourcefile), nf90_strerror(status)
8762 exit_flag=3
8763 ioerror=status
8764 END IF
8765 END IF
8766 END IF
8767
8768#if !defined PARALLEL_IO && defined DISTRIBUTE
8769!
8770! Broadcast error flags to all processors in the group.
8771!
8772 ibuffer(1)=exit_flag
8773 ibuffer(2)=ioerror
8774 CALL mp_bcasti (ng, model, ibuffer)
8775 exit_flag=ibuffer(1)
8776 ioerror=ibuffer(2)
8777#endif
8778!
8779! Close input NetCDF file.
8780!
8781 IF (.not.PRESENT(ncid)) THEN
8782 CALL netcdf_close (ng, model, my_ncid, ncname, .false.)
8783 END IF
8784!
8785 10 FORMAT (/,' NETCDF_PUT_SVAR_2D - error while inquiring ID for ', &
8786 & 'variable:',2x,a,/,22x,'in input file:',2x,a,/,22x, &
8787 & 'call from:',2x,a,/,22x,a)
8788 20 FORMAT (/,' NETCDF_PUT_SVAR_2D - error while writing variable:', &
8789 & 2x,a,/,22x,'in input file:',2x,a,/,22x,'call from:',2x,a, &
8790 & /,22x,a)
8791!
8792 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_svar_3d()

subroutine mod_netcdf::netcdf_put_svar::netcdf_put_svar_3d ( integer, intent(in) ng,
integer, intent(in) model,
character (len=*), intent(in) ncname,
character (len=*), intent(in) myvarname,
character (len=*), 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 8795 of file mod_netcdf.F.

8797!
8798!=======================================================================
8799! !
8800! This routine writes a string 3D-array variable into a file. If !
8801! the NetCDF ID is not provided, it opens the file, writes data, !
8802! and then closes the file. The CDL of the 3D-array variable has !
8803! four-dimensions in the NetCDF file, and the first dimension is !
8804! the number of characters: !
8805! !
8806! char string(dim3, dim2, dim1, Nchars) CDL !
8807! !
8808! character (len=Nchars) :: string(dim1, dim2, dim3) F90 !
8809! !
8810! to write a single array element at location (i,j,k) use: !
8811! !
8812! start = (/1, i, j, k/) !
8813! total = (/Nchars, 1, 1, 1/) !
8814! !
8815! On Input: !
8816! !
8817! ng Nested grid number (integer) !
8818! model Calling model identifier (integer) !
8819! ncname NetCDF file name (string) !
8820! myVarName Variable name (string) !
8821! A Data value(s) to be written (3D string array) !
8822! start Starting index where the first of the data values !
8823! will be written along each dimension (4D vector !
8824! integer) !
8825! total Number of data values to be written along each !
8826! dimension (4D vector integer) !
8827! ncid NetCDF file ID (integer, OPTIONAL) !
8828! varid NetCDF variable ID (integer, OPTIONAL) !
8829! !
8830! On Ouput: !
8831! !
8832! exit_flag Error flag (integer) stored in MOD_SCALARS !
8833! ioerror NetCDF return code (integer) stored in MOD_IOUNITS !
8834! !
8835!=======================================================================
8836!
8837! Imported variable declarations.
8838!
8839 integer, intent(in) :: ng, model
8840
8841 integer, intent(in) :: start(:), total(:)
8842
8843 integer, intent(in), optional :: ncid, varid
8844!
8845 character (len=*), intent(in) :: A(:,:,:)
8846
8847 character (len=*), intent(in) :: ncname
8848 character (len=*), intent(in) :: myVarName
8849!
8850! Local variable declarations.
8851!
8852 integer :: my_ncid, my_varid, status
8853
8854#if !defined PARALLEL_IO && defined DISTRIBUTE
8855 integer, dimension(2) :: ibuffer
8856#endif
8857!
8858 character (len=*), parameter :: MyFile = &
8859 & __FILE__//", netcdf_put_svar_3d"
8860!
8861!-----------------------------------------------------------------------
8862! Write out a string array element or full 3D array.
8863!-----------------------------------------------------------------------
8864!
8865! If NetCDF file ID is not provided, open NetCDF for writing.
8866!
8867 IF (.not.PRESENT(ncid)) THEN
8868 CALL netcdf_open (ng, model, trim(ncname), 1, my_ncid)
8869 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
8870 ELSE
8871 my_ncid=ncid
8872 END IF
8873!
8874! If variable ID is not provided, inquire its value.
8875!
8876 IF (outthread) THEN
8877 IF (.not.PRESENT(varid)) THEN
8878 status=nf90_inq_varid(my_ncid, trim(myvarname), my_varid)
8879 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
8880 WRITE (stdout,10) trim(myvarname), trim(ncname), &
8881 & trim(sourcefile), nf90_strerror(status)
8882 exit_flag=3
8883 ioerror=status
8884 END IF
8885 ELSE
8886 my_varid=varid
8887 END IF
8888!
8889! Write out data.
8890!
8891 IF (exit_flag.eq.noerror) THEN
8892 status=nf90_put_var(my_ncid, my_varid, a, start, total)
8893 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
8894 WRITE (stdout,20) trim(myvarname), trim(ncname), &
8895 & trim(sourcefile), nf90_strerror(status)
8896 exit_flag=3
8897 ioerror=status
8898 END IF
8899 END IF
8900 END IF
8901
8902#if !defined PARALLEL_IO && defined DISTRIBUTE
8903!
8904! Broadcast error flags to all processors in the group.
8905!
8906 ibuffer(1)=exit_flag
8907 ibuffer(2)=ioerror
8908 CALL mp_bcasti (ng, model, ibuffer)
8909 exit_flag=ibuffer(1)
8910 ioerror=ibuffer(2)
8911#endif
8912!
8913! Close input NetCDF file.
8914!
8915 IF (.not.PRESENT(ncid)) THEN
8916 CALL netcdf_close (ng, model, my_ncid, ncname, .false.)
8917 END IF
8918!
8919 10 FORMAT (/,' NETCDF_PUT_SVAR_3D - error while inquiring ID for ', &
8920 & 'variable:',2x,a,/,22x,'in input file:',2x,a,/,22x, &
8921 & 'call from:',2x,a,/,22x,a)
8922 20 FORMAT (/,' NETCDF_PUT_SVAR_3D - error while writing variable:', &
8923 & 2x,a,/,22x,'in input file:',2x,a,/,22x,'call from:',2x,a, &
8924 & /,22x,a)
8925!
8926 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: