[cig-commits] [commit] master: Introduced 'Finalized' attribute in the NetCDF file (7e55ac3)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Thu Sep 18 03:46:32 PDT 2014


Repository : https://github.com/geodynamics/axisem

On branch  : master
Link       : https://github.com/geodynamics/axisem/compare/6446c3c69458f843a58231451968e55551c41501...7e55ac39bdc9d5a95788177811461e297c4e3658

>---------------------------------------------------------------

commit 7e55ac39bdc9d5a95788177811461e297c4e3658
Author: Simon Stähler <staehler at geophysik.uni-muenchen.de>
Date:   Thu Sep 18 12:45:17 2014 +0200

    Introduced 'Finalized' attribute in the NetCDF file
    
     - is set to 0 at beginning of run, and to 1 at the finalization.
     - field_transform.f90 checks for it being 1 at the beginning and waits for 60s, if it's still 0.
     - attribute 'percent completed' stores the progress of the calculation (is only updated once a strain dump is done, so slightly lagging behind)


>---------------------------------------------------------------

7e55ac39bdc9d5a95788177811461e297c4e3658
 SOLVER/UTILS/field_transform.F90 | 17 +++++++++++++++++
 SOLVER/nc_routines.F90           | 25 ++++++++++++++++++++++++-
 SOLVER/parameters.F90            |  3 +++
 3 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/SOLVER/UTILS/field_transform.F90 b/SOLVER/UTILS/field_transform.F90
index 6d207c5..56ebe99 100644
--- a/SOLVER/UTILS/field_transform.F90
+++ b/SOLVER/UTILS/field_transform.F90
@@ -63,6 +63,7 @@ program field_transformation
     integer, dimension(9)           :: ncin_field_varid
     integer, dimension(9)           :: ncout_field_varid
 
+    integer                         :: isfinalized, percent                                                            
     integer                         :: nstep, nvars_mesh
     integer                         :: attnum, nf_att_stat
     character(len=80)               :: attname, varname
@@ -96,6 +97,8 @@ program field_transformation
     integer, parameter              :: sigdigits =  5       ! significant digits
                                                             ! below max of time trace
     
+                                                            
+
     ! initialize timer
     time_fft = 0
     time_i = 0
@@ -108,6 +111,20 @@ program field_transformation
     call check( nf90_open(path="./Data/axisem_output.nc4", & 
                           mode=NF90_NOWRITE, ncid=ncin_id) )
 
+    call check( nf90_get_att(ncin_id, NF90_GLOBAL, 'finalized', isfinalized) )
+
+    do while (isfinalized.ne.1)
+      call check( nf90_get_att(ncin_id, NF90_GLOBAL, 'percent completed', percent) )
+      print "('Solver run not yet finished (at ', I3, '%). Waiting for 60s')", percent
+      call check( nf90_close(ncin_id))
+      call sleep(60)
+
+      call check( nf90_open(path="./Data/axisem_output.nc4", & 
+                            mode=NF90_NOWRITE, ncid=ncin_id) )
+      call check( nf90_get_att(ncin_id, NF90_GLOBAL, 'finalized', isfinalized) )
+    end do
+
+
     ! get Snapshots group id
     call check( nf90_inq_grp_ncid(ncin_id, "Snapshots", ncin_snap_grpid) )
 
diff --git a/SOLVER/nc_routines.F90 b/SOLVER/nc_routines.F90
index 121926d..7ac4230 100644
--- a/SOLVER/nc_routines.F90
+++ b/SOLVER/nc_routines.F90
@@ -480,6 +480,9 @@ subroutine nc_dump_strain_to_disk() bind(c, name="nc_dump_strain_to_disk")
         dumpsize = dumpsize + 3 * maxind * ndumps
     end if
     
+    call check( nf90_put_att(ncid_out, NF90_GLOBAL, 'percent completed', &
+                             isnap_loc*100/nstrain) )
+
     call check( nf90_close(ncid_out) ) 
     call cpu_time(tack)
     deallocate(copy_oneddumpvar)
@@ -1864,13 +1867,33 @@ subroutine nc_end_output
         
         call barrier
     end do
-    !call check( nf90_close(ncid_out) )
+
+    !Set the finalized flag to true in the output file
+    if(mynum.eq.0) call nc_finalize()
 
 #endif
 end subroutine nc_end_output
 !-----------------------------------------------------------------------------------------
 
 !-----------------------------------------------------------------------------------------
+subroutine nc_finalize
+!< Set the finalized flag to true in the output file
+#ifdef unc
+    use data_io,      only: datapath, lfdata
+
+    call check( nf90_open(path=datapath(1:lfdata)//"/axisem_output.nc4", & 
+                          mode=NF90_WRITE, ncid=ncid_out) )
+    call check( nf90_redef(ncid_out))
+
+    call check( nf90_put_att(ncid_out, NF90_GLOBAL, &
+                             'finalized', 1) )
+
+    call check( nf90_close(ncid = ncid_out))
+#endif
+end subroutine nc_finalize
+!-----------------------------------------------------------------------------------------
+
+!-----------------------------------------------------------------------------------------
 subroutine nc_make_snapfile
 
     use data_mesh,    only: npoint_plot, nelem_plot
diff --git a/SOLVER/parameters.F90 b/SOLVER/parameters.F90
index 49dcd86..ec6c2ac 100644
--- a/SOLVER/parameters.F90
+++ b/SOLVER/parameters.F90
@@ -1496,6 +1496,9 @@ subroutine write_parameters
         call nc_write_att_real( dtheta_rec,            'receiver spacing (0 if not even)')
         write(clogic,*) use_netcdf
         call nc_write_att_char( clogic,                'use netcdf for wavefield output?')
+
+        call nc_write_att_int( 0,                      'percent completed')
+        call nc_write_att_int( 0,                      'finalized')
     end if
 
 



More information about the CIG-COMMITS mailing list