From 3c9c1d6cc34094cdd2f007c6db98cb76d7c99185 Mon Sep 17 00:00:00 2001
From: Dave Whipp <dwhipp@dal.ca>
Date: Tue, 14 Jun 2011 13:02:57 +0000
Subject: [PATCH] Added new program to combine velocity/temperature/cloud
 fields and update surface positions

---
 src/stitch_nest.f90 | 70 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 src/stitch_nest.f90

diff --git a/src/stitch_nest.f90 b/src/stitch_nest.f90
new file mode 100644
index 00000000..212fe74f
--- /dev/null
+++ b/src/stitch_nest.f90
@@ -0,0 +1,70 @@
+! Stitch nest
+!
+! Combines velocity fields from a coarse model and n nests at one level finer to
+! update the surface positions and temperatures in the coarse model
+!
+! dwhipp - 06/11
+
+program stitch_nest
+
+use definitions
+use threads
+
+implicit none
+
+! Variable type declaration
+type (cloud),dimension(:),allocatable :: ss_cl
+type (cloud) :: ls_cl
+type (octreev),dimension(:),allocatable :: ss_ov
+type (octreev) ls_ov
+type (parameters) :: params
+type (sheet),dimension(:),allocatable :: ls_surf,ls_surf0,ss_surf,ss_surf0
+
+integer :: i,nnest,istep
+
+character (len=4) :: cistep
+
+!-------------------------------------------------------------------------------
+
+write (*,*) 'Program started'
+
+! Read current time step from command line
+call getarg (1,istep)
+call getarg (2,nnest)
+
+write (*,*) 'Received command line arguments:'
+write (*,*) 'istep = ',istep
+write (*,*) 'nnest = ',nnest
+
+! Read the coarse model input file
+params%infile=trim('input_ls.txt')
+call read_controlling_parameters (params,threadinfo,'main')
+allocate (ls_surf  (params%ns),stat=err); if (err.ne.0) call stop_run ('Error alloc ls_surf in main$')
+allocate (ls_surf0 (params%ns),stat=err); if (err.ne.0) call stop_run ('Error alloc ls_surf0 in main$')
+call read_input_file (params,threadinfo,material0,mat,ls_surf,boxes,sections,  &
+                      cube_faces,nest)
+
+! Modify params%restartfile to read previous restart file
+if (istep > 1) then
+  call int_to_char (cistep,4,istep-1)
+  params%restartfile='OUT/time_'//cistep//'.bin'
+endif
+
+! Read the previous coarse model restart file if istep > 1, define surface,
+! cloud and ov
+call define_surface (params,ls_surf,threadinfo,total,step,inc,current_time)
+call define_cloud (ls_cl,params,zi)
+call define_ov (ls_ov,params,threadinfo)
+
+! Read the coarse model restart file from the current time step
+
+! Loop through fine model(s) and read their current restart files
+do i = 1,nnest
+  ! Change params%infile
+enddo
+
+deallocate()
+
+! Sign off
+write (*,*) 'Program execution complete'
+end
\ No newline at end of file
-- 
GitLab