[Dart-dev] DART/branches Revision: 11511
dart at ucar.edu
dart at ucar.edu
Fri Apr 21 16:08:35 MDT 2017
hendric at ucar.edu
2017-04-21 16:08:33 -0600 (Fri, 21 Apr 2017)
183
using nc_write_model_atts when creating a file from scratch. this
allows the model_mod to write out grid information if desired. currently
this has only been been tested on cam-fv.
Modified: DART/branches/rma_output_files/assimilation_code/modules/io/direct_netcdf_mod.f90
===================================================================
--- DART/branches/rma_output_files/assimilation_code/modules/io/direct_netcdf_mod.f90 2017-04-20 19:31:37 UTC (rev 11510)
+++ DART/branches/rma_output_files/assimilation_code/modules/io/direct_netcdf_mod.f90 2017-04-21 22:08:33 UTC (rev 11511)
@@ -86,7 +86,7 @@
copy_is_clamped, query_read_copy, &
query_write_copy, force_copy_back
-use model_mod, only : write_model_time
+use model_mod, only : write_model_time, nc_write_model_atts
use netcdf
@@ -882,7 +882,7 @@
dims = get_io_dim_lengths(domain, i)
ret = nf90_inq_varid(ncid, get_variable_name(domain, i), var_id)
- call nc_check(ret, 'write_variables', 'getting variable id')
+ call nc_check(ret, 'write_variables', 'getting variable id '//trim(get_variable_name(domain,i)))
ret = nf90_put_var(ncid, var_id, var_block(istart:iend), count=dims)
call nc_check(ret, 'write_variables', 'writing')
@@ -927,6 +927,7 @@
integer :: ndims
integer :: xtype ! precision for netcdf file
integer :: dimids(NF90_MAX_VAR_DIMS)
+logical :: model_writes_atts
character(len=NF90_MAX_NAME) :: filename
@@ -940,9 +941,17 @@
ret = nf90_create(filename, create_mode, ncfile_out)
call nc_check(ret, 'create_and_open_state_output: creating', trim(filename))
+ret = nf90_enddef(ncfile_out)
+call nc_check(ret, 'create_and_open_state_output', 'end define mode')
+
+! write grid information
+ret = nc_write_model_atts(ncfile_out, model_writes_atts)
+call nc_check(nf90_Redef(ncfile_out),'create_and_open_state_output', 'redef ')
+
! filename discription
call nc_write_file_information(ncfile_out, filename, get_file_description(name_handle, copy_number, dom_id))
+
! revision information
call nc_write_revision_info(ncfile_out)
@@ -949,6 +958,7 @@
! clamping information
call nc_write_global_att_clamping(ncfile_out, copy_number, dom_id, from_scratch=.true.)
+
! define dimensions, loop around unique dimensions
do i = 1, get_io_num_unique_dims(dom_id)
if ( trim(get_io_unique_dim_name(dom_id, i)) == 'time' ) then
@@ -1002,6 +1012,7 @@
call write_model_time(ncfile_out, dart_time)
+
end function create_and_open_state_output
Modified: DART/branches/rma_output_files/models/cam-fv/model_mod.f90
===================================================================
--- DART/branches/rma_output_files/models/cam-fv/model_mod.f90 2017-04-20 19:31:37 UTC (rev 11510)
+++ DART/branches/rma_output_files/models/cam-fv/model_mod.f90 2017-04-21 22:08:33 UTC (rev 11511)
@@ -2294,27 +2294,6 @@
call nc_check(nf90_Redef(nc_file_ID), 'nc_write_model_atts', 'Redef '//trim(string1))
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-! We need the dimension ID for the number of copies
-!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-call nc_check(nf90_inq_dimid(ncid=nc_file_ID, name="copy", dimid=member_dim_ID), &
- 'nc_write_model_atts', 'inq_dimid copy')
-call nc_check(nf90_inq_dimid(ncid=nc_file_ID, name="time", dimid= time_dim_ID), &
- 'nc_write_model_atts', 'inq_dimid time')
-
-if (time_dim_ID /= unlimited_dim_Id) then
- write(string1,*)'Time dimension ID ',time_dim_ID,'must match Unlimited dimension ID ',unlimited_dim_Id
- call error_handler(E_ERR,'nc_write_model_atts', string1, source, revision, revdate)
-endif
-
-!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-! Define the model size, state variable dimension ... whatever ...
-!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-call nc_check(nf90_def_dim(ncid=nc_file_ID, name="StateVariable", &
- len=model_size, dimid = state_var_dim_ID), &
- 'nc_write_model_atts', 'def_dim StateVariable')
-
-!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! Write Global Attributes
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -2459,6 +2438,14 @@
if (output_state_vector) then
More information about the Dart-dev
mailing list