program zero_ssscor ! Purpose ! ------- ! Generates a version of the auxiliary file ssscor.nc in which the SSS ! adjustments are set to zero. ! ! Usage ! ----- ! ./zero_ssscor ! ! History ! ------- ! 2008 Feb 23 Steven Phipps Original version implicit none include 'netcdf.inc' ! Define local parameters integer, parameter :: nx = 64, & ny = 56 ! Declare local variables character(len=80) :: title character(len=160) :: history integer :: datid, mondid, ncid, status, xdid, ydid real, dimension(nx, ny, 12) :: ds ! Set the SSS adjustments to zero ds = 0.0 ! Get title and history data for the netCDF output file write (*, *) write (*, *) "Please enter the title and history for the output file :" write (*, *) write (*, '(a)', advance='no') "Title : " read (*, '(a)') title write (*, '(a)', advance='no') "History : " read (*, '(a)') history ! Generate the auxiliary file ssscor.nc ! ! (1) Create netCDF file status = nf_create("ssscor.nc", nf_noclobber, ncid) if (status /= nf_noerr) stop "*** netCDF error" ! (2) Define dimensions status = nf_def_dim(ncid, "x", nx, xdid) if (status /= nf_noerr) stop "*** netCDF error" status = nf_def_dim(ncid, "y", ny, ydid) if (status /= nf_noerr) stop "*** netCDF error" status = nf_def_dim(ncid, "month", 12, mondid) if (status /= nf_noerr) stop "*** netCDF error" ! (3) Define variables status = nf_def_var(ncid, "ssscor", nf_double, 3, & (/ xdid, ydid, mondid /), datid) if (status /= nf_noerr) stop "*** netCDF error" ! (4) Create attributes status = nf_put_att_text(ncid, nf_global, "title", len(trim(title)), & trim(title)) if (status /= nf_noerr) stop "*** netCDF error" status = nf_put_att_text(ncid, nf_global, "history", len(trim(history)), & trim(history)) if (status /= nf_noerr) stop "*** netCDF error" ! (5) Exit define mode status = nf_enddef(ncid) if (status /= nf_noerr) stop "*** netCDF error" ! (6) Write data status = nf_put_var_double(ncid, datid, ds) if (status /= nf_noerr) stop "*** netCDF error" ! (7) Close netCDF file status = nf_close(ncid) if (status /= nf_noerr) stop "*** netCDF error" end program zero_ssscor