[Dart-dev] [3273] DART/trunk/models/MITgcm_ocean: Fix the code that fills the ZC() array, and correct

nancy at subversion.ucar.edu nancy at subversion.ucar.edu
Mon Mar 17 13:54:37 MDT 2008


An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/dart-dev/attachments/20080317/28f17aa0/attachment.html
-------------- next part --------------
Modified: DART/trunk/models/MITgcm_ocean/model_mod.f90
===================================================================
--- DART/trunk/models/MITgcm_ocean/model_mod.f90	2008-03-17 17:25:42 UTC (rev 3272)
+++ DART/trunk/models/MITgcm_ocean/model_mod.f90	2008-03-17 19:54:37 UTC (rev 3273)
@@ -413,16 +413,35 @@
    call exit(99)
 endif
 
+! the namelist contains a list of thicknesses of each
+! depth level; the ZC array is a list of the depths of
+! each cell center, so they must be computed.
 allocate(ZC(Nz))
-ZC(1) = 0.0_r8
+ZC(1) = -0.5 * delZ(1)
 do i=2, Nz
- ZC(i) = ZC(i-1) - delZ(i)
+ ZC(i) = ZC(i-1) - (0.5 * delZ(i-1) + 0.5 * delZ(i)) 
 enddo
 
-! for now, leave ZG undefined
+! DEBUG: since we are computing these, check to be sure
+! they look right.
+do i=1, Nz
+ print *, 'i, delZ(i), ZC(i) = ', i, delZ(i), ZC(i)
+enddo
+
+! for now, leave ZG undefined.  it really does have one
+! more depth than we read in, so it isn't clear how to
+! handle this.
 allocate(ZG(Nz))
 ZG(:) = 0.0_r8
+! if we did need depth faces, here is how to compute them.
+! the delZ array are each cell width.
+!allocate(ZG(Nz+1))
+!ZG(1) = 0.0_r8
+!do i=2, Nz+1
+! ZG(i) = ZG(i-1) - delZ(i-1)
+!enddo
 
+
 ! record where in the state vector the data type changes
 ! from one type to another, by computing the starting
 ! index for each block of data.
@@ -2171,8 +2190,8 @@
                       msgstring,source,revision,revdate) 
 endif
 
-if (size(ssh,2) /= Nx) then
-   write(msgstring,*),'dim 2 of SSH /= Nx ',size(ssh,2),Nx
+if (size(ssh,2) /= Ny) then
+   write(msgstring,*),'dim 2 of SSH /= Ny ',size(ssh,2),Ny
    call error_handler(E_ERR,'model_mod:prog_var_to_vector', &
                       msgstring,source,revision,revdate) 
 endif

Modified: DART/trunk/models/MITgcm_ocean/trans_pv_sv.f90
===================================================================
--- DART/trunk/models/MITgcm_ocean/trans_pv_sv.f90	2008-03-17 17:25:42 UTC (rev 3272)
+++ DART/trunk/models/MITgcm_ocean/trans_pv_sv.f90	2008-03-17 19:54:37 UTC (rev 3273)
@@ -5,35 +5,37 @@
  
 program trans_pv_sv
 
-! <next few lines under version control, do not edit>
-! $URL$
-! $Id$
-! $Revision$
-! $Date$
-
 !----------------------------------------------------------------------
 ! purpose: interface between MITgcm_ocean and DART
 !
-! method: Read MITgcm_ocean 'snapshot' files of model state
-!         Get target time from assim_model_state_ic (temp_ic).
-!         Reform fields into a state vector.
-!         Write out state vector in "proprietary" format for DART
+! method: Read MITgcm_ocean "snapshot" files of model state
+!         Reform fields into a DART state vector (control vector).
+!         Write out state vector in "proprietary" format for DART.
+!         The output is a "DART restart file" format.
 !
 ! author: Tim Hoar 3/13/08
+! more mangling:  nancy collins 14mar08
 !
 !----------------------------------------------------------------------
 
+! <next few lines under version control, do not edit>
+! $URL$
+! $Id$
+! $Revision$
+! $Date$
+
 use        types_mod, only : r4, r8
 use    utilities_mod, only : get_unit, file_exist, E_ERR, E_WARN, E_MSG, &
                              initialize_utilities, finalize_utilities, &
                              error_handler
 use        model_mod, only : MIT_meta_type, read_meta, read_snapshot, &
