subroutine test_amp(plane, dc) use nonlin_bpm_mod use precision_def implicit none type(cesr_det_plane_struct), intent(inout) :: plane(0:n_det_maxx) type (cesr_det_dc_position_struct) dc(0:n_det_maxx) integer :: det, i,ir real(rp) long_cos(4), long_sin(4), ccos, ssin real(rp) deg_to_rad logical orig_offsets, orig_rotation deg_to_rad = twopi/360. i=0 do det = 0,n_det_maxx if (all(plane(det)%but(:)%amp .lt. 1e-10)) then if (det < 100) print *, "All amplitudes are zero for detector",det plane(det)%x%amp = 0. plane(det)%y%amp = 0. plane(det)%x%phase = 0. plane(det)%y%phase = 0. else if(plane(det)%system_id < 1)cycle ! ir = u%db%detector(det)%ix_lat ! if(ir == 0)cycle if(any(plane(det)%but(1:4)%amp < 1.e-10))cycle i=i+1 long_cos(1:4) = plane(det)%but(1:4)%amp * cos(plane(det)%but(1:4)%phase * deg_to_rad) long_sin(1:4) = plane(det)%but(1:4)%amp * sin(plane(det)%but(1:4)%phase * deg_to_rad) ccos = long_cos(4)-long_cos(3)+long_cos(2)-long_cos(1) ssin = long_sin(4)-long_sin(3)+long_sin(2)-long_sin(1) plane(det)%x%amp = sqrt(ccos**2 + ssin**2) plane(det)%x%phase = atan2d(ssin,ccos) ccos = long_cos(4)+long_cos(3)-long_cos(2)-long_cos(1) ssin = long_sin(4)+long_sin(3)-long_sin(2)-long_sin(1) plane(det)%y%amp = sqrt(ccos**2 + ssin**2) plane(det)%y%phase = atan2d(ssin,ccos) endif end do end