~fluidity-core/fluidity/refactor-netcdf

« back to all changes in this revision

Viewing changes to diagnostics/Simple_Diagnostics.F90

  • Committer: Jon Hill
  • Date: 2013-02-16 09:01:40 UTC
  • mfrom: (3981.7.159 fluidity)
  • Revision ID: jon.hill@imperial.ac.uk-20130216090140-bplzxqzdk1eik4za
Megre from trunk, fixing several conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
 
51
51
  private
52
52
 
53
 
  public :: calculate_temporalmax, calculate_temporalmin, calculate_l2norm, &
 
53
  public :: calculate_temporalmax_scalar, calculate_temporalmax_vector, calculate_temporalmin, calculate_l2norm, &
54
54
            calculate_time_averaged_scalar, calculate_time_averaged_vector, &
55
55
            calculate_time_averaged_scalar_squared, &
56
56
            calculate_time_averaged_vector_times_scalar, calculate_period_averaged_scalar
60
60
  integer, save :: n_times_added
61
61
  
62
62
contains
63
 
  subroutine calculate_temporalmax(state, s_field)
 
63
  subroutine calculate_temporalmax_scalar(state, s_field)
64
64
    type(state_type), intent(in) :: state
65
65
    type(scalar_field), intent(inout) :: s_field
66
66
    type(scalar_field), pointer :: source_field
91
91
       val = max(node_val(s_field,i),node_val(source_field,i))
92
92
       call set(s_field,i,val)
93
93
    end do
94
 
  end subroutine calculate_temporalmax
 
94
  end subroutine calculate_temporalmax_scalar
 
95
 
 
96
  subroutine calculate_temporalmax_vector(state, v_field)
 
97
    type(state_type), intent(in) :: state
 
98
    type(vector_field), intent(inout) :: v_field
 
99
    type(vector_field), pointer :: source_field
 
100
    type(vector_field), pointer :: position
 
101
    type(scalar_field) :: magnitude_max_vel, magnitude_vel
 
102
    character(len = OPTION_PATH_LEN) :: path
 
103
    integer :: i, d
 
104
    real :: current_time, spin_up_time
 
105
    source_field => vector_source_field(state, v_field)
 
106
    assert(node_count(v_field) == node_count(source_field))
 
107
    position => extract_vector_field(state, "Coordinate")
 
108
 
 
109
    if(timestep==0) then
 
110
       path=trim(complete_field_path(v_field%option_path)) // "/algorithm/initial_condition"
 
111
       if (have_option(trim(path))) then
 
112
          call zero(v_field)
 
113
          call initialise_field_over_regions(v_field, path, position)
 
114
       else
 
115
          call set(v_field,source_field)
 
116
       end if
 
117
       return
 
118
    end if
 
119
    if(have_option(trim(complete_field_path(v_field%option_path)) // "/algorithm/spin_up_time")) then
 
120
       call get_option("/timestepping/current_time", current_time)
 
121
       call get_option(trim(complete_field_path(v_field%option_path)) // "/algorithm/spin_up_time", spin_up_time)
 
122
       if (current_time<spin_up_time) return
 
123
    end if
 
124
 
 
125
    ! We actually care about the vector that causes the maximum magnitude
 
126
    ! of velocity, so check the magnitude and store if higher than
 
127
    ! what we already have.
 
128
    magnitude_max_vel = magnitude(v_field)
 
129
    magnitude_vel = magnitude(source_field)
 
130
 
 
131
    do i=1,node_count(magnitude_vel)
 
132
        if (node_val(magnitude_vel,i) .gt. node_val(magnitude_max_vel,i)) then
 
133
            call set(v_field,i,node_val(source_field,i))
 
134
        end if
 
135
    end do
 
136
 
 
137
    call deallocate(magnitude_max_vel)
 
138
    call deallocate(magnitude_vel)
 
139
 
 
140
  end subroutine calculate_temporalmax_vector
 
141
 
95
142
 
96
143
  subroutine calculate_temporalmin(state, s_field)
97
144
    type(state_type), intent(in) :: state