-                             drop_snapshot, prog_var_to_vector
+                             drop_snapshot, prog_var_to_vector, static_init_model, &
+                             get_model_size
 use  assim_model_mod, only : assim_model_type, static_init_assim_model, &
                              init_assim_model, get_model_size, set_model_state_vector, &
                              write_state_restart, set_model_time, open_restart_read, &
                              open_restart_write, close_restart, aread_state_restart
-use time_manager_mod, only : time_type, read_time
+use time_manager_mod, only : time_type, read_time, set_time
 
 implicit none
 
@@ -45,11 +47,13 @@
 
 character (len = 128) :: msgstring
 
-! eg. [S,T,U,V,SSH].0000040992.[data,meta]
+! eg. [S,T,U,V,Eta].0000040992.[data,meta]
 !
 ! The '.meta' file contains matlab-format information about shapes, etc.
 
-character (len = 128) :: file_base = '0000000672'
+! FIXME: we have to read this someplace else
+integer :: timestep = 40992
+character (len = 128) :: file_base = '0000040992'
 character (len = 128) :: S_filename
 character (len = 128) :: T_filename
 character (len = 128) :: U_filename
@@ -71,10 +75,18 @@
 
 real(r8), allocatable  :: x_state(:)
 
-integer                :: file_unit, x_size, timestep
+integer                :: file_unit, x_size
 
 type(MIT_meta_type) :: mitmeta
 
+!
+! end of variable decls
+! 
+!----------------------------------------------------------------------
+!
+! code start
+!
+
 ! The strategy here is to use the 'write_state_restart()' routine - 
 ! which requires an 'assim_model_type' variable.  
 ! Read the individual variables and pack them
@@ -82,28 +94,23 @@
 
 call initialize_utilities('trans_pv_sv')
 
-call read_snapshot('XC',SSH,timestep)
-
 ! Static init assim model calls static_init_model
 call static_init_assim_model()
 call init_assim_model(x)
 
-write(*,*)'dimensions are ',shape(SSH)
 write(*,*)'model size is ',get_model_size()
 
-stop
-
 ! Read the [meta,data] files 
 
 mitmeta = read_meta(file_base,'U')
-write(*,*)'timestep is ',timestep
 
 call read_snapshot(file_base,S,timestep,'S')
 call read_snapshot(file_base,T,timestep,'T')
 call read_snapshot(file_base,U,timestep,'U')
 call read_snapshot(file_base,V,timestep,'V')
-call read_snapshot(file_base,SSH,timestep,'SSH')
+call read_snapshot(file_base,SSH,timestep,'Eta')
 
+! matlab debug messages
 ! write(8)mitmeta%dimList
 ! write(8)S
 ! close(8)
@@ -122,10 +129,9 @@
 ! transform fields into state vector for DART
 call prog_var_to_vector(S,T,U,V,SSH,x_state)
 
-! Integration of model was controlled by the restart file,
-! so we use the target time of the restart file (from assim_model_state)
-! as the current model state time.
- file_unit = open_restart_read(file_time)
+! use the MIT namelist and timestepcount in the meta file to construct
+! the current time.  we do not have a restart file to read; this program
+! is creating one.
 
 ! We're done with x_state, so it can be uselessly filled in aread_state_restart,
 ! while getting model_time.
@@ -133,12 +139,22 @@
 !call set_model_time (x, adv_to_time)
 !call close_restart(file_unit)
 
+! FIXME:
+model_time = set_time(3600, 100)
+
+call set_model_state_vector (x, x_state)
+call set_model_time (x, model_time)
+
 ! Get channel for output,
 ! write out state vector in "proprietary" format
-!file_unit = open_restart_write(file_out)
-!call write_state_restart(x, file_unit)
-!call close_restart(file_unit)
+print *, 'ready to call open_restart_write'
+file_unit = open_restart_write(file_out)
+print *, 'ready to call write_state_restart'
+call write_state_restart(x, file_unit)
+print *, 'ready to close unit'
+call close_restart(file_unit)
 
 call finalize_utilities()
 
 end program trans_pv_sv
+


More information about the Dart-dev mailing list