[Dart-dev] [4485] DART/trunk/integrate_model/integrate_model.f90: Add code to optionally allow this executable to be
nancy at ucar.edu
nancy at ucar.edu
Wed Sep 1 10:03:31 MDT 2010
Revision: 4485
Author: nancy
Date: 2010-09-01 10:03:30 -0600 (Wed, 01 Sep 2010)
Log Message:
-----------
Add code to optionally allow this executable to be
compiled as an MPI job. It's not really a true MPI
executable in that sense that no matter how many tasks
it is started with only task 0 runs the model.
The other tasks hang out waiting for it to finish.
But this allows integrate_model to be used to test
async 4 and is fully backwards compatible.
Also added some debug/trace messages which can be
turned on at compile time to allow easier debugging
if the model advances aren't working.
Modified Paths:
--------------
DART/trunk/integrate_model/integrate_model.f90
-------------- next part --------------
Modified: DART/trunk/integrate_model/integrate_model.f90
===================================================================
--- DART/trunk/integrate_model/integrate_model.f90 2010-08-30 16:56:23 UTC (rev 4484)
+++ DART/trunk/integrate_model/integrate_model.f90 2010-09-01 16:03:30 UTC (rev 4485)
@@ -14,7 +14,7 @@
! execution.
use types_mod, only : r8
-use time_manager_mod, only : time_type, operator(<)
+use time_manager_mod, only : time_type, operator(<), print_time
use utilities_mod, only : initialize_utilities, register_module, &
error_handler, E_MSG, E_ERR, timestamp
@@ -27,7 +27,7 @@
use ensemble_manager_mod, only : init_ensemble_manager, put_copy, ensemble_type, get_copy
use mpi_utilities_mod, only : initialize_mpi_utilities, finalize_mpi_utilities, &
- task_count
+ task_count, iam_task0
implicit none
@@ -41,52 +41,98 @@
type(time_type) :: target_time
integer :: iunit, model_size
type(ensemble_type) :: ens_handle
+
+! dummy args for the advance_state call. presumably this
+! executable was invoked by a script that was originally
+! called by advance_state() in filter, so no need to get
+! recursive here.
character (len=129) :: adv_ens_command = ''
+integer :: async = 0
-!----------------------------------------------------------------
+! for debugging
+logical :: trace_execution = .false.
+
+! for speed, accuracy write model_advance files in binary
+! both ways. for debugging make this 'formatted' instead
+! of 'unformatted' and you can see what's in the ud file.
+character(len = 32) :: advance_restart_format = 'unformatted'
+
! Input and output filenames are hardcoded at this point.
-!
character(len = 7) :: ic_file_name = "temp_ic", ud_file_name = 'temp_ud'
+! NO ONE READS THIS IN RIGHT NOW - it's just a suggested start.
+!namelist /integrate_model_nml/ ic_file_name, ud_file_name, &
+! advance_restart_format, &
+! async, adv_ens_command, &
+! target_time, trace_execution
!----------------------------------------------------------------
! This program should only be run with a single process
call initialize_mpi_utilities('integrate_model')
+
+! This version is ok to build with MPI and run with more than a single
+! task, but only task 0 reads the input, advances the model, and writes
+! the output. All the other tasks just hang out and exit when task 0 is done.
+! FIXME: that could be changed to do multiple ens members in parallel.
+! the code does NOT do this now.
if(task_count() > 1) &
- call error_handler(E_ERR,'integrate_model','Only use single process', &
+ call error_handler(E_MSG,'integrate_model','Only one process doing the work', &
source,revision,revdate)
call register_module(source,revision,revdate)
+if (trace_execution) write(*,*) 'inside integrate_model executable'
-! Initialize the model class data now that obs_sequence is all set up
+! Initialize the model class data
call static_init_assim_model()
model_size = get_model_size()
! Initialize an ensemble manager type with a single copy
call init_ensemble_manager(ens_handle, num_copies=1, num_vars=model_size)
-!------------------- Read restart from file ----------------------
-iunit = open_restart_read(ic_file_name)
-! Read in the target time
-call aread_state_restart(ens_handle%time(1), ens_handle%vars(:, 1), iunit, target_time)
-call close_restart(iunit)
-!----------------- Restart read in --------------------------------
+if (iam_task0()) then
+ !------------------- Read restart from file ----------------------
+ if (trace_execution) write(*,*) 'ready to open input restart file ', trim(ic_file_name)
-! Advance this state to the target time
-! If the model time is past the obs set time, just need to skip
-if(ens_handle%time(1) < target_time) &
- call advance_state(ens_handle, ens_size=1, target_time=target_time, &
- async=0, adv_ens_command=adv_ens_command, tasks_per_model_advance=1)
+ iunit = open_restart_read(ic_file_name)
-! Output the restart file if requested; Force to binary for bitwise reproducing
-! use in filter and perfect_model obs with shell advance options
-iunit = open_restart_write(ud_file_name, "unformatted")
-call awrite_state_restart(ens_handle%time(1), ens_handle%vars(:, 1), iunit)
-call close_restart(iunit)
+ if (trace_execution) write(*,*) 'opened, iunit = ', iunit
-call timestamp(source,revision,revdate,'end') ! closes the log file.
+ ! Read in the target time - could make a namelist item that overrides this.
+ call aread_state_restart(ens_handle%time(1), ens_handle%vars(:, 1), iunit, target_time)
+ if (trace_execution) write(*,*) 'time of data, advance-to are:'
+ if (trace_execution) call print_time(ens_handle%time(1))
+ if (trace_execution) call print_time(target_time)
+
+ call close_restart(iunit)
+ !----------------- Restart read in --------------------------------
+
+ ! Advance this state to the target time
+ ! If the model time is past the obs set time, just need to skip
+ if (trace_execution) write(*,*) 'calling advance_state if needed'
+
+ if(ens_handle%time(1) < target_time) &
+ call advance_state(ens_handle, ens_size=1, target_time=target_time, &
+ async=0, adv_ens_command=adv_ens_command, tasks_per_model_advance=1)
+
+ ! Output the restart file if requested; Force to binary for bitwise reproducing
+ ! use in filter and perfect_model obs with shell advance options
+ if (trace_execution) write(*,*) 'ready to open output restart file ', trim(ud_file_name)
+
+ iunit = open_restart_write(ud_file_name, advance_restart_format)
+
+ if (trace_execution) write(*,*) 'opened, iunit = ', iunit
+
+ call awrite_state_restart(ens_handle%time(1), ens_handle%vars(:, 1), iunit)
+
+ if (trace_execution) write(*,*) 'time of data after advance:'
+ if (trace_execution) call print_time(ens_handle%time(1))
+
+ call close_restart(iunit)
+endif
+
+if (trace_execution) write(*,*) 'end of integrate_model executable'
call finalize_mpi_utilities()
end program integrate_model
More information about the Dart-dev
mailing list