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

Public Member Functions

subroutine netcdf_put_ivar_0d (ng, model, ncname, myvarname, a, start, total, ncid, varid)
 
subroutine netcdf_put_ivar_1d (ng, model, ncname, myvarname, a, start, total, ncid, varid)
 
subroutine netcdf_put_ivar_2d (ng, model, ncname, myvarname, a, start, total, ncid, varid)
 

Detailed Description

Definition at line 96 of file mod_netcdf.F.

Member Function/Subroutine Documentation

◆ netcdf_put_ivar_0d()

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

7585!
7586!=======================================================================
7587! !
7588! This routine writes a integer scalar variable into a NetCDF file. !
7589! If the NetCDF ID is not provided, it opens the file, writes data, !
7590! and then closes the file. !
7591! !
7592! On Input: !
7593! !
7594! ng Nested grid number (integer) !
7595! model Calling model identifier (integer) !
7596! ncname NetCDF file name (string) !
7597! myVarName Variable name (string) !
7598! A Data value(s) to be written (integer) !
7599! start Starting index where the first of the data values !
7600! will be written along each dimension (integer) !
7601! total Number of data values to be written along each !
7602! dimension (integer) !
7603! ncid NetCDF file ID (integer, OPTIONAL) !
7604! varid NetCDF variable ID (integer, OPTIONAL) !
7605! !
7606! On Ouput: !
7607! !
7608! exit_flag Error flag (integer) stored in MOD_SCALARS !
7609! ioerror NetCDF return code (integer) stored in MOD_IOUNITS !
7610! !
7611! Notice: This routine must be used to write only nontiled variables. !
7612! !
7613!=======================================================================
7614!
7615! Imported variable declarations.
7616!
7617 integer, intent(in) :: ng, model
7618
7619 integer, intent(in) :: start(:), total(:)
7620
7621 integer, intent(in), optional :: ncid, varid
7622
7623 integer, intent(in) :: A
7624!
7625 character (len=*), intent(in) :: ncname
7626 character (len=*), intent(in) :: myVarName
7627!
7628! Local variable declarations.
7629!
7630 integer :: my_ncid, my_varid, status
7631
7632 integer, dimension(1) :: my_A
7633
7634#if !defined PARALLEL_IO && defined DISTRIBUTE
7635 integer, dimension(2) :: ibuffer
7636#endif
7637!
7638 character (len=*), parameter :: MyFile = &
7639 & __FILE__//", netcdf_put_ivar_0d"
7640!
7641!-----------------------------------------------------------------------
7642! Read in a floating-point scalar variable.
7643!-----------------------------------------------------------------------
7644!
7645! If file ID is not provided, open file for writing.
7646!
7647 IF (.not.PRESENT(ncid)) THEN
7648 CALL netcdf_open (ng, model, trim(ncname), 1, my_ncid)
7649 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
7650 ELSE
7651 my_ncid=ncid
7652 END IF
7653!
7654! If variable ID is not provided, inquire its value.
7655!
7656 IF (outthread) THEN
7657 IF (.not.PRESENT(varid)) THEN
7658 status=nf90_inq_varid(my_ncid, trim(myvarname), my_varid)
7659 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
7660 WRITE (stdout,10) trim(myvarname), trim(ncname), &
7661 & trim(sourcefile), nf90_strerror(status)
7662 exit_flag=3
7663 ioerror=status
7664 END IF
7665 ELSE
7666 my_varid=varid
7667 END IF
7668!
7669! Write out data.
7670!
7671 IF (exit_flag.eq.noerror) THEN
7672 IF ((start(1).eq.0).and.(total(1).eq.0)) THEN
7673 status=nf90_put_var(my_ncid, my_varid, a)
7674 ELSE
7675 my_a(1)=a
7676 status=nf90_put_var(my_ncid, my_varid, my_a, start, total)
7677 END IF
7678 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
7679 WRITE (stdout,20) trim(myvarname), trim(ncname), &
7680 & trim(sourcefile), nf90_strerror(status)
7681 exit_flag=3
7682 ioerror=status
7683 END IF
7684 END IF
7685 END IF
7686
7687#if !defined PARALLEL_IO && defined DISTRIBUTE
7688!
7689! Broadcast error flags to all processors in the group.
7690!
7691 ibuffer(1)=exit_flag
7692 ibuffer(2)=ioerror
7693 CALL mp_bcasti (ng, model, ibuffer)
7694 exit_flag=ibuffer(1)
7695 ioerror=ibuffer(2)
7696#endif
7697!
7698! Close file.
7699!
7700 IF (.not.PRESENT(ncid)) THEN
7701 CALL netcdf_close (ng, model, my_ncid, ncname, .false.)
7702 END IF
7703!
7704 10 FORMAT (/,' NETCDF_PUT_IVAR_0D - error while inquiring ID for ', &
7705 & 'variable:',2x,a,/,22x,'in input file:',2x,a,/,22x, &
7706 & 'call from:',2x,a,/,22x,a)
7707 20 FORMAT (/,' NETCDF_PUT_IVAR_0D - error while writing variable:', &
7708 & 2x,a,/,22x,'in input file:',2x,a,/,22x,'call from:',2x,a, &
7709 & /,22x,a)
7710!
7711 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_ivar_1d()

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

