[cig-commits] [commit] master: moving attribute writing routines to nc_helpers (31525ee)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Fri Oct 17 05:29:54 PDT 2014


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

On branch  : master
Link       : https://github.com/geodynamics/axisem/compare/607f803cf074063627513d235f9ed0837fc1dd44...b6457db24acdde4a4e1c08935ae1b22adf87f5bf

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

commit 31525ee2dd8b71ad302a987c8a0b81632c0749c0
Author: martinvandriel <vandriel at erdw.ethz.ch>
Date:   Thu Oct 16 19:39:42 2014 +0200

    moving attribute writing routines to nc_helpers
    
    to avoid circular dependencies, had to move ncid_out to data_io


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

31525ee2dd8b71ad302a987c8a0b81632c0749c0
 SOLVER/data_io.f90     |  1 +
 SOLVER/nc_helpers.F90  | 54 +++++++++++++++++++++++++++++++++++++++++++++++++-
 SOLVER/nc_routines.F90 | 53 ++-----------------------------------------------
 SOLVER/parameters.F90  |  3 +--
 4 files changed, 57 insertions(+), 54 deletions(-)

diff --git a/SOLVER/data_io.f90 b/SOLVER/data_io.f90
index 038a151..43dcd04 100644
--- a/SOLVER/data_io.f90
+++ b/SOLVER/data_io.f90
@@ -52,6 +52,7 @@ module data_io
   logical           :: sum_seis, sum_fields
   logical           :: add_hetero, file_exists, use_netcdf 
   character(len=6)  :: output_format  !< netcdf or binary
+  integer           :: ncid_out
   logical           :: do_anel
   integer           :: verbose
 
diff --git a/SOLVER/nc_helpers.F90 b/SOLVER/nc_helpers.F90
index 46de5f3..d5cb2d8 100644
--- a/SOLVER/nc_helpers.F90
+++ b/SOLVER/nc_helpers.F90
@@ -26,8 +26,9 @@ module nc_helpers
 #ifdef enable_netcdf
     use netcdf
 #endif
-    use data_io,    only : verbose
+    use data_io,    only : verbose, ncid_out
     use data_proc,  only : mynum
+    use global_parameters
 
     implicit none
     private 
@@ -38,6 +39,10 @@ module nc_helpers
     public :: putvar_real3d
     public :: getgrpid
     public :: getvarid
+    public :: nc_write_att_int
+    public :: nc_write_att_real
+    public :: nc_write_att_dble
+    public :: nc_write_att_char
 
 contains
 
@@ -404,5 +409,52 @@ subroutine putvar_real3d(ncid, varid, values, start, count)
 end subroutine putvar_real3d
 !-----------------------------------------------------------------------------------------
 
+!-----------------------------------------------------------------------------------------
+!> Write NetCDF attribute of type Character
+subroutine nc_write_att_char(attribute_value, attribute_name)
+    character(len=*), intent(in)    :: attribute_name, attribute_value
+
+#ifdef enable_netcdf
+    call check( nf90_put_att(ncid_out, NF90_GLOBAL, attribute_name, attribute_value) )
+#endif
+end subroutine nc_write_att_char
+!-----------------------------------------------------------------------------------------
+
+!-----------------------------------------------------------------------------------------
+!> Write NetCDF attribute of type Real
+subroutine nc_write_att_real(attribute_value, attribute_name)
+  character(len=*),  intent(in)      :: attribute_name
+  real(sp), intent(in)               :: attribute_value
+
+#ifdef enable_netcdf
+  call check( nf90_put_att(ncid_out, NF90_GLOBAL, attribute_name, attribute_value) )
+#endif
+end subroutine nc_write_att_real
+!-----------------------------------------------------------------------------------------
+
+!-----------------------------------------------------------------------------------------
+!> Write NetCDF attribute of type Double
+subroutine nc_write_att_dble(attribute_value, attribute_name)
+  character(len=*),  intent(in)      :: attribute_name
+  real(dp), intent(in)               :: attribute_value
+
+#ifdef enable_netcdf
+  call check( nf90_put_att(ncid_out, NF90_GLOBAL, attribute_name, attribute_value) )
+#endif
+end subroutine nc_write_att_dble
+!-----------------------------------------------------------------------------------------
+
+!-----------------------------------------------------------------------------------------
+!> Write NetCDF attribute of type Integer
+subroutine nc_write_att_int(attribute_value, attribute_name)
+  character(len=*),  intent(in)     :: attribute_name
+  integer, intent(in)               :: attribute_value
+
+#ifdef enable_netcdf
+  call check( nf90_put_att(ncid_out, NF90_GLOBAL, attribute_name, attribute_value) )
+#endif
+end subroutine nc_write_att_int
+!-----------------------------------------------------------------------------------------
+
 end module nc_helpers
 !=========================================================================================
