[Dart-dev] DART/branches Revision: 11092
dart at ucar.edu
dart at ucar.edu
Fri Feb 10 13:51:20 MST 2017
hendric at ucar.edu
2017-02-10 13:51:20 -0700 (Fri, 10 Feb 2017)
213
Adding a write_model_time routine for POP. This is important
when creating files from scratch such as output_mean.nc, before
the code was just using the default write_model_times which does
not have a calendar.
Modified: DART/branches/rma_single_file/io/dart_time_io_mod.f90
===================================================================
--- DART/branches/rma_single_file/io/dart_time_io_mod.f90 2017-02-10 20:49:25 UTC (rev 11091)
+++ DART/branches/rma_single_file/io/dart_time_io_mod.f90 2017-02-10 20:51:20 UTC (rev 11092)
@@ -215,20 +215,20 @@
call nc_check(ios, "write_model_time", "time long_name")
ios = nf90_put_att(ncid, VarID, "calendar", "no calendar")
- call nc_check(ios, "write_model_time", "dart_days calendar")
+ call nc_check(ios, "write_model_time", "calendar long_name")
ios = nf90_put_att(ncid, VarID, "axis", "T")
- call nc_check(ios, "write_model_time", "dart_days calendar")
+ call nc_check(ios, "write_model_time", "axis long_name")
ios = nf90_put_att(ncid, VarID, "cartesian_axis", "T")
- call nc_check(ios, "write_model_time", "dart_days calendar")
+ call nc_check(ios, "write_model_time", "cartesian_axis long_name")
ios = nf90_put_att(ncid, VarID, "month_lengths", &
(/31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 /))
- call nc_check(ios, "write_model_time", "dart_days month_lengths")
+ call nc_check(ios, "write_model_time", "month_lengths long_name")
ios = nf90_put_att(ncid, VarID, "units", "days since 0000-01-01 00:00:00")
- call nc_check(ios, "write_model_time", "dart_days units")
+ call nc_check(ios, "write_model_time", "units long_name")
! end define mode
call nc_check( nf90_Enddef(ncid),"write_model_time", "Enddef" )
Modified: DART/branches/rma_single_file/models/POP/model_mod.f90
===================================================================
--- DART/branches/rma_single_file/models/POP/model_mod.f90 2017-02-10 20:49:25 UTC (rev 11091)
+++ DART/branches/rma_single_file/models/POP/model_mod.f90 2017-02-10 20:51:20 UTC (rev 11092)
@@ -47,8 +47,6 @@
get_num_variables, get_index_start, &
get_num_dims, get_domain_size
-use dart_time_io_mod, only : write_model_time !>@todo FIXME ... this routine uses no calendar, POP uses the gregorian calendar, the variable attributes are wrong ...
-
use typesizes
use netcdf
@@ -3656,6 +3654,45 @@
!--------------------------------------------------------------------
+!> write time to the output file
+!> this is only called when creating a file from scratch
+
+
+subroutine write_model_time(ncid, dart_time)
+
+integer, intent(in) :: ncid
+type(time_type), intent(in) :: dart_time
+
+integer :: iyear, imonth, iday, ihour, iminute, isecond
+
+if ( .not. module_initialized ) call static_init_model
+
+call get_date(dart_time, iyear, imonth, iday, ihour, iminute, isecond)
+
+! begin define mode
+call nc_check(nf90_Redef(ncid),"redef")
+
+call nc_check( nf90_put_att(ncid, NF90_GLOBAL, 'iyear' , iyear), &
+ 'write_model_time', 'put_att iyear')
+call nc_check( nf90_put_att(ncid, NF90_GLOBAL, 'imonth' , imonth), &
+ 'write_model_time', 'put_att imonth')
+call nc_check( nf90_put_att(ncid, NF90_GLOBAL, 'iday' , iday), &
+ 'write_model_time', 'put_att iday')
+call nc_check( nf90_put_att(ncid, NF90_GLOBAL, 'ihour' , ihour), &
+ 'write_model_time', 'put_att ihour')
+call nc_check( nf90_put_att(ncid, NF90_GLOBAL, 'iminute', iminute), &
+ 'write_model_time', 'put_att iminute')
+call nc_check( nf90_put_att(ncid, NF90_GLOBAL, 'isecond', isecond), &
+ 'write_model_time', 'put_att isecond')
+call nc_check(nf90_put_att(ncid, NF90_GLOBAL, 'calendar', 'Gregorian'), &
+ 'write_model_time', 'put_att calendar')
+
+call nc_check( nf90_Enddef(ncid),"write_model_time", "Enddef" )
+
+end subroutine write_model_time
+
+
+!--------------------------------------------------------------------
!> read the time from the input file
!> Stolen from pop model_mod.f90 restart_to_sv
More information about the Dart-dev
mailing list