7716!
7717!=======================================================================
7718! !
7719! This routine writes a integer 1D-array variable into a file. If !
7720! the NetCDF ID is not provided, it opens the file, writes data, !
7721! and then closes the file. !
7722! !
7723! On Input: !
7724! !
7725! ng Nested grid number (integer) !
7726! model Calling model identifier (integer) !
7727! ncname NetCDF file name (string) !
7728! myVarName Variable name (string) !
7729! A Data value(s) to be written (integer) !
7730! start Starting index where the first of the data values !
7731! will be written along each dimension (integer) !
7732! total Number of data values to be written along each !
7733! dimension (integer) !
7734! ncid NetCDF file ID (integer, OPTIONAL) !
7735! varid NetCDF variable ID (integer, OPTIONAL) !
7736! !
7737! On Ouput: !
7738! !
7739! exit_flag Error flag (integer) stored in MOD_SCALARS !
7740! ioerror NetCDF return code (integer) stored in MOD_IOUNITS !
7741! !
7742! Notice: This routine must be used to write only nontiled variables. !
7743! !
7744!=======================================================================
7745!
7746! Imported variable declarations.
7747!
7748 integer, intent(in) :: ng, model
7749
7750 integer, intent(in) :: start(:), total(:)
7751
7752 integer, intent(in), optional :: ncid, varid
7753
7754 integer, intent(in) :: A(:)
7755!
7756 character (len=*), intent(in) :: ncname
7757 character (len=*), intent(in) :: myVarName
7758!
7759! Local variable declarations.
7760!
7761 integer :: my_ncid, my_varid, status
7762
7763#if !defined PARALLEL_IO && defined DISTRIBUTE
7764 integer, dimension(2) :: ibuffer
7765#endif
7766!
7767 character (len=*), parameter :: MyFile = &
7768 & __FILE__//", netcdf_put_ivar_1d"
7769!
7770!-----------------------------------------------------------------------
7771! Read in a floating-point scalar variable.
7772!-----------------------------------------------------------------------
7773!
7774! If file ID is not provided, open file for writing.
7775!
7776 IF (.not.PRESENT(ncid)) THEN
7777 CALL netcdf_open (ng, model, trim(ncname), 1, my_ncid)
7778 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
7779 ELSE
7780 my_ncid=ncid
7781 END IF
7782!
7783! If variable ID is not provided, inquire its value.
7784!
7785 IF (outthread) THEN
7786 IF (.not.PRESENT(varid)) THEN
7787 status=nf90_inq_varid(my_ncid, trim(myvarname), my_varid)
7788 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
7789 WRITE (stdout,10) trim(myvarname), trim(ncname), &
7790 & trim(sourcefile), nf90_strerror(status)
7791 exit_flag=3
7792 ioerror=status
7793 END IF
7794 ELSE
7795 my_varid=varid
7796 END IF
7797!
7798! Write out data.
7799!
7800 IF (exit_flag.eq.noerror) THEN
7801 status=nf90_put_var(my_ncid, my_varid, a, start, total)
7802 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
7803 WRITE (stdout,20) trim(myvarname), trim(ncname), &
7804 & trim(sourcefile), nf90_strerror(status)
7805 exit_flag=3
7806 ioerror=status
7807 END IF
7808 END IF
7809 END IF
7810
7811#if !defined PARALLEL_IO && defined DISTRIBUTE
7812!
7813! Broadcast error flags to all processors in the group.
7814!
7815 ibuffer(1)=exit_flag
7816 ibuffer(2)=ioerror
7817 CALL mp_bcasti (ng, model, ibuffer)
7818 exit_flag=ibuffer(1)
7819 ioerror=ibuffer(2)
7820#endif
7821!
7822! Close file.
7823!
7824 IF (.not.PRESENT(ncid)) THEN
7825 CALL netcdf_close (ng, model, my_ncid, ncname, .false.)
7826 END IF
7827!
7828 10 FORMAT (/,' NETCDF_PUT_IVAR_1D - error while inquiring ID for ', &
7829 & 'variable:',2x,a,/,22x,'in input file:',2x,a,/,22x, &
7830 & 'call from:',2x,a,/,22x,a)
7831 20 FORMAT (/,' NETCDF_PUT_IVAR_1D - error while writing variable:', &
7832 & 2x,a,/,22x,'in input file:',2x,a,/,22x,'call from:',2x,a, &
7833 & /,22x,a)
7834!
7835 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_ivar_2d()

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