diff --git a/SOLVER/nc_routines.F90 b/SOLVER/nc_routines.F90
index dc605a7..094da96 100644
--- a/SOLVER/nc_routines.F90
+++ b/SOLVER/nc_routines.F90
@@ -27,7 +27,7 @@ module nc_routines
     use netcdf
 #endif
     use nc_helpers
-    use data_io,    only : verbose, deflate_level
+    use data_io,    only : verbose, deflate_level, ncid_out
     use data_proc,  only : mynum, nproc, lpr
     use global_parameters
     use commun,     only : barrier, comm_elem_number
@@ -88,7 +88,7 @@ module nc_routines
     !> Mapping of local fluid points to global
     integer             :: npts_flu_myfirst, npts_flu_mylast
 
-    integer            :: ncid_out, ncid_recout, ncid_snapout, ncid_surfout, ncid_meshout
+    integer            :: ncid_recout, ncid_snapout, ncid_surfout, ncid_meshout
     integer            :: nc_snap_dimid, nc_proc_dimid, nc_rec_dimid, nc_recproc_dimid
     integer            :: nc_times_dimid, nc_comp_dimid, nc_disp_varid, nc_stf_seis_varid, nc_stf_d_seis_varid
     integer            :: nc_time_varid, nc_iter_dimid, nc_stf_iter_varid, nc_stf_d_iter_varid
@@ -128,8 +128,6 @@ module nc_routines
     
     public              :: nc_dump_strain, nc_dump_rec, nc_dump_surface
     public              :: nc_dump_field_solid, nc_dump_field_fluid
-    public              :: nc_write_att_char, nc_write_att_real, nc_write_att_int
-    public              :: nc_write_att_dble
     public              :: nc_define_outputfile, nc_finish_prepare, nc_end_output
     public              :: nc_dump_strain_to_disk, nc_dump_mesh_sol, nc_dump_mesh_flu
     public              :: nc_dump_mesh_kwf
@@ -1566,53 +1564,6 @@ end subroutine nc_define_outputfile
 !-----------------------------------------------------------------------------------------
 
 !-----------------------------------------------------------------------------------------
-!> Write NetCDF attribute of type Character
-subroutine nc_write_att_char(attribute_value, attribute_name)
-    character(len=*), intent(in)    :: attribute_name, attribute_value
-
-#ifdef enable_netcdf
-    call check( nf90_put_att(ncid_out, NF90_GLOBAL, attribute_name, attribute_value) )
-#endif
-end subroutine nc_write_att_char
-!-----------------------------------------------------------------------------------------
-
-!-----------------------------------------------------------------------------------------
-!> Write NetCDF attribute of type Real
-subroutine nc_write_att_real(attribute_value, attribute_name)
-  character(len=*),  intent(in)      :: attribute_name
-  real(sp), intent(in)               :: attribute_value
-
-#ifdef enable_netcdf
-  call check( nf90_put_att(ncid_out, NF90_GLOBAL, attribute_name, attribute_value) )
-#endif
-end subroutine nc_write_att_real
-!-----------------------------------------------------------------------------------------
-
-!-----------------------------------------------------------------------------------------
-!> Write NetCDF attribute of type Double
-subroutine nc_write_att_dble(attribute_value, attribute_name)
-  character(len=*),  intent(in)      :: attribute_name
-  real(dp), intent(in)               :: attribute_value
-
-#ifdef enable_netcdf
-  call check( nf90_put_att(ncid_out, NF90_GLOBAL, attribute_name, attribute_value) )
-#endif
-end subroutine nc_write_att_dble
-!-----------------------------------------------------------------------------------------
-
-!-----------------------------------------------------------------------------------------
-!> Write NetCDF attribute of type Integer
-subroutine nc_write_att_int(attribute_value, attribute_name)
-  character(len=*),  intent(in)     :: attribute_name
-  integer, intent(in)               :: attribute_value
-
-#ifdef enable_netcdf
-  call check( nf90_put_att(ncid_out, NF90_GLOBAL, attribute_name, attribute_value) )
-#endif
-end subroutine nc_write_att_int
-!-----------------------------------------------------------------------------------------
-
-!-----------------------------------------------------------------------------------------
 !> Open the NetCDF output file, check for variable IDs and dump meshes.
 subroutine nc_finish_prepare
 #ifdef enable_netcdf
diff --git a/SOLVER/parameters.F90 b/SOLVER/parameters.F90
index 741bb13..7157412 100644
--- a/SOLVER/parameters.F90
+++ b/SOLVER/parameters.F90
@@ -1174,8 +1174,7 @@ end subroutine compute_numerical_parameters
 subroutine write_parameters
 
     use data_comm
-    use nc_routines
-    !use data_mesh, ONLY : nglob,nglob_solid
+    use nc_helpers
     use data_mesh
 
     integer          :: iel,curvel,linel,seminoel,semisoel



More information about the CIG-COMMITS mailing list