7840!
7841!=======================================================================
7842! !
7843! This routine writes a integer 2D-array variable into a file. If !
7844! the NetCDF ID is not provided, it opens the file, writes data, !
7845! and then closes the file. !
7846! !
7847! On Input: !
7848! !
7849! ng Nested grid number (integer) !
7850! model Calling model identifier (integer) !
7851! ncname NetCDF file name (string) !
7852! myVarName Variable name (string) !
7853! A Data value(s) to be written (integer) !
7854! start Starting index where the first of the data values !
7855! will be written along each dimension (integer) !
7856! total Number of data values to be written along each !
7857! dimension (integer) !
7858! ncid NetCDF file ID (integer, OPTIONAL) !
7859! varid NetCDF variable ID (integer, OPTIONAL) !
7860! !
7861! On Ouput: !
7862! !
7863! exit_flag Error flag (integer) stored in MOD_SCALARS !
7864! ioerror NetCDF return code (integer) stored in MOD_IOUNITS !
7865! !
7866! Notice: This routine must be used to write only nontiled variables. !
7867! !
7868!=======================================================================
7869!
7870! Imported variable declarations.
7871!
7872 integer, intent(in) :: ng, model
7873
7874 integer, intent(in) :: start(:), total(:)
7875
7876 integer, intent(in), optional :: ncid, varid
7877
7878 integer, intent(in) :: A(:,:)
7879!
7880 character (len=*), intent(in) :: ncname
7881 character (len=*), intent(in) :: myVarName
7882!
7883! Local variable declarations.
7884!
7885 integer :: my_ncid, my_varid, status
7886
7887#if !defined PARALLEL_IO && defined DISTRIBUTE
7888 integer, dimension(2) :: ibuffer
7889#endif
7890!
7891 character (len=*), parameter :: MyFile = &
7892 & __FILE__//", netcdf_put_ivar_2d"
7893!
7894!-----------------------------------------------------------------------
7895! Read in a floating-point scalar variable.
7896!-----------------------------------------------------------------------
7897!
7898! If file ID is not provided, open file for writing.
7899!
7900 IF (.not.PRESENT(ncid)) THEN
7901 CALL netcdf_open (ng, model, trim(ncname), 1, my_ncid)
7902 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
7903 ELSE
7904 my_ncid=ncid
7905 END IF
7906!
7907! If variable ID is not provided, inquire its value.
7908!
7909 IF (outthread) THEN
7910 IF (.not.PRESENT(varid)) THEN
7911 status=nf90_inq_varid(my_ncid, trim(myvarname), my_varid)
7912 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
7913 WRITE (stdout,10) trim(myvarname), trim(ncname), &
7914 & trim(sourcefile), nf90_strerror(status)
7915 exit_flag=3
7916 ioerror=status
7917 END IF
7918 ELSE
7919 my_varid=varid
7920 END IF
7921!
7922! Write out data.
7923!
7924 IF (exit_flag.eq.noerror) THEN
7925 status=nf90_put_var(my_ncid, my_varid, a, start, total)
7926 IF (founderror(status, nf90_noerr, __line__, myfile)) THEN
7927 WRITE (stdout,20) trim(myvarname), trim(ncname), &
7928 & trim(sourcefile), nf90_strerror(status)
7929 exit_flag=3
7930 ioerror=status
7931 END IF
7932 END IF
7933 END IF
7934
7935#if !defined PARALLEL_IO && defined DISTRIBUTE
7936!
7937! Broadcast error flags to all processors in the group.
7938!
7939 ibuffer(1)=exit_flag
7940 ibuffer(2)=ioerror
7941 CALL mp_bcasti (ng, model, ibuffer)
7942 exit_flag=ibuffer(1)
7943 ioerror=ibuffer(2)
7944#endif
7945!
7946! Close file.
7947!
7948 IF (.not.PRESENT(ncid)) THEN
7949 CALL netcdf_close (ng, model, my_ncid, ncname, .false.)
7950 END IF
7951!
7952 10 FORMAT (/,' NETCDF_PUT_IVAR_2D - error while inquiring ID for ', &
7953 & 'variable:',2x,a,/,22x,'in input file:',2x,a,/,22x, &
7954 & 'call from:',2x,a,/,22x,a)
7955 20 FORMAT (/,' NETCDF_PUT_IVAR_2D - error while writing variable:', &
7956 & 2x,a,/,22x,'in input file:',2x,a,/,22x,'call from:',2x,a, &
7957 & /,22x,a)
7958!
7959 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: